ATLAS Offline Software
Loading...
Searching...
No Matches
Common.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
6namespace Common {
35
36
37static bool fromWZ(const HepMC::ConstGenParticlePtr& part )
38{
39 // Loop through parents
40 // Hit a hadron -> return false
41 // Hit a parton -> return true
42 // This catch is important - we *cannot* look explicitly for the W or Z, because some
43 // generators do not include the W or Z in the truth record (like Sherpa)
44 // This code, like the code before it, really assumes one incoming particle per vertex...
45 if (!part->production_vertex()) return false;
46 for (const auto& iter: part->production_vertex()->particles_in()){
47 int parent_pdgid = iter->pdg_id();
48 if (MC::isW(parent_pdgid) || MC::isZ(parent_pdgid)) return true;
49 if (MC::isHadron( parent_pdgid ) ) return false;
50 if ( std::abs( parent_pdgid ) < 9 ) return true;
51 if ( parent_pdgid == part->pdg_id() ) return fromWZ( iter );
52 }
53 return false;
54}
55
56static bool fromTau(const HepMC::ConstGenParticlePtr& part )
57{
58 // Loop through parents
59 // Find a tau -> return true
60 // Find a hadron or parton -> return false
61 // This code, like the code before it, really assumes one incoming particle per vertex...
62 if (!part->production_vertex()) return false;
63 for (const auto& iter: part->production_vertex()->particles_in()){
64 int parent_pdgid = iter->pdg_id();
65 if ( std::abs( parent_pdgid ) == 15 ) return true;
66 if (MC::isHadron( parent_pdgid ) || MC::isQuark( parent_pdgid ) ) return false;
67 if ( parent_pdgid == part->pdg_id() ) return fromTau( iter );
68 }
69 return false;
70}
71
72bool fromWZorTau(const HepMC::ConstGenParticlePtr& part ) { return fromWZ(part)||fromTau(part); }
73
74
75void classify(ToolHandle<IMCTruthClassifier>& classif,
76 const xAOD::TruthParticle * theParticle,
77 unsigned int& particleOutCome,
78 unsigned int& result,
79 int& hadron_pdg,
80 unsigned int& particleType,
81 unsigned int& particleOrigin )
82 {
84 std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin> classification = classif->particleTruthClassifier(theParticle, &info);
85 particleOutCome = info.particleOutCome;
86 auto tpl = MCTruthPartClassifier::defOrigOfParticle(theParticle);
87 result = (unsigned int)std::get<0>(tpl);
88 hadron_pdg = std::get<1>(tpl)?std::get<1>(tpl)->pdg_id():0;
89 particleType = classification.first;
90 particleOrigin = classification.second;
91 }
92}
Definition Common.h:9
static bool fromTau(const HepMC::ConstGenParticlePtr &part)
Definition Common.cxx:56
void classify(ToolHandle< IMCTruthClassifier > &m_classif, const xAOD::TruthParticle *theParticle, unsigned int &particleOutCome, unsigned int &result, int &hadron_pdg, unsigned int &particleType, unsigned int &particleOrigin)
Definition Common.cxx:75
bool fromWZorTau(const HepMC::ConstGenParticlePtr &part)
Definition Common.cxx:72
bool prompt(const xAOD::TruthParticle *part, ToolHandle< IMCTruthClassifier > &m_classif)
Definition Common.cxx:7
static bool fromWZ(const HepMC::ConstGenParticlePtr &part)
Definition Common.cxx:37
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
std::tuple< unsigned int, T > defOrigOfParticle(T thePart)
bool isZ(const T &p)
bool isW(const T &p)
bool isQuark(const T &p)
PDG rule 2: Quarks and leptons are numbered consecutively starting from 1 and 11 respectively; to do ...
bool isHadron(const T &p)
TruthParticle_v1 TruthParticle
Typedef to implementation.