ATLAS Offline Software
Namespaces | Classes | Functions
MC Namespace Reference

Namespaces

 Pythia8
 

Classes

class  Loops
 

Functions

template<class T >
bool isInteracting (const T &p)
 Identify if the particle with given PDG ID would not interact with the detector, i.e. not a neutrino or WIMP. More...
 
template<class T >
bool isChargedNonShowering (const T &p)
 Identify if the particle with given PDG ID would produce ID tracks but not shower in the detector if stable. More...
 
template<class T >
bool isBeam (const T &p)
 Identify if the particle is beam particle. More...
 
template<class T >
bool isDecayed (const T &p)
 Identify if the particle decayed. More...
 
template<class T >
bool isStable (const T &p)
 Identify if the particle is stable, i.e. has not decayed. More...
 
template<class T >
bool isFinalState (const T &p)
 Identify if the particle is final state particle. More...
 
template<class T >
bool isPhysical (const T &p)
 Identify if the particle is physical, i.e. is stable or decayed. More...
 
template<class T >
bool isGenStable (const T &p)
 Determine if the particle is stable at the generator (not det-sim) level,. More...
 
template<class T >
bool isSimStable (const T &p)
 Identify if the particle is considered stable at the post-detector-sim stage. More...
 
template<class T >
bool isSimInteracting (const T &p)
 Identify if the particle could interact with the detector during the simulation, e.g. not a neutrino or WIMP. More...
 
template<class T >
bool isStableOrSimDecayed (const T &p)
 Identify if particle is satble or decayed in simulation. More...
 
template<class T >
bool isZeroEnergyPhoton (const T &p)
 Identify a photon with zero energy. Probably a workaround for a generator bug. More...
 
template<class T >
bool isSingleParticle (const T &p)
 Identify a particlegun particle. More...
 
template<class T >
bool isSpecialNonInteracting (const T &p)
 Identify a special non-interacting particles. More...
 
template<class T >
findMother (T thePart)
 Function to get a mother of particle. MCTruthClassifier legacy. More...
 
template<class C , class T >
findMatching (C TruthContainer, T p)
 Function to find a particle in container. More...
 
template<class T >
void findParticleAncestors (T thePart, std::set< T > &allancestors)
 Function to find all ancestors of the particle. More...
 
template<class T >
void findParticleStableDescendants (T thePart, std::set< T > &allstabledescendants)
 Function to get the particle stable MC daughters. More...
 
template<class T >
bool isHardScatteringVertex (T pVert)
 Function to classify the vertex as hard scattering vertex. More...
 
template<class T >
bool isFromHadron (T p, T hadron, bool &fromTau, bool &fromBSM)
 Function to classify the particle. More...
 
template<class T >
auto findSimulatedEndVertex (T thePart) -> decltype(thePart->end_vertex())
 Function to find the end vertex of a particle. More...
 
template<class V >
auto findFinalStateParticles (V theVert) -> decltype(theVert->particles_out())
 Function to find the stable particle descendants of the given vertex.. More...
 

Function Documentation

◆ findFinalStateParticles()

template<class V >
auto MC::findFinalStateParticles ( theVert) -> decltype(theVert->particles_out())

Function to find the stable particle descendants of the given vertex..

This can be used for HepMC3::GenVertexPtr, HepMC3::ConstGenVertexPtr or xAOD::TruthVertex* and particle counterparts

Definition at line 263 of file HepMCHelpers.h.

263  {
264  if (!theVert) return {};
265  decltype(theVert->particles_out()) finalStatePart;
266  auto outgoing = theVert->particles_out();
267  for (const auto& thePart: outgoing) {
268  if (!thePart) continue;
269  finalStatePart.push_back(thePart);
270  if (isStable(thePart)) continue;
271  V pVert = findSimulatedEndVertex(thePart);
272  if (pVert == theVert) break; // to prevent Sherpa loop
273  if (pVert != nullptr) {
274  auto vecPart = findFinalStateParticles<V>(pVert);
275  finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
276  }
277  }
278  return finalStatePart;
279  }

