ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_Geant4
ISF_Geant4CommonTools
src
EntryLayerToolMT.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
// class header include
6
#include "
EntryLayerToolMT.h
"
7
8
#include "
TruthUtils/MagicNumbers.h
"
9
10
// ISF includes
11
#include "
ISF_Event/ISFParticle.h
"
12
13
thread_local
std::unique_ptr<std::array<TrackRecordCollection*, ISF::fNumAtlasEntryLayers>>
ISF::EntryLayerToolMT::s_collection
;
14
16
ISF::EntryLayerToolMT::EntryLayerToolMT
(
const
std::string& t,
const
std::string& n,
const
IInterface* p) :
17
base_class(t,n,p),
18
m_volumeName
()
19
{
20
// volumeNames for TrackRecords
21
declareProperty(
"CaloEntryVolumeString"
,
22
m_volumeName
[
ISF::fAtlasCaloEntry
] =
"IDET::IDET"
,
23
"VolumeName in TrackRecords in CaloEntryLayer"
);
24
declareProperty(
"MuonEntryVolumeString"
,
25
m_volumeName
[
ISF::fAtlasMuonEntry
] =
"CALO::CALO"
,
26
"VolumeName in TrackRecords in MuonEntryLayer"
);
27
declareProperty(
"MuonExitVolumeString"
,
28
m_volumeName
[
ISF::fAtlasMuonExit
] =
"MUONQ02::MUONQ02"
,
29
"VolumeName in TrackRecords in MuonExitLayer"
);
30
}
31
32
34
StatusCode
ISF::EntryLayerToolMT::initialize
()
35
{
36
ATH_MSG_INFO
(
"initialize() ..."
);
37
38
// retrieve the GeoIDSvc
39
ATH_CHECK
(
m_geoIDSvc
.retrieve() );
40
// store a quick-access pointer to the c++ class directly
41
m_geoIDSvcQuick
= &(*m_geoIDSvc);
42
43
// retrieve the ParticleFilters
44
ATH_CHECK
(
m_particleFilterHandle
.retrieve() );
45
// store a quick-access pointer to the c++ classes directly
46
m_numParticleFilters
=
m_particleFilterHandle
.size();
47
m_particleFilter
=
new
ISF::IParticleFilter
*[
m_numParticleFilters
];
48
for
(
size_t
curFilter = 0; curFilter<
m_numParticleFilters
; curFilter++) {
49
// convert ToolHandle to standard c++ class pointer
50
m_particleFilter
[curFilter] = &(*
m_particleFilterHandle
[curFilter]);
51
}
52
53
ATH_MSG_INFO
(
"initialize() successful"
);
54
return
StatusCode::SUCCESS;
55
}
56
57
59
bool
ISF::EntryLayerToolMT::passesFilters
(
const
ISFParticle
& particle) {
60
bool
pass =
true
;
61
for
(
size_t
curFilter=0; pass && (curFilter<
m_numParticleFilters
); curFilter++) {
62
// check current filter
63
pass =
m_particleFilter
[curFilter]->passFilter( particle);
64
}
65
66
return
pass;
67
}
68
69
72
ISF::EntryLayer
ISF::EntryLayerToolMT::identifyEntryLayer
(
const
ISFParticle
& particle) {
73
// the return value
74
ISF::EntryLayer
layerHit =
ISF::fUnsetEntryLayer
;
75
76
const
Amg::Vector3D
&pos = particle.position();
77
78
// check if particle on ID and/or Calo surface
79
bool
onIDSurface = (
m_geoIDSvcQuick
->inside( pos,
AtlasDetDescr::fAtlasID
) ==
ISF::fSurface
);
80
bool
onCaloSurface = (
m_geoIDSvcQuick
->inside( pos,
AtlasDetDescr::fAtlasCalo
) ==
ISF::fSurface
);
81
82
// on CaloEntry layer ?
83
if
( onIDSurface && onCaloSurface ) {
84
layerHit =
ISF::fAtlasCaloEntry
;
85
}
86
87
// no surface hit yet -> test MS volume surface hit
88
else
{
89
// check if particle on MS surface
90
bool
onMSSurface = (
m_geoIDSvcQuick
->inside( pos,
AtlasDetDescr::fAtlasMS
) ==
ISF::fSurface
);
91
92
// on MuonEntry layer ?
93
if
(onCaloSurface && onMSSurface) {
94
layerHit =
ISF::fAtlasMuonEntry
;
95
}
96
// on MuonExit layer ?
97
else
if
(onMSSurface) {
98
layerHit =
ISF::fAtlasMuonExit
;
99
}
100
}
101
return
layerHit;
102
}
103
104
106
ISF::EntryLayer
ISF::EntryLayerToolMT::registerParticle
(
const
ISF::ISFParticle
& particle,
ISF::EntryLayer
layerHit)
107
{
108
// (1.) check whether the particle actually passes all the filters
109
// -> rather fast usually
110
if
( !
passesFilters
(particle) ) {
111
// return if not passed
112
return
ISF::fUnsetEntryLayer
;
113
}
114
115
// (2.) check whether the particle lies on any entry surface
116
// -> this goes second because computation intensive routines
117
// are used for this
118
if
( layerHit ==
ISF::fUnsetEntryLayer
) {
119
layerHit =
identifyEntryLayer
( particle);
120
}
121
122
// (3.) if particle is on a boundary surface
123
// -> add it to TrackRecordCollection
124
if
( layerHit !=
ISF::fUnsetEntryLayer
) {
125
ATH_MSG_VERBOSE
(
"Particle >>"
<< particle <<
"<< hit boundary surface, "
126
"adding it to '"
<< (*
s_collection
)[layerHit]->
Name
() <<
"' TrackRecord collection"
);
127
128
const
Amg::Vector3D
&pos = particle.position();
129
const
Amg::Vector3D
&mom = particle.momentum();
130
CLHEP::Hep3Vector hepPos( pos.x(), pos.y(), pos.z() );
// not optimal, but required by TrackRecord
131
CLHEP::Hep3Vector hepMom( mom.x(), mom.y(), mom.z() );
// not optimal, but required by TrackRecord
132
133
double
mass = particle.mass();
134
double
energy = std::sqrt(mass*mass + mom.mag2());
135
136
// Use barcode of generation zero particle from truth binding if possible (reproduces legacy AtlasG4 behaviour).
137
// Use barcode assigend to ISFParticle only if no generation zero particle is present.
138
auto
truthBinding = particle.getTruthBinding();
139
auto
generationZeroGenParticle = truthBinding ? truthBinding->getGenerationZeroGenParticle() :
nullptr
;
140
const
int
barcode = generationZeroGenParticle ?
HepMC::barcode
(generationZeroGenParticle) :
HepMC::barcode
(particle);
// FIXME barcode-based
141
const
int
id
= generationZeroGenParticle ?
HepMC::uniqueID
(generationZeroGenParticle) : particle.id();
142
const
int
status = generationZeroGenParticle ? generationZeroGenParticle->status() : particle.status();
143
144
(*s_collection)[layerHit]->Emplace(particle.pdgCode(),
145
status,
146
energy,
147
hepMom,
148
hepPos,
149
particle.timeStamp(),
150
barcode,
// FIXME barcode-based
151
id
,
152
m_volumeName
[layerHit] );
153
}
154
155
return
layerHit;
156
}
157
159
StatusCode
ISF::EntryLayerToolMT::registerTrackRecordCollection
(
TrackRecordCollection
* collection,
EntryLayer
layer)
160
{
161
if
(!
s_collection
) {
162
// need to create the array of TrackRecordCollections for this thread
163
s_collection
= std::make_unique<std::array<TrackRecordCollection*, ISF::fNumAtlasEntryLayers>>();
164
}
165
(*s_collection)[layer]=collection;
166
return
StatusCode::SUCCESS;
167
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
EntryLayerToolMT.h
ISFParticle.h
Name
JetDumper::Name Name
Definition
JetDumper.cxx:19
MagicNumbers.h
TrackRecordCollection
AtlasHitsVector< TrackRecord > TrackRecordCollection
Definition
TrackRecordCollection.h:12
ISF::EntryLayerToolMT::m_geoIDSvc
ServiceHandle< ISF::IGeoIDSvc > m_geoIDSvc
GeoIDSvc will be used to determine the entry layer surface, the particle is on.
Definition
EntryLayerToolMT.h:75
ISF::EntryLayerToolMT::passesFilters
virtual bool passesFilters(const ISFParticle &particle) override final
Check if given particle passes the EntryLayer filters.
Definition
EntryLayerToolMT.cxx:59
ISF::EntryLayerToolMT::m_particleFilter
ISF::IParticleFilter ** m_particleFilter
Definition
EntryLayerToolMT.h:80
ISF::EntryLayerToolMT::m_volumeName
std::string m_volumeName[ISF::fNumAtlasEntryLayers]
Definition
EntryLayerToolMT.h:85
ISF::EntryLayerToolMT::registerTrackRecordCollection
virtual StatusCode registerTrackRecordCollection(TrackRecordCollection *collection, EntryLayer layer) override final
Register the TrackRecordCollection pointer for a layer.
Definition
EntryLayerToolMT.cxx:159
ISF::EntryLayerToolMT::identifyEntryLayer
virtual ISF::EntryLayer identifyEntryLayer(const ISFParticle &particle) override final
Identify the corresponding entry layer for the given particle (may return ISF::fUnsetEntryLayere if p...
Definition
EntryLayerToolMT.cxx:72
ISF::EntryLayerToolMT::m_numParticleFilters
size_t m_numParticleFilters
Definition
EntryLayerToolMT.h:81
ISF::EntryLayerToolMT::m_particleFilterHandle
ParticleFilterArray m_particleFilterHandle
Array of filters to decide whether a particle is added to the Entry/Exit layer.
Definition
EntryLayerToolMT.h:79
ISF::EntryLayerToolMT::initialize
virtual StatusCode initialize() override final
Athena algtool's Hooks.
Definition
EntryLayerToolMT.cxx:34
ISF::EntryLayerToolMT::EntryLayerToolMT
EntryLayerToolMT(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition
EntryLayerToolMT.cxx:16
ISF::EntryLayerToolMT::registerParticle
virtual ISF::EntryLayer registerParticle(const ISF::ISFParticle &particle, ISF::EntryLayer entryLayer) override final
Add the given particle to the corresponding Entry/Exit layer if applicable.
Definition
EntryLayerToolMT.cxx:106
ISF::EntryLayerToolMT::s_collection
static std::unique_ptr< std::array< TrackRecordCollection *, ISF::fNumAtlasEntryLayers > > s_collection
The entry layer collections.
Definition
EntryLayerToolMT.h:84
ISF::EntryLayerToolMT::m_geoIDSvcQuick
ISF::IGeoIDSvc * m_geoIDSvcQuick
Definition
EntryLayerToolMT.h:76
ISF::IParticleFilter
Definition
IParticleFilter.h:28
ISF::ISFParticle
The generic ISF particle definition,.
Definition
ISFParticle.h:42
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
AtlasDetDescr::fAtlasCalo
@ fAtlasCalo
Definition
AtlasRegion.h:29
AtlasDetDescr::fAtlasID
@ fAtlasID
Definition
AtlasRegion.h:27
AtlasDetDescr::fAtlasMS
@ fAtlasMS
Definition
AtlasRegion.h:30
HepMC::barcode
int barcode(const T *p)
Definition
Barcode.h:15
HepMC::uniqueID
int uniqueID(const T &p)
Definition
MagicNumbers.h:89
ISF::EntryLayer
EntryLayer
Identifiers for the TrackRecordCollections on the boundaries between CaloEntry: Inner Detector - Calo...
Definition
EntryLayer.h:31
ISF::fAtlasMuonExit
@ fAtlasMuonExit
Definition
EntryLayer.h:39
ISF::fUnsetEntryLayer
@ fUnsetEntryLayer
Definition
EntryLayer.h:33
ISF::fAtlasCaloEntry
@ fAtlasCaloEntry
Definition
EntryLayer.h:37
ISF::fAtlasMuonEntry
@ fAtlasMuonEntry
Definition
EntryLayer.h:38
ISF::fSurface
@ fSurface
Definition
IGeoIDSvc.h:24
Generated on
for ATLAS Offline Software by
1.17.0