ATLAS Offline Software
Functions
xAOD::EgammaHelpers Namespace Reference

Functions

template<class T >
const T * getLink (const xAOD::IParticle *particle, std::string name)
 Access to element link to object of type T stored in auxdata. More...
 
const xAOD::ElectrongetRecoElectron (const xAOD::TruthParticle *)
 return the reco electron associated to the given TruthParticle (if any) More...
 
const xAOD::PhotongetRecoPhoton (const xAOD::TruthParticle *particle)
 return the reco photon associated to the given TruthParticle (if any) More...
 
bool isTrueConvertedPhoton (const xAOD::Photon *ph, float maxRadius=800.)
 is the object matched to a true converted photon with R < maxRadius More...
 
bool isTrueConvertedPhoton (const xAOD::TruthParticle *truePh, float maxRadius=800.)
 is the true object a converted photon with R < maxRadius More...
 
const xAOD::TruthParticlegetBkgElectronMother (const xAOD::Electron *el, const bool allTheWayBack=true)
 Helper wrapper function for calling the function below that accepts truth input. More...
 
const xAOD::TruthParticlegetBkgElectronMother (const xAOD::TruthParticle *truthel, const bool allTheWayBack=true)
 Helper function for getting the True "Mother" electron for an existing electron. More...
 
std::vector< const xAOD::TruthParticle * > getBkgElectronLineage (const xAOD::Electron *el, const bool allTheWayBack=true)
 Helper wrapper function for calling the function below that accepts truth input. More...
 
std::vector< const xAOD::TruthParticle * > getBkgElectronLineage (const xAOD::TruthParticle *truthel, const bool allTheWayBack=true)
 Helper function for getting the True Lineage of an electron for an existing electron. More...
 
bool isElectron (const xAOD::Egamma *eg)
 is the object an electron (not Fwd) More...
 
bool isFwdElectron (const xAOD::Egamma *eg)
 is the object a Fwd electron More...
 
bool isPhoton (const xAOD::Egamma *eg)
 is the object a photon More...
 
bool isConvertedPhoton (const xAOD::Egamma *eg)
 is the object a converted photon More...
 
bool isBarrel (const xAOD::Egamma *eg)
 return true if the cluster is in the barrel More...
 
bool isBarrel (const xAOD::CaloCluster *cluster)
 return true if the cluster (or the majority of its energy) is in the barrel More...
 
bool isFCAL (const xAOD::CaloCluster *cluster)
 return true if the cluster (or the majority of its energy) is in the FCAL0 More...
 
std::vector< ElementLink< xAOD::CaloClusterContainer > > getAssociatedTopoClustersLinks (const xAOD::CaloCluster *cluster)
 Return a vector of all the elementlinks to the topo clusters associated with the egamma cluster. More...
 
std::vector< const xAOD::CaloCluster * > getAssociatedTopoClusters (const xAOD::CaloCluster *cluster)
 Return a vector of all the topo clusters associated with the egamma cluster. More...
 
std::vector< ElementLink< xAOD::FlowElementContainer > > getAssociatedFlowElementsLinks (const xAOD::Egamma *eg, bool neutral=true)
 Return a vector of the elementlinks to the flow elements associated with the egamma cluster (neutral for default) More...
 
std::vector< const xAOD::FlowElement * > getAssociatedFlowElements (const xAOD::Egamma *eg, bool neutral=true, bool charged=false)
 Return a vector of the flow elements associated with the egamma cluster (only neutral for default) More...
 
std::set< const xAOD::TrackParticle * > getTrackParticles (const xAOD::Egamma *eg, bool useBremAssoc=true, bool allParticles=true)
 Return a list of all or only the best TrackParticle associated to the object. More...
 
std::vector< const xAOD::TrackParticle * > getTrackParticlesVec (const xAOD::Egamma *eg, bool useBremAssoc=true, bool allParticles=true)
 Return a list of all or only the best TrackParticle associated to the object. More...
 
int summaryValueInt (const xAOD::TrackParticle &tp, const xAOD::SummaryType &info, int deflt=-999)
 return the summary value for a TrackParticle or default value (-999) (to be used mostly in python where uint8_t is converted to char and the Tracking does not provide unprotected methods) More...
 
float summaryValueFloat (const xAOD::TrackParticle &tp, const xAOD::SummaryType &info, float deflt=-999.)
 return the summary value for a TrackParticle or default value (-999) More...
 
const xAOD::TrackParticlegetOriginalTrackParticle (const xAOD::Electron *el)
 Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron. More...
 
const xAOD::TrackParticlegetOriginalTrackParticleFromGSF (const xAOD::TrackParticle *trkPar)
 Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle. More...
 
float getLastMeasurementQoverP (const xAOD::TrackParticle *tp)
 return parameters for the last measurement for a GSF track particle More...
 
std::set< const xAOD::TrackParticle * > getTrackParticles (const xAOD::Electron *el, bool useBremAssoc=true, bool allParticles=true)
 Return a list of all or only the best TrackParticle associated to the object. More...
 
std::vector< const xAOD::TrackParticle * > getTrackParticlesVec (const xAOD::Electron *el, bool useBremAssoc=true, bool allParticles=true)
 Return a list of all or only the best TrackParticle associated to the object. More...
 
std::size_t numberOfSiHits (const xAOD::TrackParticle *tp)
 return the number of Si hits in the track particle More...
 
