ATLAS Offline Software
Loading...
Searching...
No Matches
sTGCSimHitCollectionCnv_p3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
9
11
12// Gaudi
13#include "GaudiKernel/MsgStream.h"
14// Athena
16
17
19{
20 // for reasons of efficiency, set size before hand
21 unsigned int size=transCont->size();
22 persCont->m_sTGCId.reserve(size);
23 persCont->m_globalTime.reserve(size);
24 // postStep Global position
25 persCont->m_stX.reserve(size);
26 persCont->m_stY.reserve(size);
27 persCont->m_stZ.reserve(size);
28 persCont->m_particleEncoding.reserve(size);
29 persCont->m_depositEnergy.reserve(size);
30 persCont->m_partLink.reserve(size);
31 persCont->m_kineticEnergy.reserve(size);
32 // preStep global position
33 persCont->m_prestX.reserve(size);
34 persCont->m_prestY.reserve(size);
35 persCont->m_prestZ.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 position
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 persCont->m_particleEncoding.push_back(it->particleEncoding());
51 persCont->m_depositEnergy.push_back(it->depositEnergy());
52 persCont->m_kineticEnergy.push_back(it->kineticEnergy());
53 // preStep global position
54 persCont->m_prestX.push_back(it->globalPrePosition().x());
55 persCont->m_prestY.push_back(it->globalPrePosition().y());
56 persCont->m_prestZ.push_back(it->globalPrePosition().z());
57
58 hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
59 persCont->m_partLink.push_back(persLink);
60
61 }
62}
63
64
66 std::unique_ptr<sTGCSimHitCollection> trans(new sTGCSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
67 persToTrans(persObj, trans.get(), log);
68 return(trans.release());
69}
70
71
73{
74 HepMcParticleLinkCnv_p2 hepMcPLCnv;
75
76 //transCont->reserve(persCont->m_sTGCId.size());//done in createTransient
77 for (unsigned int i = 0; i < persCont->m_sTGCId.size(); i++) {
78 //postStep position
79 Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
80 // preStep position
81 Amg::Vector3D preposition(persCont->m_prestX[i], persCont->m_prestY[i], persCont->m_prestZ[i]);
82 // direction
83 Amg::Vector3D direction(persCont->m_stX[i] - persCont->m_prestX[i],
84 persCont->m_stY[i] - persCont->m_prestY[i],
85 persCont->m_stZ[i] - persCont->m_prestZ[i]);
86 // Normalize the direction vector if its length is greater than zero
87 if (direction.mag() > 0.0001) direction /= direction.mag();
88
90 hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
91
92 transCont->Emplace(persCont->m_sTGCId[i], persCont->m_globalTime[i], position,
93 persCont->m_particleEncoding[i], direction, persCont->m_depositEnergy[i], link,
94 persCont->m_kineticEnergy[i], preposition);
95 }
96}
CONT::const_iterator const_iterator
const_iterator begin() const
void Emplace(Args &&... args)
size_type size() const
const_iterator end() const
virtual void persToTrans(const HepMcParticleLink_p2 *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_p2 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p2 from its transient representation ...
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
std::vector< HepMcParticleLink_p2 > m_partLink
virtual sTGCSimHitCollection * createTransient(const Muon::sTGCSimHitCollection_p3 *persObj, MsgStream &log)
virtual void persToTrans(const Muon::sTGCSimHitCollection_p3 *persCont, sTGCSimHitCollection *transCont, MsgStream &log)
virtual void transToPers(const sTGCSimHitCollection *transCont, Muon::sTGCSimHitCollection_p3 *persCont, MsgStream &log)
Eigen::Matrix< double, 3, 1 > Vector3D
AtlasHitsVector< sTGCSimHit > sTGCSimHitCollection