ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::EgammaHelpers Namespace Reference

Functions

const xAOD::ElectrongetRecoElectron (const xAOD::TruthParticle *)
 return the reco electron associated to the given TruthParticle (if any)
const xAOD::PhotongetRecoPhoton (const xAOD::TruthParticle *particle)
 return the reco photon associated to the given TruthParticle (if any)
bool isTrueConvertedPhoton (const xAOD::Photon *ph, float maxRadius=800.)
 is the object matched to a true converted photon with R < maxRadius
bool isTrueConvertedPhoton (const xAOD::TruthParticle *truePh, float maxRadius=800.)
 is the true object a converted photon with R < maxRadius
std::vector< const xAOD::TruthParticle * > getBkgElectronLineage (const xAOD::TruthParticle *truthel, const bool allTheWayBack=true)
 Helper function for getting the truth lineage of an electron that is arising from material interactions in simulation (so called Bkg Electron) There are cases when an electron has a photon (or electron) mother, that in turn comes from another electron of photon.
const xAOD::TruthParticlegetBkgElectronMother (const xAOD::Electron *el, const bool allTheWayBack=true)
 Helper wrapper function for calling the function above extracting the truth from a reco electron.
const xAOD::TruthParticlegetBkgElectronMother (const xAOD::TruthParticle *truthel, const bool allTheWayBack=true)
 Helper function for getting the "Mother" electron for an existing electron.
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.
bool isElectron (const xAOD::Egamma *eg)
 is the object an electron (not Fwd)
bool isFwdElectron (const xAOD::Egamma *eg)
 is the object a Fwd electron
bool isPhoton (const xAOD::Egamma *eg)
 is the object a photon
bool isConvertedPhoton (const xAOD::Egamma *eg, bool excludeTRT=false)
 is the object a converted photon
bool isBarrel (const xAOD::Egamma *eg)
 return true if the cluster is in the barrel
bool isBarrel (const xAOD::CaloCluster *cluster)
 return true if the cluster (or the majority of its energy) is in the barrel
bool isFCAL (const xAOD::CaloCluster *cluster)
 return true if the cluster (or the majority of its energy) is in the FCAL0
const xAOD::CaloClustergetCluster (const xAOD::Egamma *eg, bool cook=true)
 return the associated egamma cluster, that might be cookie-cut cluster (fwd electron)
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.
std::vector< const xAOD::CaloCluster * > getAssociatedTopoClusters (const xAOD::CaloCluster *cluster)
 Return a vector of all the topo clusters associated with the egamma cluster.
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)
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)
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.
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.
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)
float summaryValueFloat (const xAOD::TrackParticle &tp, const xAOD::SummaryType &info, float deflt=-999.)
 return the summary value for a TrackParticle or default value (-999)
unsigned short energyInMissingCells (const xAOD::Egamma &eg, double &e2, double &e3)
 Get the energies in sampling 2 and 3 that are in cells rejected by the topo-cluster timing cut but that would have been expected in a egamma cluster.
const xAOD::TrackParticlegetOriginalTrackParticle (const xAOD::Electron *el)
 Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
const xAOD::TrackParticlegetOriginalTrackParticleFromGSF (const xAOD::TrackParticle *trkPar)
 Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle.
float getLastMeasurementQoverP (const xAOD::TrackParticle *tp)
 return parameters for the last measurement for a GSF track particle
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.
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.
std::size_t numberOfSiHits (const xAOD::TrackParticle *tp)
 return the number of Si hits in the track particle
bool isConvertedPhoton (const xAOD::Photon *ph, bool excludeTRT=false)
 is the object a converted photon
xAOD::EgammaParameters::ConversionType conversionType (const xAOD::Photon *ph)
 return the photon conversion type (see EgammaEnums)
xAOD::EgammaParameters::ConversionType conversionType (const xAOD::Vertex *vx)
 return the photon conversion type (see EgammaEnums)
std::size_t numberOfSiTracks (const xAOD::Photon *eg)
 return the number of Si tracks in the conversion
std::size_t numberOfSiTracks (const xAOD::Vertex *vx)
 return the number of Si tracks in the conversion
