ATLAS Offline Software
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 
12 using namespace std;
13 
14 
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
23 namespace {
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 }
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TruthParticleContainer.h
ParticleTest.tp
tp
Definition: ParticleTest.py:25
TruthParticleAuxContainer.h
CopyBosonTopLabelTruthParticles.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
CopyBosonTopLabelTruthParticles::m_ptype
std::string m_ptype
Particle selection mode.
Definition: CopyBosonTopLabelTruthParticles.h:25
CopyBosonTopLabelTruthParticles::CopyBosonTopLabelTruthParticles
CopyBosonTopLabelTruthParticles(const std::string &name)
Constructor.
Definition: CopyBosonTopLabelTruthParticles.cxx:15
hist_file_dump.f
f
Definition: hist_file_dump.py:135
CopyBosonTopLabelTruthParticles::classify
bool classify(const xAOD::TruthParticle *tp) const
Classifier function(s)
Definition: CopyBosonTopLabelTruthParticles.cxx:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CopyTruthParticles
Definition: CopyTruthParticles.h:18
TruthEventContainer.h
HepMCHelpers.h