bool isConvertedPhoton (const xAOD::Photon *ph)
 is the object a converted photon More...
 
xAOD::EgammaParameters::ConversionType conversionType (const xAOD::Photon *ph)
 return the photon conversion type (see EgammaEnums) More...
 
xAOD::EgammaParameters::ConversionType conversionType (const xAOD::Vertex *vx)
 return the photon conversion type (see EgammaEnums) More...
 
std::size_t numberOfSiTracks (const xAOD::Photon *eg)
 return the number of Si tracks in the conversion More...
 
std::size_t numberOfSiTracks (const xAOD::Vertex *vx)
 return the number of Si tracks in the conversion More...
 
std::size_t numberOfSiTracks (const xAOD::EgammaParameters::ConversionType convType)
 return the number of Si tracks in the conversion More...
 
float conversionRadius (const xAOD::Vertex *vx)
 return the conversion radius or 9999. More...
 
float conversionRadius (const xAOD::Photon *ph)
 return the conversion radius or 9999. More...
 
Amg::Vector3D momentumAtVertex (const xAOD::Photon *, bool debug=false)
 return the momentum at the vertex (which can be 0) More...
 
Amg::Vector3D momentumAtVertex (const xAOD::Vertex &, bool debug=false)
 return the momentum at the vertex (which can be 0) More...
 
std::set< const xAOD::TrackParticle * > getTrackParticles (const xAOD::Photon *ph, bool useBremAssoc=true)
 Return a list of all or only the best TrackParticle associated to the object. More...
 
std::vector< const xAOD::TrackParticle * > getTrackParticlesVec (const xAOD::Photon *ph, bool useBremAssoc=true)
 Return a list of all or only the best TrackParticle associated to the object. More...
 

Function Documentation

◆ conversionRadius() [1/2]

float xAOD::EgammaHelpers::conversionRadius ( const xAOD::Photon ph)

return the conversion radius or 9999.

Definition at line 74 of file PhotonxAODHelpers.cxx.

74  {
75  if (!ph || !ph->vertex()) return 9999.;
76  return conversionRadius(ph->vertex());
77 }

◆ conversionRadius() [2/2]

float xAOD::EgammaHelpers::conversionRadius ( const xAOD::Vertex vx)

return the conversion radius or 9999.

Definition at line 69 of file PhotonxAODHelpers.cxx.

69  {
70  if (!vx) return 9999.;
71  return sqrt( vx->x()*vx->x() + vx->y()*vx->y() );
72 }

◆ conversionType() [1/2]

xAOD::EgammaParameters::ConversionType xAOD::EgammaHelpers::conversionType ( const xAOD::Photon ph)

return the photon conversion type (see EgammaEnums)

Definition at line 19 of file PhotonxAODHelpers.cxx.

19  {
21  return conversionType(ph->vertex());
22 }

◆ conversionType() [2/2]

xAOD::EgammaParameters::ConversionType xAOD::EgammaHelpers::conversionType ( const xAOD::Vertex vx)

return the photon conversion type (see EgammaEnums)

Definition at line 24 of file PhotonxAODHelpers.cxx.

24  {
26 
27  const TrackParticle *trk1 = ( vx->nTrackParticles() ? vx->trackParticle(0) : nullptr );
28  const TrackParticle *trk2 = ( vx->nTrackParticles() > 1 ? vx->trackParticle(1) : nullptr );
29  uint8_t nSiHits1 = numberOfSiHits(trk1);
30  uint8_t nSiHits2 = numberOfSiHits(trk2);
31 
32  if (!trk1) {return xAOD::EgammaParameters::unconverted;}
33 
34  if (!trk2)
36 
37  if (nSiHits1 && nSiHits2){
39  }
40  if (nSiHits1 || nSiHits2){
42  }
43  else{
45  }
46 }

◆ getAssociatedFlowElements()

std::vector< const xAOD::FlowElement * > xAOD::EgammaHelpers::getAssociatedFlowElements ( const xAOD::Egamma eg,
bool  neutral = true,
bool  charged = false 
)

Return a vector of the flow elements associated with the egamma cluster (only neutral for default)

Definition at line 93 of file EgammaxAODHelpers.cxx.

94  {
95  std::vector< const xAOD::FlowElement* > flowelements;
96  if (!neutral && !charged)
97  return flowelements;
98  std::vector< ElementLink< xAOD::FlowElementContainer > > veclinks = xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(eg,neutral);
99  for (const auto& i : veclinks){
100  if(i.isValid()){
101  flowelements.push_back(*i);
102  }
103  else{
104  flowelements.push_back(nullptr);
105  }
106  }
107  if (neutral && charged) {
108  std::vector< ElementLink< xAOD::FlowElementContainer > > oveclinks = xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(eg,false);
109  for (const auto& i : oveclinks){
110  if(i.isValid()){
111  flowelements.push_back(*i);
112  }
113  else{
114  flowelements.push_back(nullptr);
115  }
116  }
117  }
118  return flowelements;
119 }

◆ getAssociatedFlowElementsLinks()

std::vector< ElementLink< xAOD::FlowElementContainer > > xAOD::EgammaHelpers::getAssociatedFlowElementsLinks ( const xAOD::Egamma eg,
bool  neutral = true 
)

Return a vector of the elementlinks to the flow elements associated with the egamma cluster (neutral for default)

