ATLAS Offline Software
Loading...
Searching...
No Matches
TruthQualitySelectionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9
11 : asg::AsgTool( name ) { }
12
14{
15 ATH_CHECK( m_truthTool.retrieve() );
17 return StatusCode::SUCCESS;
18}
19
20
22{
23 std::vector< const xAOD::TruthParticle* > selected;
24 for( const xAOD::TruthParticle* truth :
26 if( accept( truth ) ) selected.push_back( truth );
27 }
28
29 ATH_MSG_DEBUG( "Size before selection: " <<
30 trkAnaColls.truthPartVec( TrackAnalysisCollections::FS ).size() <<
31 "\t Size after selection: " << selected.size() );
32
35
36 return StatusCode::SUCCESS;
37}
38
39
40
42 return getParentRec( truth, flav, 0 );
43}
44
46
47 if ( truth == nullptr ) return nullptr;
48
49 if ( depth > 30 ) return nullptr;
50
51 if( flav != MC::BQUARK && flav != MC::CQUARK && flav != MC::TAU ) return nullptr;
52
53 if( flav == MC::BQUARK && truth->isBottomHadron() ) return truth;
54
55 if( flav == MC::CQUARK && truth->isCharmHadron() ) return truth;
56
57 if( flav == MC::TAU && MC::isTau(truth) ) return truth;
58
59
60 for(unsigned int p=0; p<truth->nParents(); p++) {
61 const xAOD::TruthParticle* parent = truth->parent(p);
62 if(parent == truth ) continue ; // avoid infinite recursion
63 if( getParentRec(parent, flav, depth+1)!= nullptr ) return parent;
64 }
65
66 return nullptr;
67}
68
69
70
72{
74 if( not m_truthTool->accept( truth ) ) return false;
75
77 if (m_maxEta!=-9999. and (eta(*truth)) > m_maxEta ) return false;
78 if (m_minEta!=-9999. and (eta(*truth)) < m_minEta ) return false;
79 if (m_minPhi!=-9999. and (phi(*truth)) < m_minPhi ) return false;
80 if (m_maxPhi!=-9999. and (phi(*truth)) > m_maxPhi ) return false;
81 if (m_minD0!=-9999. and (d0(*truth)) < m_minD0 ) return false;
82 if (m_maxD0!=-9999. and (d0(*truth)) > m_maxD0 ) return false;
83 if (m_minZ0!=-9999. and (z0(*truth)) < m_minZ0 ) return false;
84 if (m_maxZ0!=-9999. and (z0(*truth)) > m_maxZ0 ) return false;
85 if (m_minQoPT!=-9999. and (qOverPT(*truth)) < m_minQoPT ) return false;
86 if (m_maxQoPT!=-9999. and (qOverPT(*truth)) > m_maxQoPT ) return false;
87 if (m_minAbsEta!=-9999. and std::fabs(eta(*truth)) < m_minAbsEta ) return false;
88 if (m_minAbsPhi!=-9999. and std::fabs(phi(*truth)) < m_minAbsPhi ) return false;
89 if (m_maxAbsPhi!=-9999. and std::fabs(phi(*truth)) > m_maxAbsPhi ) return false;
90 if (m_minAbsD0!=-9999. and std::fabs(d0(*truth)) < m_minAbsD0 ) return false;
91 if (m_maxAbsD0!=-9999. and std::fabs(d0(*truth)) > m_maxAbsD0 ) return false;
92 if (m_minAbsZ0!=-9999. and std::fabs(z0(*truth)) < m_minAbsZ0 ) return false;
93 if (m_maxAbsZ0!=-9999. and std::fabs(z0(*truth)) > m_maxAbsZ0 ) return false;
94 if (m_minAbsQoPT!=-9999. and std::fabs(qOverPT(*truth)) < m_minAbsQoPT ) return false;
95 if (m_maxAbsQoPT!=-9999. and std::fabs(qOverPT(*truth)) > m_maxAbsQoPT ) return false;
96 if (m_isHadron and not isHadron(*truth) ) return false;
97 if (m_isPion and not isPion(*truth) ) return false;
98
100 const xAOD::TruthParticle* truthParent = nullptr;
101 if( m_isFromTau ) truthParent = getParent(truth, MC::TAU);
102 if( m_isFromB ) truthParent = getParent(truth, MC::BQUARK);
103 if( m_isFromC ) truthParent = getParent(truth, MC::CQUARK);
105 const xAOD::TruthParticle* truthParentB = getParent(truth, MC::BQUARK);
106 const xAOD::TruthParticle* truthParentC = getParent(truth, MC::CQUARK);
107 truthParent = truthParentB ? truthParentB : (truthParentC ? truthParentC : nullptr);
108 }
109 if (m_isFromLightFlav and truthParent ) return false;
110 if (not m_isFromLightFlav and not truthParent) return false;
111 if (m_minParentPt!=-9999. and truthParent->pt() < m_minParentPt ) return false;
112 if (m_maxParentPt!=-9999. and truthParent->pt() > m_maxParentPt ) return false;
113 }
114
115 return true;
116}
117
118
119
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
ATLAS-specific HepMC functions.
Utility methods to access track/truth particles parmeters in a consitent way in this package.
StatusCode fillTruthPartVec(const std::vector< const xAOD::TruthParticle * > &vec, Stage stage=FULL)
fill truth/offline/trigger track vector (TEST or REFERENCE)
const std::vector< const xAOD::TruthParticle * > & truthPartVec(Stage stage=FULL)
get truth/offline/trigger track vector (TEST or REFERENCE)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
bool accept(const xAOD::TruthParticle *truth)
virtual StatusCode selectTracks(TrackAnalysisCollections &trkAnaColls) override
const xAOD::TruthParticle * getParent(const xAOD::TruthParticle *truth, int flav) const
ToolHandle< InDet::IInDetTrackTruthOriginTool > m_trackTruthOriginTool
const xAOD::TruthParticle * getParentRec(const xAOD::TruthParticle *truth, int flav, int depth) const
TruthQualitySelectionTool(const std::string &name)
ToolHandle< IAthSelectionTool > m_truthTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
bool isBottomHadron() const
Determine if the PID is that of a b-hadron.
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
size_t nParents() const
Number of parents of this particle.
bool isCharmHadron() const
Determine if the PID is that of a c-hadron.
std::string depth
tag string for intendation
Definition fastadd.cxx:46
float qOverPT(const U &p)
float isPion(const U &p)
float z0(const U &p)
float d0(const U &p)
float isHadron(const U &p)
static const int CQUARK
static const int TAU
static const int BQUARK
bool isTau(const T &p)
TruthParticle_v1 TruthParticle
Typedef to implementation.