ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleJetTools
Root
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
5
#include "
ParticleJetTools/CopyBosonTopLabelTruthParticles.h
"
6
#include "
xAODTruth/TruthParticleContainer.h
"
7
#include "
xAODTruth/TruthParticleAuxContainer.h
"
8
#include "
xAODTruth/TruthEventContainer.h
"
9
#include "
AthContainers/ConstDataVector.h
"
10
#include "
TruthUtils/HepMCHelpers.h
"
11
12
using namespace
std
;
13
14
15
CopyBosonTopLabelTruthParticles::CopyBosonTopLabelTruthParticles
(
const
std::string& name)
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
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
(tp->
decayVtx
()->
outgoingParticle
(i)) {
35
if
(
f
(tp->
decayVtx
()->
outgoingParticle
(i)))
36
return
false
;
37
}
38
}
39
return
true
;
40
}
41
}
42
43
44
bool
CopyBosonTopLabelTruthParticles::classify
(
const
xAOD::TruthParticle
* tp)
const
{
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
}
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
CopyBosonTopLabelTruthParticles.h
TruthParticleContainer.h
HepMCHelpers.h
ATLAS-specific HepMC functions.
TruthEventContainer.h
TruthParticleAuxContainer.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
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
CopyBosonTopLabelTruthParticles::classify
bool classify(const xAOD::TruthParticle *tp) const
Classifier function(s).
Definition
CopyBosonTopLabelTruthParticles.cxx:44
CopyTruthParticles::CopyTruthParticles
CopyTruthParticles(const std::string &name)
Constructor.
Definition
CopyTruthParticles.cxx:15
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
xAOD::TruthParticle_v1::decayVtx
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
xAOD::TruthParticle_v1::hasDecayVtx
bool hasDecayVtx() const
Check for a decay vertex on this particle.
xAOD::TruthVertex_v1::outgoingParticle
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
Definition
TruthVertex_v1.cxx:120
MC::Z0BOSON
static const int Z0BOSON
Definition
HepMCHelpers.h:89
MC::TQUARK
static const int TQUARK
Definition
HepMCHelpers.h:70
MC::HIGGSBOSON
static const int HIGGSBOSON
Definition
HepMCHelpers.h:91
MC::WPLUSBOSON
static const int WPLUSBOSON
Definition
HepMCHelpers.h:90
hist_file_dump.f
f
Definition
hist_file_dump.py:140
lumiFormat.i
int i
Definition
lumiFormat.py:85
std
STL namespace.
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
Generated on
for ATLAS Offline Software by
1.17.0