Definition at line 80 of file EgammaxAODHelpers.cxx.

81  {
82  static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::FlowElementContainer > > > nflowElementLinks("neutralFELinks");
83  static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::FlowElementContainer > > > cflowElementLinks("chargedFELinks");
84  std::vector< ElementLink< xAOD::FlowElementContainer > > veclinks;
85  if(neutral && nflowElementLinks.isAvailable(*eg)){
86  veclinks=nflowElementLinks(*eg);
87  } else if(!neutral && cflowElementLinks.isAvailable(*eg)){
88  veclinks=cflowElementLinks(*eg);
89  }
90  return veclinks;
91 }

◆ getAssociatedTopoClusters()

std::vector< const xAOD::CaloCluster * > xAOD::EgammaHelpers::getAssociatedTopoClusters ( const xAOD::CaloCluster cluster)

Return a vector of all the topo clusters associated with the egamma cluster.

Definition at line 66 of file EgammaxAODHelpers.cxx.

66  {
67  std::vector< const xAOD::CaloCluster* > topoclusters;
68  std::vector< ElementLink< xAOD::CaloClusterContainer > > veclinks = xAOD::EgammaHelpers::getAssociatedTopoClustersLinks(cluster);
69  for (const auto& i : veclinks){
70  if(i.isValid()){
71  topoclusters.push_back(*i);
72  }
73  else{
74  topoclusters.push_back(nullptr);
75  }
76  }
77  return topoclusters;
78 }

◆ getAssociatedTopoClustersLinks()

std::vector< ElementLink< xAOD::CaloClusterContainer > > xAOD::EgammaHelpers::getAssociatedTopoClustersLinks ( const xAOD::CaloCluster cluster)

Return a vector of all the elementlinks to the topo clusters associated with the egamma cluster.

Definition at line 56 of file EgammaxAODHelpers.cxx.

56  {
57 
58  static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::CaloClusterContainer > > > caloClusterLinks("constituentClusterLinks");
59  std::vector< ElementLink< xAOD::CaloClusterContainer > > veclinks;
60  if(caloClusterLinks.isAvailable(*cluster)){
61  veclinks=caloClusterLinks(*cluster);
62  }
63  return veclinks;
64 }

◆ getBkgElectronLineage() [1/2]

std::vector< const xAOD::TruthParticle * > xAOD::EgammaHelpers::getBkgElectronLineage ( const xAOD::Electron el,
const bool  allTheWayBack = true 
)

Helper wrapper function for calling the function below that accepts truth input.

Definition at line 110 of file EgammaTruthxAODHelpers.cxx.

111  {
113  return getBkgElectronLineage(truthel,allTheWayBack);
114 }

◆ getBkgElectronLineage() [2/2]

std::vector< const xAOD::TruthParticle * > xAOD::EgammaHelpers::getBkgElectronLineage ( const xAOD::TruthParticle truthel,
const bool  allTheWayBack = true 
)

Helper function for getting the True Lineage of an electron for an existing electron.

There are cases when an electron has a photon (or electron) mother, that in turn comes from another particle (possible leading to a Z or W etc). This method will navigate back and will return all true electron and photons in the lineage. in case of complex topologies will return just the 1st electron or photon mother

The user can apply also a barcode cut. This is handy in cases when we want to find the first non geant particle occuring when going back the lineage. The method will stop after the 1st particle failing this cut

Definition at line 118 of file EgammaTruthxAODHelpers.cxx.

119  {
120  std::vector<const xAOD::TruthParticle*> vec;
121  //Truth must exist and be an electron
122  if (!truthel || !MC::isElectron(truthel)){
123  return vec;
124  }
125  vec.push_back(truthel); //push its self back as first entry
126 
127  // The first parent has to exist
128  if (!truthel->nParents()) {
129  return vec;
130  }
131 
132  if (!HepMC::is_simulation_particle(truthel) && !allTheWayBack) {
133  return vec;
134  }
135 
136  //And has to be a photon or electron
137  const xAOD::TruthParticle* parent = truthel->parent();
138  if ( !MC::isPhoton(parent) && !MC::isElectron(parent) ) {
139  return vec;
140  }
141 
142  vec.push_back(parent); //push in the parent as the second entry
143 
144  //Loop over the generations
145  while (parent->nParents() &&
146  (HepMC::is_simulation_particle(parent) || allTheWayBack)) {
147  //Find the next parent
148  const xAOD::TruthParticle* tmp = parent->parent();
149  //You want to see an electron or a photon
150  if (MC::isPhoton(tmp) || MC::isElectron(tmp)) {
151  parent=tmp;
152  } else { // if we do not see any more electron and photons we stop
153  break;
154  }
155  vec.push_back(parent); //push in the parent
156  }
157  return vec;
158 }

◆ getBkgElectronMother() [1/2]

const xAOD::TruthParticle * xAOD::EgammaHelpers::getBkgElectronMother ( const xAOD::Electron el,
const bool  allTheWayBack = true 
)

Helper wrapper function for calling the function below that accepts truth input.

It extract the truth from the reco electron and uses the function below

Definition at line 91 of file EgammaTruthxAODHelpers.cxx.

92  {
93  const xAOD::TruthParticle *truthel =
95  return getBkgElectronMother(truthel,allTheWayBack);
96 }

◆ getBkgElectronMother() [2/2]

