ATLAS Offline Software
sTGCSimHitCollectionCnv_p3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
11 
12 // Gaudi
13 #include "GaudiKernel/MsgStream.h"
14 // Athena
15 #include "StoreGate/StoreGateSvc.h"
16 
17 
19 {
20  // for reasons of efficiency, set size before hand
21  unsigned int size=transCont->size();
22  persCont->m_sTGCId.reserve(size);
23  persCont->m_globalTime.reserve(size);
24  // postStep Global position
25  persCont->m_stX.reserve(size);
26  persCont->m_stY.reserve(size);
27  persCont->m_stZ.reserve(size);
28  persCont->m_particleEncoding.reserve(size);
29  persCont->m_depositEnergy.reserve(size);
30  persCont->m_partLink.reserve(size);
31  persCont->m_kineticEnergy.reserve(size);
32  // preStep global position
33  persCont->m_prestX.reserve(size);
34  persCont->m_prestY.reserve(size);
35  persCont->m_prestZ.reserve(size);
36 
37  // make convertor to handle HepMcParticleLinks
38  HepMcParticleLinkCnv_p2 hepMcPLCnv;
39  HepMcParticleLink_p2 persLink; // will use this as a temp object inside the loop
40 
41  // loop through container, filling pers object
42  sTGCSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
43  for (; it != itEnd; ++it) {
44  persCont->m_sTGCId.push_back(it->sTGCId());
45  persCont->m_globalTime.push_back(it->globalTime());
46  // postStep Global position
47  persCont->m_stX.push_back(it->globalPosition().x());
48  persCont->m_stY.push_back(it->globalPosition().y());
49  persCont->m_stZ.push_back(it->globalPosition().z());
50  persCont->m_particleEncoding.push_back(it->particleEncoding());
51  persCont->m_depositEnergy.push_back(it->depositEnergy());
52  persCont->m_kineticEnergy.push_back(it->kineticEnergy());
53  // preStep global position
54  persCont->m_prestX.push_back(it->globalPrePosition().x());
55  persCont->m_prestY.push_back(it->globalPrePosition().y());
56  persCont->m_prestZ.push_back(it->globalPrePosition().z());
57 
58  hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
59  persCont->m_partLink.push_back(persLink);
60 
61  }
62 }
63 
64 
66  std::unique_ptr<sTGCSimHitCollection> trans(new sTGCSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
67  persToTrans(persObj, trans.get(), log);
68  return(trans.release());
69 }
70 
71 
73 {
74  HepMcParticleLinkCnv_p2 hepMcPLCnv;
75 
76  //transCont->reserve(persCont->m_sTGCId.size());//done in createTransient
77  for (unsigned int i = 0; i < persCont->m_sTGCId.size(); i++) {
78  //postStep position
79  Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
80  // preStep position
81  Amg::Vector3D preposition(persCont->m_prestX[i], persCont->m_prestY[i], persCont->m_prestZ[i]);
82  // direction
83  Amg::Vector3D direction(persCont->m_stX[i] - persCont->m_prestX[i],
84  persCont->m_stY[i] - persCont->m_prestY[i],
85  persCont->m_stZ[i] - persCont->m_prestZ[i]);
86  // Normalize the direction vector if its length is greater than zero
87  if (direction.mag() > 0.0001) direction /= direction.mag();
88 
89  HepMcParticleLink link;
90  hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
91 
92  transCont->Emplace(persCont->m_sTGCId[i], persCont->m_globalTime[i], position,
93  persCont->m_particleEncoding[i], direction, persCont->m_depositEnergy[i], link,
94  persCont->m_kineticEnergy[i], preposition);
95  }
96 }
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
Muon::sTGCSimHitCollection_p3::m_kineticEnergy
std::vector< float > m_kineticEnergy
Definition: sTGCSimHitCollection_p3.h:21
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::sTGCSimHitCollection_p3::m_stY
std::vector< float > m_stY
Definition: sTGCSimHitCollection_p3.h:17
sTGCSimHitCollectionCnv_p3::transToPers
virtual void transToPers(const sTGCSimHitCollection *transCont, Muon::sTGCSimHitCollection_p3 *persCont, MsgStream &log)
Definition: sTGCSimHitCollectionCnv_p3.cxx:18
Muon::sTGCSimHitCollection_p3::m_globalTime
std::vector< float > m_globalTime
Definition: sTGCSimHitCollection_p3.h:16
sTGCSimHitCollection
AtlasHitsVector< sTGCSimHit > sTGCSimHitCollection
Definition: sTGCSimHitCollection.h:15
AtlasHitsVector
Definition: AtlasHitsVector.h:33
sTGCSimHit.h
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Muon::sTGCSimHitCollection_p3::m_depositEnergy
std::vector< float > m_depositEnergy
Definition: sTGCSimHitCollection_p3.h:19
sTGCSimHitCollectionCnv_p3.h
Muon::sTGCSimHitCollection_p3::m_prestX
std::vector< float > m_prestX
Definition: sTGCSimHitCollection_p3.h:22
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
Muon::sTGCSimHitCollection_p3::m_prestY
std::vector< float > m_prestY
Definition: sTGCSimHitCollection_p3.h:22
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
Muon::sTGCSimHitCollection_p3::m_stX
std::vector< float > m_stX
Definition: sTGCSimHitCollection_p3.h:17
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
sTGCSimHitCollection_p3.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
sTGCSimHitCollectionCnv_p3::persToTrans
virtual void persToTrans(const Muon::sTGCSimHitCollection_p3 *persCont, sTGCSimHitCollection *transCont, MsgStream &log)
Definition: sTGCSimHitCollectionCnv_p3.cxx:72
Muon::sTGCSimHitCollection_p3
Definition: sTGCSimHitCollection_p3.h:13
Muon::sTGCSimHitCollection_p3::m_sTGCId
std::vector< int > m_sTGCId
Definition: sTGCSimHitCollection_p3.h:15
Muon::sTGCSimHitCollection_p3::m_particleEncoding
std::vector< int > m_particleEncoding
Definition: sTGCSimHitCollection_p3.h:18
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::sTGCSimHitCollection_p3::m_stZ
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
Definition: sTGCSimHitCollection_p3.h:17
Muon::sTGCSimHitCollection_p3::m_partLink
std::vector< HepMcParticleLink_p2 > m_partLink
Definition: sTGCSimHitCollection_p3.h:20
HepMcParticleLinkCnv_p2.h
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Muon::sTGCSimHitCollection_p3::m_prestZ
std::vector< float > m_prestZ
Definition: sTGCSimHitCollection_p3.h:22
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
sTGCSimHitCollectionCnv_p3::createTransient
virtual sTGCSimHitCollection * createTransient(const Muon::sTGCSimHitCollection_p3 *persObj, MsgStream &log)
Definition: sTGCSimHitCollectionCnv_p3.cxx:65
HepMcParticleLinkCnv_p2
Definition: HepMcParticleLinkCnv_p2.h:29
StoreGateSvc.h