ATLAS Offline Software
Namespaces | Functions
FlavorTagDiscriminants::TruthDecoratorHelpers Namespace Reference

Namespaces

 TruthSource
 
 TruthType
 

Functions

bool sort_particles (const xAOD::IParticle *particle_A, const xAOD::IParticle *particle_B)
 
int get_truth_type (const xAOD::TruthParticle *truth_particle)
 
int get_source_type (const int origin)
 
bool is_bc_hadron (const xAOD::TruthParticle *truth_particle, int flavour)
 
bool is_weakly_decaying_hadron (const xAOD::TruthParticle *truth_particle)
 
bool is_weakly_decaying_hadron (const xAOD::TruthParticle *truth_particle, int flavour)
 
const xAOD::TruthParticleget_parent_hadron (const xAOD::TruthParticle *truth_particle, bool user_called=true, int depth=0)
 
const xAOD::TruthVertexget_truth_vertex (const xAOD::TruthParticle *truth)
 
float get_distance (const xAOD::TruthVertex *vertex_A, const xAOD::TruthVertex *vertex_B)
 
int get_vertex_index (const xAOD::TruthVertex *vertex, const xAOD::TruthVertex *truth_PV, std::vector< const xAOD::TruthVertex * > &seen_vertices, const float truthVertexMergeDistance)
 

Function Documentation

◆ get_distance()

float FlavorTagDiscriminants::TruthDecoratorHelpers::get_distance ( const xAOD::TruthVertex vertex_A,
const xAOD::TruthVertex vertex_B 
)

Definition at line 29 of file TruthDecoratorHelpers.cxx.

29  {
30  if ( !vertex_A || !vertex_B ) { return 999.0; }
31  return (vertex_A->v4().Vect() - vertex_B->v4().Vect()).Mag();
32  }

◆ get_parent_hadron()

const xAOD::TruthParticle * FlavorTagDiscriminants::TruthDecoratorHelpers::get_parent_hadron ( const xAOD::TruthParticle truth_particle,
bool  user_called = true,
int  depth = 0 
)

Definition at line 54 of file TruthDecoratorHelpers.cxx.

54  {
55  // get the weakly decaying parent hadron of truth_particle
56  // check for sensible input
57  if ( truth_particle == nullptr ) { return nullptr; }
58  // loop protection
59  if (depth>30) { return nullptr; }
60  // if this is the weakly decaying hadron, stop here
61  if ( !user_called && is_weakly_decaying_hadron(truth_particle) ) {
62  return truth_particle;
63  }
64  for (unsigned int p = 0; p < truth_particle->nParents(); p++) {
65  const auto parent = truth_particle->parent(p);
66  if(parent == truth_particle) continue;// avoid infinite recursion
67  const auto parent_hadron = get_parent_hadron(parent, false, depth+1);
68  if ( parent_hadron != nullptr ) {
69  return parent_hadron;
70  }
71  }
72  return nullptr;
73  }

◆ get_source_type()

int FlavorTagDiscriminants::TruthDecoratorHelpers::get_source_type ( const int  origin)

Definition at line 88 of file TruthDecoratorHelpers.cxx.

88  {
89  /* this label gives information about the origin of secondary
90  particles (material interactions, gamme conversions, etc.)*/
91 
97  // For simulation tracks not included in the above categories
98  return TruthSource::Label::Other;
99  }

◆ get_truth_type()

int FlavorTagDiscriminants::TruthDecoratorHelpers::get_truth_type ( const xAOD::TruthParticle truth_particle)

Definition at line 75 of file TruthDecoratorHelpers.cxx.

75  {
76  if (!truth_particle) return TruthType::Label::NoTruth;
77  // simple pdgid check for pion based on
78  // PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifierGen.cxx#L1159
79  if (std::abs(truth_particle->pdgId()) == 211) return TruthType::Label::Pion * truth_particle->charge();
80  if (truth_particle->isStrangeMeson()) return TruthType::Label::Kaon * truth_particle->charge();
81  if (std::abs(truth_particle->pdgId()) == 3122) return TruthType::Label::Lambda;
82  if (truth_particle->isElectron()) return TruthType::Label::Electron * truth_particle->charge() * -1;
83  if (truth_particle->isMuon()) return TruthType::Label::Muon * truth_particle->charge() * -1;
84  if (truth_particle->isPhoton()) return TruthType::Label::Photon;
85  return TruthType::Label::Other;
86  }

