ATLAS Offline Software
RPCSimHitCollectionCnv_p1.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  log<<MSG::INFO<<"Processing "<<endmsg;
21  // for reasons of efficiency, set size before hand
22  unsigned int size=transCont->size();
23  persCont->m_RPCid.reserve(size);
24  persCont->m_globalTime.reserve(size);
25  persCont->m_stX.reserve(size);
26  persCont->m_stY.reserve(size);
27  persCont->m_stZ.reserve(size);
28 
29  // persCont->m_meanTime.reserve(size);
30  persCont->m_partLink.reserve(size);
31 
32  // make convertor to handle HepMcParticleLinks
33  HepMcParticleLinkCnv_p1 hepMcPLCnv;
34  HepMcParticleLink_p1 persLink; // will use this as a temp object inside the loop
35 
36  // loop through container, filling pers object
37  RPCSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
38  for (; it != itEnd; ++it) {
39  persCont->m_RPCid.push_back(it->RPCid());
40  persCont->m_globalTime.push_back(it->globalTime());
41  persCont->m_stX.push_back(it->localPosition().x());
42  persCont->m_stY.push_back(it->localPosition().y());
43  persCont->m_stZ.push_back(it->localPosition().z());
44 
45  hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
46  persCont->m_partLink.push_back(persLink);
47  }
48 }
49 
50 
52  std::unique_ptr<RPCSimHitCollection> trans(new RPCSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
53  persToTrans(persObj, trans.get(), log);
54  return(trans.release());
55 }
56 
57 
59 {
60  HepMcParticleLinkCnv_p1 hepMcPLCnv;
61 
62  //transCont->reserve(persCont->m_RPCid.size());//done in createTransient
63  for (unsigned int i = 0; i < persCont->m_RPCid.size(); i++) {
64  Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
65 
66  HepMcParticleLink link;
67  hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
68 
69  transCont->Emplace(persCont->m_RPCid[i], persCont->m_globalTime[i], position,
70  link,Amg::Vector3D(0.,0.,0.),-1,-1,0,-1);
71  }
72 }
73 
RPCSimHitCollection_p1.h
Muon::RPCSimHitCollection_p1::m_stY
std::vector< float > m_stY
Definition: RPCSimHitCollection_p1.h:17
RPCSimHitCollectionCnv_p1::persToTrans
virtual void persToTrans(const Muon::RPCSimHitCollection_p1 *persCont, RPCSimHitCollection *transCont, MsgStream &log)
Definition: RPCSimHitCollectionCnv_p1.cxx:58
Muon::RPCSimHitCollection_p1::m_stZ
std::vector< float > m_stZ
Represents m_localPosition in transient class.
Definition: RPCSimHitCollection_p1.h:17
RPCSimHitCollectionCnv_p1::createTransient
virtual RPCSimHitCollection * createTransient(const Muon::RPCSimHitCollection_p1 *persObj, MsgStream &log)
Definition: RPCSimHitCollectionCnv_p1.cxx:51
AtlasHitsVector
Definition: AtlasHitsVector.h:33
skel.it
it
Definition: skel.GENtoEVGEN.py:423
RPCSimHitCollection
AtlasHitsVector< RPCSimHit > RPCSimHitCollection
Definition: RPCSimHitCollection.h:15
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
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:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
RPCSimHitCollectionCnv_p1::transToPers
virtual void transToPers(const RPCSimHitCollection *transCont, Muon::RPCSimHitCollection_p1 *persCont, MsgStream &log)
Definition: RPCSimHitCollectionCnv_p1.cxx:18
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
Muon::RPCSimHitCollection_p1::m_stX
std::vector< float > m_stX
Definition: RPCSimHitCollection_p1.h:17
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
HepMcParticleLinkCnv_p1
Definition: HepMcParticleLinkCnv_p1.h:33
Muon::RPCSimHitCollection_p1::m_globalTime
std::vector< float > m_globalTime
Definition: RPCSimHitCollection_p1.h:16
RPCSimHitCollectionCnv_p1.h
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
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
RPCSimHit.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Muon::RPCSimHitCollection_p1::m_RPCid
std::vector< int > m_RPCid
Definition: RPCSimHitCollection_p1.h:15
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
StoreGateSvc.h
Muon::RPCSimHitCollection_p1::m_partLink
std::vector< HepMcParticleLink_p1 > m_partLink
Definition: RPCSimHitCollection_p1.h:18
Muon::RPCSimHitCollection_p1
Definition: RPCSimHitCollection_p1.h:13