ATLAS Offline Software
GenericMuonSimHitCollectionCnv_p3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 //#include <cmath>
12 
13 // Gaudi
14 #include "GaudiKernel/MsgStream.h"
15 // Athena
16 #include "StoreGate/StoreGateSvc.h"
17 
19 {
20  // for reasons of efficiency, set size before hand
21  unsigned int size=transCont->size();
22  persCont->m_GenericId.reserve(size);
23  persCont->m_globalTime.reserve(size);
24  persCont->m_globalpreTime.reserve(size);
25  // preStep Global
26  persCont->m_prestX.reserve(size);
27  persCont->m_prestY.reserve(size);
28  persCont->m_prestZ.reserve(size);
29  // preStep Local
30  persCont->m_prelocX.reserve(size);
31  persCont->m_prelocY.reserve(size);
32  persCont->m_prelocZ.reserve(size);
33  // postStep Global
34  persCont->m_stX.reserve(size);
35  persCont->m_stY.reserve(size);
36  persCont->m_stZ.reserve(size);
37  // postStep Local
38  persCont->m_locX.reserve(size);
39  persCont->m_locY.reserve(size);
40  persCont->m_locZ.reserve(size);
41  persCont->m_kineticEnergy.reserve(size);
42  persCont->m_particleEncoding.reserve(size);
43  persCont->m_ptX.reserve(size);
44  persCont->m_ptY.reserve(size);
45  persCont->m_ptZ.reserve(size);
46  persCont->m_depositEnergy.reserve(size);
47  persCont->m_StepLength.reserve(size);
48  persCont->m_partLink.reserve(size);
49 
50  // make convertor to handle HepMcParticleLinks
51  HepMcParticleLinkCnv_p3 hepMcPLCnv;
52  HepMcParticleLink_p3 persLink; // will use this as a temp object inside the loop
53 
54  // loop through container, filling pers object
55  GenericMuonSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
56  for (; it != itEnd; ++it) {
57  persCont->m_GenericId.push_back(it->GenericId());
58  persCont->m_globalTime.push_back(it->globalTime());
59  persCont->m_globalpreTime.push_back(it->globalpreTime());
60  // preStep Global
61  persCont->m_prestX.push_back(it->globalPrePosition().x());
62  persCont->m_prestY.push_back(it->globalPrePosition().y());
63  persCont->m_prestZ.push_back(it->globalPrePosition().z());
64  // preStep Local
65  persCont->m_prelocX.push_back(it->localPrePosition().x());
66  persCont->m_prelocY.push_back(it->localPrePosition().y());
67  persCont->m_prelocZ.push_back(it->localPrePosition().z());
68  // postStep Global
69  persCont->m_stX.push_back(it->globalPosition().x());
70  persCont->m_stY.push_back(it->globalPosition().y());
71  persCont->m_stZ.push_back(it->globalPosition().z());
72  // postStep Local
73  persCont->m_locX.push_back(it->localPosition().x());
74  persCont->m_locY.push_back(it->localPosition().y());
75  persCont->m_locZ.push_back(it->localPosition().z());
76  persCont->m_kineticEnergy.push_back(it->kineticEnergy());
77  persCont->m_particleEncoding.push_back(it->particleEncoding());
78  persCont->m_ptX.push_back(it->globalDirection().x());
79  persCont->m_ptY.push_back(it->globalDirection().y());
80  persCont->m_ptZ.push_back(it->globalDirection().z());
81  persCont->m_depositEnergy.push_back(it->depositEnergy());
82  persCont->m_StepLength.push_back(it->StepLength());
83 
84  hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
85  persCont->m_partLink.push_back(persLink);
86 
87  }
88 }
89 
90 
92  std::unique_ptr<GenericMuonSimHitCollection> trans(new GenericMuonSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
93  persToTrans(persObj, trans.get(), log);
94  return(trans.release());
95 }
96 
97 
99 {
100  HepMcParticleLinkCnv_p3 hepMcPLCnv;
101 
102  //transCont->reserve(persCont->m_GenericId.size());//done in createTransient
103  for (unsigned int i = 0; i < persCont->m_GenericId.size(); i++) {
104  //pre
105  Amg::Vector3D preposition(persCont->m_prestX[i], persCont->m_prestY[i], persCont->m_prestZ[i]);
106  Amg::Vector3D loc_preposition(persCont->m_prelocX[i], persCont->m_prelocY[i], persCont->m_prelocZ[i]);
107  //post
108  Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
109  Amg::Vector3D loc_position(persCont->m_locX[i], persCont->m_locY[i], persCont->m_locZ[i]);
110  Amg::Vector3D direction(persCont->m_ptX[i], persCont->m_ptY[i], persCont->m_ptZ[i]);
111 
112  HepMcParticleLink link;
113  hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
114 
115  transCont->Emplace(persCont->m_GenericId[i], persCont->m_globalTime[i], persCont->m_globalpreTime[i], position, loc_position, preposition, loc_preposition, persCont->m_particleEncoding[i], persCont->m_kineticEnergy[i], direction, persCont->m_depositEnergy[i], persCont->m_StepLength[i], link);
116  }
117 }
118 
HepMcParticleLinkCnv_p3
Definition: HepMcParticleLinkCnv_p3.h:29
HepMcParticleLinkCnv_p3.h
GenericMuonSimHitCollectionCnv_p3::createTransient
virtual GenericMuonSimHitCollection * createTransient(const Muon::GenericMuonSimHitCollection_p3 *persObj, MsgStream &log)
Definition: GenericMuonSimHitCollectionCnv_p3.cxx:91
HepMcParticleLinkCnv_p3::persToTrans
virtual void persToTrans(const HepMcParticleLink_p3 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
Definition: HepMcParticleLinkCnv_p3.cxx:15
Muon::GenericMuonSimHitCollection_p3::m_prestY
std::vector< float > m_prestY
Definition: GenericMuonSimHitCollection_p3.h:19
GenericMuonSimHitCollection
AtlasHitsVector< GenericMuonSimHit > GenericMuonSimHitCollection
Definition: GenericMuonSimHitCollection.h:15
AtlasHitsVector
Definition: AtlasHitsVector.h:33
Muon::GenericMuonSimHitCollection_p3::m_prelocY
std::vector< float > m_prelocY
Definition: GenericMuonSimHitCollection_p3.h:20
Muon::GenericMuonSimHitCollection_p3::m_globalTime
std::vector< float > m_globalTime
Definition: GenericMuonSimHitCollection_p3.h:16
skel.it
it
Definition: skel.GENtoEVGEN.py:396
GenericMuonSimHitCollectionCnv_p3::transToPers
virtual void transToPers(const GenericMuonSimHitCollection *transCont, Muon::GenericMuonSimHitCollection_p3 *persCont, MsgStream &log)
Definition: GenericMuonSimHitCollectionCnv_p3.cxx:18
Muon::GenericMuonSimHitCollection_p3::m_stZ
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
Definition: GenericMuonSimHitCollection_p3.h:22
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
GenericMuonSimHitCollectionCnv_p3::persToTrans
virtual void persToTrans(const Muon::GenericMuonSimHitCollection_p3 *persCont, GenericMuonSimHitCollection *transCont, MsgStream &log)
Definition: GenericMuonSimHitCollectionCnv_p3.cxx:98
GenericMuonSimHitCollectionCnv_p3.h
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
Muon::GenericMuonSimHitCollection_p3::m_locY
std::vector< float > m_locY
Definition: GenericMuonSimHitCollection_p3.h:23
Muon::GenericMuonSimHitCollection_p3::m_GenericId
std::vector< int > m_GenericId
Definition: GenericMuonSimHitCollection_p3.h:15
Muon::GenericMuonSimHitCollection_p3::m_prelocX
std::vector< float > m_prelocX
Definition: GenericMuonSimHitCollection_p3.h:20
Muon::GenericMuonSimHitCollection_p3::m_locX
std::vector< float > m_locX
Definition: GenericMuonSimHitCollection_p3.h:23
HepMcParticleLinkCnv_p3::transToPers
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p3 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p3 from its transient representation ...
Definition: HepMcParticleLinkCnv_p3.cxx:33
Muon::GenericMuonSimHitCollection_p3::m_depositEnergy
std::vector< float > m_depositEnergy
Definition: GenericMuonSimHitCollection_p3.h:27
Muon::GenericMuonSimHitCollection_p3::m_prelocZ
std::vector< float > m_prelocZ
Represents m_localPosition in transient class.
Definition: GenericMuonSimHitCollection_p3.h:20
Muon::GenericMuonSimHitCollection_p3::m_prestZ
std::vector< float > m_prestZ
Represents m_globalPosition in transient class.
Definition: GenericMuonSimHitCollection_p3.h:19
Muon::GenericMuonSimHitCollection_p3::m_StepLength
std::vector< float > m_StepLength
Definition: GenericMuonSimHitCollection_p3.h:28
Muon::GenericMuonSimHitCollection_p3::m_stY
std::vector< float > m_stY
Definition: GenericMuonSimHitCollection_p3.h:22
Muon::GenericMuonSimHitCollection_p3::m_globalpreTime
std::vector< float > m_globalpreTime
Definition: GenericMuonSimHitCollection_p3.h:17
GenericMuonSimHit.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::GenericMuonSimHitCollection_p3::m_prestX
std::vector< float > m_prestX
Definition: GenericMuonSimHitCollection_p3.h:19
Muon::GenericMuonSimHitCollection_p3::m_kineticEnergy
std::vector< float > m_kineticEnergy
Definition: GenericMuonSimHitCollection_p3.h:24
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
Muon::GenericMuonSimHitCollection_p3::m_ptZ
std::vector< float > m_ptZ
Definition: GenericMuonSimHitCollection_p3.h:26
Muon::GenericMuonSimHitCollection_p3::m_stX
std::vector< float > m_stX
Definition: GenericMuonSimHitCollection_p3.h:22
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
Muon::GenericMuonSimHitCollection_p3::m_locZ
std::vector< float > m_locZ
Represents m_localPosition in transient class.
Definition: GenericMuonSimHitCollection_p3.h:23
Muon::GenericMuonSimHitCollection_p3::m_ptY
std::vector< float > m_ptY
Definition: GenericMuonSimHitCollection_p3.h:26
Muon::GenericMuonSimHitCollection_p3::m_ptX
std::vector< float > m_ptX
Definition: GenericMuonSimHitCollection_p3.h:26
Muon::GenericMuonSimHitCollection_p3::m_partLink
std::vector< HepMcParticleLink_p3 > m_partLink
Definition: GenericMuonSimHitCollection_p3.h:30
Muon::GenericMuonSimHitCollection_p3::m_particleEncoding
std::vector< int > m_particleEncoding
Definition: GenericMuonSimHitCollection_p3.h:25
StoreGateSvc.h
Muon::GenericMuonSimHitCollection_p3
Definition: GenericMuonSimHitCollection_p3.h:13
GenericMuonSimHitCollection_p3.h