◆ findMatching()

template<class C , class T >
T MC::findMatching ( TruthContainer,
p 
)

Function to find a particle in container.

This can be used for HepMC3::GenVertexPtr, HepMC3::ConstGenVertexPtr or xAOD::TruthVertex*

Definition at line 133 of file HepMCHelpers.h.

133  {
134  T ptrPart = nullptr;
135  if (!p) return ptrPart;
136  if constexpr (std::is_pointer_v<C> || HepMC::is_smart_ptr_v<C>){ //C is ptr
137  for (T truthParticle : *TruthContainer) {
138  if (HepMC::is_sim_descendant(p,truthParticle)) {
139  ptrPart = truthParticle;
140  break;
141  }
142  }
143  }
144  else {
145  for (T truthParticle : TruthContainer) {
146  if (HepMC::is_sim_descendant(p,truthParticle)) {
147  ptrPart = truthParticle;
148  break;
149  }
150  }
151  }
152  return ptrPart;
153  }

◆ findMother()

template<class T >
T MC::findMother ( thePart)

Function to get a mother of particle. MCTruthClassifier legacy.

This can be used for HepMC3::GenVertexPtr, HepMC3::ConstGenVertexPtr or xAOD::TruthVertex*

Definition at line 100 of file HepMCHelpers.h.

100  {
101  auto partOriVert = thePart->production_vertex();
102  if (!partOriVert) return nullptr;
103 
104  long partPDG = thePart->pdg_id();
105  long MotherPDG(0);
106 
107  auto MothOriVert = partOriVert;
108  MothOriVert = nullptr;
109  T theMoth(nullptr);
110 
111  size_t itr = 0;
112  do {
113  if (itr != 0) partOriVert = MothOriVert;
114  auto incoming = partOriVert->particles_in();
115  for ( auto p: incoming) {
116  theMoth = p;
117  if (!theMoth) continue;
118  MotherPDG = theMoth->pdg_id();
119  MothOriVert = theMoth->production_vertex();
120  if (MotherPDG == partPDG) break;
121  }
122  itr++;
123  if (itr > 100) {
124  break;
125  }
126  } while (MothOriVert != nullptr && MotherPDG == partPDG && !HepMC::is_simulation_particle(thePart) &&
127  MothOriVert != partOriVert);
128  return theMoth;
129  }

◆ findParticleAncestors()

template<class T >
void MC::findParticleAncestors ( thePart,
std::set< T > &  allancestors 
)

Function to find all ancestors of the particle.

This can be used for HepMC3::GenParticlePtr, HepMC3::ConstGenParticlePtr or xAOD::TruthParticle*

Definition at line 156 of file HepMCHelpers.h.

156  {
157  auto prodVtx = thePart->production_vertex();
158  if (!prodVtx) return;
159  for (auto theMother: prodVtx->particles_in()) {
160  if (!theMother) continue;
161  allancestors.insert(theMother);
162  findParticleAncestors(theMother, allancestors);
163  }
164  }

◆ findParticleStableDescendants()

template<class T >
void MC::findParticleStableDescendants ( thePart,
std::set< T > &  allstabledescendants 
)

Function to get the particle stable MC daughters.

This can be used for HepMC3::GenParticlePtr, HepMC3::ConstGenParticlePtr or xAOD::TruthParticle*

Definition at line 168 of file HepMCHelpers.h.

168  {
169  auto endVtx = thePart->end_vertex();
170  if (!endVtx) return;
171  for (auto theDaughter: endVtx->particles_out()) {
172  if (!theDaughter) continue;
173  if (isStable(theDaughter) && !HepMC::is_simulation_particle(theDaughter)) {
174  allstabledescendants.insert(theDaughter);
175  }
176  findParticleStableDescendants(theDaughter, allstabledescendants);
177  }
178  }