const xAOD::TruthParticle * xAOD::EgammaHelpers::getBkgElectronMother ( const xAOD::TruthParticle truthel,
const bool  allTheWayBack = true 
)

Helper function for getting the True "Mother" electron for an existing electron.

There are cases when an electron has a photon (or electron) mother, that in turn comes from another particle (possible leading to a Z or W etc). This method will navigate back up to the last electron or photon it can find in the lineage of the original true electron. Then the user just needs to check this electron/photon. If it fails returns null pointer.

The user can also get the first Geant4 particle cut. This is handy in cases when we want to find the first non geant particle occuring when going back the lineage. The method will stop after the 1st particle failing this cut

Definition at line 99 of file EgammaTruthxAODHelpers.cxx.

100  {
101  std::vector<const xAOD::TruthParticle*> vec =
102  xAOD::EgammaHelpers::getBkgElectronLineage(truthel,allTheWayBack);
103  if (!vec.empty()) {
104  return vec.back();
105  }
106  return nullptr;
107 }

◆ getLastMeasurementQoverP()

float xAOD::EgammaHelpers::getLastMeasurementQoverP ( const xAOD::TrackParticle tp)

return parameters for the last measurement for a GSF track particle

Definition at line 31 of file ElectronxAODHelpers.cxx.

31  {
32  static const SG::AuxElement::Accessor<float > QoverPLM ("QoverPLM");
33  if(tp && QoverPLM.isAvailable(*tp)){
34  return QoverPLM(*tp);
35  }
36  return -999 ;
37 }

◆ getLink()

template<class T >
const T* xAOD::EgammaHelpers::getLink ( const xAOD::IParticle particle,
std::string  name 
)

Access to element link to object of type T stored in auxdata.

Definition at line 27 of file EgammaTruthxAODHelpers.h.

27  {
28  if (!particle) return nullptr;
29  typedef ElementLink< DataVector<T> > Link_t;
30 
31  if (!particle->isAvailable< Link_t >(name) ) {
32  return nullptr;
33  }
34  const Link_t link = particle->auxdata<Link_t>(name);
35  if (!link.isValid()) {
36  return nullptr;
37  }
38  return *link;
39  }

◆ getOriginalTrackParticle()

const xAOD::TrackParticle * xAOD::EgammaHelpers::getOriginalTrackParticle ( const xAOD::Electron el)

Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.

Definition at line 11 of file ElectronxAODHelpers.cxx.

11  {
12 
13  if(el){
14  const xAOD::TrackParticle* trkPar= el->trackParticle();
15  if(trkPar){
16  return getOriginalTrackParticleFromGSF(trkPar);
17  }
18  }
19  return nullptr;
20 }

◆ getOriginalTrackParticleFromGSF()

const xAOD::TrackParticle * xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF ( const xAOD::TrackParticle trkPar)

Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle.

Definition at line 22 of file ElectronxAODHelpers.cxx.

22  {
23 
24  if(! trkPar) {return nullptr;}
25  static const SG::AuxElement::Accessor<ElementLink<xAOD::TrackParticleContainer> > orig ("originalTrackParticle");
26  if (!orig.isAvailable(*trkPar) || !orig(*trkPar).isValid()) {return nullptr;}
27 
28  return (*orig(*trkPar));
29 }

◆ getRecoElectron()

const xAOD::Electron * xAOD::EgammaHelpers::getRecoElectron ( const xAOD::TruthParticle particle)

return the reco electron associated to the given TruthParticle (if any)

Definition at line 31 of file EgammaTruthxAODHelpers.cxx.

31  {
32 
33  if( ! recoElectronLinkAcc.isAvailable( *particle ) ) {
34  return nullptr;
35  }
37  recoElectronLinkAcc( *particle );
38  if( ! link.isValid() ) {
39  return nullptr;
40  }
41  return *link;
42 }

◆ getRecoPhoton()

const xAOD::Photon * xAOD::EgammaHelpers::getRecoPhoton ( const xAOD::TruthParticle particle)

return the reco photon associated to the given TruthParticle (if any)

Definition at line 54 of file EgammaTruthxAODHelpers.cxx.

54  {
55 
56  if( ! recoPhotonLinkAcc.isAvailable( *particle ) ) {
57  return nullptr;
58  }
60  recoPhotonLinkAcc( *particle );
61  if( ! link.isValid() ) {
62  return nullptr;
63  }
64  return *link;
65 }

◆ getTrackParticles() [1/3]

std::set< const xAOD::TrackParticle * > xAOD::EgammaHelpers::getTrackParticles ( const xAOD::Egamma eg,
bool  useBremAssoc = true,
bool  allParticles = true 
)

Return a list of all or only the best TrackParticle associated to the object.

If useBremAssoc is set, get the original TrackParticle This is useful when a std::set of the original track Particles is required, which is mainly the case for the as it will re-order the elements in pointer order and not best match.

Definition at line 121 of file EgammaxAODHelpers.cxx.

123  {
124 
125  if (eg) {
126  if (eg->type()==xAOD::Type::Electron) {
127  const xAOD::Electron* el = static_cast<const xAOD::Electron*> (eg);
128  if (el) {
129  return getTrackParticles(el, useBremAssoc, allParticles);
130  }
131  }
132  else if (eg->type()==xAOD::Type::Photon) {
133  const xAOD::Photon* ph = static_cast<const xAOD::Photon*> (eg);
134  if (ph) {
135  return getTrackParticles(ph, useBremAssoc);
136  }
137  }
138  }
139  return std::set<const xAOD::TrackParticle*>{};
140 }

