ATLAS Offline Software
GenericMuonSimHitCollectionCnv_p2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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_p2 hepMcPLCnv;
52  HepMcParticleLink_p2 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_p2 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 
Muon::GenericMuonSimHitCollection_p2::m_kineticEnergy
std::vector< float > m_kineticEnergy
Definition: GenericMuonSimHitCollection_p2.h:24
HepMcParticleLinkCnv_p2::persToTrans
virtual void persToTrans(const HepMcParticleLink_p2 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
Definition: HepMcParticleLinkCnv_p2.cxx:16
HepMcParticleLinkCnv_p2::transToPers
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p2 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p2 from its transient representation ...
Definition: HepMcParticleLinkCnv_p2.cxx:36
Muon::GenericMuonSimHitCollection_p2::m_prelocY
std::vector< float > m_prelocY
Definition: GenericMuonSimHitCollection_p2.h:20
Muon::GenericMuonSimHitCollection_p2::m_locX
std::vector< float > m_locX
Definition: GenericMuonSimHitCollection_p2.h:23
Muon::GenericMuonSimHitCollection_p2::m_particleEncoding
std::vector< int > m_particleEncoding
Definition: GenericMuonSimHitCollection_p2.h:25
Muon::GenericMuonSimHitCollection_p2::m_GenericId
std::vector< int > m_GenericId
Definition: GenericMuonSimHitCollection_p2.h:15
Muon::GenericMuonSimHitCollection_p2::m_prestY
std::vector< float > m_prestY
Definition: GenericMuonSimHitCollection_p2.h:19
Muon::GenericMuonSimHitCollection_p2::m_prelocZ
std::vector< float > m_prelocZ
Represents m_localPosition in transient class.
Definition: GenericMuonSimHitCollection_p2.h:20
GenericMuonSimHitCollection
AtlasHitsVector< GenericMuonSimHit > GenericMuonSimHitCollection
Definition: GenericMuonSimHitCollection.h:15
AtlasHitsVector
Definition: AtlasHitsVector.h:33
skel.it
it
Definition: skel.GENtoEVGEN.py:396
GenericMuonSimHitCollectionCnv_p2.h
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
Muon::GenericMuonSimHitCollection_p2::m_locY
std::vector< float > m_locY
Definition: GenericMuonSimHitCollection_p2.h:23
Muon::GenericMuonSimHitCollection_p2::m_ptX
std::vector< float > m_ptX
Definition: GenericMuonSimHitCollection_p2.h:26
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
Muon::GenericMuonSimHitCollection_p2::m_globalTime
std::vector< float > m_globalTime
Definition: GenericMuonSimHitCollection_p2.h:16
Muon::GenericMuonSimHitCollection_p2::m_StepLength
std::vector< float > m_StepLength
Definition: GenericMuonSimHitCollection_p2.h:28
lumiFormat.i
int i
Definition: lumiFormat.py:85
GenericMuonSimHitCollectionCnv_p2::persToTrans
virtual void persToTrans(const Muon::GenericMuonSimHitCollection_p2 *persCont, GenericMuonSimHitCollection *transCont, MsgStream &log)
Definition: GenericMuonSimHitCollectionCnv_p2.cxx:98
Muon::GenericMuonSimHitCollection_p2::m_depositEnergy
std::vector< float > m_depositEnergy
Definition: GenericMuonSimHitCollection_p2.h:27
Muon::GenericMuonSimHitCollection_p2::m_partLink
std::vector< HepMcParticleLink_p2 > m_partLink
Definition: GenericMuonSimHitCollection_p2.h:30
Muon::GenericMuonSimHitCollection_p2::m_prestZ
std::vector< float > m_prestZ
Represents m_globalPosition in transient class.
Definition: GenericMuonSimHitCollection_p2.h:19
Muon::GenericMuonSimHitCollection_p2::m_globalpreTime
std::vector< float > m_globalpreTime
Definition: GenericMuonSimHitCollection_p2.h:17
GenericMuonSimHit.h
Muon::GenericMuonSimHitCollection_p2::m_stZ
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
Definition: GenericMuonSimHitCollection_p2.h:22
GenericMuonSimHitCollectionCnv_p2::transToPers
virtual void transToPers(const GenericMuonSimHitCollection *transCont, Muon::GenericMuonSimHitCollection_p2 *persCont, MsgStream &log)
Definition: GenericMuonSimHitCollectionCnv_p2.cxx:18
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::GenericMuonSimHitCollection_p2::m_prestX
std::vector< float > m_prestX
Definition: GenericMuonSimHitCollection_p2.h:19
Muon::GenericMuonSimHitCollection_p2
Definition: GenericMuonSimHitCollection_p2.h:13
Muon::GenericMuonSimHitCollection_p2::m_stY
std::vector< float > m_stY
Definition: GenericMuonSimHitCollection_p2.h:22
HepMcParticleLinkCnv_p2.h
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
Muon::GenericMuonSimHitCollection_p2::m_ptY
std::vector< float > m_ptY
Definition: GenericMuonSimHitCollection_p2.h:26
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
Muon::GenericMuonSimHitCollection_p2::m_prelocX
std::vector< float > m_prelocX
Definition: GenericMuonSimHitCollection_p2.h:20
HepMcParticleLinkCnv_p2
Definition: HepMcParticleLinkCnv_p2.h:29
StoreGateSvc.h
Muon::GenericMuonSimHitCollection_p2::m_locZ
std::vector< float > m_locZ
Represents m_localPosition in transient class.
Definition: GenericMuonSimHitCollection_p2.h:23
GenericMuonSimHitCollectionCnv_p2::createTransient
virtual GenericMuonSimHitCollection * createTransient(const Muon::GenericMuonSimHitCollection_p2 *persObj, MsgStream &log)
Definition: GenericMuonSimHitCollectionCnv_p2.cxx:91
Muon::GenericMuonSimHitCollection_p2::m_stX
std::vector< float > m_stX
Definition: GenericMuonSimHitCollection_p2.h:22
Muon::GenericMuonSimHitCollection_p2::m_ptZ
std::vector< float > m_ptZ
Definition: GenericMuonSimHitCollection_p2.h:26
GenericMuonSimHitCollection_p2.h