ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleBaseCnv_p1.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2025 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
22
23// ParticleEvent includes
26
27// ParticleEventTPCnv includes
29
30// internal: do not change
31//#define PBC_P1_VERBOSE 1
32//
33
35
36// pre-allocate converters
37static const VxLinkCnv_t vxCnv;
39
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(static_cast<const AthenaBarCodeImpl*>(&(trans->getAthenaBarCodeImpl())), static_cast<AthenaBarCode_p1*>(&(pers->m_athenabarcode)),msg);
164
165// msg << MSG::DEBUG << "Created persistent state of ParticleBase [OK]"
166// << endmsg;
167 return;
168}
#define endmsg
This file contains the class definition for the ElementLinkCnv_p1 class.
static const VxLinkCnv_t vxCnv
static const AthenaBarCodeCnv_p1 s_abcCnv
ElementLinkCnv_p1< ElementLink< VxContainer > > VxLinkCnv_t
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...
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...
virtual ~ParticleBaseCnv_p1()
d-tor
AthenaBarCode_p1 m_athenabarcode
athena barcode
bool m_hasPdgId
switch to know if the particle has PDG Id informations
float m_charge
Charge of the particle.
ElementLinkInt_p1 m_origin
link to the particle's origin
int m_pdgId
ParticleDataGroup Id of the particle.
int m_dataType
type of data (see IParticle for more infos)
bool m_hasCharge
switch to know if the particle has charge informations
void set_charge(ChargeType x)
void set_origin(const VxContainer *theContainer, int index)
virtual ParticleDataType::DataType dataType() const
Return enum indicating real data, fast, or full simulation Return Type has a DataType enum with the f...
void set_dataType(ParticleDataType::DataType x)
virtual ChargeType charge() const
returns charge as a typedef ChargeType currently Charge Type is a double for jets this may be changed...
virtual bool hasCharge() const
method to check if charge information is available
void reset_pdgId()
virtual const ElementLink< VxContainer > & originLink() const
Return an ElementLink corresponding to particle's Origin.
virtual bool hasPdgId() const
method to check if particle id information is available
virtual int pdgId() const
Return particle id.
void set_pdgId(int x)
void reset_charge()
bool hasCharge() const
method to check if charge information is available
Definition Base.h:218
void set_charge(ChargeType x)
Definition Base.h:254
void set_dataType(ParticleDataType::DataType x)
Definition Base.h:247
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
void set_origin(const VxContainer *theContainer, int index)
Definition Base.h:284
void reset_charge()
Definition Base.h:270
void set_pdgId(int x)
Definition Base.h:262
const AthenaBarCodeImpl & getAthenaBarCodeImpl() const
Definition Base.h:96
const ElementLink< VxContainer > & originLink() const
Return the ElementLink to particle Origin.
Definition Base.cxx:38
bool hasPdgId() const
method to check if particle id information is available
Definition Base.h:230
int pdgId() const
Return enum indicating particle id the enum file is available in Event/EventKernel/PdtPdg....
Definition Base.h:236
void reset_pdgId()
Definition Base.h:277
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
MsgStream & msg
Definition testRead.cxx:32