ATLAS Offline Software
Loading...
Searching...
No Matches
CopyBosonTopLabelTruthParticles.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12using namespace std;
13
14
16 : CopyTruthParticles(name)
17{
18 declareProperty("ParticleType", m_ptype="None", "Sort of particles to pick: WBosons | ZBosons | HBosons | TQuarksFinal");
19}
20
21
22// Unnamed namespace for helpers: only visible to this compilation unit
23namespace {
24 inline bool isWBoson(const xAOD::TruthParticle* tp) { return (abs(tp->pdgId()) == MC::WPLUSBOSON); }
25 inline bool isZBoson(const xAOD::TruthParticle* tp) { return (abs(tp->pdgId()) == MC::Z0BOSON); }
26 inline bool isHBoson(const xAOD::TruthParticle* tp) { return (abs(tp->pdgId()) == MC::HIGGSBOSON); }
27 inline bool isTQuark(const xAOD::TruthParticle* tp) { return (abs(tp->pdgId()) == MC::TQUARK); }
28
29 template <typename FN>
30 inline bool isFinalWith(const xAOD::TruthParticle* tp, const FN& f) {
31 if (!f(tp)) return false;
32 if (!tp->hasDecayVtx()) return false;
33 for (unsigned int i = 0; i < tp->decayVtx()->nOutgoingParticles(); ++i) {
34 if (tp->decayVtx()->outgoingParticle(i)) {
35 if (f(tp->decayVtx()->outgoingParticle(i)))
36 return false;
37 }
38 }
39 return true;
40 }
41}
42
43
45 // Cut on particle type
46 if (m_ptype == "WBosons") {
47 return isFinalWith(tp, isWBoson);
48 } else if (m_ptype == "ZBosons") {
49 return isFinalWith(tp, isZBoson);
50 } else if (m_ptype == "HBosons") {
51 return isFinalWith(tp, isHBoson);
52 } else if (m_ptype == "TQuarksFinal") {
53 return isFinalWith(tp, isTQuark);
54 }
55
56 // not good.
57 throw std::runtime_error("Requested unknown particle classification type: " + m_ptype);
58 return false;
59}
DataVector adapter that acts like it holds const pointers.
ATLAS-specific HepMC functions.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_ptype
Particle selection mode.
CopyBosonTopLabelTruthParticles(const std::string &name)
Constructor.
bool classify(const xAOD::TruthParticle *tp) const
Classifier function(s)
CopyTruthParticles(const std::string &name)
Constructor.
int pdgId() const
PDG ID code.
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
bool hasDecayVtx() const
Check for a decay vertex on this particle.
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
static const int Z0BOSON
static const int TQUARK
static const int HIGGSBOSON
static const int WPLUSBOSON
STL namespace.
TruthParticle_v1 TruthParticle
Typedef to implementation.