ATLAS Offline Software
MMSimHitCollectionCnv_p3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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_MMId.reserve(size);
23  persCont->m_globalTime.reserve(size);
24  // postStep Global
25  persCont->m_stX.reserve(size);
26  persCont->m_stY.reserve(size);
27  persCont->m_stZ.reserve(size);
28  persCont->m_kineticEnergy.reserve(size);
29  persCont->m_particleEncoding.reserve(size);
30  persCont->m_ptX.reserve(size);
31  persCont->m_ptY.reserve(size);
32  persCont->m_ptZ.reserve(size);
33  persCont->m_depositEnergy.reserve(size);
34  persCont->m_partLink.reserve(size);
35 
36  // make convertor to handle HepMcParticleLinks
37  HepMcParticleLinkCnv_p3 hepMcPLCnv;
38  HepMcParticleLink_p3 persLink; // will use this as a temp object inside the loop
39 
40  // loop through container, filling pers object
41  MMSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
42  for (; it != itEnd; ++it) {
43  persCont->m_MMId.push_back(it->MMId());
44  persCont->m_globalTime.push_back(it->globalTime());
45  // postStep Global
46  persCont->m_stX.push_back(it->globalPosition().x());
47  persCont->m_stY.push_back(it->globalPosition().y());
48  persCont->m_stZ.push_back(it->globalPosition().z());
49  persCont->m_kineticEnergy.push_back(it->kineticEnergy());
50  persCont->m_particleEncoding.push_back(it->particleEncoding());
51  persCont->m_ptX.push_back(it->globalDirection().x());
52  persCont->m_ptY.push_back(it->globalDirection().y());
53  persCont->m_ptZ.push_back(it->globalDirection().z());
54  persCont->m_depositEnergy.push_back(it->depositEnergy());
55 
56  hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
57  persCont->m_partLink.push_back(persLink);
58 
59  }
60 }
61 
62 
64  std::unique_ptr<MMSimHitCollection> trans(new MMSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
65  persToTrans(persObj, trans.get(), log);
66  return(trans.release());
67 }
68 
69 
71 {
72  HepMcParticleLinkCnv_p3 hepMcPLCnv;
73 
74  for (unsigned int i = 0; i < persCont->m_MMId.size(); i++) {
75  //post
76  Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
77  Amg::Vector3D direction(persCont->m_ptX[i], persCont->m_ptY[i], persCont->m_ptZ[i]);
78 
79  HepMcParticleLink link;
80  hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
81 
82  transCont->Emplace(persCont->m_MMId[i], persCont->m_globalTime[i], position, persCont->m_particleEncoding[i], persCont->m_kineticEnergy[i], direction, persCont->m_depositEnergy[i], link);
83  }
84 }
85 
MMSimHitCollectionCnv_p3::persToTrans
virtual void persToTrans(const Muon::MMSimHitCollection_p3 *persCont, MMSimHitCollection *transCont, MsgStream &log)
Definition: MMSimHitCollectionCnv_p3.cxx:70
HepMcParticleLinkCnv_p3
Definition: HepMcParticleLinkCnv_p3.h:29
Muon::MMSimHitCollection_p3::m_partLink
std::vector< HepMcParticleLink_p3 > m_partLink
Definition: MMSimHitCollection_p3.h:24
HepMcParticleLinkCnv_p3.h
Muon::MMSimHitCollection_p3::m_depositEnergy
std::vector< float > m_depositEnergy
Definition: MMSimHitCollection_p3.h:22
Muon::MMSimHitCollection_p3::m_ptY
std::vector< float > m_ptY
Definition: MMSimHitCollection_p3.h:21
Muon::MMSimHitCollection_p3::m_stX
std::vector< float > m_stX
Definition: MMSimHitCollection_p3.h:18
HepMcParticleLinkCnv_p3::persToTrans
virtual void persToTrans(const HepMcParticleLink_p3 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
Definition: HepMcParticleLinkCnv_p3.cxx:15
Muon::MMSimHitCollection_p3::m_stZ
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
Definition: MMSimHitCollection_p3.h:18
AtlasHitsVector
Definition: AtlasHitsVector.h:33
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Muon::MMSimHitCollection_p3::m_globalTime
std::vector< float > m_globalTime
Definition: MMSimHitCollection_p3.h:16
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
MMSimHitCollection
AtlasHitsVector< MMSimHit > MMSimHitCollection
Definition: MMSimHitCollection.h:15
Muon::MMSimHitCollection_p3::m_MMId
std::vector< int > m_MMId
Definition: MMSimHitCollection_p3.h:15
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
Muon::MMSimHitCollection_p3::m_particleEncoding
std::vector< int > m_particleEncoding
Definition: MMSimHitCollection_p3.h:20
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
MMSimHit.h
MMSimHitCollectionCnv_p3::createTransient
virtual MMSimHitCollection * createTransient(const Muon::MMSimHitCollection_p3 *persObj, MsgStream &log)
Definition: MMSimHitCollectionCnv_p3.cxx:63
lumiFormat.i
int i
Definition: lumiFormat.py:85
HepMcParticleLinkCnv_p3::transToPers
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p3 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p3 from its transient representation ...
Definition: HepMcParticleLinkCnv_p3.cxx:33
Muon::MMSimHitCollection_p3
Definition: MMSimHitCollection_p3.h:13
MMSimHitCollectionCnv_p3.h
MMSimHitCollection_p3.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::MMSimHitCollection_p3::m_ptZ
std::vector< float > m_ptZ
Definition: MMSimHitCollection_p3.h:21
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
MMSimHitCollectionCnv_p3::transToPers
virtual void transToPers(const MMSimHitCollection *transCont, Muon::MMSimHitCollection_p3 *persCont, MsgStream &log)
Definition: MMSimHitCollectionCnv_p3.cxx:18
Muon::MMSimHitCollection_p3::m_ptX
std::vector< float > m_ptX
Definition: MMSimHitCollection_p3.h:21
StoreGateSvc.h
Muon::MMSimHitCollection_p3::m_stY
std::vector< float > m_stY
Definition: MMSimHitCollection_p3.h:18
Muon::MMSimHitCollection_p3::m_kineticEnergy
std::vector< float > m_kineticEnergy
Definition: MMSimHitCollection_p3.h:19