ATLAS Offline Software
Loading...
Searching...
No Matches
TruthTrackSelector.cxx
Go to the documentation of this file.
1
10
11
12#include "TruthParticleTraits.h"
13
14#include "TruthTrackSelector.h"
16
17#include "AncestorFinder.h"
18#include "MsgMacros.h"
19
20
22
23
24template<typename T>
25bool isHeavyFlavour( const T* t ) {
26 return t->isBottomHadron() || t->isCharmHadron();
27}
28
29
31
33
34 if ( !m_truthTool.empty() ) ATH_CHECK( m_truthTool.retrieve() );
35 // ATH_CHECK( m_trackTruthOriginTool.retrieve() );
36
39
40 int findercount = 0;
41
45
46 if ( m_fromHadronPdgId==MC::BQUARK ) { m_ancestorFinder = std::make_unique<HadronFinder>( &xAOD::TruthParticle::isBottomHadron ); findercount++; }
47 if ( m_fromHadronPdgId==MC::CQUARK ) { m_ancestorFinder = std::make_unique<HadronFinder>( &xAOD::TruthParticle::isCharmHadron ); findercount++; }
48 if ( isset(m_fromPdgId) ) { m_ancestorFinder = std::make_unique<PdgFinder>( m_fromPdgId.value() ); findercount++; }
49 if ( m_isFromHeavyFlavour || m_isFromLightFlavour ) { m_ancestorFinder = std::make_unique<PredicateFinder>( isHeavyFlavour<xAOD::TruthParticle> ); findercount++; }
50
51 if ( findercount>1 ) {
52 MY_MSG_ERROR << "too many Truth selections requested" << endmsg;
53 }
54
55 return StatusCode::SUCCESS;
56}
57
58
59
61
62 const xAOD::TruthParticle* truth = t.as<xAOD::TruthParticle>();
63
64 if ( !truth ) return false;
65
67 if ( m_truthTool && !m_truthTool->accept( truth ) ) return false;
68
69 if ( !GenericTrackSelector::selectTrack(t) ) return false;
70
73
74 if ( std::abs(truth->pdgId())!=m_pdgId ) return false;
75
76 if ( m_isHadron && !truth->isHadron() ) return false;
77
78 if ( m_isPion ) {
79 int pdgid = std::abs(truth->pdgId());
80 if ( pdgid!=111 && pdgid!=211 ) return false;
81 }
82
86 if ( m_ancestorFinder ) {
87 const xAOD::TruthParticle* parent = m_ancestorFinder->findAncestor( truth );
88 if ( m_isFromLightFlavour && parent ) return false;
89 if ( !parent ) return false;
90 if ( parent->pt()<m_minParentPt ) return false;
91 if ( parent->pt()>m_maxParentPt ) return false;
92 }
93
94 return true;
95}
96
97
98
#define endmsg
emacs: this is -*- c++ -*-
#define ATH_CHECK
Evaluate an expression and check for errors.
bool isset(const Gaudi::Property< ConfiguredValue< T, UnsetResult > > &p)
ATLAS-specific HepMC functions.
emacs: this is -*- c++ -*-
#define MY_MSG_ERROR
Definition MsgMacros.h:22
bool isHeavyFlavour(const T *t)
emacs: this is -*- c++ -*-
virtual bool selectTrack(const TrackView &t) const override
GenericTrackSelector(const std::string &name)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
allows more sophisticated selection predicates that use class functions, such as isBottomHadron() etc...
now a specific selector using the above PDG ID helper so we can select whatever sort we want - even e...
a type using a generic bool function pointer since - for some reason, I can not fathom,...
Gaudi::Property< bool > m_isFromLightFlavour
Gaudi::Property< bool > m_isHadron
Gaudi::Property< ConfiguredValue< int > > m_pdgId
This here is never used, so comment it out for the time being in case it is important.
Gaudi::Property< ConfiguredValue< int > > m_fromPdgId
Gaudi::Property< bool > m_isFromHeavyFlavour
set with parent pdgid = 4 or 5
Gaudi::Property< ConfiguredValue< float > > m_maxParentPt
std::unique_ptr< IFinder< xAOD::TruthParticle > > m_ancestorFinder
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< ConfiguredValue< int > > m_fromHadronPdgId
TruthTrackSelector(const std::string &name)
Gaudi::Property< bool > m_isPion
Gaudi::Property< ConfiguredValue< float > > m_minParentPt
set with parent pdgid = 15
ToolHandle< IAthSelectionTool > m_truthTool
bool selectTrack(const TrackView &t) const override
forward declaration required for function prototype
Definition TrackView.h:43
bool isBottomHadron() const
Determine if the PID is that of a b-hadron.
bool isHadron() const
Whether the particle is a hadron.
int pdgId() const
PDG ID code.
bool isCharmHadron() const
Determine if the PID is that of a c-hadron.
static const int CQUARK
static const int BQUARK
TruthParticle_v1 TruthParticle
Typedef to implementation.