ATLAS Offline Software
Loading...
Searching...
No Matches
CopyBosonTopLabelTruthParticles.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 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 (f(tp->decayVtx()->outgoingParticle(i))) return false;
35 }
36 return true;
37 }
38}
39
40
42 // Cut on particle type
43 if (m_ptype == "WBosons") {
44 return isFinalWith(tp, isWBoson);
45 } else if (m_ptype == "ZBosons") {
46 return isFinalWith(tp, isZBoson);
47 } else if (m_ptype == "HBosons") {
48 return isFinalWith(tp, isHBoson);
49 } else if (m_ptype == "TQuarksFinal") {
50 return isFinalWith(tp, isTQuark);
51 }
52
53 // not good.
54 throw std::runtime_error("Requested unknown particle classification type: " + m_ptype);
55 return false;
56}
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.
static const int Z0BOSON
static const int TQUARK
static const int HIGGSBOSON
static const int WPLUSBOSON
STL namespace.
TruthParticle_v1 TruthParticle
Typedef to implementation.