ATLAS Offline Software
Loading...
Searching...
No Matches
TGCSimHitCollectionCnv_p2.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_TGCid.reserve(size);
23 persCont->m_globalTime.reserve(size);
24 persCont->m_stX.reserve(size);
25 persCont->m_stY.reserve(size);
26 persCont->m_stZ.reserve(size);
27 persCont->m_enX.reserve(size);
28 persCont->m_enY.reserve(size);
29 persCont->m_enZ.reserve(size);
30 persCont->m_partLink.reserve(size);
31 persCont->m_energyDeposit.reserve(size);
32 persCont->m_stepLength.reserve(size);
33
34 // make convertor to handle HepMcParticleLinks
35 HepMcParticleLinkCnv_p1 hepMcPLCnv;
36 HepMcParticleLink_p1 persLink; // will use this as a temp object inside the loop
37
38 // loop through container, filling pers object
39 TGCSimHitCollection::const_iterator it = transCont->begin(), itEnd = transCont->end();
40 for (; it != itEnd; ++it) {
41 persCont->m_TGCid.push_back(it->TGCid());
42 persCont->m_globalTime.push_back(it->globalTime());
43 persCont->m_stX.push_back(it->localPosition().x());
44 persCont->m_stY.push_back(it->localPosition().y());
45 persCont->m_stZ.push_back(it->localPosition().z());
46 persCont->m_enX.push_back(it->localDireCos().x());
47 persCont->m_enY.push_back(it->localDireCos().y());
48 persCont->m_enZ.push_back(it->localDireCos().z());
49 persCont->m_energyDeposit.push_back(it->energyDeposit());
50 persCont->m_stepLength.push_back(it->stepLength());
51
52 hepMcPLCnv.transToPers(&it->particleLink(),&persLink, log);
53 persCont->m_partLink.push_back(persLink);
54 }
55}
56
57
59 std::unique_ptr<TGCSimHitCollection> trans(new TGCSimHitCollection("DefaultCollectionName",persObj->m_globalTime.size()));
60 persToTrans(persObj, trans.get(), log);
61 return(trans.release());
62}
63
64
66{
67 HepMcParticleLinkCnv_p1 hepMcPLCnv;
68
69 //transCont->reserve(persCont->m_TGCid.size()); //done in createTransient
70 for (unsigned int i = 0; i < persCont->m_TGCid.size(); i++) {
71 Amg::Vector3D position(persCont->m_stX[i], persCont->m_stY[i], persCont->m_stZ[i]);
72 Amg::Vector3D localDireCos(persCont->m_enX[i], persCont->m_enY[i], persCont->m_enZ[i]);
73
75 hepMcPLCnv.persToTrans(&persCont->m_partLink[i],&link, log);
76
77 transCont->Emplace(persCont->m_TGCid[i], persCont->m_globalTime[i], position, localDireCos,
78 link,
79 persCont->m_energyDeposit[i], persCont->m_stepLength[i]);
80 }
81}
82
AtlasHitsVector< TGCSimHit > TGCSimHitCollection
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_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< HepMcParticleLink_p1 > m_partLink
std::vector< float > m_enZ
Represents m_localDireCos in transient class.
std::vector< float > m_stZ
Represents m_localPosition in transient class.
virtual void persToTrans(const Muon::TGCSimHitCollection_p2 *persCont, TGCSimHitCollection *transCont, MsgStream &log)
virtual TGCSimHitCollection * createTransient(const Muon::TGCSimHitCollection_p2 *persObj, MsgStream &log)
virtual void transToPers(const TGCSimHitCollection *transCont, Muon::TGCSimHitCollection_p2 *persCont, MsgStream &log)
Eigen::Matrix< double, 3, 1 > Vector3D