ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
TruthPartonLevelAnalysisAlgorithms
Root
PartonHistoryUtils.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
7
8
#include "
PartonHistory/PartonHistoryUtils.h
"
9
10
namespace
CP
{
11
namespace
PartonHistoryUtils
{
12
16
17
bool
hasParentPdgId
(
const
xAOD::TruthParticle
* p,
int
pdgId) {
18
// Checks if the particle or its parent are nullptr.
19
if
(!p || !p->parent(0)) {
20
return
false
;
21
}
22
// Checks if the parent of the given particle has a specific PDG ID.
23
return
p->parent(0)->pdgId() == pdgId;
24
}
25
26
bool
hasParentPdgId
(
const
xAOD::TruthParticle
* p) {
27
// Checks if the parent of the given particle has a specific PDG ID.
28
return
hasParentPdgId
(p, p->pdgId());
29
}
30
31
bool
hasIdenticalChild
(
const
xAOD::TruthParticle
* p) {
32
// Checks if the given particle has at least one child with an identical PDG
33
// ID.
34
bool
check =
false
;
35
for
(
size_t
i = 0; i < p->nChildren(); i++) {
36
if
(p->child(i) && p->child(i)->pdgId() == p->pdgId())
37
check =
true
;
38
}
39
return
check;
40
}
41
42
bool
hasParentAbsPdgId
(
const
xAOD::TruthParticle
* p,
int
absPdgId) {
43
// Checks if the parent of the given particle has a specific absolute PDG ID.
44
return
p->parent(0) && p->parent(0)->absPdgId() == absPdgId;
45
}
46
47
bool
hasParticleIdenticalParent
(
const
xAOD::TruthParticle
* p) {
48
// Checks if particle and any of ity parents are identical.
49
bool
skipit(
false
);
50
for
(
size_t
i = 0; i < p->nParents(); i++) {
51
const
xAOD::TruthParticle
* parent = p->parent(i);
52
if
(parent && parent->pdgId() == p->pdgId()) {
53
skipit =
true
;
54
break
;
55
}
// if
56
}
// for
57
return
skipit;
58
}
59
60
bool
isChildOf
(
const
xAOD::TruthParticle
* parent,
61
const
xAOD::TruthParticle
* child) {
62
// Checks if child is child of parent.
63
if
(!(parent && child))
64
return
false
;
65
if
(parent->uid() == child->
uid
()) {
66
return
true
;
67
}
68
// Loop through all children of the parent
69
for
(
size_t
i = 0; i < parent->nChildren(); ++i) {
70
// Recursively check if child is a child of the current child
71
if
(
isChildOf
(parent->child(i), child)) {
72
return
true
;
73
}
74
}
75
// If child is not found in the children or their descendants, return
76
// false
77
return
false
;
78
}
79
83
84
bool
isAfterFSR
(
const
xAOD::TruthParticle
* p) {
85
bool
isAfter =
true
;
86
for
(
size_t
j = 0; j < p->nChildren(); j++) {
87
if
(p->child(j) && p->child(j)->pdgId() == p->pdgId())
88
isAfter =
false
;
89
}
90
return
isAfter;
91
}
92
93
const
xAOD::TruthParticle
*
findAfterFSR
(
const
xAOD::TruthParticle
* p) {
94
bool
isAfter(
false
);
95
const
int
pdgId = p->pdgId();
96
int
i = 0;
97
while
(!isAfter) {
98
i = 0;
99
for
(
size_t
j = 0; j < p->nChildren(); j++) {
100
const
xAOD::TruthParticle
* tmp_children = p->child(j);
101
if
(tmp_children && tmp_children->
pdgId
() == pdgId) {
102
p = p->child(j);
103
i++;
104
break
;
105
}
// if
106
}
// for
107
if
(i == 0)
108
isAfter =
true
;
109
}
// while
110
return
p;
111
}
112
116
117
bool
isBrokenTop
(
const
xAOD::TruthParticle
* p) {
118
// check if particle is a top without children.
119
return
(p->pdgId() == 6 && p->nChildren() == 0);
120
}
121
122
std::string
getretrievalstring
(
const
std::string& parent,
123
const
std::string& suffix,
124
const
std::string& postfix) {
125
std::string baseprefix =
"MC_"
;
126
return
baseprefix + (parent.empty() ?
""
: parent +
"_"
) + suffix + postfix;
127
}
128
129
bool
isQuarkFromPDF
(
const
xAOD::TruthParticle
* particle) {
130
// In principle we could use some status codes here, e.g. 31/41/42/53/61 for
131
// Pythia 8. But that is not guaranteed to be compatible across generators,
132
// so instead we just check if it's a massless quark.
133
bool
isQuark
= 1 <= particle->absPdgId() && particle->absPdgId() <= 5;
134
bool
isMassless = particle->m() == 0;
135
return
isQuark
&& isMassless;
136
}
137
138
139
}
// namespace PartonHistoryUtils
140
}
// namespace CP
isQuark
bool isQuark(const T &p)
PDG rule 2: Quarks and leptons are numbered consecutively starting from 1 and 11 respectively; to do ...
Definition
AtlasPID.h:173
PartonHistoryUtils.h
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
xAOD::TruthParticle_v1::uid
int uid() const
Unique ID.
CP::PartonHistoryUtils
Definition
PartonHistoryUtils.h:16
CP::PartonHistoryUtils::hasIdenticalChild
bool hasIdenticalChild(const xAOD::TruthParticle *particle)
Definition
PartonHistoryUtils.cxx:31
CP::PartonHistoryUtils::hasParticleIdenticalParent
bool hasParticleIdenticalParent(const xAOD::TruthParticle *particle)
Return true when particle is a top before FSR.
Definition
PartonHistoryUtils.cxx:47
CP::PartonHistoryUtils::isQuarkFromPDF
bool isQuarkFromPDF(const xAOD::TruthParticle *particle)
Definition
PartonHistoryUtils.cxx:129
CP::PartonHistoryUtils::hasParentPdgId
bool hasParentPdgId(const xAOD::TruthParticle *particle, int PdgId)
Definition
PartonHistoryUtils.cxx:17
CP::PartonHistoryUtils::findAfterFSR
const xAOD::TruthParticle * findAfterFSR(const xAOD::TruthParticle *particle)
Return particle after FSR (before the decay vertex).
Definition
PartonHistoryUtils.cxx:93
CP::PartonHistoryUtils::isChildOf
bool isChildOf(const xAOD::TruthParticle *parent, const xAOD::TruthParticle *potentialChild)
Definition
PartonHistoryUtils.cxx:60
CP::PartonHistoryUtils::isAfterFSR
bool isAfterFSR(const xAOD::TruthParticle *particle)
Determine whether particle is afterFSR.
Definition
PartonHistoryUtils.cxx:84
CP::PartonHistoryUtils::getretrievalstring
std::string getretrievalstring(const std::string &parent, const std::string &suffix, const std::string &postfix)
Definition
PartonHistoryUtils.cxx:122
CP::PartonHistoryUtils::isBrokenTop
bool isBrokenTop(const xAOD::TruthParticle *particle)
Looking for tops without children -> must be broken.
Definition
PartonHistoryUtils.cxx:117
CP::PartonHistoryUtils::hasParentAbsPdgId
bool hasParentAbsPdgId(const xAOD::TruthParticle *particle, int absPdgId)
Definition
PartonHistoryUtils.cxx:42
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
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