ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleJetTools
Root
CopyFlavorLabelTruthParticles.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
ParticleJetTools/CopyFlavorLabelTruthParticles.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
CopyFlavorLabelTruthParticles::CopyFlavorLabelTruthParticles
(
const
std::string& name)
16
:
CopyTruthParticles
(name)
17
{
18
declareProperty
(
"ParticleType"
,
m_ptype
=
"BHadronsFinal"
,
"Sort of particles to pick: BHadronsFinal | BHadronsInitial | BQuarksFinal | CHadronsFinal | CHadronsInitial | CQuarksFinal | TausFinal"
);
19
}
20
21
22
// Unnamed namespace for helpers: only visible to this compilation unit
23
namespace
{
24
inline
bool
isBQuark(
const
xAOD::TruthParticle
* tp) {
return
(abs(tp->
pdgId
()) ==
MC::BQUARK
); }
25
inline
bool
isCQuark(
const
xAOD::TruthParticle
* tp) {
return
(abs(tp->
pdgId
()) ==
MC::CQUARK
); }
26
inline
bool
isBHadron(
const
xAOD::TruthParticle
* tp) {
return
MC::isBottomHadron
(tp->
pdgId
()); }
27
inline
bool
isCHadron(
const
xAOD::TruthParticle
* tp) {
return
MC::isCharmHadron
(tp->
pdgId
()); }
28
inline
bool
isTau
(
const
xAOD::TruthParticle
* tp) {
return
MC::isTau
(tp->
pdgId
()); }
29
30
template
<
typename
FN>
31
inline
bool
isFinalWith(
const
xAOD::TruthParticle
* tp,
const
FN& f) {
32
if
(!
f
(tp))
return
false
;
33
if
(!tp->
hasDecayVtx
())
return
false
;
34
for
(
unsigned
int
i = 0;
i
< tp->
decayVtx
()->nOutgoingParticles(); ++
i
) {
35
if
(tp->
decayVtx
()->
outgoingParticle
(i)==
nullptr
)
continue
;
36
if
(
f
(tp->
decayVtx
()->
outgoingParticle
(i)))
return
false
;
37
}
38
return
true
;
39
}
40
41
template
<
typename
FN>
42
inline
bool
isInitialWith(
const
xAOD::TruthParticle
* tp,
const
FN& f) {
43
if
(!
f
(tp))
return
false
;
44
if
(!tp->
hasProdVtx
())
return
false
;
45
for
(
unsigned
int
i = 0;
i
< tp->
prodVtx
()->nIncomingParticles(); ++
i
) {
46
if
(tp->
prodVtx
()->
incomingParticle
(i)==
nullptr
)
continue
;
47
if
(
f
(tp->
prodVtx
()->
incomingParticle
(i)))
return
false
;
48
}
49
return
true
;
50
}
51
}
52
53
54
bool
CopyFlavorLabelTruthParticles::classify
(
const
xAOD::TruthParticle
* tp)
const
{
55
// Cut on particle type
56
if
(tp ==
nullptr
){
57
return
false
;
58
}
59
if
(
m_ptype
==
"BHadronsFinal"
) {
60
//ATH_MSG_DEBUG("Selecting in BHadronsFinal mode");
61
return
isFinalWith(tp, isBHadron);
62
}
else
if
(
m_ptype
==
"BHadronsInitial"
) {
63
//ATH_MSG_DEBUG("Selecting in BHadronsInitial mode");
64
return
isInitialWith(tp, isBHadron);
65
}
else
if
(
m_ptype
==
"BQuarksFinal"
) {
66
//ATH_MSG_DEBUG("Selecting in BQuarksFinal mode");
67
return
isFinalWith(tp, isBQuark);
68
}
else
if
(
m_ptype
==
"CHadronsFinal"
) {
69
//ATH_MSG_DEBUG("Selecting in CHadronsFinal mode");
70
return
isFinalWith(tp, isCHadron);
71
}
else
if
(
m_ptype
==
"CHadronsInitial"
) {
72
//ATH_MSG_DEBUG("Selecting in CHadronsInitial mode");
73
return
isInitialWith(tp, isCHadron);
74
}
else
if
(
m_ptype
==
"CQuarksFinal"
) {
75
//ATH_MSG_DEBUG("Selecting in CQuarksFinal mode");
76
return
isFinalWith(tp, isCQuark);
77
}
else
if
(
m_ptype
==
"TausFinal"
) {
78
//ATH_MSG_DEBUG("Selecting in TausFinal mode");
79
return
isFinalWith(tp,
isTau
);
80
}
81
throw
std::runtime_error(
"Requested unknown particle classification type: "
+
m_ptype
);
82
return
false
;
83
}
isTau
bool isTau(const T &p)
Definition
AtlasPID.h:214
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
CopyFlavorLabelTruthParticles.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
CopyFlavorLabelTruthParticles::m_ptype
std::string m_ptype
Particle selection mode.
Definition
CopyFlavorLabelTruthParticles.h:25
CopyFlavorLabelTruthParticles::CopyFlavorLabelTruthParticles
CopyFlavorLabelTruthParticles(const std::string &name)
Constructor.
Definition
CopyFlavorLabelTruthParticles.cxx:15
CopyFlavorLabelTruthParticles::classify
bool classify(const xAOD::TruthParticle *tp) const
Classifier function(s).
Definition
CopyFlavorLabelTruthParticles.cxx:54
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::hasProdVtx
bool hasProdVtx() const
Check for a production vertex on this particle.
Definition
TruthParticle_v1.cxx:69
xAOD::TruthParticle_v1::hasDecayVtx
bool hasDecayVtx() const
Check for a decay vertex on this particle.
xAOD::TruthParticle_v1::prodVtx
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
Definition
TruthParticle_v1.cxx:75
xAOD::TruthVertex_v1::outgoingParticle
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
Definition
TruthVertex_v1.cxx:120
xAOD::TruthVertex_v1::incomingParticle
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
Definition
TruthVertex_v1.cxx:70
MC::isCharmHadron
bool isCharmHadron(const T &p)
Definition
HepMCHelpers.h:918
MC::CQUARK
static const int CQUARK
Definition
HepMCHelpers.h:68
MC::isBottomHadron
bool isBottomHadron(const T &p)
Definition
HepMCHelpers.h:919
MC::BQUARK
static const int BQUARK
Definition
HepMCHelpers.h:69
MC::isTau
bool isTau(const T &p)
Definition
HepMCHelpers.h:215
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