std::size_t numberOfSiTracks (const xAOD::EgammaParameters::ConversionType convType)
 return the number of Si tracks in the conversion
float conversionRadius (const xAOD::Vertex *vx)
 return the conversion radius or 9999.
float conversionRadius (const xAOD::Photon *ph)
 return the conversion radius or 9999.
Amg::Vector3D momentumAtVertex (const xAOD::Photon *, bool debug=false)
 return the momentum at the vertex (which can be 0)
Amg::Vector3D momentumAtVertex (const xAOD::Vertex &, bool debug=false)
 return the momentum at the vertex (which can be 0)
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.
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.

Function Documentation

◆ conversionRadius() [1/2]

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

return the conversion radius or 9999.

Definition at line 63 of file PhotonxAODHelpers.cxx.

63 {
64 if (!ph || !ph->vertex()) return 9999.;
65 return conversionRadius(ph->vertex());
66}
const xAOD::Vertex * vertex(size_t index=0) const
Pointer to the xAOD::Vertex/es that match the photon candidate.
Definition Photon_v1.cxx:61
float conversionRadius(const xAOD::Vertex *vx)
return the conversion radius or 9999.

◆ conversionRadius() [2/2]

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

return the conversion radius or 9999.

Definition at line 58 of file PhotonxAODHelpers.cxx.

58 {
59 if (!vx) return 9999.;
60 return sqrt( vx->x()*vx->x() + vx->y()*vx->y() );
61}
float y() const
Returns the y position.
float x() const
Returns the x position.

◆ conversionType() [1/2]

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

return the photon conversion type (see EgammaEnums)

Definition at line 21 of file PhotonxAODHelpers.cxx.

21 {
23 return conversionType(ph->vertex());
24}
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
@ NumberOfVertexConversionTypes
maximum number of types

◆ conversionType() [2/2]

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

return the photon conversion type (see EgammaEnums)

Definition at line 26 of file PhotonxAODHelpers.cxx.

26 {
28
29 const TrackParticle *trk1 = ( vx->nTrackParticles() ? vx->trackParticle(0) : nullptr );
30 const TrackParticle *trk2 = ( vx->nTrackParticles() > 1 ? vx->trackParticle(1) : nullptr );
31 uint8_t nSiHits1 = numberOfSiHits(trk1);
32 uint8_t nSiHits2 = numberOfSiHits(trk2);
33
34 return EgammaDetails::conversionType (trk1 != nullptr, trk2 != nullptr, nSiHits1, nSiHits2);
35}
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
ConversionType conversionType(const bool hasTrk1, const bool hasTrk2, const std::uint8_t nSiHits1, const std::uint8_t nSiHits2)
return the photon conversion type (see EgammaEnums)
std::size_t numberOfSiHits(const xAOD::TrackParticle *tp)
return the number of Si hits in the track particle
@ unconverted
unconverted photon
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ energyInMissingCells()

unsigned short xAOD::EgammaHelpers::energyInMissingCells ( const xAOD::Egamma & eg,
double & e2,
double & e3 )

Get the energies in sampling 2 and 3 that are in cells rejected by the topo-cluster timing cut but that would have been expected in a egamma cluster.

Definition at line 188 of file EgammaxAODHelpers.cxx.

189 {
190
191 const static SG::AuxElement::ConstAccessor<float> acc_Eadded_s2("Eadded_Lr2");
192 const static SG::AuxElement::ConstAccessor<float> acc_Eadded_s3("Eadded_Lr3");
193
194 unsigned short status = 0;
195 if (acc_Eadded_s2.isAvailable(eg))
196 { e2 = acc_Eadded_s2(eg); }
197 else
198 { status += 1; }
199 if (acc_Eadded_s3.isAvailable(eg))
200 { e3 = acc_Eadded_s3(eg); }
201 else
202 { status += 2; }
203 return status;
204}
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
status
Definition merge.py:16

◆ 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 104 of file EgammaxAODHelpers.cxx.

