ATLAS Offline Software
sTGCSimHitCollectionCnv_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 
18 
20 {
21  // for reasons of efficiency, set size before hand
22  unsigned int size=transCont->size();
23  persCont->m_sTGCId.reserve(size);
24  persCont->m_globalTime.reserve(size);
25  // postStep Global
26  persCont->m_stX.reserve(size);
27  persCont->m_stY.reserve(size);
28  persCont->m_stZ.reserve(size);
29  // postStep Local
30  persCont->m_particleEncoding.reserve(size);
31  persCont->m_ptX.reserve(size);
32  persCont->m_ptY.reserve(size);
33  persCont->m_ptZ.reserve(size);
34  persCont->m_depositEnergy.reserve(size);
35  persCont->m_partLink.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
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  // postStep Local
51  persCont->m_particleEncoding.push_back(it->particleEncoding());
52  persCont->m_ptX.push_back(it->globalDirection().x());
53  persCont->m_ptY.push_back(it->globalDirection().y());
54  persCont->m_ptZ.push_back(it->globalDirection().z());
55  persCont->m_depositEnergy.push_back(it->depositEnergy());
56 
57  hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
58  persCont->m_partLink.push_back(persLink);
59 
60  }
61 }
62 
63 
65  std::unique_ptr<sTGCSimHitCollection> trans(new sTGCSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
66  persToTrans(persObj, trans.get(), log);
67  return(trans.release());
68 }
69 
70 
72 {
73  HepMcParticleLinkCnv_p2 hepMcPLCnv;
74 
75  //transCont->reserve(persCont->m_sTGCId.size());//done in createTransient
76  for (unsigned int i = 0; i < persCont->m_sTGCId.size(); i++) {
77  //post
78  Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
79  Amg::Vector3D direction(persCont->m_ptX[i], persCont->m_ptY[i], persCont->m_ptZ[i]);
80 
81  HepMcParticleLink link;
82  hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
83 
84  // The _p2 class doesn't have kinetic energy and pre-step position.
85  // So, set kinectic energy to -1 and pre-step position to (0,0,0).
86  Amg::Vector3D preposition(0., 0., 0.);
87 
88  transCont->Emplace(persCont->m_sTGCId[i], persCont->m_globalTime[i], position, persCont->m_particleEncoding[i],
89  direction, persCont->m_depositEnergy[i], link, -1.0, preposition);
90  }
91 }
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_p2::m_depositEnergy
std::vector< float > m_depositEnergy
Definition: sTGCSimHitCollection_p2.h:21
Muon::sTGCSimHitCollection_p2::m_stZ
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
Definition: sTGCSimHitCollection_p2.h:18
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_p2
Definition: sTGCSimHitCollection_p2.h:13
sTGCSimHitCollectionCnv_p2::transToPers
virtual void transToPers(const sTGCSimHitCollection *transCont, Muon::sTGCSimHitCollection_p2 *persCont, MsgStream &log)
Definition: sTGCSimHitCollectionCnv_p2.cxx:19
sTGCSimHitCollectionCnv_p2.h
Muon::sTGCSimHitCollection_p2::m_stY
std::vector< float > m_stY
Definition: sTGCSimHitCollection_p2.h:18
sTGCSimHitCollection
AtlasHitsVector< sTGCSimHit > sTGCSimHitCollection
Definition: sTGCSimHitCollection.h:15
sTGCSimHitCollectionCnv_p2::persToTrans
virtual void persToTrans(const Muon::sTGCSimHitCollection_p2 *persCont, sTGCSimHitCollection *transCont, MsgStream &log)
Definition: sTGCSimHitCollectionCnv_p2.cxx:71
AtlasHitsVector
Definition: AtlasHitsVector.h:33
sTGCSimHit.h
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Muon::sTGCSimHitCollection_p2::m_particleEncoding
std::vector< int > m_particleEncoding
Definition: sTGCSimHitCollection_p2.h:19
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
Muon::sTGCSimHitCollection_p2::m_globalTime
std::vector< float > m_globalTime
Definition: sTGCSimHitCollection_p2.h:16
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
Muon::sTGCSimHitCollection_p2::m_stX
std::vector< float > m_stX
Definition: sTGCSimHitCollection_p2.h:18
lumiFormat.i
int i
Definition: lumiFormat.py:85
Muon::sTGCSimHitCollection_p2::m_sTGCId
std::vector< int > m_sTGCId
Definition: sTGCSimHitCollection_p2.h:15
Muon::sTGCSimHitCollection_p2::m_ptX
std::vector< float > m_ptX
Definition: sTGCSimHitCollection_p2.h:20
sTGCSimHitCollection_p2.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
HepMcParticleLinkCnv_p2.h
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
Muon::sTGCSimHitCollection_p2::m_ptY
std::vector< float > m_ptY
Definition: sTGCSimHitCollection_p2.h:20
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
sTGCSimHitCollectionCnv_p2::createTransient
virtual sTGCSimHitCollection * createTransient(const Muon::sTGCSimHitCollection_p2 *persObj, MsgStream &log)
Definition: sTGCSimHitCollectionCnv_p2.cxx:64
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
Muon::sTGCSimHitCollection_p2::m_partLink
std::vector< HepMcParticleLink_p2 > m_partLink
Definition: sTGCSimHitCollection_p2.h:23
Muon::sTGCSimHitCollection_p2::m_ptZ
std::vector< float > m_ptZ
Definition: sTGCSimHitCollection_p2.h:20
HepMcParticleLinkCnv_p2
Definition: HepMcParticleLinkCnv_p2.h:29
StoreGateSvc.h