ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelAthenaPool
src
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
14
#include "
DataModelAthenaPool/CLHEPConverters.h
"
15
#include "
RootConversions/TConverterRegistry.h
"
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
32
class
PointConverter
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
58
PointConverter::PointConverter
()
59
{
60
m_cl
= gROOT->GetClass (
"Hep3Vector"
);
61
m_cl
= gROOT->GetClass (
"CLHEP::Hep3Vector"
);
62
}
63
64
71
void
PointConverter::operator()
(TBuffer& b,
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
100
void
CLHEPConverters::initialize
()
101
{
102
TConverterRegistry::Instance
()->
AddStreamerConverter
103
(
"CLHEP::Hep3Vector"
,
"HepGeomPoint3D<double>"
,
new
PointConverter
);
104
}
105
106
107
}
// namespace DataModelAthenaPool
CLHEPConverters.h
Define converters for CLHEP types needed to read old data files.
size
size_t size() const
Number of registered mappings.
TConverterRegistry.h
Registry for Root converters.
DataModelAthenaPool::CLHEPConverters::initialize
static void initialize()
Register all CLHEP converters.
Definition
CLHEPConverters.cxx:100
DataModelAthenaPool::PointConverter
Converter for Hep3Vector to Point3D<double>.
Definition
CLHEPConverters.cxx:34
DataModelAthenaPool::PointConverter::m_cl
TClass * m_cl
Hold the class for Hep3Vector.
Definition
CLHEPConverters.cxx:51
DataModelAthenaPool::PointConverter::operator()
virtual void operator()(TBuffer &b, void *pmember, Int_t size=0)
Run the streamer.
Definition
CLHEPConverters.cxx:71
DataModelAthenaPool::PointConverter::PointConverter
PointConverter()
Constructor.
Definition
CLHEPConverters.cxx:58
TConverterRegistry::Instance
static TConverterRegistry * Instance()
Return a pointer to the global registry instance.
Definition
TConverterRegistry.cxx:142
TConverterRegistry::AddStreamerConverter
void AddStreamerConverter(const std::string &from_type, const std::string &to_type, TMemberStreamer *streamer)
Definition
TConverterRegistry.cxx:113
DataModelAthenaPool
Definition
CLHEPConverters.h:20
Generated on
for ATLAS Offline Software by
1.17.0