ATLAS Offline Software
Loading...
Searching...
No Matches
CP::PartonHistoryUtils Namespace Reference

Functions

const xAOD::TruthParticlefindAfterFSR (const xAOD::TruthParticle *particle)
 Return particle after FSR (before the decay vertex).
bool isChildOf (const xAOD::TruthParticle *parent, const xAOD::TruthParticle *potentialChild)
bool isBrokenTop (const xAOD::TruthParticle *particle)
 Looking for tops without children -> must be broken.
bool isAfterFSR (const xAOD::TruthParticle *particle)
 Determine whether particle is afterFSR.
bool hasParticleIdenticalParent (const xAOD::TruthParticle *particle)
 Return true when particle is a top before FSR.
bool hasParentPdgId (const xAOD::TruthParticle *particle, int PdgId)
bool hasParentPdgId (const xAOD::TruthParticle *particle)
bool hasParentAbsPdgId (const xAOD::TruthParticle *particle, int absPdgId)
bool hasIdenticalChild (const xAOD::TruthParticle *particle)
bool isQuarkFromPDF (const xAOD::TruthParticle *particle)
std::string getretrievalstring (const std::string &parent, const std::string &suffix, const std::string &postfix)

Function Documentation

◆ findAfterFSR()

const xAOD::TruthParticle * CP::PartonHistoryUtils::findAfterFSR ( const xAOD::TruthParticle * particle)

Return particle after FSR (before the decay vertex).

Definition at line 93 of file PartonHistoryUtils.cxx.

93 {
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}
int pdgId() const
PDG ID code.
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ getretrievalstring()

std::string CP::PartonHistoryUtils::getretrievalstring ( const std::string & parent,
const std::string & suffix,
const std::string & postfix )

Definition at line 122 of file PartonHistoryUtils.cxx.

124 {
125 std::string baseprefix = "MC_";
126 return baseprefix + (parent.empty() ? "" : parent + "_") + suffix + postfix;
127}

◆ hasIdenticalChild()

bool CP::PartonHistoryUtils::hasIdenticalChild ( const xAOD::TruthParticle * particle)

Definition at line 31 of file PartonHistoryUtils.cxx.

31 {
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}

◆ hasParentAbsPdgId()

bool CP::PartonHistoryUtils::hasParentAbsPdgId ( const xAOD::TruthParticle * particle,
int absPdgId )

Definition at line 42 of file PartonHistoryUtils.cxx.

42 {
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}

◆ hasParentPdgId() [1/2]

bool CP::PartonHistoryUtils::hasParentPdgId ( const xAOD::TruthParticle * particle)

Definition at line 26 of file PartonHistoryUtils.cxx.

26 {
27 // Checks if the parent of the given particle has a specific PDG ID.
28 return hasParentPdgId(p, p->pdgId());
29}
bool hasParentPdgId(const xAOD::TruthParticle *particle, int PdgId)

◆ hasParentPdgId() [2/2]

bool CP::PartonHistoryUtils::hasParentPdgId ( const xAOD::TruthParticle * particle,
int PdgId )

Definition at line 17 of file PartonHistoryUtils.cxx.

17 {
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}

◆ hasParticleIdenticalParent()

bool CP::PartonHistoryUtils::hasParticleIdenticalParent ( const xAOD::TruthParticle * particle)

Return true when particle is a top before FSR.

Definition at line 47 of file PartonHistoryUtils.cxx.

47 {
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}

◆ isAfterFSR()

bool CP::PartonHistoryUtils::isAfterFSR ( const xAOD::TruthParticle * particle)

Determine whether particle is afterFSR.

Definition at line 84 of file PartonHistoryUtils.cxx.

84 {
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}

◆ isBrokenTop()

bool CP::PartonHistoryUtils::isBrokenTop ( const xAOD::TruthParticle * particle)

Looking for tops without children -> must be broken.

Definition at line 117 of file PartonHistoryUtils.cxx.

117 {
118 // check if particle is a top without children.
119 return (p->pdgId() == 6 && p->nChildren() == 0);
120}

◆ isChildOf()

bool CP::PartonHistoryUtils::isChildOf ( const xAOD::TruthParticle * parent,
const xAOD::TruthParticle * potentialChild )

Definition at line 60 of file PartonHistoryUtils.cxx.

61 {
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}
bool isChildOf(const xAOD::TruthParticle *parent, const xAOD::TruthParticle *potentialChild)

◆ isQuarkFromPDF()

bool CP::PartonHistoryUtils::isQuarkFromPDF ( const xAOD::TruthParticle * particle)

Definition at line 129 of file PartonHistoryUtils.cxx.

129 {
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}
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:167