ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_HepMC
ISF_HepMC_Tools
src
GenericTruthStrategy.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// class header include
6
#include "
GenericTruthStrategy.h
"
7
8
// ISF includes
9
#include "
ISF_Event/ITruthIncident.h
"
10
#include "
ISF_Event/ISFParticle.h
"
11
13
ISF::GenericTruthStrategy::GenericTruthStrategy
(
const
std::string& t,
const
std::string& n,
const
IInterface* p) :
14
base_class(t,n,p)
15
{
16
}
17
18
// Athena algtool's Hooks
19
StatusCode
ISF::GenericTruthStrategy::initialize
()
20
{
21
ATH_MSG_VERBOSE
(
"Initializing ..."
);
22
23
// (*) setup parent particle cuts
24
// -----
25
// (compute and store the squared cut parameters (faster comparisons))
26
// check whether the user input makes sense (error case)
27
if
( (
m_parentPt
>=0.) && (
m_parentEkin
>=0.) ) {
28
ATH_MSG_ERROR
(
"Both, pT and Ekin cuts are given for parent particles. Unclear which one to use! ABORT!"
);
29
return
StatusCode::FAILURE;
30
}
31
// neither pT nor Energy cuts were given (never being used so far)
32
// -> enable pT cut and set it to 0.
33
else
if
( (
m_parentPt
<0.) && (
m_parentEkin
<0.) ) {
34
// we don't use a flag to disable energy/momentum checks, because
35
// all relevant truth strategies up to now do use such cuts
36
m_useParentPt
=
true
;
37
m_parentPt2
= 0.;
38
m_parentEkin
= 0.;
// would not be needed actually
39
}
40
// either pT or Ekin cut is given (standard case)
41
else
{
42
// enable pT cut if value given (greater than 0.):
43
m_useParentPt
= !(
m_parentPt
<0.);
44
m_parentPt2
=
m_parentPt
*
m_parentPt
;
45
}
46
47
// (*) setup child particle cuts
48
// -----
49
// (compute and store the squared cut parameters (faster comparisons))
50
// check whether the user input makes sense (error case)
51
if
( (
m_childPt
>=0.) && (
m_childEkin
>=0.) ) {
52
ATH_MSG_ERROR
(
"Both, pT and Ekin cuts are given for child particles. Unclear which one to use! ABORT!"
);
53
return
StatusCode::FAILURE;
54
}
55
// neither pT nor Energy cuts were given (never being used so far)
56
// -> enable pT cut and set it to 0.
57
else
if
( (
m_childPt
<0.) && (
m_childEkin
<0.) ) {
58
// we don't use a flag to disable energy/momentum checks, because
59
// all relevant truth strategies up to now do use such cuts
60
m_useChildPt
=
true
;
61
m_childPt2
= 0.;
62
m_childEkin
= 0.;
// would not be needed actually
63
}
64
// either pT or Ekin cut is given (standard case)
65
else
{
66
// enable pT cut if value given (greater than 0.):
67
m_useChildPt
= !(
m_childPt
<0.);
68
m_childPt2
=
m_childPt
*
m_childPt
;
69
}
70
71
// VertexTypeRanges:
72
//
73
// check whether user input makes sense:
74
if
(
m_vertexTypeRangeHigh
<
m_vertexTypeRangeLow
) {
75
ATH_MSG_ERROR
(
"The given parameter VertexTypeRangeLow is bigger than VertexTypeRangeHigh. ABORT"
);
76
return
StatusCode::FAILURE;
77
}
78
// the length of the given vertex type range
79
m_vertexTypeRangeLength
= unsigned(
m_vertexTypeRangeHigh
-
m_vertexTypeRangeLow
) + 1;
80
// if neither lower now upper range limit given, disable range check
81
m_doVertexRangeCheck
=
m_vertexTypeRangeLow
&&
m_vertexTypeRangeHigh
;
82
83
84
// fill PDG code std::set used for optimized search
85
m_parentPdgCodes
.insert(
m_parentPdgCodesVector
.begin(),
m_parentPdgCodesVector
.end());
86
87
// fill vertex type std::set used for optimized search
88
m_vertexTypes
.insert(
m_vertexTypesVector
.begin(),
m_vertexTypesVector
.end());
89
90
for
(
auto
region :
m_regionListProperty
.value()) {
91
if
(region < AtlasDetDescr::fFirstAtlasRegion || region >=
AtlasDetDescr::fNumAtlasRegions
) {
92
ATH_MSG_ERROR
(
"Unknown Region ("
<< region <<
") specified. Please check your configuration."
);
93
return
StatusCode::FAILURE;
94
}
95
}
96
return
StatusCode::SUCCESS;
97
}
98
99
bool
ISF::GenericTruthStrategy::pass
(
ITruthIncident
& ti)
const
{
100
101
// (1.) momentum/energy check
102
// ----
103
//
104
{
105
// check whether parent particle passes cut or not
106
bool
primFail = (
m_useParentPt
) ? (ti.
parentPt2
()<
m_parentPt2
)
107
: (ti.
parentEkin
()<
m_parentEkin
) ;
108
109
110
// if parent particle failed and strategy does not
111
// allow for child-only pass -> failed
112
if
( ( primFail && (!
m_allowChildrenOrParentPass
) ) ) {
113
return
false
;
114
}
115
116
// check child particles
117
bool
secPass =
m_useChildPt
? ti.
childrenPt2Pass
(
m_childPt2
)
118
: ti.
childrenEkinPass
(
m_childEkin
);
119
120
// if child particles do not pass cuts
121
if
(!secPass) {
122
if
(!
m_allowChildrenOrParentPass
) {
123
// child particles were required to pass cuts but did not
124
return
false
;
125
}
else
if
(primFail) {
126
// neither parent nor child particles passed cuts
127
return
false
;
128
}
129
}
130
131
}
132
133
134
// (2.) parent particle PDG code check
135
// ----
136
// check whether parent PDG code matches with any of the given ones
137
if
(
m_parentPdgCodes
.size() &&
138
(
m_parentPdgCodes
.find(ti.
parentPdgCode
()) ==
m_parentPdgCodes
.end()) ) {
139
140
// parent particle PDG code not found
141
return
false
;
142
}
143
144
145
// (3.) vertex type check
146
// ----
147
if
(
m_doVertexRangeCheck
||
m_vertexTypes
.size()) {
148
int
vxtype = ti.
physicsProcessCode
();
149
150
// (3.1) vxtype in given range?: this is a small performance trick (only one comparison operator to check if within range)
151
// -> exactly equivalent to: m_doVertexRangeCheck && (m_vertexTypeLow<=vxtype) && (vxtype<=m_vertexTypeRangeHigh)
152
bool
vtxTypeRangePassed =
m_doVertexRangeCheck
&& ( unsigned(vxtype-
m_vertexTypeRangeLow
) <
m_vertexTypeRangeLength
);
153
// (3.2) if not in range or range check disabled, check whether vxtype
154
// std::set contains the given vertex type
155
if
( (!vtxTypeRangePassed) && (
m_vertexTypes
.find(vxtype)==
m_vertexTypes
.end()) ) {
156
// vxtype not registered -> not passed
157
return
false
;
158
}
159
}
160
161
// all cuts passed
162
return
true
;
163
}
164
165
bool
ISF::GenericTruthStrategy::appliesToRegion
(
unsigned
short
geoID)
const
166
{
167
return
std::find(
m_regionListProperty
.begin(),
168
m_regionListProperty
.end(),
169
geoID ) !=
m_regionListProperty
.end();
170
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
GenericTruthStrategy.h
ISFParticle.h
ITruthIncident.h
ISF::GenericTruthStrategy::pass
virtual bool pass(ITruthIncident &incident) const override final
true if the ITruthStrategy implementation applies to the given ITruthIncident
Definition
GenericTruthStrategy.cxx:99
ISF::GenericTruthStrategy::initialize
virtual StatusCode initialize() override final
Definition
GenericTruthStrategy.cxx:19
ISF::GenericTruthStrategy::appliesToRegion
virtual bool appliesToRegion(unsigned short geoID) const override final
Definition
GenericTruthStrategy.cxx:165
ISF::GenericTruthStrategy::m_vertexTypesVector
Gaudi::Property< VertexTypesVector > m_vertexTypesVector
vertex type (physics code) checks
Definition
GenericTruthStrategy.h:70
ISF::GenericTruthStrategy::m_useChildPt
bool m_useChildPt
child particle kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faste...
Definition
GenericTruthStrategy.h:61
ISF::GenericTruthStrategy::m_regionListProperty
IntegerArrayProperty m_regionListProperty
Definition
GenericTruthStrategy.h:81
ISF::GenericTruthStrategy::m_childPt2
double m_childPt2
Definition
GenericTruthStrategy.h:62
ISF::GenericTruthStrategy::m_useParentPt
bool m_useParentPt
parent kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faster compar...
Definition
GenericTruthStrategy.h:54
ISF::GenericTruthStrategy::m_childEkin
Gaudi::Property< double > m_childEkin
Ekin cut.
Definition
GenericTruthStrategy.h:64
ISF::GenericTruthStrategy::m_vertexTypes
VertexTypesSet m_vertexTypes
optimized for search
Definition
GenericTruthStrategy.h:71
ISF::GenericTruthStrategy::m_childPt
Gaudi::Property< double > m_childPt
pT momentum cut
Definition
GenericTruthStrategy.h:63
ISF::GenericTruthStrategy::m_allowChildrenOrParentPass
Gaudi::Property< bool > m_allowChildrenOrParentPass
pass cuts if parent did not
Definition
GenericTruthStrategy.h:65
ISF::GenericTruthStrategy::m_parentPt2
double m_parentPt2
Definition
GenericTruthStrategy.h:55
ISF::GenericTruthStrategy::m_parentPdgCodesVector
Gaudi::Property< PDGCodesVector > m_parentPdgCodesVector
PDG code checks.
Definition
GenericTruthStrategy.h:78
ISF::GenericTruthStrategy::GenericTruthStrategy
GenericTruthStrategy(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition
GenericTruthStrategy.cxx:13
ISF::GenericTruthStrategy::m_doVertexRangeCheck
bool m_doVertexRangeCheck
Definition
GenericTruthStrategy.h:72
ISF::GenericTruthStrategy::m_parentPdgCodes
PDGCodesSet m_parentPdgCodes
optimized for search
Definition
GenericTruthStrategy.h:79
ISF::GenericTruthStrategy::m_vertexTypeRangeLow
Gaudi::Property< int > m_vertexTypeRangeLow
Definition
GenericTruthStrategy.h:73
ISF::GenericTruthStrategy::m_parentPt
Gaudi::Property< double > m_parentPt
parent particle
Definition
GenericTruthStrategy.h:56
ISF::GenericTruthStrategy::m_parentEkin
Gaudi::Property< double > m_parentEkin
parent particle
Definition
GenericTruthStrategy.h:57
ISF::GenericTruthStrategy::m_vertexTypeRangeLength
unsigned m_vertexTypeRangeLength
Definition
GenericTruthStrategy.h:75
ISF::GenericTruthStrategy::m_vertexTypeRangeHigh
Gaudi::Property< int > m_vertexTypeRangeHigh
Definition
GenericTruthStrategy.h:74
ISF::ITruthIncident
ISF interface class for TruthIncidents.
Definition
ITruthIncident.h:45
ISF::ITruthIncident::physicsProcessCode
virtual int physicsProcessCode() const =0
Return specific physics process code of the truth incident (eg ionisation, bremsstrahlung,...
ISF::ITruthIncident::parentPdgCode
virtual int parentPdgCode() const =0
Return the PDG Code of the parent particle.
ISF::ITruthIncident::childrenEkinPass
bool childrenEkinPass(double ekincut)
Return true if at least one child particle passes the given Ekin cut (= at least one child with Ekin ...
Definition
ITruthIncident.h:170
ISF::ITruthIncident::parentEkin
virtual double parentEkin() const =0
Return Ekin of the parent particle.
ISF::ITruthIncident::parentPt2
virtual double parentPt2() const =0
Return pT^2 of the parent particle.
ISF::ITruthIncident::childrenPt2Pass
bool childrenPt2Pass(double pt2cut)
Return true if at least one child particle passes the given pT^2 cut (= at least one child with pT^2 ...
Definition
ITruthIncident.h:158
AtlasDetDescr::fNumAtlasRegions
@ fNumAtlasRegions
Definition
AtlasRegion.h:33
Generated on
for ATLAS Offline Software by
1.17.0