ATLAS Offline Software
Loading...
Searching...
No Matches
GenericMuonSimHitCollectionCnv_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
17
19{
20 // for reasons of efficiency, set size before hand
21 unsigned int size=transCont->size();
22 persCont->m_GenericId.reserve(size);
23 persCont->m_globalTime.reserve(size);
24 persCont->m_globalpreTime.reserve(size);
25 // preStep Global
26 persCont->m_prestX.reserve(size);
27 persCont->m_prestY.reserve(size);
28 persCont->m_prestZ.reserve(size);
29 // preStep Local
30 persCont->m_prelocX.reserve(size);
31 persCont->m_prelocY.reserve(size);
32 persCont->m_prelocZ.reserve(size);
33 // postStep Global
34 persCont->m_stX.reserve(size);
35 persCont->m_stY.reserve(size);
36 persCont->m_stZ.reserve(size);
37 // postStep Local
38 persCont->m_locX.reserve(size);
39 persCont->m_locY.reserve(size);
40 persCont->m_locZ.reserve(size);
41 persCont->m_kineticEnergy.reserve(size);
42 persCont->m_particleEncoding.reserve(size);
43 persCont->m_ptX.reserve(size);
44 persCont->m_ptY.reserve(size);
45 persCont->m_ptZ.reserve(size);
46 persCont->m_depositEnergy.reserve(size);
47 persCont->m_StepLength.reserve(size);
48 persCont->m_partLink.reserve(size);
49
50 // make convertor to handle HepMcParticleLinks
51 HepMcParticleLinkCnv_p1 hepMcPLCnv;
52 HepMcParticleLink_p1 persLink; // will use this as a temp object inside the loop
53
54 // loop through container, filling pers object
55 GenericMuonSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
56 for (; it != itEnd; ++it) {
57 persCont->m_GenericId.push_back(it->GenericId());
58 persCont->m_globalTime.push_back(it->globalTime());
59 persCont->m_globalpreTime.push_back(it->globalpreTime());
60 // preStep Global
61 persCont->m_prestX.push_back(it->globalPrePosition().x());
62 persCont->m_prestY.push_back(it->globalPrePosition().y());
63 persCont->m_prestZ.push_back(it->globalPrePosition().z());
64 // preStep Local
65 persCont->m_prelocX.push_back(it->localPrePosition().x());
66 persCont->m_prelocY.push_back(it->localPrePosition().y());
67 persCont->m_prelocZ.push_back(it->localPrePosition().z());
68 // postStep Global
69 persCont->m_stX.push_back(it->globalPosition().x());
70 persCont->m_stY.push_back(it->globalPosition().y());
71 persCont->m_stZ.push_back(it->globalPosition().z());
72 // postStep Local
73 persCont->m_locX.push_back(it->localPosition().x());
74 persCont->m_locY.push_back(it->localPosition().y());
75 persCont->m_locZ.push_back(it->localPosition().z());
76 persCont->m_kineticEnergy.push_back(it->kineticEnergy());
77 persCont->m_particleEncoding.push_back(it->particleEncoding());
78 persCont->m_ptX.push_back(it->globalDirection().x());
79 persCont->m_ptY.push_back(it->globalDirection().y());
80 persCont->m_ptZ.push_back(it->globalDirection().z());
81 persCont->m_depositEnergy.push_back(it->depositEnergy());
82 persCont->m_StepLength.push_back(it->StepLength());
83
84 hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
85 persCont->m_partLink.push_back(persLink);
86
87 }
88}
89
90
92 std::unique_ptr<GenericMuonSimHitCollection> trans(new GenericMuonSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
93 persToTrans(persObj, trans.get(), log);
94 return(trans.release());
95}
96
97
99{
100 HepMcParticleLinkCnv_p1 hepMcPLCnv;
101
102 //transCont->reserve(persCont->m_GenericId.size());//done in createTransient
103 for (unsigned int i = 0; i < persCont->m_GenericId.size(); i++) {
104 //pre
105 Amg::Vector3D preposition(persCont->m_prestX[i], persCont->m_prestY[i], persCont->m_prestZ[i]);
106 Amg::Vector3D loc_preposition(persCont->m_prelocX[i], persCont->m_prelocY[i], persCont->m_prelocZ[i]);
107 //post
108 Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
109 Amg::Vector3D loc_position(persCont->m_locX[i], persCont->m_locY[i], persCont->m_locZ[i]);
110 Amg::Vector3D direction(persCont->m_ptX[i], persCont->m_ptY[i], persCont->m_ptZ[i]);
111
113 hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
114
115 transCont->Emplace(persCont->m_GenericId[i], persCont->m_globalTime[i], persCont->m_globalpreTime[i], position, loc_position, preposition, loc_preposition, persCont->m_particleEncoding[i], persCont->m_kineticEnergy[i], direction, persCont->m_depositEnergy[i], persCont->m_StepLength[i], link);
116 }
117}
118
AtlasHitsVector< GenericMuonSimHit > GenericMuonSimHitCollection
const_iterator begin() const
void Emplace(Args &&... args)
size_type size() const
const_iterator end() const
virtual void transToPers(const GenericMuonSimHitCollection *transCont, Muon::GenericMuonSimHitCollection_p1 *persCont, MsgStream &log)
virtual GenericMuonSimHitCollection * createTransient(const Muon::GenericMuonSimHitCollection_p1 *persObj, MsgStream &log)
virtual void persToTrans(const Muon::GenericMuonSimHitCollection_p1 *persCont, GenericMuonSimHitCollection *transCont, MsgStream &log)
virtual void persToTrans(const HepMcParticleLink_p1 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p1 from its transient representation ...
std::vector< float > m_prelocZ
Represents m_localPosition in transient class.
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
std::vector< float > m_locZ
Represents m_localPosition in transient class.
std::vector< float > m_prestZ
Represents m_globalPosition in transient class.
std::vector< HepMcParticleLink_p1 > m_partLink
Eigen::Matrix< double, 3, 1 > Vector3D