ATLAS Offline Software
EgammaxAODHelpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "xAODEgamma/Egamma.h"
7 #include "xAODEgamma/Photon.h"
8 #include "xAODEgamma/Electron.h"
11 
13  return ( (eg->type()==xAOD::Type::Electron) &&
15 }
16 // ==================================================================
19 }
20 // ==================================================================
22  return (eg->type()==xAOD::Type::Photon);
23 }
24 // ==================================================================
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 }
32 // ==================================================================
34  return (eg ? isBarrel(eg->caloCluster()) : false);
35 }
36 // ==================================================================
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 }
45 // ==================================================================
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 }
54 // ==================================================================
55 std::vector< ElementLink< xAOD::CaloClusterContainer > > xAOD::EgammaHelpers::getAssociatedTopoClustersLinks(const xAOD::CaloCluster *cluster){
56 
57  static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::CaloClusterContainer > > > caloClusterLinks("constituentClusterLinks");
58  std::vector< ElementLink< xAOD::CaloClusterContainer > > veclinks;
59  if(caloClusterLinks.isAvailable(*cluster)){
60  veclinks=caloClusterLinks(*cluster);
61  }
62  return veclinks;
63 }
64 // ==================================================================
65 std::vector<const xAOD::CaloCluster*> xAOD::EgammaHelpers::getAssociatedTopoClusters(const xAOD::CaloCluster *cluster){
66  std::vector< const xAOD::CaloCluster* > topoclusters;
67  std::vector< ElementLink< xAOD::CaloClusterContainer > > veclinks = xAOD::EgammaHelpers::getAssociatedTopoClustersLinks(cluster);
68  for (const auto& i : veclinks){
69  if(i.isValid()){
70  topoclusters.push_back(*i);
71  }
72  else{
73  topoclusters.push_back(nullptr);
74  }
75  }
76  return topoclusters;
77 }
78 // ==================================================================
79 std::vector< ElementLink< xAOD::FlowElementContainer > > xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(const xAOD::Egamma *eg,
80  bool neutral){
81  static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::FlowElementContainer > > > nflowElementLinks("neutralFELinks");
82  static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::FlowElementContainer > > > cflowElementLinks("chargedFELinks");
83  std::vector< ElementLink< xAOD::FlowElementContainer > > veclinks;
84  if(neutral && nflowElementLinks.isAvailable(*eg)){
85  veclinks=nflowElementLinks(*eg);
86  } else if(!neutral && cflowElementLinks.isAvailable(*eg)){
87  veclinks=cflowElementLinks(*eg);
88  }
89  return veclinks;
90 }
91 // ==================================================================
92 std::vector<const xAOD::FlowElement*> xAOD::EgammaHelpers::getAssociatedFlowElements(const xAOD::Egamma *eg,
93  bool neutral, bool charged){
94  std::vector< const xAOD::FlowElement* > flowelements;
95  if (!neutral && !charged)
96  return flowelements;
97  std::vector< ElementLink< xAOD::FlowElementContainer > > veclinks = xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(eg,neutral);
98  for (const auto& i : veclinks){
99  if(i.isValid()){
100  flowelements.push_back(*i);
101  }
102  else{
103  flowelements.push_back(nullptr);
104  }
105  }
106  if (neutral && charged) {
107  std::vector< ElementLink< xAOD::FlowElementContainer > > oveclinks = xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(eg,false);
108  for (const auto& i : oveclinks){
109  if(i.isValid()){
110  flowelements.push_back(*i);
111  }
112  else{
113  flowelements.push_back(nullptr);
114  }
115  }
116  }
117  return flowelements;
118 }
119 // ==================================================================
120 std::set<const xAOD::TrackParticle*> xAOD::EgammaHelpers::getTrackParticles(const xAOD::Egamma *eg,
121  bool useBremAssoc /* = true */,
122  bool allParticles /* = true */){
123 
124  if (eg) {
125  if (eg->type()==xAOD::Type::Electron) {
126  const xAOD::Electron* el = static_cast<const xAOD::Electron*> (eg);
127  if (el) {
128  return getTrackParticles(el, useBremAssoc, allParticles);
129  }
130  }
131  else if (eg->type()==xAOD::Type::Photon) {
132  const xAOD::Photon* ph = static_cast<const xAOD::Photon*> (eg);
133  if (ph) {
134  return getTrackParticles(ph, useBremAssoc);
135  }
136  }
137  }
138  return std::set<const xAOD::TrackParticle*>{};
139 }
140 // ==================================================================
141 std::vector<const xAOD::TrackParticle*> xAOD::EgammaHelpers::getTrackParticlesVec(const xAOD::Egamma *eg,
142  bool useBremAssoc /* = true */,
143  bool allParticles /* = true */){
144  if (eg) {
145  if (eg->type()==xAOD::Type::Electron) {
146  const xAOD::Electron* el = static_cast<const xAOD::Electron*> (eg);
147  if (el) {
148  return getTrackParticlesVec(el, useBremAssoc, allParticles);
149  }
150  }
151  else if (eg->type()==xAOD::Type::Photon) {
152  const xAOD::Photon* ph = static_cast<const xAOD::Photon*> (eg);
153  if (ph) {
154  return getTrackParticlesVec(ph, useBremAssoc);
155  }
156  }
157  }
158  return std::vector<const xAOD::TrackParticle*>{};
159 }
160 // ==================================================================
162  const xAOD::SummaryType& info,
163  int deflt /* = -999 */){
164  uint8_t dummy(0);
165  return (tp.summaryValue(dummy, info) ? dummy : deflt);
166 }
167 // ==================================================================
169  const xAOD::SummaryType& info,
170  float deflt /* = -999. */){
171  float dummy(0);
172  return (tp.summaryValue(dummy, info) ? dummy : deflt);
173 }
174 
175 // ==================================================================
177  double& e2, double& e3) {
178 
179  const static SG::AuxElement::ConstAccessor<float> acc_Eadded_s2("Eadded_Lr2");
180  const static SG::AuxElement::ConstAccessor<float> acc_Eadded_s3("Eadded_Lr3");
181 
182  unsigned short status = 0;
183  if (acc_Eadded_s2.isAvailable(eg))
184  { e2 = acc_Eadded_s2(eg); }
185  else
186  { status += 1; }
187  if (acc_Eadded_s3.isAvailable(eg))
188  { e3 = acc_Eadded_s3(eg); }
189  else
190  { status += 2; }
191  return status;
192 }
grepfile.info
info
Definition: grepfile.py:38
xAOD::EgammaHelpers::energyInMissingCells
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 th...
Definition: EgammaxAODHelpers.cxx:176
xAOD::EgammaHelpers::summaryValueFloat
float summaryValueFloat(const xAOD::TrackParticle &tp, const xAOD::SummaryType &info, float deflt=-999.)
return the summary value for a TrackParticle or default value (-999)
Definition: EgammaxAODHelpers.cxx:168
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
xAOD::EgammaHelpers::getAssociatedTopoClusters
std::vector< const xAOD::CaloCluster * > getAssociatedTopoClusters(const xAOD::CaloCluster *cluster)
Return a vector of all the topo clusters associated with the egamma cluster.
Definition: EgammaxAODHelpers.cxx:65
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
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:68
xAOD::EgammaHelpers::getAssociatedFlowElements
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)
Definition: EgammaxAODHelpers.cxx:92
ParticleTest.tp
tp
Definition: ParticleTest.py:25
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:120
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
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:141
xAOD::EgammaHelpers::isBarrel
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel
Definition: EgammaxAODHelpers.cxx:33
Egamma.h
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
xAOD::CaloCluster_v1::inEndcap
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
Definition: CaloCluster_v1.h:901
EgammaxAODHelpers.h
xAOD::SummaryType
SummaryType
Enumerates the different types of information stored in Summary.
Definition: TrackingPrimitives.h:228
xAOD::EgammaHelpers::isConvertedPhoton
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
Definition: EgammaxAODHelpers.cxx:25
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCluster.h
Photon.h
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:12
xAOD::CaloCluster_v1::inBarrel
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
Definition: CaloCluster_v1.h:896
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
python.xAODType.dummy
dummy
Definition: xAODType.py:4
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:55
xAOD::EgammaHelpers::isFwdElectron
bool isFwdElectron(const xAOD::Egamma *eg)
is the object a Fwd electron
Definition: EgammaxAODHelpers.cxx:17
xAOD::EgammaHelpers::summaryValueInt
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 whe...
Definition: EgammaxAODHelpers.cxx:161
CP::neutral
@ neutral
Definition: Reconstruction/PFlow/PFlowUtils/PFlowUtils/PFODefs.h:11
xAOD::EgammaHelpers::isFCAL
bool isFCAL(const xAOD::CaloCluster *cluster)
return true if the cluster (or the majority of its energy) is in the FCAL0
Definition: EgammaxAODHelpers.cxx:46
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
TrackParticle.h
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:79
xAOD::CaloCluster_v1::eSample
float eSample(const CaloSample sampling) const
Definition: CaloCluster_v1.cxx:521
xAOD::Photon_v1
Definition: Photon_v1.h:37
egammaEnergyPositionAllSamples::e2
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
xAOD::EgammaHelpers::isPhoton
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Definition: EgammaxAODHelpers.cxx:21
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
SG::ConstAccessor< T, AuxAllocator_t< T > >::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
merge.status
status
Definition: merge.py:17
Electron.h
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
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CP::charged
@ charged
Definition: Reconstruction/PFlow/PFlowUtils/PFlowUtils/PFODefs.h:11