ATLAS Offline Software
Loading...
Searching...
No Matches
CLHEPConverters.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
12
13
16#include "CLHEP/Vector/ThreeVector.h"
17#include "CLHEP/Geometry/Point3D.h"
18#include "TMemberStreamer.h"
19#include "TBuffer.h"
20#include "TClass.h"
21#include "TROOT.h"
22#include "Rtypes.h"
23#include <cassert>
24
25
26namespace DataModelAthenaPool {
27
28
33 : public TMemberStreamer
34{
35public:
38
39
46 virtual void operator() (TBuffer& b, void* pmember, Int_t size=0);
47
48
49private:
51 TClass* m_cl;
52};
53
54
59{
60 m_cl = gROOT->GetClass ("Hep3Vector");
61 m_cl = gROOT->GetClass ("CLHEP::Hep3Vector");
62}
63
64
72 void* pmember,
73 Int_t size /*=0*/)
74{
75 // This only works for reading!
76 assert (b.IsReading());
77
78 // The transient object.
79 HepGeom::Point3D<double>* obj =
80 reinterpret_cast<HepGeom::Point3D<double>*> (pmember);
81
82 // We'll read into this object.
83 CLHEP::Hep3Vector tmp;
84
85 if (size == 0) size = 1;
86 while (size-- > 0) {
87 // Read into tmp and copy data to *obj.
88 m_cl->Streamer (&tmp, b);
89 obj->setX (tmp.x());
90 obj->setY (tmp.y());
91 obj->setZ (tmp.z());
92 ++obj;
93 }
94}
95
96
101{
103 ("CLHEP::Hep3Vector", "HepGeomPoint3D<double>", new PointConverter);
104}
105
106
107} // namespace DataModelAthenaPool
Define converters for CLHEP types needed to read old data files.
Registry for Root converters.
static void initialize()
Register all CLHEP converters.
Converter for Hep3Vector to Point3D<double>.
TClass * m_cl
Hold the class for Hep3Vector.
virtual void operator()(TBuffer &b, void *pmember, Int_t size=0)
Run the streamer.
static TConverterRegistry * Instance()
Return a pointer to the global registry instance.
void AddStreamerConverter(const std::string &from_type, const std::string &to_type, TMemberStreamer *streamer)