ATLAS Offline Software
eflowRecCluster.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * eflowRecCluster.h
7  *
8  * Created on: 30.09.2013
9  * Author: tlodd
10  */
11 
12 #ifndef EFLOWRECCLUSTER_H_
13 #define EFLOWRECCLUSTER_H_
14 
15 #include <cassert>
16 #include <vector>
17 #include <utility>
18 
19 #include "CxxUtils/fpcompare.h"
20 
21 #include "AthLinks/ElementLink.h"
22 
25 
26 #include "CxxUtils/CachedValue.h"
29 class eflowMatchCluster;
30 
40 {
41 public:
43  const ElementLink<xAOD::CaloClusterContainer>& clusElementLink,
44  xAOD::CaloClusterContainer& newClusContainer);
45  eflowRecCluster(const eflowRecCluster& originalEflowRecCluster);
46  eflowRecCluster& operator=(const eflowRecCluster& originalEflowRecCluster) = delete;
47  virtual ~eflowRecCluster();
48 
50  const xAOD::CaloCluster* getCluster() const{ return m_cluster; }
51 
52 
53 
55  {
56  return m_clusElementLink;
57  }
59  {
61  }
62 
64 
65  double getSumExpectedEnergy();
67  bool isEOverPFail(bool consistencySigmaCut, bool useGoldenMode);
68 
70  {
71  m_trackMatches.push_back(trackMatch);
72  }
73  const std::vector<eflowTrackClusterLink*>& getTrackMatches() const
74  {
75  return m_trackMatches;
76  }
77  void clearTrackMatches() { m_trackMatches.clear(); }
78  int getNTracks() const { return m_trackMatches.size(); }
79  int getClusterId() const { return m_clusterId; }
80  void setClusterId(int clusterId) { m_clusterId = clusterId; }
81  void setCellsWeight(std::map<IdentifierHash, double> &&cellsWeight)
82  {
83  m_cellsWeightMap = std::move(cellsWeight);
84  }
85  const std::map<IdentifierHash, double>& getCellsWeight() const
86  {
87  return m_cellsWeightMap;
88  }
90  int getClusterType() const { return m_calorimeterType; }
91  bool isTouchable() const { return m_isTouchable; }
92 
93 private:
94  void setClusterType();
97  {
100  ECAL = 1,
101  HCAL = 2,
102  FCAL = 3,
103  UNKNOWN = 4,
104  CALORIMETER_END = 5
105  };
106 
113 
114 
115  /* for EM mode, LC weight for cells are retrieved before doing any
116  * subtraction; they will be used after subtraction */
117  std::map<IdentifierHash, double> m_cellsWeightMap;
118 
119  std::unique_ptr<eflowMatchCluster> m_matchCluster;
120  std::vector<eflowTrackClusterLink*> m_trackMatches;
121 
122 public:
124  {
125  public:
127  {
128  return CxxUtils::fpcompare::greater(a->getCluster()->pt(),
129  b->getCluster()->pt());
130  }
131  };
132 };
133 
140 {
141 public:
143  : m_efRecCluster(efRecCluster)
144  , m_cellEta{}
145  , m_cellPhi{}
149  , m_clusterEtaMean(0.0)
150  , m_clusterPhiMean(0.0)
153  , m_calVariance(false)
154  {
155  assert(m_efRecCluster);
156  }
157  virtual ~eflowMatchCluster() {}
158 
160  const eflowRecCluster* getEfRecCluster() const { return m_efRecCluster; }
161 
162  virtual double e() const { return m_clusterEne; }
163  virtual double eta() const { return m_clusterEta; }
164  virtual double phi() const { return m_clusterPhi; }
165  virtual double etaMean() const { return m_clusterEtaMean; }
166  virtual double phiMean() const { return m_clusterPhiMean; }
167  virtual double etaVariance() const { return m_clusterEtaVariance; }
168  virtual double phiVariance() const { return m_clusterPhiVariance; }
169  virtual bool calVarianceStatus() const { return m_calVariance; }
170  //
171  virtual void etaMean(double clusterEtaMean)
172  {
173  m_clusterEtaMean = clusterEtaMean;
174  }
175  virtual void phiMean(double clusterPhiMean)
176  {
177  m_clusterPhiMean = clusterPhiMean;
178  }
179  virtual void etaVariance(double clusterEtaVariance)
180  {
181  m_clusterEtaVariance = clusterEtaVariance;
182  }
183  virtual void phiVariance(double clusterPhiVariance)
184  {
185  m_clusterPhiVariance = clusterPhiVariance;
186  }
187  virtual void setCalVarianceStatus() { m_calVariance = true; }
188 
189  virtual unsigned int nCells() const
190  {
191  if (m_efRecCluster) {
192  const xAOD::CaloCluster* thisCluster = std::as_const(*m_efRecCluster).getCluster();
193  if (thisCluster)
194  return thisCluster->size();
195  // Logically if we have no valid pointer to xAOD::CaloCluster, we have no
196  // link to any CaloCells
197  else {
198  std::cerr
199  << "eflowMatchCluster ERROR: No valid link to xAOD::CaloCluster"
200  << std::endl;
201  return 0;
202  }
203  }
204  // Logically if we have no valid pointer to eflowRecCluster, we have no link
205  // to any CaloCells
206  else {
207  std::cerr << "eflowMatchCluster ERROR: No valid link to eflowRecCluster"
208  << std::endl;
209  return 0;
210  }
211  }
212  virtual const std::vector<double>& cellEta() const
213  {
214  if (!m_cellEta.isValid()) {
216  }
217  return *(m_cellEta.ptr());
218  }
219  virtual const std::vector<double>& cellPhi() const
220  {
221  if (!m_cellPhi.isValid()) {
223  }
224  return *(m_cellPhi.ptr());
225  }
226 
227 private:
228  void initCellPositions() const
229  {
230  std::vector<double> tmp_cellEta;
231  std::vector<double> tmp_cellPhi;
232  if (m_efRecCluster) {
233  const xAOD::CaloCluster* thisCluster = std::as_const(*m_efRecCluster).getCluster();
234  if (thisCluster) {
235  const CaloClusterCellLink* theCellLink = thisCluster->getCellLinks();
236  CaloClusterCellLink::const_iterator itCell = theCellLink->begin();
237  CaloClusterCellLink::const_iterator endCell = theCellLink->end();
238 
239  for (; itCell != endCell; ++itCell) {
240  const CaloCell* thisCell = *itCell;
241  tmp_cellEta.push_back(thisCell->eta());
242  tmp_cellPhi.push_back(thisCell->phi());
243  }
244  } else {
245  std::cerr
246  << "eflowMatchCluster ERROR: No valid link to xAOD::CaloCluster"
247  << std::endl;
248  }
249  } else {
250  std::cerr << "eflowMatchCluster ERROR: No valid link to eflowRecCluster"
251  << std::endl;
252  }
253  m_cellEta.set(std::move(tmp_cellEta));
254  m_cellPhi.set(std::move(tmp_cellPhi));
255  }
256 
260  double m_clusterEne;
261  double m_clusterEta;
262  double m_clusterPhi;
268 };
269 
271 #include "AthenaKernel/CLASS_DEF.h"
272 
273 class eflowRecClusterContainer : public DataVector<eflowRecCluster>
274 
275 {
276 
277 public:
278  void print(){};
279 };
280 
282 #endif /* EFLOWRECCLUSTER_H_ */
eflowRecCluster
This class extends the information about a xAOD::CaloCluster.
Definition: eflowRecCluster.h:40
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
eflowRecCluster::SortDescendingPt
Definition: eflowRecCluster.h:124
eflowRecCluster::m_cellsWeightMap
std::map< IdentifierHash, double > m_cellsWeightMap
Definition: eflowRecCluster.h:117
PFMatchInterfaces.h
CxxUtils::CachedValue::ptr
const T * ptr() const
Return a pointer to the cached value.
CaloCell::phi
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition: CaloCell.h:359
eflowRecCluster::setClusterType
void setClusterType()
Definition: eflowRecCluster.cxx:86
eflowRecCluster::m_calorimeterType
int m_calorimeterType
Definition: eflowRecCluster.h:108
eflowMatchCluster::etaMean
virtual void etaMean(double clusterEtaMean)
Definition: eflowRecCluster.h:171
eflowMatchCluster::m_efRecCluster
eflowRecCluster * m_efRecCluster
Definition: eflowRecCluster.h:257
eflowRecCluster::getClusterType
int getClusterType() const
Specifies if we have a cluster mainly in ECAL, HCAL or FCAL
Definition: eflowRecCluster.h:90
eflowRecCluster::addTrackMatch
void addTrackMatch(eflowTrackClusterLink *trackMatch)
Definition: eflowRecCluster.h:69
CxxUtils::CachedValue::isValid
bool isValid() const
Test to see if the value is valid.
eflowRecCluster::getTrackMatches
const std::vector< eflowTrackClusterLink * > & getTrackMatches() const
Definition: eflowRecCluster.h:73
eflowMatchCluster::m_calVariance
bool m_calVariance
Definition: eflowRecCluster.h:267
eflowRecCluster::getSumExpectedEnergy
double getSumExpectedEnergy()
Definition: eflowRecCluster.cxx:69
eflowRecClusterContainer
Definition: eflowRecCluster.h:275
eflowMatchCluster::m_clusterPhiMean
double m_clusterPhiMean
Definition: eflowRecCluster.h:264
eflowRecCluster::CalorimeterType
CalorimeterType
ENUM that defines calorimeter regions as ECAL, HCAL or FCAL
Definition: eflowRecCluster.h:97
eflowMatchCluster::e
virtual double e() const
Definition: eflowRecCluster.h:162
eflowMatchCluster::m_cellPhi
CxxUtils::CachedValue< std::vector< double > > m_cellPhi
Definition: eflowRecCluster.h:259
eflowMatchCluster::etaMean
virtual double etaMean() const
Definition: eflowRecCluster.h:165
eflowRecClusterContainer::print
void print()
Definition: eflowRecCluster.h:278
eflowMatchCluster::phiVariance
virtual double phiVariance() const
Definition: eflowRecCluster.h:168
eflowMatchCluster::m_clusterEne
double m_clusterEne
Definition: eflowRecCluster.h:260
eflowMatchCluster::phi
virtual double phi() const
Definition: eflowRecCluster.h:164
eflowRecCluster::getCellsWeight
const std::map< IdentifierHash, double > & getCellsWeight() const
Definition: eflowRecCluster.h:85
eflowMatchCluster::m_clusterPhi
double m_clusterPhi
Definition: eflowRecCluster.h:262
eflowRecCluster::getClusterId
int getClusterId() const
Definition: eflowRecCluster.h:79
eflowRecCluster::m_clusterId
int m_clusterId
Definition: eflowRecCluster.h:107
CxxUtils::fpcompare::greater
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:140
eflowMatchCluster::nCells
virtual unsigned int nCells() const
Definition: eflowRecCluster.h:189
eflowRecCluster::UNASSIGNED
@ UNASSIGNED
Definition: eflowRecCluster.h:99
eflowMatchCluster::phiVariance
virtual void phiVariance(double clusterPhiVariance)
Definition: eflowRecCluster.h:183
eflowMatchCluster::phiMean
virtual double phiMean() const
Definition: eflowRecCluster.h:166
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
PFMatch::ICluster
Definition: PFMatchInterfaces.h:37
eflowRecCluster::m_matchCluster
std::unique_ptr< eflowMatchCluster > m_matchCluster
Definition: eflowRecCluster.h:119
eflowMatchCluster::cellPhi
virtual const std::vector< double > & cellPhi() const
Definition: eflowRecCluster.h:219
eflowRecCluster::eflowRecCluster
eflowRecCluster(const ElementLink< xAOD::CaloClusterContainer > &clusElementLink, xAOD::CaloClusterContainer &newClusContainer)
Definition: eflowRecCluster.cxx:17
eflowRecCluster::CALORIMETER_START
@ CALORIMETER_START
Definition: eflowRecCluster.h:98
eflowRecCluster::m_clusElementLink
ElementLink< xAOD::CaloClusterContainer > m_clusElementLink
Definition: eflowRecCluster.h:111
eflowRecCluster::m_trackMatches
std::vector< eflowTrackClusterLink * > m_trackMatches
Definition: eflowRecCluster.h:120
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
CaloCluster.h
eflowMatchCluster::calVarianceStatus
virtual bool calVarianceStatus() const
Definition: eflowRecCluster.h:169
fpcompare.h
Workaround x86 precision issues for FP inequality comparisons.
eflowRecCluster::operator=
eflowRecCluster & operator=(const eflowRecCluster &originalEflowRecCluster)=delete
CxxUtils::CachedValue
Cached value with atomic update.
Definition: CachedValue.h:55
xAOD::CaloCluster_v1::size
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
Definition: CaloCluster_v1.cxx:996
eflowRecCluster::setCellsWeight
void setCellsWeight(std::map< IdentifierHash, double > &&cellsWeight)
Definition: eflowRecCluster.h:81
eflowRecCluster::getNTracks
int getNTracks() const
Definition: eflowRecCluster.h:78
eflowRecCluster::getCluster
xAOD::CaloCluster * getCluster()
Definition: eflowRecCluster.h:49
eflowRecCluster::getOriginalClusElementLink
ElementLink< xAOD::CaloClusterContainer > getOriginalClusElementLink() const
Definition: eflowRecCluster.h:58
eflowMatchCluster::etaVariance
virtual void etaVariance(double clusterEtaVariance)
Definition: eflowRecCluster.h:179
eflowMatchCluster::setCalVarianceStatus
virtual void setCalVarianceStatus()
Definition: eflowRecCluster.h:187
eflowMatchCluster::cellEta
virtual const std::vector< double > & cellEta() const
Definition: eflowRecCluster.h:212
eflowRecCluster::m_cluster
xAOD::CaloCluster * m_cluster
Definition: eflowRecCluster.h:109
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:905
eflowMatchCluster::getEfRecCluster
eflowRecCluster * getEfRecCluster()
Definition: eflowRecCluster.h:159
eflowRecCluster::UNKNOWN
@ UNKNOWN
Definition: eflowRecCluster.h:103
eflowRecCluster::CALORIMETER_END
@ CALORIMETER_END
Definition: eflowRecCluster.h:104
eflowMatchCluster::etaVariance
virtual double etaVariance() const
Definition: eflowRecCluster.h:167
eflowRecCluster::getMatchCluster
eflowMatchCluster * getMatchCluster() const
Definition: eflowRecCluster.h:63
eflowRecCluster::getCluster
const xAOD::CaloCluster * getCluster() const
Definition: eflowRecCluster.h:50
eflowRecCluster::isEOverPFail
bool isEOverPFail(bool consistencySigmaCut, bool useGoldenMode)
Definition: eflowRecCluster.cxx:53
CachedValue.h
Cached value with atomic update.
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
eflowRecCluster::~eflowRecCluster
virtual ~eflowRecCluster()
eflowRecCluster::isTouchable
bool isTouchable() const
Definition: eflowRecCluster.h:91
CxxUtils::CachedValue::set
void set(const T &val) const
Set the value, assuming it is currently invalid.
eflowRecCluster::m_originalClusElementLink
ElementLink< xAOD::CaloClusterContainer > m_originalClusElementLink
Definition: eflowRecCluster.h:110
eflowMatchCluster::m_clusterEta
double m_clusterEta
Definition: eflowRecCluster.h:261
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
a
TList * a
Definition: liststreamerinfos.cxx:10
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
eflowMatchCluster::initCellPositions
void initCellPositions() const
Definition: eflowRecCluster.h:228
eflowMatchCluster::getEfRecCluster
const eflowRecCluster * getEfRecCluster() const
Definition: eflowRecCluster.h:160
eflowMatchCluster::m_clusterPhiVariance
double m_clusterPhiVariance
Definition: eflowRecCluster.h:266
eflowMatchCluster
This class, which inherits from the pure virtual ICluster, stores a pointer to an eflowRecCluster.
Definition: eflowRecCluster.h:140
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
eflowMatchCluster::eta
virtual double eta() const
Definition: eflowRecCluster.h:163
CaloClusterContainer.h
eflowMatchCluster::phiMean
virtual void phiMean(double clusterPhiMean)
Definition: eflowRecCluster.h:175
eflowRecCluster::clearTrackMatches
void clearTrackMatches()
Definition: eflowRecCluster.h:77
eflowMatchCluster::~eflowMatchCluster
virtual ~eflowMatchCluster()
Definition: eflowRecCluster.h:157
eflowRecCluster::SortDescendingPt::operator()
bool operator()(const eflowRecCluster *a, const eflowRecCluster *b)
Definition: eflowRecCluster.h:126
eflowMatchCluster::eflowMatchCluster
eflowMatchCluster(eflowRecCluster *efRecCluster)
Definition: eflowRecCluster.h:142
eflowRecCluster::HCAL
@ HCAL
Definition: eflowRecCluster.h:101
eflowMatchCluster::m_clusterEtaMean
double m_clusterEtaMean
Definition: eflowRecCluster.h:263
CLASS_DEF.h
macros to associate a CLID to a type
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
eflowRecCluster::ECAL
@ ECAL
Definition: eflowRecCluster.h:100
eflowRecCluster::getClusElementLink
ElementLink< xAOD::CaloClusterContainer > getClusElementLink() const
Definition: eflowRecCluster.h:54
eflowMatchCluster::m_clusterEtaVariance
double m_clusterEtaVariance
Definition: eflowRecCluster.h:265
eflowRecCluster::getVarianceOfSumExpectedEnergy
double getVarianceOfSumExpectedEnergy()
Definition: eflowRecCluster.cxx:77
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366
eflowRecCluster::m_isTouchable
bool m_isTouchable
Definition: eflowRecCluster.h:112
eflowRecCluster::FCAL
@ FCAL
Definition: eflowRecCluster.h:102
eflowRecCluster::setClusterId
void setClusterId(int clusterId)
Definition: eflowRecCluster.h:80
eflowMatchCluster::m_cellEta
CxxUtils::CachedValue< std::vector< double > > m_cellEta
Definition: eflowRecCluster.h:258