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 97 of file PartonHistoryUtils.cxx.

97 {
98 bool isAfter(false);
99 const int pdgId = p->pdgId();
100 int i = 0;
101 while (!isAfter) {
102 i = 0;
103 for (size_t j = 0; j < p->nChildren(); j++) {
104 const xAOD::TruthParticle* tmp_children = p->child(j);
105 if (tmp_children && tmp_children->pdgId() == pdgId) {
106 p = p->child(j);
107 i++;
108 break;
109 } // if
110 } // for
111 if (i == 0)
112 isAfter = true;
113 } // while
114 return p;
115}
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 126 of file PartonHistoryUtils.cxx.

128 {
129 std::string baseprefix = "MC_";
130 return baseprefix + (parent.empty() ? "" : parent + "_") + suffix + postfix;
131}

◆ hasIdenticalChild()

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

Definition at line 35 of file PartonHistoryUtils.cxx.

35 {
36 // Checks if the given particle has at least one child with an identical PDG
37 // ID.
38 bool check = false;
39 for (size_t i = 0; i < p->nChildren(); i++) {
40 if (p->child(i) && p->child(i)->pdgId() == p->pdgId())
41 check = true;
42 }
43 return check;
44}

◆ hasParentAbsPdgId()

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

Definition at line 46 of file PartonHistoryUtils.cxx.

46 {
47 // Checks if the parent of the given particle has a specific absolute PDG ID.
48 return p->parent(0) && p->parent(0)->absPdgId() == absPdgId;
49}

◆ hasParentPdgId() [1/2]

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

Definition at line 30 of file PartonHistoryUtils.cxx.

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

◆ hasParentPdgId() [2/2]

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

Definition at line 21 of file PartonHistoryUtils.cxx.

21 {
22 // Checks if the particle or its parent are nullptr.
23 if (!p || !p->parent(0)) {
24 return false;
25 }
26 // Checks if the parent of the given particle has a specific PDG ID.
27 return p->parent(0)->pdgId() == pdgId;
28}

◆ hasParticleIdenticalParent()

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

Return true when particle is a top before FSR.

Definition at line 51 of file PartonHistoryUtils.cxx.

51 {
52 // Checks if particle and any of ity parents are identical.
53 bool skipit(false);
54 for (size_t i = 0; i < p->nParents(); i++) {
55 const xAOD::TruthParticle* parent = p->parent(i);
56 if (parent && parent->pdgId() == p->pdgId()) {
57 skipit = true;
58 break;
59 } // if
60 } // for
61 return skipit;
62}

◆ isAfterFSR()

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

Determine whether particle is afterFSR.

Definition at line 88 of file PartonHistoryUtils.cxx.

88 {
89 bool isAfter = true;
90 for (size_t j = 0; j < p->nChildren(); j++) {
91 if (p->child(j) && p->child(j)->pdgId() == p->pdgId())
92 isAfter = false;
93 }
94 return isAfter;
95}

◆ isBrokenTop()

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

Looking for tops without children -> must be broken.

Definition at line 121 of file PartonHistoryUtils.cxx.

121 {
122 // check if particle is a top without children.
123 return (p->pdgId() == 6 && p->nChildren() == 0);
124}

◆ isChildOf()

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

Definition at line 64 of file PartonHistoryUtils.cxx.

65 {
66 // Checks if child is child of parent.
67 if (!(parent && child))
68 return false;
69 if (parent->uid() == child->uid()) {
70 return true;
71 }
72 // Loop through all children of the parent
73 for (size_t i = 0; i < parent->nChildren(); ++i) {
74 // Recursively check if child is a child of the current child
75 if (isChildOf(parent->child(i), child)) {
76 return true;
77 }
78 }
79 // If child is not found in the children or their descendants, return
80 // false
81 return false;
82}
bool isChildOf(const xAOD::TruthParticle *parent, const xAOD::TruthParticle *potentialChild)

◆ isQuarkFromPDF()

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

Definition at line 133 of file PartonHistoryUtils.cxx.

133 {
134 // In principle we could use some status codes here, e.g. 31/41/42/53/61 for
135 // Pythia 8. But that is not guaranteed to be compatible across generators,
136 // so instead we just check if it's a massless quark.
137 bool isQuark = 1 <= particle->absPdgId() && particle->absPdgId() <= 5;
138 bool isMassless = particle->m() == 0;
139 return isQuark && isMassless;
140}
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