ATLAS Offline Software
KeepChildrenTruthStrategy.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // KeepChildrenTruthStrategy.cxx, (c) ATLAS Detector software
8 
9 // class header include
11 
12 // ISF includes
14 #include "ISF_Event/ISFParticle.h"
15 
16 // For BSM helper
18 
19 
21 ISF::KeepChildrenTruthStrategy::KeepChildrenTruthStrategy(const std::string& t, const std::string& n, const IInterface* p)
22  : base_class(t,n,p)
23  , m_vertexTypesVector(0)
24  , m_vertexTypes()
25  , m_doVertexRangeCheck(false)
26  , m_vertexTypeRangeLow(0)
27  , m_vertexTypeRangeHigh(0)
28  , m_vertexTypeRangeLength(0)
29  , m_passProcessCategory(0)
30  , m_bsmParent(false)
31  , m_parentPdgCodesVector(0)
32  , m_parentPdgCodes()
33 {
34  // if set to true, kinetic cuts are passed even if only child particles pass them
35  // (used for special cases such as de-excitation)
36  declareProperty("VertexTypes" , m_vertexTypesVector );
37  declareProperty("VertexTypeRangeLow" , m_vertexTypeRangeLow );
38  declareProperty("VertexTypeRangeHigh" , m_vertexTypeRangeHigh );
39  declareProperty("PassProcessCategory", m_passProcessCategory=9);
40  declareProperty("ParentPDGCodes" , m_parentPdgCodesVector );
41  declareProperty("BSMParent" , m_bsmParent );
42 }
43 
46 {
47 }
48 
49 // Athena algtool's Hooks
51 {
52  ATH_MSG_VERBOSE("Initializing ...");
53 
54  // VertexTypeRanges:
55  //
56  // check whether user input makes sense:
57  if ( m_vertexTypeRangeHigh < m_vertexTypeRangeLow) {
58  ATH_MSG_ERROR("The given parameter VertexTypeRangeLow is bigger than VertexTypeRangeHigh. ABORT");
59  return StatusCode::FAILURE;
60  }
61  // the length of the given vertex type range
62  m_vertexTypeRangeLength = unsigned(m_vertexTypeRangeHigh - m_vertexTypeRangeLow) + 1;
63  // if neither lower now upper range limit given, disable range check
64  m_doVertexRangeCheck = m_vertexTypeRangeLow && m_vertexTypeRangeHigh;
65 
66  // fill PDG code std::set used for optimized search
67  m_parentPdgCodes.insert( m_parentPdgCodesVector.begin(), m_parentPdgCodesVector.end());
68 
69  // fill vertex type std::set used for optimized search
70  m_vertexTypes.insert( m_vertexTypesVector.begin(), m_vertexTypesVector.end());
71 
72  return StatusCode::SUCCESS;
73 }
74 
76 
77  // check whether parent PDG code matches with any of the given ones
78  // Could require BSM parents and hit BSM, or give a list and be on the list
79  // Or require neither and apply to everything
80  if ( !( (m_bsmParent && MC::isBSM(abs(ti.parentPdgCode()))) || // BSM parent and parent is BSM
81  (m_parentPdgCodes.size() && m_parentPdgCodes.find(ti.parentPdgCode())==m_parentPdgCodes.end()) || // Explicit list and parent in the list
82  (!m_bsmParent && !m_parentPdgCodes.size()) ) ){ // Neither BSM parent nor explicit list -- allow all
83  return false;
84  }
85 
86  // vertex type check
87  // ----
88  int vxtype = ti.physicsProcessCode();
89  int processCategory = ti.physicsProcessCategory(); // == G4ProcessType
90  if ((processCategory!=m_passProcessCategory && m_passProcessCategory!=0) && // Not in the category we were after
91  (m_doVertexRangeCheck || m_vertexTypes.size()) ){ // Should do the category check
92  // (part 1) vxtype in given range?: this is a small performance trick (only one comparison operator to check if within range)
93  // -> exactly equivalent to: m_doVertexRangeCheck && (m_vertexTypeLow<=vxtype) && (vxtype<=m_vertexTypeRangeHigh)
94  bool vtxTypeRangePassed = m_doVertexRangeCheck && ( unsigned(vxtype-m_vertexTypeRangeLow) < m_vertexTypeRangeLength );
95  // (part 2) if not in range or range check disabled, check whether vxtype
96  // std::set contains the given vertex type
97  if ( (!vtxTypeRangePassed) && (m_vertexTypes.find(vxtype)==m_vertexTypes.end()) ) {
98  // vxtype not registered -> not passed
99  return false;
100  }
101  }
102 
103  // all cuts passed. Save all children.
104  for (unsigned short i=0;i<ti.numberOfChildren();++i){
106  }
107 
108  // This strategy does not cause the *saving* of a vertex -- it only changes the strategy for the children
109  return false;
110 }
111 
113 {
114  // This applies to all regions, since it is only a modifier
115  return true;
116 }
ISF::KeepChildrenTruthStrategy::appliesToRegion
virtual bool appliesToRegion(unsigned short) const override
true if the strategy applies to this region
Definition: KeepChildrenTruthStrategy.cxx:112
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ISF::ITruthIncident::physicsProcessCode
virtual int physicsProcessCode() const =0
Return specific physics process code of the truth incident (eg ionisation, bremsstrahlung,...
isBSM
bool isBSM(const T &p)
Definition: AtlasPID.h:213
ISF::ITruthIncident::parentPdgCode
virtual int parentPdgCode() const =0
Return the PDG Code of the parent particle.
KeepChildrenTruthStrategy.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::KeepChildrenTruthStrategy::initialize
StatusCode initialize() override
Definition: KeepChildrenTruthStrategy.cxx:50
ISF::KeepChildrenTruthStrategy::m_passProcessCategory
int m_passProcessCategory
Definition: KeepChildrenTruthStrategy.h:62
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
ISFParticle.h
ISF::ITruthIncident::numberOfChildren
unsigned short numberOfChildren() const
Return total number of child particles.
Definition: ITruthIncident.h:139
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
ITruthIncident.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ISF::ITruthIncident
Definition: ITruthIncident.h:45
ISF::KeepChildrenTruthStrategy::KeepChildrenTruthStrategy
KeepChildrenTruthStrategy(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: KeepChildrenTruthStrategy.cxx:21
ISF::KeepChildrenTruthStrategy::pass
bool pass(ITruthIncident &incident) const override
true if the ITruthStrategy implementation applies to the given ITruthIncident
Definition: KeepChildrenTruthStrategy.cxx:75
ISF::KeepChildrenTruthStrategy::m_bsmParent
bool m_bsmParent
Apply to BSM parents.
Definition: KeepChildrenTruthStrategy.h:63
ISF::KeepChildrenTruthStrategy::~KeepChildrenTruthStrategy
~KeepChildrenTruthStrategy()
Destructor.
Definition: KeepChildrenTruthStrategy.cxx:45
ISF::KeepChildrenTruthStrategy::m_parentPdgCodesVector
PDGCodesVector m_parentPdgCodesVector
PDG code checks.
Definition: KeepChildrenTruthStrategy.h:65
ISF::KeepChildrenTruthStrategy::m_vertexTypeRangeHigh
int m_vertexTypeRangeHigh
Definition: KeepChildrenTruthStrategy.h:60
ISF::KeepChildrenTruthStrategy::m_vertexTypesVector
VertexTypesVector m_vertexTypesVector
vertex type (physics code) checks
Definition: KeepChildrenTruthStrategy.h:56
ISF::ITruthIncident::physicsProcessCategory
virtual int physicsProcessCategory() const =0
Return category of the physics process represented by the truth incident (eg hadronic,...
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
ISF::ITruthIncident::setChildPassedFilters
void setChildPassedFilters(unsigned short index)
Record that a particular child passed a check.
Definition: ITruthIncident.h:181
ISF::KeepChildrenTruthStrategy::m_vertexTypeRangeLow
int m_vertexTypeRangeLow
Definition: KeepChildrenTruthStrategy.h:59
HepMCHelpers.h