ATLAS Offline Software
CaloTowerGeometry.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 #ifndef CALOREC_CALOTOWERGEOMETRY_H
3 #define CALOREC_CALOTOWERGEOMETRY_H
4 
5 /* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */
6 
8 
10 
11 #include "CaloDetDescr/CaloDetDescrElement.h"
13 
14 #include "GaudiKernel/MsgStream.h"
15 
16 #include <string>
17 #include <vector>
18 #include <cmath>
19 #include <array>
20 #include <tuple>
21 #include <fstream>
22 
24 public:
26  typedef std::size_t uint_t;
28  typedef std::tuple<index_t,double> element_t;
29  typedef std::vector<element_t> elementvector_t;
30  typedef std::vector<elementvector_t> elementmap_t;
31 
34 
36  CaloTowerGeometry(const CaloDetDescrManager* caloDDM);
37 
38  CaloTowerGeometry() = delete;
39  StatusCode initialize(MsgStream& msg);
40 
41  // --- Full documentation of this block after end of class definition!
44  StatusCode access(IdentifierHash cellHash,std::vector<index_t>& towerIdx,std::vector<double>& towerWghts) const;
47 
50  uint_t maxCellHash() const;
51  uint_t totalNumberCells() const;
52  uint_t etaBins() const;
53  double etaMin() const;
54  double etaMax() const;
55  double etaWidth() const;
56  uint_t phiBins() const;
57  double phiMin() const;
58  double phiMax() const;
59  double phiWidth() const;
60  uint_t towerBins() const;
61  double towerArea() const;
62 
67  index_t etaIndex(double eta) const;
68  index_t etaIndexFromTowerIndex(index_t towerIdx) const;
70  index_t phiIndex(double phi) const;
71  index_t phiIndexFromTowerIndex(index_t towerIdx) const;
73  index_t towerIndex(double eta,double phi) const;
74  index_t towerIndex(index_t etaIdx,index_t phiIdx) const;
75  index_t towerIndex(const element_t& elm) const;
76  index_t invalidIndex() const;
77  bool isInvalidIndex(index_t idx) const;
78  bool isInvalidIndex(index_t idx,index_t maxIdx) const;
79  bool isInvalidEtaIndex(index_t idx) const;
80  bool isInvalidPhiIndex(index_t idx) const;
81  bool isInvalidTowerIndex(index_t idx) const;
82 
86  double towerEtaLocal(index_t etaIndex) const;
87  double towerPhiLocal(index_t phiIndex) const;
88  double towerEta(index_t towerIndex) const;
89  double towerPhi(index_t towerIndex) const;
90  double invalidValue() const;
91  bool isInvalidValue(double val) const;
92 
96  double cellWeight(const element_t& elm) const;
97  double cellWeight(IdentifierHash cellHash,index_t towerIdx) const;
98 
102  elementmap_t::const_iterator begin() const;
103  elementmap_t::const_iterator end() const;
104  size_t size() const;
105  bool empty() const;
106 
108 private:
109 
112  StatusCode f_setupTowerGrid(MsgStream& msg);
113  StatusCode f_setupTowerGridFCal(const CaloDetDescrElement* pCaloDDE, MsgStream& msg);
114  StatusCode f_setupTowerGridProj(const CaloDetDescrElement* pCaloDDE, MsgStream& msg);
115  double f_assign(IdentifierHash cellHash,index_t towerIdx,double wgt);
116 
121 
123 protected:
124 
130  double m_towerArea;
134 
140  double m_towerEtaMin;
141  double m_towerEtaMax;
142  bool m_adjustEta;
144  double m_towerPhiMin;
145  double m_towerPhiMax;
146  double m_fcal1Xslice;
147  double m_fcal1Yslice;
148  double m_fcal2Xslice;
149  double m_fcal2Yslice;
150  double m_fcal3Xslice;
151  double m_fcal3Yslice;
152 
156  const static index_t m_invalidIndex;
157  const static double m_invalidValue;
158  const CaloDetDescrManager* f_caloDDM() const;
159 
161 
162  double f_cellEta(IdentifierHash cellHash) const;
163 
164  double f_cellPhi(IdentifierHash cellHash) const;
165 
169  std::array<double,3> m_ndxFCal{};
170  std::array<double,3> m_ndyFCal{};
171  std::array<double,3> m_wgtFCal{};
172 };
174 
175 #include "AthenaKernel/CLASS_DEF.h"
176 CLASS_DEF( CaloTowerGeometry, 9072807, 1 )
177 #include "AthenaKernel/CondCont.h"
179 
180 
181 
182 //-------------------------------------------------//
183 // Documentation for grouped methods and functions //
184 // (removed from before/after method for better //
185 // formatting by doxygen in html). //
186 //-------------------------------------------------//
187 
200 
209 
210 //---------------------//
211 // Class documentation //
212 //---------------------//
213 
267 
268 //------------------//
269 // Inline Functions //
270 //------------------//
271 
272 //---------------------------//
273 // Control and configuration //
274 //---------------------------//
276 
277 //------------------------------------//
278 // Public access to tower descriptors //
279 //------------------------------------//
282 
284 inline double CaloTowerGeometry::etaMin() const { return m_towerEtaMin; }
285 inline double CaloTowerGeometry::etaMax() const { return m_towerEtaMax; }
286 inline double CaloTowerGeometry::etaWidth() const { return m_towerEtaWidth; }
287 
289 inline double CaloTowerGeometry::phiMin() const { return m_towerPhiMin; }
290 inline double CaloTowerGeometry::phiMax() const { return m_towerPhiMax; }
291 inline double CaloTowerGeometry::phiWidth() const { return m_towerPhiWidth; }
292 
294 inline double CaloTowerGeometry::towerArea() const { return m_towerArea; }
295 
296 //----------------//
297 // Index checking //
298 //----------------//
299 inline bool CaloTowerGeometry::isInvalidIndex(index_t idx) const { return idx == invalidIndex(); }
300 inline bool CaloTowerGeometry::isInvalidIndex(index_t idx,index_t maxIdx) const { return idx == invalidIndex() || idx >= maxIdx; }
304 
305 //------------------------------//
306 // Index retrieval/construction //
307 //------------------------------//
308 
311 inline CaloTowerGeometry::index_t CaloTowerGeometry::towerIndex(index_t etaIdx,index_t phiIdx) const { return !isInvalidEtaIndex(etaIdx) && !isInvalidPhiIndex(phiIdx) ? phiIdx+etaIdx*m_towerPhiBins : invalidIndex(); }
312 
313 inline CaloTowerGeometry::index_t CaloTowerGeometry::towerIndex(const element_t& elm) const { return std::get<0>(elm); }
314 
317 
318 //-----------------------------//
319 // Access to tower description //
320 //-----------------------------//
321 
322 inline double CaloTowerGeometry::invalidValue() const { return m_invalidValue; }
323 inline bool CaloTowerGeometry::isInvalidValue(double val) const { return val == invalidValue(); }
324 inline double CaloTowerGeometry::towerEtaLocal(index_t etaIdx) const { return !isInvalidEtaIndex(etaIdx) ? etaMin()+(static_cast<double>(etaIdx)+0.5)*etaWidth() : invalidValue(); }
325 inline double CaloTowerGeometry::towerPhiLocal(index_t phiIdx) const { return !isInvalidPhiIndex(phiIdx) ? phiMin()+(static_cast<double>(phiIdx)+0.5)*phiWidth() : invalidValue(); }
326 inline double CaloTowerGeometry::towerEta(index_t towerIdx) const { return towerEtaLocal(etaIndexFromTowerIndex(towerIdx)); }
327 inline double CaloTowerGeometry::towerPhi(index_t towerIdx) const { return towerPhiLocal(phiIndexFromTowerIndex(towerIdx)); }
328 
329 inline CaloTowerGeometry::elementmap_t::const_iterator CaloTowerGeometry::begin() const { return m_towerLookup.begin(); }
330 inline CaloTowerGeometry::elementmap_t::const_iterator CaloTowerGeometry::end() const { return m_towerLookup.end(); }
331 inline size_t CaloTowerGeometry::size() const { return m_towerLookup.size(); }
332 inline bool CaloTowerGeometry::empty() const { return m_towerLookup.empty(); }
333 
334 //-------------------//
335 // Other data access //
336 //-------------------//
337 inline double CaloTowerGeometry::cellWeight(const element_t& elm) const { return std::get<1>(elm); }
338 
339 
340 //----------------------------------//
341 // Internal functions and accessors //
342 //----------------------------------//
345 
348 
349 #endif
CaloTowerGeometry::m_fcal2Yslice
double m_fcal2Yslice
Number of y slices for cells in FCal2.
Definition: CaloTowerGeometry.h:149
IdentifierHash::value_type
unsigned int value_type
Definition: IdentifierHash.h:48
CaloTowerGeometry::size
size_t size() const
Size of internal look-up table.
Definition: CaloTowerGeometry.h:331
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloTowerGeometry::f_cellEta
double f_cellEta(IdentifierHash cellHash) const
Retrieve calorimeter cell pseudorapidity for a given cell hash identifier.
Definition: CaloTowerGeometry.h:346
CaloTowerGeometry::towerPhiLocal
double towerPhiLocal(index_t phiIndex) const
Return azimuth from local index (bin center)
Definition: CaloTowerGeometry.h:325
CaloTowerGeometry::isInvalidEtaIndex
bool isInvalidEtaIndex(index_t idx) const
Returns true if argument is not a valid pseudorapidity index.
Definition: CaloTowerGeometry.h:301
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CaloTowerGeometry::isInvalidTowerIndex
bool isInvalidTowerIndex(index_t idx) const
Returns true if argument is not a valid tower index.
Definition: CaloTowerGeometry.h:303
CaloTowerGeometry::etaWidth
double etaWidth() const
Width of pseudorapidity bin
Definition: CaloTowerGeometry.h:286
CaloTowerGeometry::m_towerEtaWidth
double m_towerEtaWidth
Width of tower bin in pseudorapidity.
Definition: CaloTowerGeometry.h:128
CaloTowerGeometry::index_t
IdentifierHash::value_type index_t
Type for scalar (pseudorapidity,azimuth) index (is an unsigned int type)
Definition: CaloTowerGeometry.h:27
CaloTowerGeometry::access
StatusCode access(IdentifierHash cellHash, std::vector< index_t > &towerIdx, std::vector< double > &towerWghts) const
Retrieve the list of towers associated with a calorimeter cell referenced its hash identifier.
Definition: CaloTowerGeometry.cxx:234
CaloTowerGeometry::phiMax
double phiMax() const
Upper boundary of azimuth.
Definition: CaloTowerGeometry.h:290
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloTowerGeometry::m_fcal1Yslice
double m_fcal1Yslice
Number of y slices for cells in FCal1.
Definition: CaloTowerGeometry.h:147
CaloTowerGeometry::elementvector_t
std::vector< element_t > elementvector_t
Type for list of elements holding tower index and list of weights.
Definition: CaloTowerGeometry.h:29
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
CaloTowerGeometry::phiBins
uint_t phiBins() const
Number of azimuth bins.
Definition: CaloTowerGeometry.h:288
CaloTowerGeometry::isInvalidPhiIndex
bool isInvalidPhiIndex(index_t idx) const
Returns true if argumant is not a valid azimuth index.
Definition: CaloTowerGeometry.h:302
CaloTowerGeometry::f_setupTowerGridProj
StatusCode f_setupTowerGridProj(const CaloDetDescrElement *pCaloDDE, MsgStream &msg)
Internally used function mapping a projective cell onto the tower grid.
Definition: CaloTowerGeometry.cxx:170
CaloTowerGeometry::m_caloDDM
const CaloDetDescrManager * m_caloDDM
Pointer to calorimeter detector description.
Definition: CaloTowerGeometry.h:120
CaloTowerGeometry::m_towerEtaMax
double m_towerEtaMax
Upper boundary .
Definition: CaloTowerGeometry.h:141
CaloTowerGeometry::phiMin
double phiMin() const
Lower boundary of azimuth.
Definition: CaloTowerGeometry.h:289
CaloTowerGeometry::towerPhi
double towerPhi(index_t towerIndex) const
Return azimuth from global tower index (bin center)
Definition: CaloTowerGeometry.h:327
CaloTowerGeometry::f_caloDDE
const CaloDetDescrElement * f_caloDDE(IdentifierHash cellHash) const
Retrieve calorimeter detector description element for a given cell hash identifier.
Definition: CaloTowerGeometry.h:344
CaloTowerGeometry::elementmap_t
std::vector< elementvector_t > elementmap_t
Type for lists of lists of elements (lookup table type)
Definition: CaloTowerGeometry.h:30
CaloTowerGeometry::m_towerBins
uint_t m_towerBins
Maximum number of towers.
Definition: CaloTowerGeometry.h:131
CaloTowerGeometry::towerArea
double towerArea() const
Area of individual tower.
Definition: CaloTowerGeometry.h:294
CaloTowerGeometry::etaMin
double etaMin() const
Lower boundary of pseudorapidity range.
Definition: CaloTowerGeometry.h:284
CaloTowerGeometry::end
elementmap_t::const_iterator end() const
Iterator marks end of internal look-up table (only const access)
Definition: CaloTowerGeometry.h:330
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
CaloTowerGeometry::m_ndyFCal
std::array< double, 3 > m_ndyFCal
Stores number of fragments along y for each FCal module.
Definition: CaloTowerGeometry.h:170
CaloTowerGeometry::m_maxCellHash
uint_t m_maxCellHash
Maximum cell hash value.
Definition: CaloTowerGeometry.h:132
CaloTowerGeometry::f_cellPhi
double f_cellPhi(IdentifierHash cellHash) const
Retrieve calorimeter cell azimuth for a given cell hash identifier.
Definition: CaloTowerGeometry.h:347
CaloTowerGeometry::CaloTowerGeometry
CaloTowerGeometry()=delete
CaloTowerGeometry::maxCellHash
uint_t maxCellHash() const
Maximum cell hash value.
Definition: CaloTowerGeometry.h:280
CaloTowerGeometry::m_towerPhiMin
double m_towerPhiMin
Lower boundary .
Definition: CaloTowerGeometry.h:144
CONDCONT_DEF
CONDCONT_DEF(CaloTowerGeometry, 52208619)
CaloTowerGeometry::etaIndexFromTowerIndex
index_t etaIndexFromTowerIndex(index_t towerIdx) const
Get tower bin index for a given global tower index.
Definition: CaloTowerGeometry.h:315
CaloTowerGeometry::phiIndex
index_t phiIndex(IdentifierHash cellHash) const
Get tower bin index for a calorimeter cell referenced by its hash identifier.
Definition: CaloTowerGeometry.cxx:300
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloTowerGeometry::etaIndex
index_t etaIndex(IdentifierHash cellHash) const
Get tower bin index for a calorimeter cell referenced by its hash identifier.
Definition: CaloTowerGeometry.cxx:287
CaloTowerGeometry::m_towerPhiMax
double m_towerPhiMax
Upper boundary .
Definition: CaloTowerGeometry.h:145
CaloTowerGeometry::towerEta
double towerEta(index_t towerIndex) const
Return pseudorapidity from global tower index (bin center)
Definition: CaloTowerGeometry.h:326
CaloTowerGeometry::etaBins
uint_t etaBins() const
Number of pseudorapidity bins.
Definition: CaloTowerGeometry.h:283
CaloTowerGeometry::m_fcal3Xslice
double m_fcal3Xslice
Number of x slices for cells in FCal3.
Definition: CaloTowerGeometry.h:150
CaloPhiRange.h
CaloPhiRange class declaration.
CaloTowerGeometry::phiWidth
double phiWidth() const
Width of azimuth bin.
Definition: CaloTowerGeometry.h:291
CaloTowerGeometry::towerEtaLocal
double towerEtaLocal(index_t etaIndex) const
Return pseudorapdity from local index (bin center)
Definition: CaloTowerGeometry.h:324
CaloTowerGeometry::isInvalidValue
bool isInvalidValue(double val) const
Return true if given value is invalid.
Definition: CaloTowerGeometry.h:323
CaloTowerGeometry::uint_t
std::size_t uint_t
Type for unsigned integer.
Definition: CaloTowerGeometry.h:26
CaloTowerGeometry::f_caloDDM
const CaloDetDescrManager * f_caloDDM() const
Pointer to calorimeter detector description manager.
Definition: CaloTowerGeometry.h:343
CaloTowerGeometryCondAlg
Definition: CaloTowerGeometryCondAlg.h:13
WriteCellNoiseToCool.cellHash
cellHash
Definition: WriteCellNoiseToCool.py:433
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
CaloTowerGeometry::empty
bool empty() const
Internal look-up table is empty if true.
Definition: CaloTowerGeometry.h:332
CaloTowerGeometry::towerBins
uint_t towerBins() const
Total number of towers.
Definition: CaloTowerGeometry.h:293
CaloTowerGeometry::m_numberOfCells
uint_t m_numberOfCells
Total number of cells.
Definition: CaloTowerGeometry.h:133
IdentifierHash.h
CaloTowerGeometry
Tower geometry store and description provider.
Definition: CaloTowerGeometry.h:23
CaloTowerGeometry::m_towerLookup
elementmap_t m_towerLookup
Cell-to-tower mapping lookup store.
Definition: CaloTowerGeometry.h:127
CaloTowerGeometry::f_setupTowerGridFCal
StatusCode f_setupTowerGridFCal(const CaloDetDescrElement *pCaloDDE, MsgStream &msg)
Internally used function mapping an FCal cell onto the tower grid.
Definition: CaloTowerGeometry.cxx:96
CaloTowerGeometry::f_setupTowerGrid
StatusCode f_setupTowerGrid(MsgStream &msg)
Internally used function setting up the lookup store.
Definition: CaloTowerGeometry.cxx:61
CaloTowerGeometry::m_towerEtaBins
uint_t m_towerEtaBins
Number of bins.
Definition: CaloTowerGeometry.h:139
CaloTowerGeometry::element_t
std::tuple< index_t, double > element_t
Type storing tower index and geometrical weight.
Definition: CaloTowerGeometry.h:28
CaloTowerGeometry::m_fcal1Xslice
double m_fcal1Xslice
Number of x slices for cells in FCal1.
Definition: CaloTowerGeometry.h:146
CaloTowerGeometry::towerIndex
index_t towerIndex(IdentifierHash cellHash) const
Get global tower index for a calorimeter cell referenced by its hash identifier.
Definition: CaloTowerGeometry.h:309
CaloTowerGeometry::totalNumberCells
uint_t totalNumberCells() const
Total number of cells.
Definition: CaloTowerGeometry.h:281
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
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
CaloTowerGeometry::m_fcal2Xslice
double m_fcal2Xslice
Number of x slices for cells in FCal2.
Definition: CaloTowerGeometry.h:148
CaloTowerGeometry::begin
elementmap_t::const_iterator begin() const
Iterator points to first entry in internal look-up table (only const access!)
Definition: CaloTowerGeometry.h:329
CaloTowerGeometry::m_adjustEta
bool m_adjustEta
Adjust FCal cells to eta boundary (default true )
Definition: CaloTowerGeometry.h:142
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
CaloTowerGeometry::initialize
StatusCode initialize(MsgStream &msg)
Initialize object.
Definition: CaloTowerGeometry.cxx:32
CaloTowerGeometry::m_towerEtaMin
double m_towerEtaMin
Lower boundary .
Definition: CaloTowerGeometry.h:140
CaloTowerGeometry::f_assign
double f_assign(IdentifierHash cellHash, index_t towerIdx, double wgt)
Internally used function assigning tower to cell with update of weight if same tower is already assig...
Definition: CaloTowerGeometry.cxx:218
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloTowerGeometry::m_towerPhiWidth
double m_towerPhiWidth
Width of tower bin in azimuth.
Definition: CaloTowerGeometry.h:129
CaloTowerGeometry::m_invalidIndex
static const index_t m_invalidIndex
Invalid index indicator.
Definition: CaloTowerGeometry.h:156
IdentifierHash
Definition: IdentifierHash.h:38
CaloTowerGeometry::m_fcal3Yslice
double m_fcal3Yslice
Number of y slices for cells in FCal3.
Definition: CaloTowerGeometry.h:151
CaloTowerGeometry::etaMax
double etaMax() const
Upper boundary of pseudorapidity range.
Definition: CaloTowerGeometry.h:285
CaloTowerGeometry::phiIndexFromTowerIndex
index_t phiIndexFromTowerIndex(index_t towerIdx) const
Get tower bin index for a given global tower index.
Definition: CaloTowerGeometry.h:316
CaloTowerGeometry::cellWeight
double cellWeight(const element_t &elm) const
Retrieve cell signal weight from lookup table entry.
Definition: CaloTowerGeometry.h:337
CaloTowerGeometry::invalidValue
double invalidValue() const
Return invalid value.
Definition: CaloTowerGeometry.h:322
CaloTowerGeometry::m_wgtFCal
std::array< double, 3 > m_wgtFCal
Stores geometrical weights.
Definition: CaloTowerGeometry.h:171
CaloTowerGeometry::getTowers
elementvector_t getTowers(IdentifierHash cellHash) const
Retrieve the list of towers associated with a calorimeter cell referenced by its hash identifier.
Definition: CaloTowerGeometry.cxx:254
CaloTowerGeometry::invalidIndex
index_t invalidIndex() const
Returns value of invalid index.
Definition: CaloTowerGeometry.h:275
CLASS_DEF.h
macros to associate a CLID to a type
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
CaloTowerGeometry::m_invalidValue
static const double m_invalidValue
Return value for out-of-range indices andother invalid conversions to a physical quantity.
Definition: CaloTowerGeometry.h:157
CaloTowerGeometry::isInvalidIndex
bool isInvalidIndex(index_t idx) const
Returns true if argument is equal to the value provided by invalidIndex()
Definition: CaloTowerGeometry.h:299
CaloTowerGeometry::m_towerArea
double m_towerArea
Area of individual tower.
Definition: CaloTowerGeometry.h:130
CaloTowerGeometry::m_ndxFCal
std::array< double, 3 > m_ndxFCal
Stores number of fragments along x for each FCal module.
Definition: CaloTowerGeometry.h:169
CaloTowerGeometry::m_towerPhiBins
uint_t m_towerPhiBins
Number of bins.
Definition: CaloTowerGeometry.h:143