105 {
106 std::vector< const xAOD::FlowElement* > flowelements;
107 if (!neutral && !charged)
108 return flowelements;
109 std::vector< ElementLink< xAOD::FlowElementContainer > > veclinks = xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(eg,neutral);
110 for (const auto& i : veclinks){
111 if(i.isValid()){
112 flowelements.push_back(*i);
113 }
114 else{
115 flowelements.push_back(nullptr);
116 }
117 }
118 if (neutral && charged) {
119 std::vector< ElementLink< xAOD::FlowElementContainer > > oveclinks = xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(eg,false);
120 for (const auto& i : oveclinks){
121 if(i.isValid()){
122 flowelements.push_back(*i);
123 }
124 else{
125 flowelements.push_back(nullptr);
126 }
127 }
128 }
129 return flowelements;
130}
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 ...

◆ 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 91 of file EgammaxAODHelpers.cxx.

92 {
93 static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::FlowElementContainer > > > nflowElementLinks("neutralFELinks");
94 static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::FlowElementContainer > > > cflowElementLinks("chargedFELinks");
95 std::vector< ElementLink< xAOD::FlowElementContainer > > veclinks;
96 if(neutral && nflowElementLinks.isAvailable(*eg)){
97 veclinks=nflowElementLinks(*eg);
98 } else if(!neutral && cflowElementLinks.isAvailable(*eg)){
99 veclinks=cflowElementLinks(*eg);
100 }
101 return veclinks;
102}
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572

◆ 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 77 of file EgammaxAODHelpers.cxx.

77 {
78 std::vector< const xAOD::CaloCluster* > topoclusters;
79 std::vector< ElementLink< xAOD::CaloClusterContainer > > veclinks = xAOD::EgammaHelpers::getAssociatedTopoClustersLinks(cluster);
80 for (const auto& i : veclinks){
81 if(i.isValid()){
82 topoclusters.push_back(*i);
83 }
84 else{
85 topoclusters.push_back(nullptr);
86 }
87 }
88 return topoclusters;
89}
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.

◆ 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 67 of file EgammaxAODHelpers.cxx.

67 {
68
69 static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::CaloClusterContainer > > > caloClusterLinks("constituentClusterLinks");
70 std::vector< ElementLink< xAOD::CaloClusterContainer > > veclinks;
71 if(caloClusterLinks.isAvailable(*cluster)){
72 veclinks=caloClusterLinks(*cluster);
73 }
74 return veclinks;
75}

◆ 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 157 of file EgammaTruthxAODHelpers.cxx.

158 {
160 return getBkgElectronLineage(truthel,allTheWayBack);
161}
std::vector< const xAOD::TruthParticle * > getBkgElectronLineage(const xAOD::TruthParticle *truthel, const bool allTheWayBack=true)
Helper function for getting the truth lineage of an electron that is arising from material interactio...
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ getBkgElectronLineage() [2/2]

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

Helper function for getting the truth lineage of an electron that is arising from material interactions in simulation (so called Bkg Electron) There are cases when an electron has a photon (or electron) mother, that in turn comes from another electron of photon.

The allTheWayBack (default true) will return the full lineage of the electron going back to the earliest generator e/gamma truth particle available. When this is set to false we stop at the generator e/gamma particle that interacted with material in simulation (meaning we will not go at the beginning of the generator record). The 0th entry of the returned vector is the passed e/gamma particle, while the last is the last e/gamma particle we have seen in the lineage.

Definition at line 90 of file EgammaTruthxAODHelpers.cxx.

