ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
ISF::GenericTruthStrategy Class Referencefinal

#include <GenericTruthStrategy.h>

Inheritance diagram for ISF::GenericTruthStrategy:
Collaboration diagram for ISF::GenericTruthStrategy:

Public Member Functions

 GenericTruthStrategy (const std::string &t, const std::string &n, const IInterface *p)
 Constructor with parameters. More...
 
 ~GenericTruthStrategy ()
 Destructor. More...
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual bool pass (ITruthIncident &incident) const override
 true if the ITruthStrategy implementation applies to the given ITruthIncident More...
 
virtual bool appliesToRegion (unsigned short geoID) const override
 

Private Attributes

bool m_useParentPt
 parent kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faster comparisons) More...
 
double m_parentPt2
 parent particle More...
 
double m_parentEkin
 parent particle More...
 
bool m_useChildPt
 child particle kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faster comparisons) More...
 
double m_childPt2
 pT momentum cut More...
 
double m_childEkin
 Ekin cut. More...
 
bool m_allowChildrenOrParentPass
 pass cuts if parent did not More...
 
VertexTypesVector m_vertexTypesVector
 vertex type (physics code) checks More...
 
VertexTypesSet m_vertexTypes
 optimized for search More...
 
bool m_doVertexRangeCheck
 
int m_vertexTypeRangeLow
 
int m_vertexTypeRangeHigh
 
unsigned m_vertexTypeRangeLength
 
PDGCodesVector m_parentPdgCodesVector
 PDG code checks. More...
 
PDGCodesSet m_parentPdgCodes
 optimized for search More...
 
IntegerArrayProperty m_regionListProperty
 

Detailed Description

A multi-purpose implementation of an ISF TruthStrategy.

Author
Elmar.Ritsch -at- cern.ch

Definition at line 35 of file GenericTruthStrategy.h.

Constructor & Destructor Documentation

◆ GenericTruthStrategy()

ISF::GenericTruthStrategy::GenericTruthStrategy ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Constructor with parameters.

Constructor.

Definition at line 17 of file GenericTruthStrategy.cxx.

17  :
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.),
27  m_vertexTypes(),
28  m_doVertexRangeCheck(false),
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 );
50 }

◆ ~GenericTruthStrategy()

ISF::GenericTruthStrategy::~GenericTruthStrategy ( )

Destructor.

Definition at line 53 of file GenericTruthStrategy.cxx.

54 {
55 }

Member Function Documentation

◆ appliesToRegion()

bool ISF::GenericTruthStrategy::appliesToRegion ( unsigned short  geoID) const
overridevirtual

Definition at line 210 of file GenericTruthStrategy.cxx.

211 {
212  return std::find( m_regionListProperty.begin(),
213  m_regionListProperty.end(),
214  geoID ) != m_regionListProperty.end();
215 }

◆ finalize()

StatusCode ISF::GenericTruthStrategy::finalize ( )
overridevirtual

Definition at line 138 of file GenericTruthStrategy.cxx.

139 {
140  ATH_MSG_VERBOSE("Finalizing ...");
141  return StatusCode::SUCCESS;
142 }

◆ initialize()

StatusCode ISF::GenericTruthStrategy::initialize ( )
overridevirtual

Definition at line 58 of file GenericTruthStrategy.cxx.

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.):
82  m_useParentPt = !(m_parentPt2<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
127  m_vertexTypes.insert( m_vertexTypesVector.begin(), m_vertexTypesVector.end());
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 }

◆ pass()

bool ISF::GenericTruthStrategy::pass ( ITruthIncident incident) const
overridevirtual

true if the ITruthStrategy implementation applies to the given ITruthIncident

Definition at line 144 of file GenericTruthStrategy.cxx.

144  {
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)
163  : ti.childrenEkinPass(m_childEkin);
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 }

Member Data Documentation

◆ m_allowChildrenOrParentPass

bool ISF::GenericTruthStrategy::m_allowChildrenOrParentPass
private

pass cuts if parent did not

Definition at line 64 of file GenericTruthStrategy.h.

◆ m_childEkin

double ISF::GenericTruthStrategy::m_childEkin
private

Ekin cut.

Definition at line 63 of file GenericTruthStrategy.h.

◆ m_childPt2

double ISF::GenericTruthStrategy::m_childPt2
private

pT momentum cut

Definition at line 62 of file GenericTruthStrategy.h.

◆ m_doVertexRangeCheck

bool ISF::GenericTruthStrategy::m_doVertexRangeCheck
private

Definition at line 69 of file GenericTruthStrategy.h.

◆ m_parentEkin

double ISF::GenericTruthStrategy::m_parentEkin
private

parent particle

Definition at line 57 of file GenericTruthStrategy.h.

