ATLAS Offline Software
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$
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 
26 namespace DataModelAthenaPool {
27 
28 
33  : public TMemberStreamer
34 {
35 public:
37  PointConverter ();
38 
39 
46  virtual void operator() (TBuffer& b, void* pmember, Int_t size=0);
47 
48 
49 private:
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
DataModelAthenaPool::CLHEPConverters::initialize
static void initialize()
Register all CLHEP converters.
Definition: CLHEPConverters.cxx:100
DataModelAthenaPool
Definition: CLHEPConverters.h:20
DataModelAthenaPool::PointConverter
Converter for Hep3Vector to Point3D<double>.
Definition: CLHEPConverters.cxx:34
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
DataModelAthenaPool::PointConverter::operator()
virtual void operator()(TBuffer &b, void *pmember, Int_t size=0)
Run the streamer.
Definition: CLHEPConverters.cxx:71
DataModelAthenaPool::PointConverter::m_cl
TClass * m_cl
Hold the class for Hep3Vector.
Definition: CLHEPConverters.cxx:51
DataModelAthenaPool::PointConverter::PointConverter
PointConverter()
Constructor.
Definition: CLHEPConverters.cxx:58
TConverterRegistry::AddStreamerConverter
void AddStreamerConverter(const std::string &from_type, const std::string &to_type, TMemberStreamer *streamer)
Definition: TConverterRegistry.cxx:114
CLHEPConverters.h
Define converters for CLHEP types needed to read old data files.
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TConverterRegistry.h
Registry for Root converters.
TConverterRegistry::Instance
static TConverterRegistry * Instance()
Return a pointer to the global registry instance.
Definition: TConverterRegistry.cxx:143
python.PyAthena.obj
obj
Definition: PyAthena.py:132