◆ getTrackParticles() [2/3]

std::set< const xAOD::TrackParticle * > xAOD::EgammaHelpers::getTrackParticles ( const xAOD::Electron el,
bool  useBremAssoc = true,
bool  allParticles = true 
)

Return a list of all or only the best TrackParticle associated to the object.

If useBremAssoc is set, get the original TrackParticle This is useful when a std::set of the original track Particles is required, which is mainly the case for the
as it will re-order the elements in pointer order and not best match.

Definition at line 39 of file ElectronxAODHelpers.cxx.

41  {
42  std::set<const xAOD::TrackParticle*> tps;
43  for (unsigned int i = 0; i < el->nTrackParticles(); ++i){
44  const xAOD::TrackParticle* tp = el->trackParticle(i);
46  if (tp) tps.insert( tp );
47  if (!allParticles) break; // break after first particle
48  }
49  return tps;
50 }

◆ getTrackParticles() [3/3]

std::set< const xAOD::TrackParticle * > xAOD::EgammaHelpers::getTrackParticles ( const xAOD::Photon ph,
bool  useBremAssoc = true 
)

Return a list of all or only the best TrackParticle associated to the object.

If useBremAssoc is set, get the original TrackParticle This is useful when a std::set of the original track Particles is required, which is mainly the case for the
as it will re-order the elements in pointer order and not best match.

Definition at line 108 of file PhotonxAODHelpers.cxx.

109  {
110 
111  std::set<const xAOD::TrackParticle*> tps;
112  if (!ph) return tps;
113  for (unsigned int ivx = 0; ivx < ph->nVertices(); ++ivx)
114  {
115  const xAOD::Vertex* vx = ph->vertex(ivx);
116  for (unsigned int i=0; vx && i < vx->nTrackParticles(); ++i){
117  const xAOD::TrackParticle *tp = vx->trackParticle(i);
118  tps.insert( useBremAssoc ? xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF(tp) : tp );
119  }
120  }
121  return tps;
122 }

◆ getTrackParticlesVec() [1/3]

std::vector< const xAOD::TrackParticle * > xAOD::EgammaHelpers::getTrackParticlesVec ( const xAOD::Egamma eg,
bool  useBremAssoc = true,
bool  allParticles = true 
)

Return a list of all or only the best TrackParticle associated to the object.

If useBremAssoc is set, get the original TrackParticle This one returns a vector so as to be more "user friendly", as it retains the original best match ordering

Definition at line 142 of file EgammaxAODHelpers.cxx.

144  {
145  if (eg) {
146  if (eg->type()==xAOD::Type::Electron) {
147  const xAOD::Electron* el = static_cast<const xAOD::Electron*> (eg);
148  if (el) {
149  return getTrackParticlesVec(el, useBremAssoc, allParticles);
150  }
151  }
152  else if (eg->type()==xAOD::Type::Photon) {
153  const xAOD::Photon* ph = static_cast<const xAOD::Photon*> (eg);
154  if (ph) {
155  return getTrackParticlesVec(ph, useBremAssoc);
156  }
157  }
158  }
159  return std::vector<const xAOD::TrackParticle*>{};
160 }

◆ getTrackParticlesVec() [2/3]

std::vector< const xAOD::TrackParticle * > xAOD::EgammaHelpers::getTrackParticlesVec ( const xAOD::Electron el,
bool  useBremAssoc = true,
bool  allParticles = true 
)

Return a list of all or only the best TrackParticle associated to the object.

If useBremAssoc is set, get the original TrackParticle This one returns a vector so as to be more "user friendly",as it retains the original best match ordering

Definition at line 52 of file ElectronxAODHelpers.cxx.

54  {
55 
56  std::vector<const xAOD::TrackParticle*> tps;
57  for (unsigned int i = 0; i < el->nTrackParticles(); ++i){
58  const xAOD::TrackParticle* tp = el->trackParticle(i);
60  if (tp) {tps.push_back( tp );}
61  if (!allParticles) {break;} // break after first particle
62  }
63  return tps;
64 }

◆ getTrackParticlesVec() [3/3]

std::vector< const xAOD::TrackParticle * > xAOD::EgammaHelpers::getTrackParticlesVec ( const xAOD::Photon ph,
bool  useBremAssoc = true 
)

Return a list of all or only the best TrackParticle associated to the object.

If useBremAssoc is set, get the original TrackParticle This one returns a vector so as to be more "user friendly",as it retains the original best match ordering

Definition at line 124 of file PhotonxAODHelpers.cxx.

125  {
126  std::vector<const xAOD::TrackParticle*> tps;
127  if (!ph) return tps;
128  for (unsigned int ivx = 0; ivx < ph->nVertices(); ++ivx)
129  {
130  const xAOD::Vertex* vx = ph->vertex(ivx);
131  for (unsigned int i=0; vx && i < vx->nTrackParticles(); ++i){
132  const xAOD::TrackParticle *tp = vx->trackParticle(i);
133  tps.push_back( useBremAssoc ? xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF(tp) : tp );
134  }
135  }
136  return tps;
137 }

◆ isBarrel() [1/2]

