ATLAS Offline Software
Loading...
Searching...
No Matches
MDTSimHitCollectionCnv_p3.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_MDTid.reserve(size);
23 persCont->m_globalTime.reserve(size);
24 persCont->m_driftRadius.reserve(size);
25 persCont->m_stX.reserve(size);
26 persCont->m_stY.reserve(size);
27 persCont->m_stZ.reserve(size);
28 persCont->m_stepLength.reserve(size);
29 persCont->m_energyDeposit.reserve(size);
30 persCont->m_particleEncoding.reserve(size);
31 persCont->m_kineticEnergy.reserve(size);
32 // persCont->m_meanTime.reserve(size);
33 persCont->m_partLink.reserve(size);
34
35 // make convertor to handle HepMcParticleLinks
36 HepMcParticleLinkCnv_p2 hepMcPLCnv;
37 HepMcParticleLink_p2 persLink; // will use this as a temp object inside the loop
38
39 // loop through container, filling pers object
40 MDTSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
41 for (; it != itEnd; ++it) {
42 persCont->m_MDTid.push_back(it->MDTid());
43 persCont->m_globalTime.push_back(it->globalTime());
44 persCont->m_driftRadius.push_back(it->driftRadius());
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 // persCont->m_meanTime.push_back(hit->m_meanTime);
49 persCont->m_stepLength.push_back(it->stepLength());
50 persCont->m_energyDeposit.push_back(it->energyDeposit());
51 persCont->m_particleEncoding.push_back(it->particleEncoding());
52 persCont->m_kineticEnergy.push_back(it->kineticEnergy());
53
54 hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
55 persCont->m_partLink.push_back(persLink);
56
57 }
58}
59
60
62 std::unique_ptr<MDTSimHitCollection> trans(new MDTSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
63 persToTrans(persObj, trans.get(), log);
64 return(trans.release());
65}
66
67
69{
70 HepMcParticleLinkCnv_p2 hepMcPLCnv;
71
72 //transCont->reserve(persCont->m_MDTid.size());//done in createTransient
73 for (unsigned int i = 0; i < persCont->m_MDTid.size(); i++) {
74 Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
75
77 hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
78
79 transCont->Emplace(persCont->m_MDTid[i], persCont->m_globalTime[i], persCont->m_driftRadius[i], position,
80 link,
81 persCont->m_stepLength[i], persCont->m_energyDeposit[i], persCont->m_particleEncoding[i], persCont->m_kineticEnergy[i]);
82 }
83}
84
AtlasHitsVector< MDTSimHit > MDTSimHitCollection
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 ...
virtual void persToTrans(const Muon::MDTSimHitCollection_p3 *persCont, MDTSimHitCollection *transCont, MsgStream &log)
virtual MDTSimHitCollection * createTransient(const Muon::MDTSimHitCollection_p3 *persObj, MsgStream &log)
virtual void transToPers(const MDTSimHitCollection *transCont, Muon::MDTSimHitCollection_p3 *persCont, MsgStream &log)
std::vector< HepMcParticleLink_p2 > m_partLink
std::vector< float > m_stZ
Represents m_localPosition in transient class.
Eigen::Matrix< double, 3, 1 > Vector3D