ATLAS Offline Software
ParticleBaseCnv_p1.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // ParticleBaseCnv_p1.cxx
8 // Implementation file for class ParticleBaseCnv_p1
9 // Author: K.Cranmer<cranmer@cern.ch>
10 // Author: S.Binet<binet@cern.ch>
12 
13 
14 // STL includes
15 
16 // DataModelAthenaPool includes
19 
20 // VxVertex includes
21 #include "VxVertex/VxContainer.h"
22 
23 // ParticleEvent includes
25 #include "ParticleEvent/Lib/Base.h"
26 
27 // ParticleEventTPCnv includes
29 
30 // internal: do not change
31 //#define PBC_P1_VERBOSE 1
32 //
33 
35 
36 // pre-allocate converters
37 static const VxLinkCnv_t vxCnv;
38 static const AthenaBarCodeCnv_p1 s_abcCnv;
39 
43 {}
44 
46 // Non-Const methods:
48 
50  ParticleBase* trans,
51  MsgStream& msg ) const
52 {
53 // msg << MSG::DEBUG << "Loading ParticleBase from persistent state..."
54 // << endmsg;
55 
57  vxCnv.persToTrans( &pers->m_origin, &origin, msg );
58 
59  trans->set_origin (origin);
60  if (pers->m_hasCharge) {
61  trans->set_charge (pers->m_charge);
62  }
63  else {
64  trans->reset_charge();
65  }
66  if (pers->m_hasPdgId) {
67  trans->set_pdgId (pers->m_pdgId );
68  }
69  else {
70  trans->reset_pdgId();
71  }
72  trans->set_dataType (static_cast<ParticleDataType::DataType>( pers->m_dataType ));
73 
74 // msg << MSG::DEBUG << "Loaded ParticleBase from persistent state [OK]"
75 // << endmsg;
76 
77  return;
78 }
79 
81  ParticleBase_p1* pers,
82  MsgStream& msg ) const
83 {
84 // msg << MSG::DEBUG << "Creating persistent state of ParticleBase..."
85 // << endmsg;
86 
87  vxCnv.transToPers( &trans->originLink(), &pers->m_origin, msg );
88 
89  pers->m_charge = trans->charge();
90  pers->m_hasCharge = trans->hasCharge();
91  pers->m_pdgId = trans->pdgId();
92  pers->m_hasPdgId = trans->hasPdgId();
93  pers->m_dataType = trans->dataType();
94 
95 // msg << MSG::DEBUG << "Created persistent state of ParticleBase [OK]"
96 // << endmsg;
97  return;
98 }
99 
100 
102  ParticleEvent::Base* trans,
103  MsgStream& msg ) const
104 {
105 // msg << MSG::DEBUG << "Loading ParticleBase from persistent state..."
106 // << endmsg;
107 
109  vxCnv.persToTrans( &pers->m_origin, &origin, msg );
110 
111  trans->set_origin (origin);
112  if (pers->m_hasCharge) {
113  trans->set_charge (pers->m_charge);
114  }
115  else {
116  trans->reset_charge();
117  }
118  if (pers->m_hasPdgId) {
119  trans->set_pdgId (pers->m_pdgId );
120  }
121  else {
122  trans->reset_pdgId();
123  }
124  trans->set_dataType (static_cast<ParticleDataType::DataType>( pers->m_dataType ));
125 
126  // convert AthenaBarCode
127  s_abcCnv.persToTrans((const AthenaBarCode_p1*)(&(pers->m_athenabarcode)),
128  &(trans->getAthenaBarCodeImpl()), msg);
129 
130 
131 // msg << MSG::DEBUG << "Loaded ParticleBase from persistent state [OK]"
132 // << endmsg;
133 
134  return;
135 }
136 
138  ParticleBase_p1* pers,
139  MsgStream& msg ) const
140 {
141 // msg << MSG::DEBUG << "Creating persistent state of ParticleBase..."
142 // << endmsg;
143 
144 #ifdef PBC_P1_VERBOSE
145  msg << MSG::WARNING
146  << "an old T->P ParticleBase converter is being called!"
147  // << endmsg
148  // << "consider migrating to ParticleBase(Cnv)_p2 !" << endmsg
149  // << "this method will be removed for 16.0.0"
150  << endmsg;
151 #endif
152 
153 
154  vxCnv.transToPers( &trans->originLink(), &pers->m_origin, msg );
155 
156  pers->m_charge = trans->charge();
157  pers->m_hasCharge = trans->hasCharge();
158  pers->m_pdgId = trans->pdgId();
159  pers->m_hasPdgId = trans->hasPdgId();
160  pers->m_dataType = trans->dataType();
161 
162  // convert AthenaBarCode
163  s_abcCnv.transToPers((const AthenaBarCodeImpl*)(&(trans->getAthenaBarCodeImpl())), (AthenaBarCode_p1*)(&(pers->m_athenabarcode)),msg);
164 
165 // msg << MSG::DEBUG << "Created persistent state of ParticleBase [OK]"
166 // << endmsg;
167  return;
168 }
ElementLinkCnv_p1.h
This file contains the class definition for the ElementLinkCnv_p1 class.
ParticleEvent::Base::reset_charge
void reset_charge()
Definition: Base.h:270
ParticleEvent::Base::set_dataType
void set_dataType(ParticleDataType::DataType x)
Definition: Base.h:247
AthenaBarCodeImpl
Definition: AthenaBarCodeImpl.h:37
AthenaBarCodeCnv_p1
Definition: AthenaBarCodeCnv_p1.h:20
ParticleEvent::Base::reset_pdgId
void reset_pdgId()
Definition: Base.h:277
ParticleBase
Definition: ParticleBase.h:17
ParticleBase::dataType
virtual ParticleDataType::DataType dataType() const
Return enum indicating real data, fast, or full simulation Return Type has a DataType enum with the f...
Definition: ParticleBase.h:93
ParticleBase_p1
Definition: ParticleBase_p1.h:26
ParticleBase::reset_charge
void reset_charge()
Definition: ParticleBase.h:64
ParticleEvent::Base::hasCharge
bool hasCharge() const
method to check if charge information is available
Definition: Base.h:218
ParticleBase.h
ParticleBase_p1::m_origin
ElementLinkInt_p1 m_origin
link to the particle's origin
Definition: ParticleBase_p1.h:54
ParticleBase_p1::m_hasCharge
bool m_hasCharge
switch to know if the particle has charge informations
Definition: ParticleBase_p1.h:60
ParticleEvent::Base::charge
ChargeType charge() const
returns charge as a typedef ChargeType currently Charge Type is a double for jets this may be changed...
Definition: Base.h:224
ParticleDataType::DataType
DataType
Definition: Event/EventKernel/EventKernel/IParticle.h:36
AthenaBarCodeCnv_p1::transToPers
virtual void transToPers(const AthenaBarCodeImpl *transObj, AthenaBarCode_p1 *persObj, MsgStream &) const override
Definition: AthenaBarCodeCnv_p1.h:36
AthenaBarCodeCnv_p1::persToTrans
virtual void persToTrans(const AthenaBarCode_p1 *persObj, AthenaBarCodeImpl *transObj, MsgStream &) const override
Definition: AthenaBarCodeCnv_p1.h:43
ParticleEvent::Base::set_charge
void set_charge(ChargeType x)
Definition: Base.h:254
ParticleBase::pdgId
virtual int pdgId() const
Return particle id.
Definition: ParticleBase.h:100
Base.h
ParticleBaseCnv_p1::persToTrans
virtual void persToTrans(const ParticleBase_p1 *persObj, ParticleBase *transObj, MsgStream &msg) const final
Method creating the transient representation of ParticleBase from its persistent representation Parti...
Definition: ParticleBaseCnv_p1.cxx:49
ParticleBase::hasCharge
virtual bool hasCharge() const
method to check if charge information is available
Definition: ParticleBase.h:97
ParticleBase::hasPdgId
virtual bool hasPdgId() const
method to check if particle id information is available
Definition: ParticleBase.h:99
ParticleEvent::Base::pdgId
int pdgId() const
Return enum indicating particle id the enum file is available in Event/EventKernel/PdtPdg....
Definition: Base.h:236
ParticleBase::originLink
virtual const ElementLink< VxContainer > & originLink() const
Return an ElementLink corresponding to particle's Origin.
Definition: ParticleBase.h:44
ParticleEvent::Base
Definition: Base.h:34
ElementLinkCnv_p1::transToPers
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ParticleBaseCnv_p1.h
VxContainer.h
ElementLinkCnv_p1
Definition: ElementLinkCnv_p1.h:27
ParticleBase::reset_pdgId
void reset_pdgId()
Definition: ParticleBase.h:65
ParticleBaseCnv_p1::~ParticleBaseCnv_p1
virtual ~ParticleBaseCnv_p1()
d-tor
Definition: ParticleBaseCnv_p1.cxx:42
ParticleEvent::Base::getAthenaBarCodeImpl
const AthenaBarCodeImpl & getAthenaBarCodeImpl() const
Definition: Base.h:96
ElementLinkCnv_p1::persToTrans
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
ParticleEvent::Base::hasPdgId
bool hasPdgId() const
method to check if particle id information is available
Definition: Base.h:230
ParticleBase::set_dataType
void set_dataType(ParticleDataType::DataType x)
Definition: ParticleBase.h:61
ParticleBase_p1::m_hasPdgId
bool m_hasPdgId
switch to know if the particle has PDG Id informations
Definition: ParticleBase_p1.h:66
ParticleBase::set_charge
void set_charge(ChargeType x)
Definition: ParticleBase.h:62
AthenaBarCode_p1
Definition: AthenaBarCode_p1.h:10
ParticleBase_p1::m_athenabarcode
AthenaBarCode_p1 m_athenabarcode
athena barcode
Definition: ParticleBase_p1.h:72
ParticleBase::charge
virtual ChargeType charge() const
returns charge as a typedef ChargeType currently Charge Type is a double for jets this may be changed...
Definition: ParticleBase.h:98
VxLinkCnv_t
ElementLinkCnv_p1< ElementLink< VxContainer > > VxLinkCnv_t
Definition: ParticleBaseCnv_p1.cxx:34
ParticleEvent::Base::dataType
ParticleDataType::DataType dataType() const
Return enum indicating real data, fast, or full simulation Return Type has a DataType enum with the f...
Definition: Base.h:204
ParticleBaseCnv_p1::transToPers
virtual void transToPers(const ParticleBase *transObj, ParticleBase_p1 *persObj, MsgStream &msg) const final
Method creating the persistent representation ParticleBase_p1 from its transient representation Parti...
Definition: ParticleBaseCnv_p1.cxx:80
ParticleEvent::Base::set_origin
void set_origin(const VxContainer *theContainer, int index)
Definition: Base.h:284
ParticleBase_p1::m_charge
float m_charge
Charge of the particle.
Definition: ParticleBase_p1.h:57
AthenaBarCodeCnv_p1.h
ParticleBase::set_origin
void set_origin(const VxContainer *theContainer, int index)
Definition: ParticleBase.h:81
ParticleBase_p1::m_pdgId
int m_pdgId
ParticleDataGroup Id of the particle.
Definition: ParticleBase_p1.h:63
ParticleBase::set_pdgId
void set_pdgId(int x)
Definition: ParticleBase.h:63
ParticleBase_p1::m_dataType
int m_dataType
type of data (see IParticle for more infos)
Definition: ParticleBase_p1.h:69
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ParticleEvent::Base::set_pdgId
void set_pdgId(int x)
Definition: Base.h:262
ParticleEvent::Base::originLink
const ElementLink< VxContainer > & originLink() const
Return the ElementLink to particle Origin
Definition: Base.cxx:38