91 {
92 std::vector<const xAOD::TruthParticle*> vec;
93 //Truth must exist and be an electron
94 if (!truthel || !MC::isElectron(truthel)){
95 return vec;
96 }
97 vec.push_back(truthel); //push its self back as first entry
98
99 // The first parent has to exist
100 if (!truthel->nParents()) {
101 return vec;
102 }
103
104 if (!HepMC::is_simulation_particle(truthel) && !allTheWayBack) {
105 return vec;
106 }
107
108 //And has to be a photon or electron
109 const xAOD::TruthParticle* parent = nullptr;
110 for (size_t p = 0; p < truthel->nParents(); ++p) {
111 if ( !MC::isPhoton(truthel->parent(p)) && !MC::isElectron(truthel->parent(p)) ) return vec;
112 parent = truthel->parent(p); //AV: note, here is an ambiguity for the case of multiple parents.
113 }
114
115 if (!parent) return vec;
116 vec.push_back(parent); //push in the parent as the second entry
117
118 //Loop over the generations
119 while (parent->nParents() &&
120 (HepMC::is_simulation_particle(parent) || allTheWayBack)) {
121 //Find the next parent
122 const xAOD::TruthParticle* tmp = nullptr;
123 //You want to see an electron or a photon
124 for (size_t p = 0; p < parent->nParents(); ++p) {
125 if (MC::isPhoton(parent->parent(p)) || MC::isElectron(parent->parent(p))) tmp = parent->parent(p); //AV: note some ambiguity for multiple parents passing the selection
126 }
127 if (tmp) {
128 parent = tmp;
129 } else { // if we do not see any more electron and photons we stop
130 break;
131 }
132 vec.push_back(parent); //push in the parent
133 }
134 return vec;
135}
std::vector< size_t > vec
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
size_t nParents() const
Number of parents of this 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...
bool isPhoton(const T &p)
bool isElectron(const T &p)

◆ getBkgElectronMother() [1/2]

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

Helper wrapper function for calling the function above extracting the truth from a reco electron.

Definition at line 137 of file EgammaTruthxAODHelpers.cxx.

138 {
139 const xAOD::TruthParticle *truthel =
141 return getBkgElectronMother(truthel,allTheWayBack);
142}
const xAOD::TruthParticle * getBkgElectronMother(const xAOD::Electron *el, const bool allTheWayBack=true)
Helper wrapper function for calling the function above extracting the truth from a reco electron.

◆ getBkgElectronMother() [2/2]

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

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

return the last entry in the lineage vector

Definition at line 145 of file EgammaTruthxAODHelpers.cxx.

146 {
147 std::vector<const xAOD::TruthParticle*> vec =
148 xAOD::EgammaHelpers::getBkgElectronLineage(truthel,allTheWayBack);
149 if (!vec.empty()) {
150 return vec.back();
151 }
152 return nullptr;
153}

◆ getCluster()

const xAOD::CaloCluster * xAOD::EgammaHelpers::getCluster ( const xAOD::Egamma * eg,
bool cook = true )

return the associated egamma cluster, that might be cookie-cut cluster (fwd electron)

Definition at line 55 of file EgammaxAODHelpers.cxx.

57{
58 if (!eg) { return nullptr; }
59 if (!cook) { return eg->caloCluster(); }
61 cookClusLinkAcc( "cookiecutClusterLink" );
62 if (!cookClusLinkAcc.isAvailable(*eg) || !cookClusLinkAcc(*eg).isValid())
63 { return nullptr; }
64 return (*cookClusLinkAcc(*eg));
65}

◆ 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}

◆ 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){
17 }
18 }
19 return nullptr;
20}
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...

◆ 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}
static const SG::AuxElement::Accessor< ElementLink< xAOD::ElectronContainer > > recoElectronLinkAcc("recoElectronLink")
Accessor for the "recoElectronLink" dynamic variable.

◆ 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}
static const SG::AuxElement::Accessor< ElementLink< xAOD::PhotonContainer > > recoPhotonLinkAcc("recoPhotonLink")
Accessor for the "recoPhotonLink" dynamic variable.

◆ 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 132 of file EgammaxAODHelpers.cxx.

134 {
135
136 if (eg) {
137 if (eg->type()==xAOD::Type::Electron) {
138 const xAOD::Electron* el = static_cast<const xAOD::Electron*> (eg);
139 if (el) {
140 return getTrackParticles(el, useBremAssoc, allParticles);
141 }
142 }
143 else if (eg->type()==xAOD::Type::Photon) {
144 const xAOD::Photon* ph = static_cast<const xAOD::Photon*> (eg);
145 if (ph) {
146 return getTrackParticles(ph, useBremAssoc);
147 }
148 }
149 }
150 return std::set<const xAOD::TrackParticle*>{};
151}
@ Photon
The object is a photon.
Definition ObjectType.h:47
@ Electron
The object is an electron.
Definition ObjectType.h:46
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.
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".

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

