ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonSimEventTPCnv
src
sTGCSimHitCollectionCnv_p4.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuonSimEvent/sTGCSimHit.h
"
6
#include "
MuonSimEventTPCnv/sTGCSimHitCollectionCnv_p4.h
"
7
#include "
MuonSimEventTPCnv/sTGCSimHitCollection_p4.h
"
8
#include "
GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p3.h
"
9
10
#include "
GeoPrimitives/GeoPrimitives.h
"
11
12
// Gaudi
13
#include "GaudiKernel/MsgStream.h"
14
// Athena
15
#include "
StoreGate/StoreGateSvc.h
"
16
17
18
void
sTGCSimHitCollectionCnv_p4::transToPers
(
const
sTGCSimHitCollection
* transCont,
Muon::sTGCSimHitCollection_p4
* persCont, MsgStream &log)
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_p3
hepMcPLCnv;
39
HepMcParticleLink_p3
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
65
sTGCSimHitCollection
*
sTGCSimHitCollectionCnv_p4::createTransient
(
const
Muon::sTGCSimHitCollection_p4
* persObj, MsgStream &log) {
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
72
void
sTGCSimHitCollectionCnv_p4::persToTrans
(
const
Muon::sTGCSimHitCollection_p4
* persCont,
sTGCSimHitCollection
* transCont, MsgStream &log)
73
{
74
HepMcParticleLinkCnv_p3
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
89
HepMcParticleLink
link;
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
}
GeoPrimitives.h
HepMcParticleLinkCnv_p3.h
StoreGateSvc.h
size
size_t size() const
Number of registered mappings.
AtlasHitsVector< sTGCSimHit >::const_iterator
CONT::const_iterator const_iterator
Definition
AtlasHitsVector.h:42
AtlasHitsVector::begin
const_iterator begin() const
Definition
AtlasHitsVector.h:130
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition
AtlasHitsVector.h:80
AtlasHitsVector::size
size_type size() const
Definition
AtlasHitsVector.h:142
AtlasHitsVector::end
const_iterator end() const
Definition
AtlasHitsVector.h:133
HepMcParticleLinkCnv_p3
Definition
HepMcParticleLinkCnv_p3.h:29
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
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
HepMcParticleLink_p3
Definition
HepMcParticleLink_p3.h:17
HepMcParticleLink
a link optimized in size for a GenParticle in a McEventCollection
Definition
HepMcParticleLink.h:72
Muon::sTGCSimHitCollection_p4
Definition
sTGCSimHitCollection_p4.h:13
Muon::sTGCSimHitCollection_p4::m_sTGCId
std::vector< int > m_sTGCId
Definition
sTGCSimHitCollection_p4.h:15
Muon::sTGCSimHitCollection_p4::m_stX
std::vector< float > m_stX
Definition
sTGCSimHitCollection_p4.h:17
Muon::sTGCSimHitCollection_p4::m_globalTime
std::vector< float > m_globalTime
Definition
sTGCSimHitCollection_p4.h:16
Muon::sTGCSimHitCollection_p4::m_stY
std::vector< float > m_stY
Definition
sTGCSimHitCollection_p4.h:17
Muon::sTGCSimHitCollection_p4::m_kineticEnergy
std::vector< float > m_kineticEnergy
Definition
sTGCSimHitCollection_p4.h:21
Muon::sTGCSimHitCollection_p4::m_prestY
std::vector< float > m_prestY
Definition
sTGCSimHitCollection_p4.h:22
Muon::sTGCSimHitCollection_p4::m_prestX
std::vector< float > m_prestX
Definition
sTGCSimHitCollection_p4.h:22
Muon::sTGCSimHitCollection_p4::m_partLink
std::vector< HepMcParticleLink_p3 > m_partLink
Definition
sTGCSimHitCollection_p4.h:20
Muon::sTGCSimHitCollection_p4::m_stZ
std::vector< float > m_stZ
Represents m_globalPosition in transient class.
Definition
sTGCSimHitCollection_p4.h:17
Muon::sTGCSimHitCollection_p4::m_prestZ
std::vector< float > m_prestZ
Definition
sTGCSimHitCollection_p4.h:22
Muon::sTGCSimHitCollection_p4::m_particleEncoding
std::vector< int > m_particleEncoding
Definition
sTGCSimHitCollection_p4.h:18
Muon::sTGCSimHitCollection_p4::m_depositEnergy
std::vector< float > m_depositEnergy
Definition
sTGCSimHitCollection_p4.h:19
sTGCSimHitCollectionCnv_p4::createTransient
virtual sTGCSimHitCollection * createTransient(const Muon::sTGCSimHitCollection_p4 *persObj, MsgStream &log)
Definition
sTGCSimHitCollectionCnv_p4.cxx:65
sTGCSimHitCollectionCnv_p4::transToPers
virtual void transToPers(const sTGCSimHitCollection *transCont, Muon::sTGCSimHitCollection_p4 *persCont, MsgStream &log)
Definition
sTGCSimHitCollectionCnv_p4.cxx:18
sTGCSimHitCollectionCnv_p4::persToTrans
virtual void persToTrans(const Muon::sTGCSimHitCollection_p4 *persCont, sTGCSimHitCollection *transCont, MsgStream &log)
Definition
sTGCSimHitCollectionCnv_p4.cxx:72
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
sTGCSimHitCollectionCnv_p4.h
sTGCSimHitCollection
AtlasHitsVector< sTGCSimHit > sTGCSimHitCollection
Definition
sTGCSimHitCollection.h:15
sTGCSimHitCollection_p4.h
sTGCSimHit.h
Generated on
for ATLAS Offline Software by
1.17.0