◆ findSimulatedEndVertex()

template<class T >
auto MC::findSimulatedEndVertex ( thePart) -> decltype(thePart->end_vertex())

Function to find the end vertex of a particle.

This algorithm allows for 1->1 decays.
This can be used for HepMC3::GenVertexPtr, HepMC3::ConstGenVertexPtr or xAOD::TruthVertex* and particle counterparts

Definition at line 235 of file HepMCHelpers.h.

235  {
236  decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
237  decltype(thePart->end_vertex()) pVert(nullptr);
238  if (EndVert != nullptr) {
239  do {
240  bool samePart = false;
241  pVert = nullptr;
242  auto outgoing = EndVert->particles_out();
243  auto incoming = EndVert->particles_in();
244  for (const auto& itrDaug: outgoing) {
245  if (!itrDaug) continue;
246  if ((( HepMC::is_same_generator_particle(itrDaug,thePart)) ||
247  // brem on generator level for tau
248  (outgoing.size() == 1 && incoming.size() == 1 &&
250  itrDaug->pdg_id() == thePart->pdg_id()) {
251  samePart = true;
252  pVert = itrDaug->end_vertex();
253  }
254  }
255  if (samePart) EndVert = pVert;
256  } while (pVert != nullptr && pVert != EndVert); // pVert!=EndVert to prevent Sherpa loop
257  }
258  return EndVert;
259  }

◆ isBeam()

template<class T >
bool MC::isBeam ( const T &  p)
inline

Identify if the particle is beam particle.

Definition at line 39 of file HepMCHelpers.h.

◆ isChargedNonShowering()

template<class T >
bool MC::isChargedNonShowering ( const T &  p)
inline

Identify if the particle with given PDG ID would produce ID tracks but not shower in the detector if stable.

Definition at line 36 of file HepMCHelpers.h.

36 { return (isMuon<T>(p) || isSUSY<T>(p)); }

◆ isDecayed()

template<class T >
bool MC::isDecayed ( const T &  p)
inline

Identify if the particle decayed.

Definition at line 42 of file HepMCHelpers.h.

◆ isFinalState()

template<class T >
bool MC::isFinalState ( const T &  p)
inline

Identify if the particle is final state particle.

Definition at line 48 of file HepMCHelpers.h.

48 { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1 && !p->end_vertex();}

◆ isFromHadron()

template<class T >
bool MC::isFromHadron ( p,
hadron,
bool &  fromTau,
bool &  fromBSM 
)

Function to classify the particle.

AV: This is MCtruthClassifier legacy. The function should be improved in the future. This can be used for HepMC3::GenVertexPtr, HepMC3::ConstGenVertexPtr or xAOD::TruthVertex*

Definition at line 210 of file HepMCHelpers.h.

210  {
211  if (isHadron(p)&&!isBeam(p)) return true; // trivial case
212  auto vtx = p->production_vertex();
213  if (!vtx) return false;
214  bool fromHad = false;
215  auto incoming = vtx->particles_in();
216  for (auto parent: incoming) {
217  if (!parent) continue;
218  // should this really go into parton-level territory?
219  // probably depends where BSM particles are being decayed
220  fromBSM |= isBSM(parent);
221  if (!isPhysical(parent)) return false;
222  fromTau |= isTau(parent);
223  if (isHadron(parent)&&!isBeam(parent)) {
224  if (!hadron) hadron = parent; // assumes linear hadron parentage
225  return true;
226  }
227  fromHad |= isFromHadron(parent, hadron, fromTau, fromBSM);
228  }
229  return fromHad;
230  }

◆ isGenStable()

template<class T >
bool MC::isGenStable ( const T &  p)
inline

Determine if the particle is stable at the generator (not det-sim) level,.

Definition at line 54 of file HepMCHelpers.h.

54 { return isStable<T>(p) && !HepMC::is_simulation_particle<T>(p);}

◆ isHardScatteringVertex()

template<class T >
bool MC::isHardScatteringVertex ( pVert)

Function to classify the vertex as hard scattering vertex.

AV: This is MCtruthClassifier legacy. Note that this function willnot capture some cases of the HardScattering vertices. The function should be improved in the future. This can be used for HepMC3::GenVertexPtr, HepMC3::ConstGenVertexPtr or xAOD::TruthVertex*

Definition at line 184 of file HepMCHelpers.h.

184  {
185  if (pVert == nullptr) return false;
186  T pV = pVert;
187  int numOfPartIn(0);
188  int pdg(0);
189 
190  do {
191  pVert = pV;
192  auto incoming = pVert->particles_in();
193  numOfPartIn = incoming.size();
194  pdg = numOfPartIn && incoming.front() != nullptr ? incoming.front()->pdg_id() : 0;
195  pV = numOfPartIn && incoming.front() != nullptr ? incoming.front()->production_vertex() : nullptr;
196 
197  } while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV != nullptr);
198 
199  if (numOfPartIn == 2) {
200  auto incoming = pVert->particles_in();
201  if (incoming.at(0) && incoming.at(1) && (std::abs(incoming.at(0)->pdg_id()) < 7 || incoming.at(0)->pdg_id() == 21) && (std::abs(incoming.at(1)->pdg_id()) < 7 || incoming.at(1)->pdg_id() == 21)) return true;
202  }
203  return false;
204 }

◆ isInteracting()

template<class T >
bool MC::isInteracting ( const T &  p)
inline

Identify if the particle with given PDG ID would not interact with the detector, i.e. not a neutrino or WIMP.

Definition at line 33 of file HepMCHelpers.h.

33 { return isStrongInteracting<T>(p) || isEMInteracting<T>(p) || isGeantino<T>(p); }

◆ isPhysical()

template<class T >
bool MC::isPhysical ( const T &  p)
inline

Identify if the particle is physical, i.e. is stable or decayed.

Definition at line 51 of file HepMCHelpers.h.

51 { return isStable<T>(p) || isDecayed<T>(p); }

◆ isSimInteracting()

template<class T >
bool MC::isSimInteracting ( const T &  p)
inline

Identify if the particle could interact with the detector during the simulation, e.g. not a neutrino or WIMP.

Definition at line 60 of file HepMCHelpers.h.

60 { return isGenStable<T>(p) && isInteracting<T>(p);}

◆ isSimStable()

template<class T >
bool MC::isSimStable ( const T &  p)
inline

Identify if the particle is considered stable at the post-detector-sim stage.

Definition at line 57 of file HepMCHelpers.h.

57 { return isStable<T>(p) && !p->end_vertex() && HepMC::is_simulation_particle<T>(p);}

◆ isSingleParticle()

template<class T >
bool MC::isSingleParticle ( const T &  p)
inline

Identify a particlegun particle.

Definition at line 74 of file HepMCHelpers.h.

74  {
75  if constexpr (std::is_same_v<std::remove_const_t<HepMC::remove_smart_pointer_t<std::remove_pointer_t<T>>>, xAOD::TruthParticle_v1>) {
76  return HepMC::uniqueID(p) == 3 // Post migration format
77  || HepMC::uniqueID(p) == 10001; // pre-migration file read in so barcode copied to id for xAOD::Truth
78  }
79  else {
80 #if defined(HEPMC3)
81  return HepMC::uniqueID(p) == 3 || HepMC::barcode(p) == 10001;
82 #else
83  return HepMC::barcode(p) == 10001;
84 #endif
85  }
86  }

◆ isSpecialNonInteracting()

template<class T >
bool MC::isSpecialNonInteracting ( const T &  p)
inline

Identify a special non-interacting particles.

Definition at line 89 of file HepMCHelpers.h.

89  {
90  const int apid = std::abs(p->pdg_id());
91  if (apid == NU_E || apid == NU_MU || apid == NU_TAU) return true; //< neutrinos
92  if (apid == 1000022 || apid == 1000024 || apid == 5100022) return true; // SUSY & KK photon and Z partners
93  if (apid == GRAVITON || apid == 1000039 || apid == 5000039) return true; //< gravitons: standard, SUSY and KK
94  if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006) return true; //< exotic particles from monotop model
95  return false;
96  }