bool xAOD::EgammaHelpers::isBarrel ( const xAOD::CaloCluster cluster)

return true if the cluster (or the majority of its energy) is in the barrel

Definition at line 38 of file EgammaxAODHelpers.cxx.

38  {
39  const bool isBarrel = cluster->inBarrel();
40  const bool isEndcap = cluster->inEndcap();
41  if (isBarrel && isEndcap){
42  return cluster->eSample(CaloSampling::EMB2) >= cluster->eSample(CaloSampling::EME2);
43  }
44  return isBarrel;
45 }

◆ isBarrel() [2/2]

bool xAOD::EgammaHelpers::isBarrel ( const xAOD::Egamma eg)

return true if the cluster is in the barrel

Definition at line 34 of file EgammaxAODHelpers.cxx.

34  {
35  return (eg ? isBarrel(eg->caloCluster()) : false);
36 }

◆ isConvertedPhoton() [1/2]

bool xAOD::EgammaHelpers::isConvertedPhoton ( const xAOD::Egamma eg)

is the object a converted photon

Definition at line 26 of file EgammaxAODHelpers.cxx.

26  {
27  if (!eg || eg->type()!=xAOD::Type::Photon){
28  return false;
29  }
30  const xAOD::Photon *ph = static_cast<const xAOD::Photon*>(eg);
31  return (ph->nVertices()>0);
32 }

◆ isConvertedPhoton() [2/2]

bool xAOD::EgammaHelpers::isConvertedPhoton ( const xAOD::Photon ph)

is the object a converted photon

Definition at line 15 of file PhotonxAODHelpers.cxx.

15  {
16  return (ph && (ph->nVertices()>0) );
17 }

◆ isElectron()

bool xAOD::EgammaHelpers::isElectron ( const xAOD::Egamma eg)

is the object an electron (not Fwd)

Definition at line 13 of file EgammaxAODHelpers.cxx.

