ATLAS Offline Software
Loading...
Searching...
No Matches
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
7
8// ISF includes
11
13ISF::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
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.):
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.);
69 }
70
71 // VertexTypeRanges:
72 //
73 // check whether user input makes sense:
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
80 // if neither lower now upper range limit given, disable range check
82
83
84 // fill PDG code std::set used for optimized search
86
87 // fill vertex type std::set used for optimized search
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
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)
119
120 // if child particles do not pass cuts
121 if (!secPass) {
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
165bool ISF::GenericTruthStrategy::appliesToRegion(unsigned short geoID) const
166{
167 return std::find( m_regionListProperty.begin(),
169 geoID ) != m_regionListProperty.end();
170}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
virtual bool pass(ITruthIncident &incident) const override final
true if the ITruthStrategy implementation applies to the given ITruthIncident
virtual StatusCode initialize() override final
virtual bool appliesToRegion(unsigned short geoID) const override final
Gaudi::Property< VertexTypesVector > m_vertexTypesVector
vertex type (physics code) checks
bool m_useChildPt
child particle kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faste...
IntegerArrayProperty m_regionListProperty
bool m_useParentPt
parent kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faster compar...
Gaudi::Property< double > m_childEkin
Ekin cut.
VertexTypesSet m_vertexTypes
optimized for search
Gaudi::Property< double > m_childPt
pT momentum cut
Gaudi::Property< bool > m_allowChildrenOrParentPass
pass cuts if parent did not
Gaudi::Property< PDGCodesVector > m_parentPdgCodesVector
PDG code checks.
GenericTruthStrategy(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
PDGCodesSet m_parentPdgCodes
optimized for search
Gaudi::Property< int > m_vertexTypeRangeLow
Gaudi::Property< double > m_parentPt
parent particle
Gaudi::Property< double > m_parentEkin
parent particle
Gaudi::Property< int > m_vertexTypeRangeHigh
ISF interface class for TruthIncidents.
virtual int physicsProcessCode() const =0
Return specific physics process code of the truth incident (eg ionisation, bremsstrahlung,...
virtual int parentPdgCode() const =0
Return the PDG Code of the parent particle.
bool childrenEkinPass(double ekincut)
Return true if at least one child particle passes the given Ekin cut (= at least one child with Ekin ...
virtual double parentEkin() const =0
Return Ekin of the parent particle.
virtual double parentPt2() const =0
Return pT^2 of the parent particle.
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 ...