ATLAS Offline Software
RPCSimHitCollectionCnv_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_RPCid.reserve(size);
23  persCont->m_globalTime.reserve(size);
24  persCont->m_stX.reserve(size);
25  persCont->m_stY.reserve(size);
26  persCont->m_stZ.reserve(size);
27  persCont->m_partLink.reserve(size);
28  persCont->m_stopX.reserve(size);
29  persCont->m_stopY.reserve(size);
30  persCont->m_stopZ.reserve(size);
31  persCont->m_energyDeposit.reserve(size);
32  persCont->m_stepLength.reserve(size);
33  persCont->m_particleEncoding.reserve(size);
34  persCont->m_kineticEnergy.reserve(size);
35 
36  // make convertor to handle HepMcParticleLinks
37  HepMcParticleLinkCnv_p1 hepMcPLCnv;
38  HepMcParticleLink_p1 persLink; // will use this as a temp object inside the loop
39 
40  // loop through container, filling pers object
41  RPCSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
42  for (; it != itEnd; ++it) {
43  persCont->m_RPCid.push_back(it->RPCid());
44  persCont->m_globalTime.push_back(it->globalTime());
45  persCont->m_stX.push_back(it->localPosition().x());
46  persCont->m_stY.push_back(it->localPosition().y());
47  persCont->m_stZ.push_back(it->localPosition().z());
48 
49  hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
50  persCont->m_partLink.push_back(persLink);
51  persCont->m_stopX.push_back(it->postLocalPosition().x());
52  persCont->m_stopY.push_back(it->postLocalPosition().y());
53  persCont->m_stopZ.push_back(it->postLocalPosition().z());
54  persCont->m_energyDeposit.push_back(it->energyDeposit());
55  persCont->m_stepLength.push_back(it->stepLength());
56  persCont->m_particleEncoding.push_back(it->particleEncoding());
57  persCont->m_kineticEnergy.push_back(it->kineticEnergy());
58  }
59 }
60 
61 
63  std::unique_ptr<RPCSimHitCollection> trans(new RPCSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
64  persToTrans(persObj, trans.get(), log);
65  return(trans.release());
66 }
67 
68 
70 {
71  HepMcParticleLinkCnv_p1 hepMcPLCnv;
72 
73  //transCont->reserve(persCont->m_RPCid.size());//done in createTransient
74  for (unsigned int i = 0; i < persCont->m_RPCid.size(); i++) {
75  Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
76  Amg::Vector3D postPosition(persCont->m_stopX[i], persCont->m_stopY[i], persCont->m_stopZ[i]);
77 
78 
79  HepMcParticleLink link;
80  hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
81 
82  transCont->Emplace(persCont->m_RPCid[i], persCont->m_globalTime[i], position,
83  link, postPosition,
84  persCont->m_energyDeposit[i], persCont->m_stepLength[i],
85  persCont->m_particleEncoding[i], persCont->m_kineticEnergy[i]);
86  }
87 }
88 
Muon::RPCSimHitCollection_p2::m_stepLength
std::vector< float > m_stepLength
Definition: RPCSimHitCollection_p2.h:21
AtlasHitsVector
Definition: AtlasHitsVector.h:33
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Muon::RPCSimHitCollection_p2
Definition: RPCSimHitCollection_p2.h:13
RPCSimHitCollection
AtlasHitsVector< RPCSimHit > RPCSimHitCollection
Definition: RPCSimHitCollection.h:15
Muon::RPCSimHitCollection_p2::m_stX
std::vector< float > m_stX
Definition: RPCSimHitCollection_p2.h:17
Muon::RPCSimHitCollection_p2::m_stopZ
std::vector< float > m_stopZ
Represents end-point of the g4 step in the transient class.
Definition: RPCSimHitCollection_p2.h:19
Muon::RPCSimHitCollection_p2::m_stZ
std::vector< float > m_stZ
Represents m_localPosition in transient class.
Definition: RPCSimHitCollection_p2.h:17
RPCSimHitCollectionCnv_p2::createTransient
virtual RPCSimHitCollection * createTransient(const Muon::RPCSimHitCollection_p2 *persObj, MsgStream &log)
Definition: RPCSimHitCollectionCnv_p2.cxx:62
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
Muon::RPCSimHitCollection_p2::m_RPCid
std::vector< int > m_RPCid
Definition: RPCSimHitCollection_p2.h:15
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
Muon::RPCSimHitCollection_p2::m_particleEncoding
std::vector< int > m_particleEncoding
Definition: RPCSimHitCollection_p2.h:22
Muon::RPCSimHitCollection_p2::m_stopX
std::vector< float > m_stopX
Definition: RPCSimHitCollection_p2.h:19
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
Muon::RPCSimHitCollection_p2::m_stY
std::vector< float > m_stY
Definition: RPCSimHitCollection_p2.h:17
lumiFormat.i
int i
Definition: lumiFormat.py:92
Muon::RPCSimHitCollection_p2::m_partLink
std::vector< HepMcParticleLink_p1 > m_partLink
Definition: RPCSimHitCollection_p2.h:18
Muon::RPCSimHitCollection_p2::m_kineticEnergy
std::vector< float > m_kineticEnergy
Definition: RPCSimHitCollection_p2.h:23
HepMcParticleLinkCnv_p1.h
HepMcParticleLinkCnv_p1::transToPers
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p1 from its transient representation ...
Definition: HepMcParticleLinkCnv_p1.cxx:46
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
HepMcParticleLinkCnv_p1
Definition: HepMcParticleLinkCnv_p1.h:33
RPCSimHitCollection_p2.h
Muon::RPCSimHitCollection_p2::m_globalTime
std::vector< float > m_globalTime
Definition: RPCSimHitCollection_p2.h:16
HepMcParticleLinkCnv_p1::persToTrans
virtual void persToTrans(const HepMcParticleLink_p1 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
Definition: HepMcParticleLinkCnv_p1.cxx:30
Muon::RPCSimHitCollection_p2::m_energyDeposit
std::vector< float > m_energyDeposit
Definition: RPCSimHitCollection_p2.h:20
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
RPCSimHit.h
RPCSimHitCollectionCnv_p2.h
RPCSimHitCollectionCnv_p2::persToTrans
virtual void persToTrans(const Muon::RPCSimHitCollection_p2 *persCont, RPCSimHitCollection *transCont, MsgStream &log)
Definition: RPCSimHitCollectionCnv_p2.cxx:69
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
RPCSimHitCollectionCnv_p2::transToPers
virtual void transToPers(const RPCSimHitCollection *transCont, Muon::RPCSimHitCollection_p2 *persCont, MsgStream &log)
Definition: RPCSimHitCollectionCnv_p2.cxx:18
Muon::RPCSimHitCollection_p2::m_stopY
std::vector< float > m_stopY
Definition: RPCSimHitCollection_p2.h:19
StoreGateSvc.h