◆ m_parentPdgCodes

PDGCodesSet ISF::GenericTruthStrategy::m_parentPdgCodes
private

optimized for search

Definition at line 76 of file GenericTruthStrategy.h.

◆ m_parentPdgCodesVector

PDGCodesVector ISF::GenericTruthStrategy::m_parentPdgCodesVector
private

PDG code checks.

Python property

Definition at line 75 of file GenericTruthStrategy.h.

◆ m_parentPt2

double ISF::GenericTruthStrategy::m_parentPt2
private

parent particle

Definition at line 56 of file GenericTruthStrategy.h.

◆ m_regionListProperty

IntegerArrayProperty ISF::GenericTruthStrategy::m_regionListProperty
private

Definition at line 78 of file GenericTruthStrategy.h.

◆ m_useChildPt

bool ISF::GenericTruthStrategy::m_useChildPt
private

child particle kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faster comparisons)

use pT or Ekin cuts?

Definition at line 61 of file GenericTruthStrategy.h.

◆ m_useParentPt

bool ISF::GenericTruthStrategy::m_useParentPt
private

parent kinetic energy / transverse momentum cuts (pT is stored as pT^2 which allows for faster comparisons)

use pT or Ekin cuts?

Definition at line 55 of file GenericTruthStrategy.h.

◆ m_vertexTypeRangeHigh

int ISF::GenericTruthStrategy::m_vertexTypeRangeHigh
private

Definition at line 71 of file GenericTruthStrategy.h.

◆ m_vertexTypeRangeLength

unsigned ISF::GenericTruthStrategy::m_vertexTypeRangeLength
private

Definition at line 72 of file GenericTruthStrategy.h.

◆ m_vertexTypeRangeLow

int ISF::GenericTruthStrategy::m_vertexTypeRangeLow
private

Definition at line 70 of file GenericTruthStrategy.h.

◆ m_vertexTypes

VertexTypesSet ISF::GenericTruthStrategy::m_vertexTypes
private

optimized for search

Definition at line 68 of file GenericTruthStrategy.h.

◆ m_vertexTypesVector

VertexTypesVector ISF::GenericTruthStrategy::m_vertexTypesVector
private

vertex type (physics code) checks

Python property

Definition at line 67 of file GenericTruthStrategy.h.


The documentation for this class was generated from the following files:
AtlasDetDescr::fNumAtlasRegions
@ fNumAtlasRegions
Definition: AtlasRegion.h:39
ISF::GenericTruthStrategy::m_parentPdgCodes
PDGCodesSet m_parentPdgCodes
optimized for search
Definition: GenericTruthStrategy.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
ISF::GenericTruthStrategy::m_doVertexRangeCheck
bool m_doVertexRangeCheck
Definition: GenericTruthStrategy.h:69
ISF::GenericTruthStrategy::m_allowChildrenOrParentPass
bool m_allowChildrenOrParentPass
pass cuts if parent did not
Definition: GenericTruthStrategy.h:64
ISF::GenericTruthStrategy::m_childPt2
double m_childPt2
pT momentum cut
Definition: GenericTruthStrategy.h:62
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::GenericTruthStrategy::m_parentEkin
double m_parentEkin
parent particle
Definition: GenericTruthStrategy.h:57
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
ISF::GenericTruthStrategy::m_vertexTypesVector
VertexTypesVector m_vertexTypesVector
vertex type (physics code) checks
Definition: GenericTruthStrategy.h:67
ISF::GenericTruthStrategy::m_vertexTypeRangeLow
int m_vertexTypeRangeLow
Definition: GenericTruthStrategy.h:70
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ISF::GenericTruthStrategy::m_vertexTypeRangeHigh
int m_vertexTypeRangeHigh
Definition: GenericTruthStrategy.h:71
beamspotman.n
n
Definition: beamspotman.py:731
ISF::GenericTruthStrategy::m_vertexTypeRangeLength
unsigned m_vertexTypeRangeLength
Definition: GenericTruthStrategy.h:72
ISF::GenericTruthStrategy::m_parentPdgCodesVector
PDGCodesVector m_parentPdgCodesVector
PDG code checks.
Definition: GenericTruthStrategy.h:75
ISF::GenericTruthStrategy::m_parentPt2
double m_parentPt2
parent particle
Definition: GenericTruthStrategy.h:56
ISF::GenericTruthStrategy::m_regionListProperty
IntegerArrayProperty m_regionListProperty
Definition: GenericTruthStrategy.h:78
ISF::GenericTruthStrategy::m_childEkin
double m_childEkin
Ekin cut.
Definition: GenericTruthStrategy.h:63
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_vertexTypes
VertexTypesSet m_vertexTypes
optimized for search
Definition: GenericTruthStrategy.h:68
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
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:55