◆ isStable()

template<class T >
bool MC::isStable ( const T &  p)
inline

Identify if the particle is stable, i.e. has not decayed.

Definition at line 45 of file HepMCHelpers.h.

◆ isStableOrSimDecayed()

template<class T >
bool MC::isStableOrSimDecayed ( const T &  p)
inline

Identify if particle is satble or decayed in simulation.

  • a pathological case of decayed particle w/o end vertex. The decayed particles w/o end vertex might occur in case of simulation of long lived particles in Geant stripped off the decay products. I.e. those particles should be re-decayed later.

Definition at line 65 of file HepMCHelpers.h.

65  {
66  const auto vertex = p->end_vertex();
67  return ( isStable<T>(p) || (isDecayed<T>(p) && (!vertex || HepMC::is_simulation_vertex(vertex))));
68  }

◆ isZeroEnergyPhoton()

template<class T >
bool MC::isZeroEnergyPhoton ( const T &  p)
inline

Identify a photon with zero energy. Probably a workaround for a generator bug.

Definition at line 71 of file HepMCHelpers.h.

71 { return isPhoton<T>(p) && p->e() == 0;}
MC::isFromHadron
bool isFromHadron(T p, T hadron, bool &fromTau, bool &fromBSM)
Function to classify the particle.
Definition: HepMCHelpers.h:210
MCTruthPartClassifier::hadron
@ hadron
Definition: TruthClassifiers.h:148
MC::findParticleAncestors
void findParticleAncestors(T thePart, std::set< T > &allancestors)
Function to find all ancestors of the particle.
Definition: HepMCHelpers.h:156
isBSM
bool isBSM(const T &p)
APID: graviton and all Higgs extensions are BSM.
Definition: AtlasPID.h:836
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
MC::isPhysical
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
Definition: HepMCHelpers.h:51
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
HepMC::is_same_generator_particle
bool is_same_generator_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same generated particle.
Definition: MagicNumbers.h:363
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition: MagicNumbers.h:354
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:116
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MC::findParticleStableDescendants
void findParticleStableDescendants(T thePart, std::set< T > &allstabledescendants)
Function to get the particle stable MC daughters.
Definition: HepMCHelpers.h:168
HepMC::is_simulation_vertex
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
Definition: MagicNumbers.h:360
isTau
bool isTau(const T &p)
Definition: AtlasPID.h:205
HepMC::SIM_STATUS_THRESHOLD
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
Definition: MagicNumbers.h:46
isHadron
bool isHadron(const T &p)
Definition: AtlasPID.h:348
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition: HepMCHelpers.h:45
MC::isBeam
bool isBeam(const T &p)
Identify if the particle is beam particle.
Definition: HepMCHelpers.h:39
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
HepMC::remove_smart_pointer_t
typename remove_smart_pointer< T >::type remove_smart_pointer_t
Definition: MagicNumbers.h:73
HepMC::is_sim_descendant
bool is_sim_descendant(const T1 &p1, const T2 &p2)
Method to check if the first particle is a descendant of the second in the simulation,...
Definition: MagicNumbers.h:372
HepMC::status
int status(const T &p)
Definition: MagicNumbers.h:143
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
MC::findSimulatedEndVertex
auto findSimulatedEndVertex(T thePart) -> decltype(thePart->end_vertex())
Function to find the end vertex of a particle.
Definition: HepMCHelpers.h:235