◆ get_truth_vertex()

const xAOD::TruthVertex * FlavorTagDiscriminants::TruthDecoratorHelpers::get_truth_vertex ( const xAOD::TruthParticle truth)

Definition at line 16 of file TruthDecoratorHelpers.cxx.

16  {
17  // no truth
18  if ( not truth ) { return nullptr; }
19 
20  // no vertex
21  const xAOD::TruthVertex* truth_vertex = truth->prodVtx();
22  if ( not truth_vertex || truth_vertex->perp() > 440.0 ) {
23  return nullptr;
24  }
25 
26  return truth_vertex;
27  }

◆ get_vertex_index()

int FlavorTagDiscriminants::TruthDecoratorHelpers::get_vertex_index ( const xAOD::TruthVertex vertex,
const xAOD::TruthVertex truth_PV,
std::vector< const xAOD::TruthVertex * > &  seen_vertices,
const float  truthVertexMergeDistance 
)

Definition at line 101 of file TruthDecoratorHelpers.cxx.

104  {
105  // no vertex
106  if (!this_vertex) {
107  return -2;
108  }
109  // primary vertex
110  if (get_distance(this_vertex, truth_PV) < truthVertexMergeDistance) {
111  return 0;
112  }
113  // have we already seen this vertex?
114  for ( size_t i = 0; i != seen_vertices.size(); i++) {
115  float dr = get_distance(seen_vertices.at(i), this_vertex);
116  if ( dr < truthVertexMergeDistance ) {
117  // a vertex is nearby, reuse it
118  return i + 1;
119  }
120  }
121  seen_vertices.push_back(this_vertex);
122  return seen_vertices.size();
123  }

◆ is_bc_hadron()

bool FlavorTagDiscriminants::TruthDecoratorHelpers::is_bc_hadron ( const xAOD::TruthParticle truth_particle,
int  flavour 
)

Definition at line 34 of file TruthDecoratorHelpers.cxx.

34  {
35  if( truth_particle == nullptr ) { return false; }
36  if( flavour == 5 && truth_particle->isBottomHadron() ) { return true; }
37  if( flavour == 4 && truth_particle->isCharmHadron() ) { return true; }
38  return false;
39  }

◆ is_weakly_decaying_hadron() [1/2]

bool FlavorTagDiscriminants::TruthDecoratorHelpers::is_weakly_decaying_hadron ( const xAOD::TruthParticle truth_particle)

Definition at line 50 of file TruthDecoratorHelpers.cxx.

50  {
51  return is_weakly_decaying_hadron(truth_particle, 5) || is_weakly_decaying_hadron(truth_particle, 4);
52  }

◆ is_weakly_decaying_hadron() [2/2]

bool FlavorTagDiscriminants::TruthDecoratorHelpers::is_weakly_decaying_hadron ( const xAOD::TruthParticle truth_particle,
int  flavour 
)

Definition at line 41 of file TruthDecoratorHelpers.cxx.

41  {
42  if (!is_bc_hadron(truth_particle, flavour)) return false;
43  if (!truth_particle->hasDecayVtx() ) return false;
44  for ( const auto out_part: truth_particle->decayVtx()->particles_out()) {
45  if ( is_bc_hadron(out_part, flavour) ) return false;
46  }
47  return true;
48  }

◆ sort_particles()

bool FlavorTagDiscriminants::TruthDecoratorHelpers::sort_particles ( const xAOD::IParticle particle_A,
const xAOD::IParticle particle_B 
)

Definition at line 12 of file TruthDecoratorHelpers.cxx.

