ATLAS Offline Software
EgammaxAODHelpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 
12 
14  return ( (eg->type()==xAOD::Type::Electron) &&
16 }
17 // ==================================================================
20 }
21 // ==================================================================
23  return (eg->type()==xAOD::Type::Photon);
24 }
25 // ==================================================================
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 xAOD::EgammaHelpers::isConvertedPhoton(ph,excludeTRT);
32 }
33 // ==================================================================
35  return (eg ? isBarrel(eg->caloCluster()) : false);
36 }
37 // ==================================================================
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 }
46 // ==================================================================
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 }
55 // ==================================================================
56 std::vector< ElementLink< xAOD::CaloClusterContainer > > xAOD::EgammaHelpers::getAssociatedTopoClustersLinks(const xAOD::CaloCluster *cluster){
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 }
65 // ==================================================================
66 std::vector<const xAOD::CaloCluster*> xAOD::EgammaHelpers::getAssociatedTopoClusters(const xAOD::CaloCluster *cluster){
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 }
79 // ==================================================================
80 std::vector< ElementLink< xAOD::FlowElementContainer > > xAOD::EgammaHelpers::getAssociatedFlowElementsLinks(const xAOD::Egamma *eg,
81  bool neutral){
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 }
92 // ==================================================================
93 std::vector<const xAOD::FlowElement*> xAOD::EgammaHelpers::getAssociatedFlowElements(const xAOD::Egamma *eg,
94  bool neutral, bool charged){
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 }
120 // ==================================================================
121 std::set<const xAOD::TrackParticle*> xAOD::EgammaHelpers::getTrackParticles(const xAOD::Egamma *eg,
122  bool useBremAssoc /* = true */,
123  bool allParticles /* = true */){
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 }
141 // ==================================================================
142 std::vector<const xAOD::TrackParticle*> xAOD::EgammaHelpers::getTrackParticlesVec(const xAOD::Egamma *eg,
143  bool useBremAssoc /* = true */,
144  bool allParticles /* = true */){
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 }
161 // ==================================================================
163  const xAOD::SummaryType& info,
164  int deflt /* = -999 */){
165  uint8_t dummy(0);
166  return (tp.summaryValue(dummy, info) ? dummy : deflt);
167 }
168 // ==================================================================
170  const xAOD::SummaryType& info,
171  float deflt /* = -999. */){
172  float dummy(0);
173  return (tp.summaryValue(dummy, info) ? dummy : deflt);
174 }
175 
176 // ==================================================================
178  double& e2, double& e3) {
179 
180  const static SG::AuxElement::ConstAccessor<float> acc_Eadded_s2("Eadded_Lr2");
181  const static SG::AuxElement::ConstAccessor<float> acc_Eadded_s3("Eadded_Lr3");
182 
183  unsigned short status = 0;
184  if (acc_Eadded_s2.isAvailable(eg))
185  { e2 = acc_Eadded_s2(eg); }
186  else
187  { status += 1; }
188  if (acc_Eadded_s3.isAvailable(eg))
189  { e3 = acc_Eadded_s3(eg); }
190  else
191  { status += 2; }
192  return status;
193 }
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:177
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:169
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:66
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
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:93
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:121
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
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::isBarrel
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel
Definition: EgammaxAODHelpers.cxx:34
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:26
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:92
CaloCluster.h
Photon.h
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:13
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:56
xAOD::EgammaHelpers::isFwdElectron
bool isFwdElectron(const xAOD::Egamma *eg)
is the object a Fwd electron
Definition: EgammaxAODHelpers.cxx:18
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:162
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:47
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:80
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:22
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