ATLAS Offline Software
CaloCellContainer.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef CALOEVENT_CALOCELLCONTAINER_H
8 #define CALOEVENT_CALOCELLCONTAINER_H
9 
30 /********************************************************************
31 
32 NAME: CaloCellContainer.h
33 PACKAGE: offline/Calorimeter/CaloRec
34 
35 AUTHORS: S. Rajagopalan
36 CREATED: April 2001
37 
38 PURPOSE: Container for CaloCell - stored as DataObject in TDS.
39 MODIFIED: David Rousseau: heavy modification to allow storing all
40  calorimeter cells in one single container
41 ********************************************************************/
42 
44 #include "AthenaKernel/CLASS_DEF.h"
45 #include "CaloEvent/CaloCell.h"
46 
49 #include "CxxUtils/PackedArray.h"
50 #include "CxxUtils/CachedValue.h"
52 
53 
54 class CaloCellContainer : public DataVector<CaloCell>
55 {
56 
57 // only class allowed to use private functions
58 // this is because CaloCellContainer need to be told by
59 // someone the maximum hash size. Cannot do it by
60 // itself to avoid dependencies
61 
62  friend class CaloConstCellContainer;
63  friend class CaloCellContainerFinalizerTool;
64  friend class CaloCompactCellTool;
65  friend class FullCaloCellContMaker;
66  friend class EmptyCellBuilderTool;
67  friend class CaloCellContCopyTool;
68  public:
69 
70 
72  typedef std::vector<const CaloCell*> CellVector;
73 
75  typedef std::vector<CaloCell*> MutableCellVector;
76 
79 
80 
83 
84 
86  virtual ~CaloCellContainer() { };
87 
88 
90  void push_back(CaloCell *);
91 
93  void push_back(std::unique_ptr<CaloCell>);
94 
95 
98 
100  void push_back_fast(std::unique_ptr<CaloCell> theCell);
101 
102 
104  static void print() ;
105 
108 
111 
112 
115  bool checkOrderedAndComplete() const ;
116 
118  void setIsOrderedAndComplete(const bool ordered);
119 
121  bool isOrderedAndComplete() const ;
122 
124  bool checkOrdered() const ;
125 
127  void setIsOrdered(const bool ordered);
128 
130  bool isOrdered() const ;
131 
133  bool hasTotalSize() const ;
134 
135 
137  bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const ;
138 
139 
142  int indexFirstCellCalo(const CaloCell_ID::SUBCALO caloNum) const ;
143 
146  int indexLastCellCalo(const CaloCell_ID::SUBCALO caloNum) const ;
147 
149  int nCellsCalo(const CaloCell_ID::SUBCALO caloNum) const ;
150 
152  void setHasCalo(const CaloCell_ID::SUBCALO caloNum);
153 
159  void updateCaloIterators();
160 
163  void updateCaloBeginIterators(int ic, int ind);
164 
167  void updateCaloEndIterators(int ic,int ind);
168 
172  const CaloCell * findCell(const IdentifierHash theHash) const;
173 
177  CaloCell * findCell(const IdentifierHash theHash);
178 
181  int findIndex(const IdentifierHash theHash) const;
182 
186  void findCellVector(const std::vector<IdentifierHash> & theVectorHash,CellVector & theCellVector) const;
187 
191  void findCellVector(const std::vector<IdentifierHash> & theVectorHash,MutableCellVector & theCellVector);
192 
193 
194 
200  void initializeLookUpTable();
201 
203  void resetLookUpTable();
204 
206  void order();
207 
209  class orderWithCaloHash
210  {
211  public:
212  bool operator() ( const CaloCell * a ,const CaloCell * b ) const;
213  // implement in .cxx so that CaloDetDescrElement.h does not need to be included
214  // {return a->caloDDE()->calo_hash() < b->caloDDE()->calo_hash(); }
215  bool operator() ( const CaloCell & a ,const CaloCell & b ) const ;
216  // { return a.caloDDE()->calo_hash() < b.caloDDE()->calo_hash(); }
217  };
218 
219 
220  private:
222  IMessageSvc* msgSvc() const;
223 
228  void setHasTotalSize(const bool);
229 
230 
236 
237 
239  void orderWhenIncomplete();
241  void orderWhenComplete();
242 
243 
252  template <class CONT, class VECT>
253  static void findCellVectorT(CONT& cont,
254  const std::vector<IdentifierHash> & theVectorHash,
255  VECT& theCellVector);
256 
258  const CxxUtils::PackedArray& getLookUpTable() const;
259 
262 
265  bool m_hasTotalSize ;
266 
267 
269  bool m_isOrdered ;
270 
273 
275  std::vector<bool> m_hasCalo;
276 
278  std::vector<int> m_indexFirstCellCalo;
279 
281  std::vector<int> m_indexLastCellCalo;
282 
284  std::vector< CaloCellContainer::const_iterator > m_beginConstCalo,m_endConstCalo ;
286  std::vector< CaloCellContainer::iterator > m_beginCalo,m_endCalo;
287 };
288 
289 inline bool CaloCellContainer::hasTotalSize() const {
290  return m_hasTotalSize ;
291 }
292 
293 inline bool CaloCellContainer::isOrdered() const {
294  return m_isOrdered ;
295 }
296 
297 
299  return m_isOrderedAndComplete ;
300 }
301 
302 
305 
306 namespace SG {
307 
308 
309 // Specialize this for CaloCellContainer.
310 // We'll implement it using findIndex.
311 template <>
312 bool
314  CaloCell const * const & element,
316 
317 
318 } // namespace SG
319 
320 
321 #endif
322 
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CaloCellContainer::m_lookUpTable
CxxUtils::CachedValue< CxxUtils::PackedArray > m_lookUpTable
look up table of size HashIdentifiermax.
Definition: CaloCellContainer.h:272
CaloCellContainer::updateCaloIteratorsOrdered
void updateCaloIteratorsOrdered(CaloCellContainer::iterator beg, CaloCellContainer::iterator end)
Recursively find division points between subcalos in the container.
Definition: CaloCellContainer.cxx:245
CaloCellContainer::indexLastCellCalo
int indexLastCellCalo(const CaloCell_ID::SUBCALO caloNum) const
index of last cell of given calorimeter (-2 if none) Note that it is normally more efficient to use i...
Definition: CaloCellContainer.cxx:141
CaloCellContainer::initializeLookUpTable
void initializeLookUpTable()
initialize look up table.
Definition: CaloCellContainer.cxx:467
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CaloCellContainer::checkOrderedAndComplete
bool checkOrderedAndComplete() const
verify one by one the container is complete (i.e.
Definition: CaloCellContainer.cxx:150
CaloCellContainer::hasTotalSize
bool hasTotalSize() const
tell wether container has total hash id size
Definition: CaloCellContainer.h:289
CaloCellContainer::setHasTotalSize
void setHasTotalSize(const bool)
If @ flag is true, then the container size equals the maximum hash.
Definition: CaloCellContainer.cxx:169
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
CaloCellContainer::findCellVector
void findCellVector(const std::vector< IdentifierHash > &theVectorHash, CellVector &theCellVector) const
fast find method given vector of identifier hash.
Definition: CaloCellContainer.cxx:422
index
Definition: index.py:1
CaloCellContainer::m_indexFirstCellCalo
std::vector< int > m_indexFirstCellCalo
index of first cell of given calo (-1 if none)
Definition: CaloCellContainer.h:289
CaloCellContainerFinalizerTool
Definition: CaloCellContainerFinalizerTool.h:20
CaloCellContainer::m_isOrderedAndComplete
bool m_isOrderedAndComplete
true if complete and in right order
Definition: CaloCellContainer.h:283
CaloCellContainer::m_hasTotalSize
bool m_hasTotalSize
true if size correspond to maximum hash.
Definition: CaloCellContainer.h:276
CaloCellContainer::setIsOrdered
void setIsOrdered(const bool ordered)
indicates that the container is ordered
Definition: CaloCellContainer.cxx:204
CaloCellContainer::setHasCalo
void setHasCalo(const CaloCell_ID::SUBCALO caloNum)
set which calo has been filled.
Definition: CaloCellContainer.cxx:213
CaloCellContainer::updateCaloBeginIterators
void updateCaloBeginIterators(int ic, int ind)
fills calo iterators and the index of first cell for a given subcalo
Definition: CaloCellContainer.cxx:326
CaloCellContainer::m_isOrdered
bool m_isOrdered
true if ordered
Definition: CaloCellContainer.h:280
CaloCellContainer::beginConstCalo
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
Definition: CaloCellContainer.cxx:119
CaloCellContainer::isOrdered
bool isOrdered() const
tell wether container is ordered
Definition: CaloCellContainer.h:293
CaloCellContainer::~CaloCellContainer
virtual ~CaloCellContainer()
destructor
Definition: CaloCellContainer.h:97
CaloCell.h
CaloCellContainer::orderWithCaloHash
functor to order cells according to caloHash
Definition: CaloCellContainer.h:221
CaloCellContainer::orderWithCaloHash::operator()
bool operator()(const CaloCell *a, const CaloCell *b) const
Definition: CaloCellContainer.cxx:665
CaloCellContainer::print
static void print()
dump (obsolete)
Definition: CaloCellContainer.cxx:112
CaloCellContainer::endCalo
CaloCellContainer::iterator endCalo(CaloCell_ID::SUBCALO caloNum)
Definition: CaloCellContainer.cxx:128
CaloCell_ID.h
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
CaloCellContCopyTool
Concrete tool for coping an entire CaloCellContainer.
Definition: CaloCellContCopyTool.h:24
CxxUtils::PackedArray
An array of unsigned values of some bit size, packed tightly.
Definition: PackedArray.h:42
CaloCellContainer::indexFirstCellCalo
int indexFirstCellCalo(const CaloCell_ID::SUBCALO caloNum) const
index of first cell of given calorimeter (-1 if none).
Definition: CaloCellContainer.cxx:137
CaloCellContainer::orderWhenComplete
void orderWhenComplete()
order when container is complete
Definition: CaloCellContainer.cxx:556
CaloCellContainer::CaloCellContainer
CaloCellContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Main constructor.
Definition: CaloCellContainer.cxx:48
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
beamspotman.n
n
Definition: beamspotman.py:731
SG_BASE
SG_BASE(CaloCellContainer, DataVector< CaloCell >)
CaloCellContainer::msgSvc
IMessageSvc * msgSvc() const
get message service
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
CaloCellContainer::FullCaloCellContMaker
friend class FullCaloCellContMaker
Definition: CaloCellContainer.h:76
CaloCellContainer::nCellsCalo
int nCellsCalo(const CaloCell_ID::SUBCALO caloNum) const
get number of cels of given calorimeter
Definition: CaloCellContainer.cxx:145
CxxUtils::CachedValue< CxxUtils::PackedArray >
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CaloCellContainer::findCell
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
Definition: CaloCellContainer.cxx:345
grepfile.ic
int ic
Definition: grepfile.py:33
CaloCellContainer::push_back_fast
void push_back_fast(CaloCell *)
reimplementation of push_back to gain speed in readin
Definition: CaloCellContainer.cxx:102
CachedValue.h
Cached value with atomic update.
CaloCellContainer::MutableCellVector
std::vector< CaloCell * > MutableCellVector
Return from non-const findCellVector.
Definition: CaloCellContainer.h:86
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
CaloCellContainer::updateCaloIterators
void updateCaloIterators()
fill calo iterators and the index of first and last cell IT IS THE RESPONSABILITY OF THE PRODUCER TO ...
Definition: CaloCellContainer.cxx:268
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
IdentifierHash.h
CaloCellContainer::checkOrdered
bool checkOrdered() const
verify one by one the container is ordered
Definition: CaloCellContainer.cxx:173
SG::findInContainer
bool findInContainer(const CaloCellContainer &data, CaloCell const *const &element, CaloCellContainer::size_type &index)
Definition: CaloCellContainer.cxx:676
CaloCellContainer::order
void order()
order container
Definition: CaloCellContainer.cxx:474
CaloCellContainer::m_beginCalo
std::vector< CaloCellContainer::iterator > m_beginCalo
non const iterators for the different calorimeters
Definition: CaloCellContainer.h:297
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloCellContainer::getLookUpTable
const CxxUtils::PackedArray & getLookUpTable() const
Retrieve an initialized lookup table.
Definition: CaloCellContainer.cxx:586
CaloCellContainer::beginCalo
CaloCellContainer::iterator beginCalo(CaloCell_ID::SUBCALO caloNum)
get non const iterators on cell of just one calo
Definition: CaloCellContainer.cxx:123
CaloCellContainer::m_beginConstCalo
std::vector< CaloCellContainer::const_iterator > m_beginConstCalo
const iterators for the different calorimeters
Definition: CaloCellContainer.h:295
CaloCellContainer::resetLookUpTable
void resetLookUpTable()
reset look up table
Definition: CaloCellContainer.cxx:462
DataVector< CaloCell >::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
findInContainer.h
Define a specializable method for finding the index of an object within a container.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
CaloCellContainer::m_hasCalo
std::vector< bool > m_hasCalo
true if given cell from given calo has been filled (even if none)
Definition: CaloCellContainer.h:286
a
TList * a
Definition: liststreamerinfos.cxx:10
CaloCellContainer::isOrderedAndComplete
bool isOrderedAndComplete() const
tell wether container is complete and in order
Definition: CaloCellContainer.h:298
CaloCompactCellTool
helper to convert from CaloCellContainer to CaloCompactCellContainer and back
Definition: CaloCompactCellTool.h:29
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloConstCellContainer
CaloCellContainer that can accept const cell pointers.
Definition: CaloConstCellContainer.h:45
CaloCellContainer::orderWhenIncomplete
void orderWhenIncomplete()
order when container is incomplete
Definition: CaloCellContainer.cxx:485
CaloCellContainer::push_back
void push_back(CaloCell *)
reimplementation of const push_back
Definition: CaloCellContainer.cxx:74
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
EmptyCellBuilderTool
Building Cells objects from Atlfast.
Definition: EmptyCellBuilderTool.h:21
CaloCellContainer::endConstCalo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
Definition: CaloCellContainer.cxx:133
CaloCellContainer::findIndex
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
Definition: CaloCellContainer.cxx:363
DataVector< CaloCell >::ownPolicy
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
PackedArray.h
An array of unsigned values of some bit size, packed tightly.
CaloCellContainer::hasCalo
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
Definition: CaloCellContainer.cxx:209
CaloCellContainer::m_endConstCalo
std::vector< CaloCellContainer::const_iterator > m_endConstCalo
Definition: CaloCellContainer.h:295
CaloCellContainer::m_endCalo
std::vector< CaloCellContainer::iterator > m_endCalo
Definition: CaloCellContainer.h:297
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
DataVector< CaloCell >::size_type
BASE::size_type size_type
Definition: DataVector.h:813
CaloCellContainer::findCellVectorT
static void findCellVectorT(CONT &cont, const std::vector< IdentifierHash > &theVectorHash, VECT &theCellVector)
Look up a group of cells by IdentifierHash.
Definition: CaloCellContainer.cxx:389
CaloCellContainer::setIsOrderedAndComplete
void setIsOrderedAndComplete(const bool ordered)
indicate that the container is complete and in order
Definition: CaloCellContainer.cxx:165
CLASS_DEF.h
macros to associate a CLID to a type
CaloCellContainer::CellVector
std::vector< const CaloCell * > CellVector
type to be used for the internal lookup table, and to return list of cells
Definition: CaloCellContainer.h:83
checkFileSG.ind
list ind
Definition: checkFileSG.py:118
CaloCellContainer::updateCaloEndIterators
void updateCaloEndIterators(int ic, int ind)
fills calo iterators and the index of last cell for a given subcalo
Definition: CaloCellContainer.cxx:338
CaloCellContainer::m_indexLastCellCalo
std::vector< int > m_indexLastCellCalo
index of first cell of given calo (-2 if none)
Definition: CaloCellContainer.h:292