12  {
13  return particle_A->pt() < particle_B->pt();
14  }
xAOD::TruthParticle_v1::parent
const TruthParticle_v1 * parent(size_t i=0) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
Definition: TruthParticle_v1.cxx:131
FlavorTagDiscriminants::TruthDecoratorHelpers::is_bc_hadron
bool is_bc_hadron(const xAOD::TruthParticle *truth_particle, int flavour)
Definition: TruthDecoratorHelpers.cxx:34
egammaParameters::depth
@ depth
pointing depth of the shower as calculated in egammaqgcld
Definition: egammaParamDefs.h:276
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
xAOD::TruthParticle_v1::isElectron
bool isElectron() const
Whether the particle is an electron (or positron)
FlavorTagDiscriminants::TruthDecoratorHelpers::get_distance
float get_distance(const xAOD::TruthVertex *vertex_A, const xAOD::TruthVertex *vertex_B)
Definition: TruthDecoratorHelpers.cxx:29
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
InDet::TrkOrigin::isHadronicInteraction
bool isHadronicInteraction(int origin)
from hadronic interactions
Definition: InDetTrackTruthOriginDefs.h:92
xAOD::TruthParticle_v1::isCharmHadron
bool isCharmHadron() const
Determine if the PID is that of a c-hadron.
FlavorTagDiscriminants::TruthDecoratorHelpers::is_weakly_decaying_hadron
bool is_weakly_decaying_hadron(const xAOD::TruthParticle *truth_particle)
Definition: TruthDecoratorHelpers.cxx:50
InDet::TrkOrigin::isStrangeMesonDecay
bool isStrangeMesonDecay(int origin)
from strange meson decay
Definition: InDetTrackTruthOriginDefs.h:74
FlavorTagDiscriminants::TruthDecoratorHelpers::get_parent_hadron
const xAOD::TruthParticle * get_parent_hadron(const xAOD::TruthParticle *truth_particle, bool user_called=true, int depth=0)
Definition: TruthDecoratorHelpers.cxx:54
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthType::Kaon
@ Kaon
Definition: TruthDecoratorHelpers.h:20
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthSource::NotSecondary
@ NotSecondary
Definition: TruthDecoratorHelpers.h:30
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
xAOD::TruthVertex_v1::v4
FourVec_t v4() const
The full 4-vector of the vertex.
Definition: TruthVertex_v1.cxx:186
InDet::TrkOrigin::isGammaConversion
bool isGammaConversion(int origin)
from conversions
Definition: InDetTrackTruthOriginDefs.h:86
xAOD::TruthParticle_v1::hasDecayVtx
bool hasDecayVtx() const
Check for a decay vertex on this particle.
xAOD::TruthParticle_v1::nParents
size_t nParents() const
Number of parents of this particle.
Definition: TruthParticle_v1.cxx:122
lumiFormat.i
int i
Definition: lumiFormat.py:92
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthSource::StrangeMesonDecay
@ StrangeMesonDecay
Definition: TruthDecoratorHelpers.h:32
xAOD::TruthVertex_v1::perp
float perp() const
Vertex transverse distance from the beam line.
Definition: TruthVertex_v1.cxx:165
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::IParticle::pt
virtual double pt() const =0
The transverse momentum ( ) of the particle.
xAOD::TruthParticle_v1::decayVtx
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
xAOD::TruthParticle_v1::isBottomHadron
bool isBottomHadron() const
Determine if the PID is that of a b-hadron.
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthSource::HadronicInteraction
@ HadronicInteraction
Definition: TruthDecoratorHelpers.h:31
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:41
InDet::TrkOrigin::isSecondary
bool isSecondary(int origin)
from long living particle decays or gamma conversions or hadronic interactions and anything else with...
Definition: InDetTrackTruthOriginDefs.h:104
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthSource::GammaConversion
@ GammaConversion
Definition: TruthDecoratorHelpers.h:34
xAOD::TruthVertex_v1::particles_out
std::vector< const TruthParticle * > particles_out() const
Get the outgoing particles.
Definition: TruthVertex_v1.cxx:66
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
Muon
struct TBPatternUnitContext Muon
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthType::NoTruth
@ NoTruth
Definition: TruthDecoratorHelpers.h:17
InDet::TrkOrigin::isStrangeBaryonDecay
bool isStrangeBaryonDecay(int origin)
from strange baryon decay
Definition: InDetTrackTruthOriginDefs.h:80
xAOD::TruthParticle_v1::isPhoton
bool isPhoton() const
Whether the particle is a photon.
xAOD::TruthParticle_v1::isMuon
bool isMuon() const
Whether the particle is a muon (or antimuon)
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthSource::StrangeBaryonDecay
@ StrangeBaryonDecay
Definition: TruthDecoratorHelpers.h:33
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthType::Pion
@ Pion
Definition: TruthDecoratorHelpers.h:19
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthType::Lambda
@ Lambda
Definition: TruthDecoratorHelpers.h:21
xAOD::TruthParticle_v1::isStrangeMeson
bool isStrangeMeson() const
Determine if the PID is that of a strange meson.
xAOD::TruthParticle_v1::charge
double charge() const
Physical charge.