ATLAS Offline Software
Loading...
Searching...
No Matches
GenericTruthStrategy.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6// GenericTruthStrategy.cxx, (c) ATLAS Detector software
8
9// class header include
11
12// ISF includes
15
17ISF::GenericTruthStrategy::GenericTruthStrategy(const std::string& t, const std::string& n, const IInterface* p) :
18 base_class(t,n,p),
19 m_useParentPt(true),
20 m_parentPt2(-1.),
21 m_parentEkin(-1.),
22 m_useChildPt(true),
23 m_childPt2(-1.),
24 m_childEkin(-1.),
34{
35 // provide either a pT or Ekin cut for the parent and child particles respectively.
36 // if none are given for either type, it will not use pT or Ekin cuts
37 // (the Pt2 variables get squared in the initialize() method)
38 declareProperty("ParentMinPt" , m_parentPt2 );
39 declareProperty("ParentMinEkin" , m_parentEkin );
40 declareProperty("ChildMinPt" , m_childPt2 );
41 declareProperty("ChildMinEkin" , m_childEkin );
42 // if set to true, kinetic cuts are passed even if only child particles pass them
43 // (used for special cases such as de-excitation)
44 declareProperty("AllowChildrenOrParentPassKineticCuts" , m_allowChildrenOrParentPass );
45 declareProperty("VertexTypes" , m_vertexTypesVector );
46 declareProperty("VertexTypeRangeLow" , m_vertexTypeRangeLow );
47 declareProperty("VertexTypeRangeHigh" , m_vertexTypeRangeHigh );
48 declareProperty("ParentPDGCodes" , m_parentPdgCodesVector );
49 declareProperty("Regions" , m_regionListProperty );
50}
51
56
57// Athena algtool's Hooks
59{
60 ATH_MSG_VERBOSE("Initializing ...");
61
62 // (*) setup parent particle cuts
63 // -----
64 // (compute and store the squared cut parameters (faster comparisons))
65 // check whether the user input makes sense (error case)
66 if ( (m_parentPt2>=0.) && (m_parentEkin>=0.) ) {
67 ATH_MSG_ERROR("Both, pT and Ekin cuts are given for parent particles. Unclear which one to use! ABORT!");
68 return StatusCode::FAILURE;
69 }
70 // neither pT nor Energy cuts were given (never being used so far)
71 // -> enable pT cut and set it to 0.
72 else if ( (m_parentPt2<0.) && (m_parentEkin<0.) ) {
73 // we don't use a flag to disable energy/momentum checks, because
74 // all relevant truth strategies up to now do use such cuts
75 m_useParentPt = true;
76 m_parentPt2 = 0.;
77 m_parentEkin = 0.; // would not be needed actually
78 }
79 // either pT or Ekin cut is given (standard case)
80 else {
81 // enable pT cut if value given (greater than 0.):
84 }
85
86 // (*) setup child particle cuts
87 // -----
88 // (compute and store the squared cut parameters (faster comparisons))
89 // check whether the user input makes sense (error case)
90 if ( (m_childPt2>=0.) && (m_childEkin>=0.) ) {
91 ATH_MSG_ERROR("Both, pT and Ekin cuts are given for child particles. Unclear which one to use! ABORT!");
92 return StatusCode::FAILURE;
93 }
94 // neither pT nor Energy cuts were given (never being used so far)
95 // -> enable pT cut and set it to 0.
96 else if ( (m_childPt2<0.) && (m_childEkin<0.) ) {
97 // we don't use a flag to disable energy/momentum checks, because
98 // all relevant truth strategies up to now do use such cuts
99 m_useChildPt = true;
100 m_childPt2 = 0.;
101 m_childEkin = 0.; // would not be needed actually
102 }
103 // either pT or Ekin cut is given (standard case)
104 else {
105 // enable pT cut if value given (greater than 0.):
106 m_useChildPt = !(m_childPt2<0.);
108 }
109
110 // VertexTypeRanges:
111 //
112 // check whether user input makes sense:
114 ATH_MSG_ERROR("The given parameter VertexTypeRangeLow is bigger than VertexTypeRangeHigh. ABORT");
115 return StatusCode::FAILURE;
116 }
117 // the length of the given vertex type range
119 // if neither lower now upper range limit given, disable range check
121
122
123 // fill PDG code std::set used for optimized search
125
126 // fill vertex type std::set used for optimized search
128
129 for(auto region : m_regionListProperty.value()) {
130 if(region < AtlasDetDescr::fFirstAtlasRegion || region >= AtlasDetDescr::fNumAtlasRegions) {
131 ATH_MSG_ERROR("Unknown Region (" << region << ") specified. Please check your configuration.");
132 return StatusCode::FAILURE;
133 }
134 }
135 return StatusCode::SUCCESS;
136}
137
139{
140 ATH_MSG_VERBOSE("Finalizing ...");
141 return StatusCode::SUCCESS;
142}
143
145
146 // (1.) momentum/energy check
147 // ----
148 //
149 {
150 // check whether parent particle passes cut or not
151 bool primFail = (m_useParentPt) ? (ti.parentPt2()<m_parentPt2)
152 : (ti.parentEkin()<m_parentEkin) ;
153
154
155 // if parent particle failed and strategy does not
156 // allow for child-only pass -> failed
157 if ( ( primFail && (!m_allowChildrenOrParentPass) ) ) {
158 return false;
159 }
160
161 // check child particles
162 bool secPass = m_useChildPt ? ti.childrenPt2Pass(m_childPt2)
164
165 // if child particles do not pass cuts
166 if (!secPass) {
168 // child particles were required to pass cuts but did not
169 return false;
170 } else if (primFail) {
171 // neither parent nor child particles passed cuts
172 return false;
173 }
174 }
175
176 }
177
178
179 // (2.) parent particle PDG code check
180 // ----
181 // check whether parent PDG code matches with any of the given ones
182 if ( m_parentPdgCodes.size() &&
183 (m_parentPdgCodes.find(ti.parentPdgCode()) == m_parentPdgCodes.end()) ) {
184
185 // parent particle PDG code not found
186 return false;
187 }
188
189
190 // (3.) vertex type check
191 // ----
192 if ( m_doVertexRangeCheck || m_vertexTypes.size()) {
193 int vxtype = ti.physicsProcessCode();
194
195 // (3.1) vxtype in given range?: this is a small performance trick (only one comparison operator to check if within range)
196 // -> exactly equivalent to: m_doVertexRangeCheck && (m_vertexTypeLow<=vxtype) && (vxtype<=m_vertexTypeRangeHigh)
197 bool vtxTypeRangePassed = m_doVertexRangeCheck && ( unsigned(vxtype-m_vertexTypeRangeLow) < m_vertexTypeRangeLength );
198 // (3.2) if not in range or range check disabled, check whether vxtype
199 // std::set contains the given vertex type
200 if ( (!vtxTypeRangePassed) && (m_vertexTypes.find(vxtype)==m_vertexTypes.end()) ) {
201 // vxtype not registered -> not passed
202 return false;
203 }
204 }
205
206 // all cuts passed
207 return true;
208}
209
210bool ISF::GenericTruthStrategy::appliesToRegion(unsigned short geoID) const
211{
212 return std::find( m_regionListProperty.begin(),
214 geoID ) != m_regionListProperty.end();
215}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
bool m_useChildPt
child particle kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faste...
bool m_allowChildrenOrParentPass
pass cuts if parent did not
IntegerArrayProperty m_regionListProperty
double m_childPt2
pT momentum cut
bool m_useParentPt
parent kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faster compar...
VertexTypesSet m_vertexTypes
optimized for search
virtual StatusCode initialize() override
double m_parentPt2
parent particle
GenericTruthStrategy(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
VertexTypesVector m_vertexTypesVector
vertex type (physics code) checks
virtual StatusCode finalize() override
PDGCodesSet m_parentPdgCodes
optimized for search
virtual bool appliesToRegion(unsigned short geoID) const override
virtual bool pass(ITruthIncident &incident) const override
true if the ITruthStrategy implementation applies to the given ITruthIncident
PDGCodesVector m_parentPdgCodesVector
PDG code checks.
double m_parentEkin
parent particle
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 ...