13  {
14  return ( (eg->type()==xAOD::Type::Electron) &&
16 }

◆ isFCAL()

bool xAOD::EgammaHelpers::isFCAL ( const xAOD::CaloCluster cluster)

return true if the cluster (or the majority of its energy) is in the FCAL0

Definition at line 47 of file EgammaxAODHelpers.cxx.

47  {
48  const bool hasEME2 = cluster->hasSampling(CaloSampling::EME2);
49  const bool hasFCAL0 = cluster->hasSampling(CaloSampling::FCAL0);
50  if (hasEME2 && hasFCAL0){
51  return cluster->eSample(CaloSampling::FCAL0) >= cluster->eSample(CaloSampling::EME2);
52  }
53  return hasFCAL0;
54 }

◆ isFwdElectron()

bool xAOD::EgammaHelpers::isFwdElectron ( const xAOD::Egamma eg)

is the object a Fwd electron

Definition at line 18 of file EgammaxAODHelpers.cxx.

18  {
20 }

◆ isPhoton()

bool xAOD::EgammaHelpers::isPhoton ( const xAOD::Egamma eg)

is the object a photon

Definition at line 22 of file EgammaxAODHelpers.cxx.

22  {
23  return (eg->type()==xAOD::Type::Photon);
24 }

◆ isTrueConvertedPhoton() [1/2]

bool xAOD::EgammaHelpers::isTrueConvertedPhoton ( const xAOD::Photon ph,
float  maxRadius = 800. 
)

is the object matched to a true converted photon with R < maxRadius

Definition at line 69 of file EgammaTruthxAODHelpers.cxx.

69  {
71  if (!truthPh) {return false;}
72  // In older versions egammaTruthParticles did not have a decay vertex associated
73  // so we look for the original truth particle
74  if (truthPh->hasDecayVtx()){
75  return isTrueConvertedPhoton(truthPh, maxRadius);
76  }
77  const xAOD::TruthParticle *orgTruthPh = xAOD::TruthHelpers::getTruthParticle(*truthPh);
78  if (!orgTruthPh){ return false;}
79  return xAOD::EgammaHelpers::isTrueConvertedPhoton(orgTruthPh, maxRadius);
80 }

◆ isTrueConvertedPhoton() [2/2]

bool xAOD::EgammaHelpers::isTrueConvertedPhoton ( const xAOD::TruthParticle truePh,
float  maxRadius = 800. 
)

is the true object a converted photon with R < maxRadius

Definition at line 83 of file EgammaTruthxAODHelpers.cxx.

83  {
84  return (MC::isPhoton(truthPh) && truthPh->hasDecayVtx()
85  && truthPh->decayVtx()->perp() < maxRadius);
86 }

◆ momentumAtVertex() [1/2]

Amg::Vector3D xAOD::EgammaHelpers::momentumAtVertex ( const xAOD::Photon photon,
bool  debug = false 
)

return the momentum at the vertex (which can be 0)

Definition at line 81 of file PhotonxAODHelpers.cxx.

81  {
82  if (!photon || !photon->vertex()) return Amg::Vector3D(0., 0., 0.);
83  return momentumAtVertex(*photon->vertex(), debug);
84 }

◆ momentumAtVertex() [2/2]

Amg::Vector3D xAOD::EgammaHelpers::momentumAtVertex ( const xAOD::Vertex vertex,
bool  debug = false 
)

return the momentum at the vertex (which can be 0)

Definition at line 87 of file PhotonxAODHelpers.cxx.

87  {
88 
89  static const SG::AuxElement::Accessor<float> accPx("px");
90  static const SG::AuxElement::Accessor<float> accPy("py");
91  static const SG::AuxElement::Accessor<float> accPz("pz");
92 
93  if (accPx.isAvailable(vertex) &&
94  accPy.isAvailable(vertex) &&
95  accPz.isAvailable(vertex))
96  {
97  return Amg::Vector3D(accPx(vertex),
98  accPy(vertex),
99  accPz(vertex));
100  }
101  if (debug){
102  std::cout << "Vertex not decorated with momentum" << std::endl;
103  }
104  return Amg::Vector3D(0., 0., 0.);
105 }

◆ numberOfSiHits()

std::size_t xAOD::EgammaHelpers::numberOfSiHits ( const xAOD::TrackParticle tp)

return the number of Si hits in the track particle

Definition at line 66 of file ElectronxAODHelpers.cxx.

66  {
67  if (!tp) return 0;
68  uint8_t dummy(0);
69  uint8_t nSiHits(0);
70  if (tp->summaryValue(dummy, xAOD::numberOfPixelHits)){
71  nSiHits += dummy;
72  }
73  if (tp->summaryValue(dummy, xAOD::numberOfSCTHits)){
74  nSiHits += dummy;
75  }
76  return nSiHits;
77 }

◆ numberOfSiTracks() [1/3]

std::size_t xAOD::EgammaHelpers::numberOfSiTracks ( const xAOD::EgammaParameters::ConversionType  convType)

return the number of Si tracks in the conversion

Definition at line 60 of file PhotonxAODHelpers.cxx.

60  {
61  if (convType == xAOD::EgammaParameters::doubleSi) {return 2;}
62  if (convType == xAOD::EgammaParameters::singleSi ||
63  convType == xAOD::EgammaParameters::doubleSiTRT) {return 1;}
64  return 0;
65 }

◆ numberOfSiTracks() [2/3]

std::size_t xAOD::EgammaHelpers::numberOfSiTracks ( const xAOD::Photon eg)

return the number of Si tracks in the conversion

Definition at line 50 of file PhotonxAODHelpers.cxx.

50  {
51  if (!ph || !ph->vertex()) {return 0;}
52  return numberOfSiTracks(ph->vertex());
53 }

◆ numberOfSiTracks() [3/3]

std::size_t xAOD::EgammaHelpers::numberOfSiTracks ( const xAOD::Vertex vx)

return the number of Si tracks in the conversion

Definition at line 55 of file PhotonxAODHelpers.cxx.

55  {
56  if (!vx) return 0;
57  return numberOfSiTracks(conversionType(vx));
58 }

◆ summaryValueFloat()

float xAOD::EgammaHelpers::summaryValueFloat ( const xAOD::TrackParticle tp,
const xAOD::SummaryType info,
float  deflt = -999. 
)

return the summary value for a TrackParticle or default value (-999)

Definition at line 169 of file EgammaxAODHelpers.cxx.

171  {
172  float dummy(0);
173  return (tp.summaryValue(dummy, info) ? dummy : deflt);
174 }

◆ summaryValueInt()

int xAOD::EgammaHelpers::summaryValueInt ( const xAOD::TrackParticle tp,
const xAOD::SummaryType info,
int  deflt = -999 
)

return the summary value for a TrackParticle or default value (-999) (to be used mostly in python where uint8_t is converted to char and the Tracking does not provide unprotected methods)

Definition at line 162 of file EgammaxAODHelpers.cxx.

164  {
165  uint8_t dummy(0);
166  return (tp.summaryValue(dummy, info) ? dummy : deflt);
167 }
xAOD::EgammaParameters::unconverted
@ unconverted
unconverted photon
Definition: EgammaEnums.h:270
grepfile.info
info
Definition: grepfile.py:38
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
xAOD::Photon_v1::nVertices
size_t nVertices() const
Return the number xAOD::Vertex/vertices that match the photon candidate.
xAOD::Vertex_v1::x
float x() const
Returns the x position.
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
ParticleTest.eg
eg
Definition: ParticleTest.py:29
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition: TrackingPrimitives.h:259
xAOD::EgammaHelpers::getTrackParticles
std::set< const xAOD::TrackParticle * > getTrackParticles(const xAOD::Egamma *eg, bool useBremAssoc=true, bool allParticles=true)
Return a list of all or only the best TrackParticle associated to the object.
Definition: EgammaxAODHelpers.cxx:121
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
xAOD::EgammaParameters::AuthorFwdElectron
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
Definition: EgammaDefs.h:30
xAOD::EgammaHelpers::getTrackParticlesVec
std::vector< const xAOD::TrackParticle * > getTrackParticlesVec(const xAOD::Egamma *eg, bool useBremAssoc=true, bool allParticles=true)
Return a list of all or only the best TrackParticle associated to the object.
Definition: EgammaxAODHelpers.cxx:142
xAOD::EgammaHelpers::getBkgElectronMother
const xAOD::TruthParticle * getBkgElectronMother(const xAOD::Electron *el, const bool allTheWayBack=true)
Helper wrapper function for calling the function below that accepts truth input.
Definition: EgammaTruthxAODHelpers.cxx:91
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
xAOD::TruthParticle_v1::hasDecayVtx
bool hasDecayVtx() const
Check for a decay vertex on this particle.
xAOD::CaloCluster_v1::inEndcap
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
Definition: CaloCluster_v1.h:901
xAOD::TruthParticle_v1::nParents
size_t nParents() const
Number of parents of this particle.
Definition: TruthParticle_v1.cxx:122
TauGNNUtils::Variables::Track::nSiHits
bool nSiHits(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:691
xAOD::EgammaHelpers::numberOfSiTracks
std::size_t numberOfSiTracks(const xAOD::Photon *eg)
return the number of Si tracks in the conversion
Definition: PhotonxAODHelpers.cxx:50
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
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:129
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:13
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
xAOD::EgammaHelpers::momentumAtVertex
Amg::Vector3D momentumAtVertex(const xAOD::Photon *, bool debug=false)
return the momentum at the vertex (which can be 0)
Definition: PhotonxAODHelpers.cxx:81
xAOD::CaloCluster_v1::inBarrel
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
Definition: CaloCluster_v1.h:896
xAOD::EgammaParameters::doubleSi
@ doubleSi
two tracks, both with Si hits
Definition: EgammaEnums.h:279
test_pyathena.parent
parent
Definition: test_pyathena.py:15
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
python.xAODType.dummy
dummy
Definition: xAODType.py:4
xAOD::Vertex_v1::trackParticle
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
Definition: Vertex_v1.cxx:249
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
xAOD::EgammaHelpers::getAssociatedTopoClustersLinks
std::vector< ElementLink< xAOD::CaloClusterContainer > > getAssociatedTopoClustersLinks(const xAOD::CaloCluster *cluster)
Return a vector of all the elementlinks to the topo clusters associated with the egamma cluster.
Definition: EgammaxAODHelpers.cxx:56
xAOD::EgammaParameters::doubleSiTRT
@ doubleSiTRT
two tracks, only one with Si hits
Definition: EgammaEnums.h:285
xAOD::EgammaParameters::singleTRT
@ singleTRT
one track only, no Si hits (TRT only)
Definition: EgammaEnums.h:276
CP::neutral
@ neutral
Definition: Reconstruction/PFlow/PFlowUtils/PFlowUtils/PFODefs.h:11
xAOD::EgammaHelpers::isTrueConvertedPhoton
bool isTrueConvertedPhoton(const xAOD::Photon *ph, float maxRadius=800.)
is the object matched to a true converted photon with R < maxRadius
Definition: EgammaTruthxAODHelpers.cxx:69
xAOD::EgammaParameters::singleSi
@ singleSi
one track only, with Si hits
Definition: EgammaEnums.h:273
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
xAOD::TruthHelpers::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
Definition: xAODTruthHelpers.cxx:25
xAOD::EgammaHelpers::conversionRadius
float conversionRadius(const xAOD::Vertex *vx)
return the conversion radius or 9999.
Definition: PhotonxAODHelpers.cxx:69
xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF
const xAOD::TrackParticle * getOriginalTrackParticleFromGSF(const xAOD::TrackParticle *trkPar)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle...
Definition: ElectronxAODHelpers.cxx:22
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
xAOD::EgammaHelpers::numberOfSiHits
std::size_t numberOfSiHits(const xAOD::TrackParticle *tp)
return the number of Si hits in the track particle
Definition: ElectronxAODHelpers.cxx:66
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::EgammaHelpers::getAssociatedFlowElementsLinks
std::vector< ElementLink< xAOD::FlowElementContainer > > getAssociatedFlowElementsLinks(const xAOD::Egamma *eg, bool neutral=true)
Return a vector of the elementlinks to the flow elements associated with the egamma cluster (neutral ...
Definition: EgammaxAODHelpers.cxx:80
xAOD::CaloCluster_v1::eSample
float eSample(const CaloSample sampling) const
Definition: CaloCluster_v1.cxx:521
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::Photon_v1
Definition: Photon_v1.h:37
xAOD::EgammaHelpers::isPhoton
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Definition: EgammaxAODHelpers.cxx:22
xAOD::Vertex_v1::y
float y() const
Returns the y position.
xAOD::EgammaHelpers::conversionType
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
Definition: PhotonxAODHelpers.cxx:19
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
xAOD::numberOfSCTHits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
Definition: TrackingPrimitives.h:268
xAOD::EgammaParameters::doubleTRT
@ doubleTRT
two tracks, none with Si hits (TRT only)
Definition: EgammaEnums.h:282
xAOD::EgammaParameters::NumberOfVertexConversionTypes
@ NumberOfVertexConversionTypes
maximum number of types
Definition: EgammaEnums.h:288
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::CaloCluster_v1::hasSampling
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
Definition: CaloCluster_v1.h:890
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
xAOD::Photon_v1::vertex
const xAOD::Vertex * vertex(size_t index=0) const
Pointer to the xAOD::Vertex/es that match the photon candidate.
Definition: Photon_v1.cxx:46
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CP::charged
@ charged
Definition: Reconstruction/PFlow/PFlowUtils/PFlowUtils/PFODefs.h:11
xAOD::EgammaHelpers::getBkgElectronLineage
std::vector< const xAOD::TruthParticle * > getBkgElectronLineage(const xAOD::Electron *el, const bool allTheWayBack=true)
Helper wrapper function for calling the function below that accepts truth input.
Definition: EgammaTruthxAODHelpers.cxx:110