ATLAS Offline Software
Loading...
Searching...
No Matches
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
24public:
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;
32
34
37
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;
63
66 index_t etaIndex(IdentifierHash cellHash) const;
67 index_t etaIndex(double eta) const;
68 index_t etaIndexFromTowerIndex(index_t towerIdx) const;
69 index_t phiIndex(IdentifierHash cellHash) const;
70 index_t phiIndex(double phi) const;
71 index_t phiIndexFromTowerIndex(index_t towerIdx) const;
72 index_t towerIndex(IdentifierHash cellHash) 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;
83
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;
93
96 double cellWeight(const element_t& elm) const;
97 double cellWeight(IdentifierHash cellHash,index_t towerIdx) const;
99
102 elementmap_t::const_iterator begin() const;
103 elementmap_t::const_iterator end() const;
104 size_t size() const;
105 bool empty() const;
107
108private:
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);
117
122
123protected:
124
130 double m_towerArea;
135
153
156 const static index_t m_invalidIndex;
157 const static double m_invalidValue;
158 const CaloDetDescrManager* f_caloDDM() const;
159
160 const CaloDetDescrElement* f_caloDDE(IdentifierHash cellHash) const;
161
162 double f_cellEta(IdentifierHash cellHash) const;
163
164 double f_cellPhi(IdentifierHash cellHash) const;
166
169 std::array<double,3> m_ndxFCal{};
170 std::array<double,3> m_ndyFCal{};
171 std::array<double,3> m_wgtFCal{};
173};
174
176CLASS_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
284inline double CaloTowerGeometry::etaMin() const { return m_towerEtaMin; }
285inline double CaloTowerGeometry::etaMax() const { return m_towerEtaMax; }
286inline double CaloTowerGeometry::etaWidth() const { return m_towerEtaWidth; }
287
289inline double CaloTowerGeometry::phiMin() const { return m_towerPhiMin; }
290inline double CaloTowerGeometry::phiMax() const { return m_towerPhiMax; }
291inline double CaloTowerGeometry::phiWidth() const { return m_towerPhiWidth; }
292
294inline double CaloTowerGeometry::towerArea() const { return m_towerArea; }
295
296//----------------//
297// Index checking //
298//----------------//
299inline bool CaloTowerGeometry::isInvalidIndex(index_t idx) const { return idx == invalidIndex(); }
300inline bool CaloTowerGeometry::isInvalidIndex(index_t idx,index_t maxIdx) const { return idx == invalidIndex() || idx >= maxIdx; }
304
305//------------------------------//
306// Index retrieval/construction //
307//------------------------------//
308
311inline CaloTowerGeometry::index_t CaloTowerGeometry::towerIndex(index_t etaIdx,index_t phiIdx) const { return !isInvalidEtaIndex(etaIdx) && !isInvalidPhiIndex(phiIdx) ? phiIdx+etaIdx*m_towerPhiBins : invalidIndex(); }
312
313inline 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
322inline double CaloTowerGeometry::invalidValue() const { return m_invalidValue; }
323inline bool CaloTowerGeometry::isInvalidValue(double val) const { return val == invalidValue(); }
324inline double CaloTowerGeometry::towerEtaLocal(index_t etaIdx) const { return !isInvalidEtaIndex(etaIdx) ? etaMin()+(static_cast<double>(etaIdx)+0.5)*etaWidth() : invalidValue(); }
325inline double CaloTowerGeometry::towerPhiLocal(index_t phiIdx) const { return !isInvalidPhiIndex(phiIdx) ? phiMin()+(static_cast<double>(phiIdx)+0.5)*phiWidth() : invalidValue(); }
326inline double CaloTowerGeometry::towerEta(index_t towerIdx) const { return towerEtaLocal(etaIndexFromTowerIndex(towerIdx)); }
327inline double CaloTowerGeometry::towerPhi(index_t towerIdx) const { return towerPhiLocal(phiIndexFromTowerIndex(towerIdx)); }
328
329inline CaloTowerGeometry::elementmap_t::const_iterator CaloTowerGeometry::begin() const { return m_towerLookup.begin(); }
330inline CaloTowerGeometry::elementmap_t::const_iterator CaloTowerGeometry::end() const { return m_towerLookup.end(); }
331inline size_t CaloTowerGeometry::size() const { return m_towerLookup.size(); }
332inline bool CaloTowerGeometry::empty() const { return m_towerLookup.empty(); }
333
334//-------------------//
335// Other data access //
336//-------------------//
337inline double CaloTowerGeometry::cellWeight(const element_t& elm) const { return std::get<1>(elm); }
338
339
340//----------------------------------//
341// Internal functions and accessors //
342//----------------------------------//
344inline const CaloDetDescrElement* CaloTowerGeometry::f_caloDDE(IdentifierHash cellHash) const { return f_caloDDM()->get_element(cellHash); }
345
346inline double CaloTowerGeometry::f_cellEta(IdentifierHash cellHash) const { return f_caloDDE(cellHash)->eta(); }
347inline double CaloTowerGeometry::f_cellPhi(IdentifierHash cellHash) const { return CaloPhiRange::fix(f_caloDDE(cellHash)->phi()); }
348
349#endif
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Definition of CaloDetDescrManager.
CaloPhiRange class declaration.
#define CONDCONT_DEF(...)
Definition CondCont.h:1413
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
static double fix(double phi)
Retrieve the list of towers associated with a calorimeter cell referenced by its hash identifier.
index_t invalidIndex() const
Returns value of invalid index.
double m_fcal3Xslice
Number of x slices for cells in FCal3.
uint_t m_towerBins
Maximum number of towers.
index_t towerIndex(IdentifierHash cellHash) const
Get global tower index for a calorimeter cell referenced by its hash identifier.
double phiWidth() const
Width of azimuth bin.
double m_fcal2Yslice
Number of y slices for cells in FCal2.
double m_fcal2Xslice
Number of x slices for cells in FCal2.
IdentifierHash::value_type index_t
Type for scalar (pseudorapidity,azimuth) index (is an unsigned int type)
friend class CaloTowerGeometryCondAlg
uint_t etaBins() const
Number of pseudorapidity bins.
static const index_t m_invalidIndex
Invalid index indicator.
double m_fcal3Yslice
Number of y slices for cells in FCal3.
elementmap_t::const_iterator begin() const
Iterator points to first entry in internal look-up table (only const access!)
uint_t m_maxCellHash
Maximum cell hash value.
double towerEtaLocal(index_t etaIndex) const
Return pseudorapdity from local index (bin center)
uint_t totalNumberCells() const
Total number of cells.
double m_towerPhiMin
Lower boundary .
uint_t m_towerPhiBins
Number of bins.
CaloTowerGeometry()=delete
bool isInvalidValue(double val) const
Return true if given value is invalid.
double phiMax() const
Upper boundary of azimuth.
std::vector< elementvector_t > elementmap_t
Type for lists of lists of elements (lookup table type)
index_t etaIndex(IdentifierHash cellHash) const
Get tower bin index for a calorimeter cell referenced by its hash identifier.
StatusCode f_setupTowerGridFCal(const CaloDetDescrElement *pCaloDDE, MsgStream &msg)
Internally used function mapping an FCal cell onto the tower grid.
double m_towerPhiMax
Upper boundary .
uint_t m_towerEtaBins
Internally stored tower grid descriptors.
bool isInvalidTowerIndex(index_t idx) const
Returns true if argument is not a valid tower index.
double towerPhiLocal(index_t phiIndex) const
Return azimuth from local index (bin center)
index_t phiIndex(IdentifierHash cellHash) const
Get tower bin index for a calorimeter cell referenced by its hash identifier.
double m_fcal1Yslice
Number of y slices for cells in FCal1.
std::size_t uint_t
Type for unsigned integer.
double m_towerPhiWidth
Width of tower bin in azimuth.
uint_t m_numberOfCells
Total number of cells.
index_t phiIndexFromTowerIndex(index_t towerIdx) const
Get tower bin index for a given global tower index.
double towerEta(index_t towerIndex) const
Return pseudorapidity from global tower index (bin center)
std::array< double, 3 > m_ndxFCal
Stores number of fragments along x for each FCal module.
const CaloDetDescrElement * f_caloDDE(IdentifierHash cellHash) const
Retrieve calorimeter detector description element for a given cell hash identifier.
double f_cellPhi(IdentifierHash cellHash) const
Retrieve calorimeter cell azimuth for a given cell hash identifier.
size_t size() const
Size of internal look-up table.
double m_towerEtaMin
Lower boundary .
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...
const CaloDetDescrManager * f_caloDDM() const
Pointer to calorimeter detector description manager.
elementmap_t::const_iterator end() const
Iterator marks end of internal look-up table (only const access)
CaloTowerGeometry(const CaloDetDescrManager *caloDDM)
Standard constructor.
double etaWidth() const
Width of pseudorapidity bin.
elementmap_t m_towerLookup
Cell-to-tower mapping lookup store.
double etaMin() const
Lower boundary of pseudorapidity range.
std::array< double, 3 > m_wgtFCal
Stores geometrical weights.
const CaloDetDescrManager * m_caloDDM
Pointer to calorimeter detector description.
std::array< double, 3 > m_ndyFCal
Stores number of fragments along y for each FCal module.
uint_t towerBins() const
Total number of towers.
double etaMax() const
Upper boundary of pseudorapidity range.
StatusCode access(IdentifierHash cellHash, std::vector< index_t > &towerIdx, std::vector< double > &towerWghts) const
double cellWeight(const element_t &elm) const
Retrieve cell signal weight from lookup table entry.
bool isInvalidEtaIndex(index_t idx) const
Returns true if argument is not a valid pseudorapidity index.
std::tuple< index_t, double > element_t
Type storing tower index and geometrical weight.
uint_t phiBins() const
Number of azimuth bins.
double m_towerEtaWidth
Width of tower bin in pseudorapidity.
double m_fcal1Xslice
Number of x slices for cells in FCal1.
double m_towerArea
Area of individual tower.
StatusCode f_setupTowerGrid(MsgStream &msg)
Internally used function setting up the lookup store.
bool isInvalidPhiIndex(index_t idx) const
Returns true if argumant is not a valid azimuth index.
bool m_adjustEta
Adjust FCal cells to eta boundary (default true )
StatusCode f_setupTowerGridProj(const CaloDetDescrElement *pCaloDDE, MsgStream &msg)
Internally used function mapping a projective cell onto the tower grid.
std::vector< element_t > elementvector_t
Type for list of elements holding tower index and list of weights.
bool empty() const
Internal look-up table is empty if true.
double towerPhi(index_t towerIndex) const
Return azimuth from global tower index (bin center)
double invalidValue() const
Return invalid value.
bool isInvalidIndex(index_t idx) const
Returns true if argument is equal to the value provided by invalidIndex()
double towerArea() const
Area of individual tower.
double f_cellEta(IdentifierHash cellHash) const
Retrieve calorimeter cell pseudorapidity for a given cell hash identifier.
static const double m_invalidValue
Return value for out-of-range indices andother invalid conversions to a physical quantity.
elementvector_t getTowers(IdentifierHash cellHash) const
Retrieve the list of towers associated with a calorimeter cell referenced its hash identifier.
index_t etaIndexFromTowerIndex(index_t towerIdx) const
Get tower bin index for a given global tower index.
double m_towerEtaMax
Upper boundary .
double phiMin() const
Lower boundary of azimuth.
uint_t maxCellHash() const
Maximum cell hash value.
This is a "hash" representation of an Identifier.
unsigned int value_type
void initialize()
MsgStream & msg
Definition testRead.cxx:32