98 {
99
100 std::set<const xAOD::TrackParticle*> tps;
101 if (!ph) return tps;
102 for (unsigned int ivx = 0; ivx < ph->nVertices(); ++ivx)
103 {
104 const xAOD::Vertex* vx = ph->vertex(ivx);
105 for (unsigned int i=0; vx && i < vx->nTrackParticles(); ++i){
106 const xAOD::TrackParticle *tp = vx->trackParticle(i);
107 tps.insert( useBremAssoc ? xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF(tp) : tp );
108 }
109 }
110 return tps;
111}
size_t nVertices() const
Return the number xAOD::Vertex/vertices that match the photon candidate.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ 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 153 of file EgammaxAODHelpers.cxx.

155 {
156 if (eg) {
157 if (eg->type()==xAOD::Type::Electron) {
158 const xAOD::Electron* el = static_cast<const xAOD::Electron*> (eg);
159 if (el) {
160 return getTrackParticlesVec(el, useBremAssoc, allParticles);
161 }
162 }
163 else if (eg->type()==xAOD::Type::Photon) {
164 const xAOD::Photon* ph = static_cast<const xAOD::Photon*> (eg);
165 if (ph) {
166 return getTrackParticlesVec(ph, useBremAssoc);
167 }
168 }
169 }
170 return std::vector<const xAOD::TrackParticle*>{};
171}
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.

◆ 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 113 of file PhotonxAODHelpers.cxx.

114 {
115 std::vector<const xAOD::TrackParticle*> tps;
116 if (!ph) return tps;
117 for (unsigned int ivx = 0; ivx < ph->nVertices(); ++ivx)
118 {
119 const xAOD::Vertex* vx = ph->vertex(ivx);
120 for (unsigned int i=0; vx && i < vx->nTrackParticles(); ++i){
121 const xAOD::TrackParticle *tp = vx->trackParticle(i);
122 tps.push_back( useBremAssoc ? xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF(tp) : tp );
123 }
124 }
125 return tps;
126}

◆ 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 37 of file EgammaxAODHelpers.cxx.

37 {
38 const bool isBarrel = cluster->inBarrel();
39 const bool isEndcap = cluster->inEndcap();
40 if (isBarrel && isEndcap){
41 return cluster->eSample(CaloSampling::EMB2) >= cluster->eSample(CaloSampling::EME2);
42 }
43 return isBarrel;
44}
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
float eSample(const CaloSample sampling) const
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel

◆ isBarrel() [2/2]

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

return true if the cluster is in the barrel

Definition at line 33 of file EgammaxAODHelpers.cxx.

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

◆ isConvertedPhoton() [1/2]

bool xAOD::EgammaHelpers::isConvertedPhoton ( const xAOD::Egamma * eg,
bool excludeTRT = false )

is the object a converted photon

Definition at line 25 of file EgammaxAODHelpers.cxx.

25 {
26 if (!eg || eg->type()!=xAOD::Type::Photon){
27 return false;
28 }
29 const xAOD::Photon *ph = static_cast<const xAOD::Photon*>(eg);
30 return xAOD::EgammaHelpers::isConvertedPhoton(ph,excludeTRT);
31}
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon

◆ isConvertedPhoton() [2/2]

bool xAOD::EgammaHelpers::isConvertedPhoton ( const xAOD::Photon * ph,
bool excludeTRT = false )

is the object a converted photon

Definition at line 16 of file PhotonxAODHelpers.cxx.

16 {
17 if (!ph) return false;
18 return EgammaDetails::isConvertedPhoton(excludeTRT, ph->eta(), ph->nVertices(), conversionType(ph));
19}
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
bool isConvertedPhoton(const bool excludeTRT, const float eta, const std::size_t nVertices, const ConversionType conversionType)
is the object a converted photon

◆ isElectron()

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

is the object an electron (not Fwd)

Definition at line 12 of file EgammaxAODHelpers.cxx.

12 {
13 return ( (eg->type()==xAOD::Type::Electron) &&
15}
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
Definition EgammaDefs.h:30

◆ 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 46 of file EgammaxAODHelpers.cxx.

46 {
47 const bool hasEME2 = cluster->hasSampling(CaloSampling::EME2);
48 const bool hasFCAL0 = cluster->hasSampling(CaloSampling::FCAL0);
49 if (hasEME2 && hasFCAL0){
50 return cluster->eSample(CaloSampling::FCAL0) >= cluster->eSample(CaloSampling::EME2);
51 }
52 return hasFCAL0;
53}
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.

◆ isFwdElectron()

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

is the object a Fwd electron

Definition at line 17 of file EgammaxAODHelpers.cxx.

17 {
19}

◆ isPhoton()

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

is the object a photon

Definition at line 21 of file EgammaxAODHelpers.cxx.

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

◆ 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 }
78 if (!orgTruthPh){ return false;}
79 return xAOD::EgammaHelpers::isTrueConvertedPhoton(orgTruthPh, maxRadius);
80}
bool hasDecayVtx() const
Check for a decay vertex on this particle.
bool isTrueConvertedPhoton(const xAOD::Photon *ph, float maxRadius=800.)
is the object matched to a true converted photon with R < maxRadius

◆ 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 70 of file PhotonxAODHelpers.cxx.

70 {
71 if (!photon || !photon->vertex()) return Amg::Vector3D(0., 0., 0.);
72 return momentumAtVertex(*photon->vertex(), debug);
73}
const bool debug
Eigen::Matrix< double, 3, 1 > Vector3D
Amg::Vector3D momentumAtVertex(const xAOD::Photon *, bool debug=false)
return the momentum at the vertex (which can be 0)

◆ 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 76 of file PhotonxAODHelpers.cxx.

76 {
77
78 static const SG::AuxElement::Accessor<float> accPx("px");
79 static const SG::AuxElement::Accessor<float> accPy("py");
80 static const SG::AuxElement::Accessor<float> accPz("pz");
81
82 if (accPx.isAvailable(vertex) &&
83 accPy.isAvailable(vertex) &&
84 accPz.isAvailable(vertex))
85 {
86 return Amg::Vector3D(accPx(vertex),
87 accPy(vertex),
88 accPz(vertex));
89 }
90 if (debug){
91 std::cout << "Vertex not decorated with momentum" << std::endl;
92 }
93 return Amg::Vector3D(0., 0., 0.);
94}
static const SG::AuxElement::Accessor< float > accPx("px")
static const SG::AuxElement::Accessor< float > accPy("py")
static const SG::AuxElement::Accessor< float > accPz("pz")

◆ 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}
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].

◆ 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 49 of file PhotonxAODHelpers.cxx.

49 {
50 if (convType == xAOD::EgammaParameters::doubleSi) {return 2;}
51 if (convType == xAOD::EgammaParameters::singleSi ||
52 convType == xAOD::EgammaParameters::doubleSiTRT) {return 1;}
53 return 0;
54}
@ singleSi
one track only, with Si hits
@ doubleSi
two tracks, both with Si hits
@ doubleSiTRT
two tracks, only one with Si hits

◆ 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 39 of file PhotonxAODHelpers.cxx.

39 {
40 if (!ph || !ph->vertex()) {return 0;}
41 return numberOfSiTracks(ph->vertex());
42}
std::size_t numberOfSiTracks(const xAOD::Photon *eg)
return the number of Si tracks in the conversion

◆ 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 44 of file PhotonxAODHelpers.cxx.

44 {
45 if (!vx) return 0;
47}

◆ 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 180 of file EgammaxAODHelpers.cxx.

182 {
183 float dummy(0);
184 return (tp.summaryValue(dummy, info) ? dummy : deflt);
185}

◆ 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 173 of file EgammaxAODHelpers.cxx.

175 {
176 uint8_t dummy(0);
177 return (tp.summaryValue(dummy, info) ? dummy : deflt);
178}