ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellContainer.h
Go to the documentation of this file.
1
2
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
29
30/********************************************************************
31
32NAME: CaloCellContainer.h
33PACKAGE: offline/Calorimeter/CaloRec
34
35AUTHORS: S. Rajagopalan
36CREATED: April 2001
37
38PURPOSE: Container for CaloCell - stored as DataObject in TDS.
39MODIFIED: David Rousseau: heavy modification to allow storing all
40 calorimeter cells in one single container
41********************************************************************/
42
45#include "CaloEvent/CaloCell.h"
46
52
53
54class 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
64 friend class CaloCompactCellTool;
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
97 void push_back_fast(CaloCell *);
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
199
201
203 void resetLookUpTable();
204
206 void order();
207
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
259
262
266
267
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
290 return m_hasTotalSize ;
291}
292
293inline bool CaloCellContainer::isOrdered() const {
294 return m_isOrdered ;
295}
296
297
301
302
305
306namespace SG {
307
308
309// Specialize this for CaloCellContainer.
310// We'll implement it using findIndex.
311template <>
312bool
313findInContainer (const CaloCellContainer& data,
314 CaloCell const * const & element,
316
317
318} // namespace SG
319
320
321#endif
322
Cached value with atomic update.
#define SG_BASE(D, B)
Declare that class D derives from class B.
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
An STL vector of pointers that by default owns its pointed-to elements.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t a
An array of unsigned values of some bit size, packed tightly.
functor to order cells according to caloHash
bool operator()(const CaloCell *a, const CaloCell *b) const
Container class for CaloCell.
std::vector< CaloCellContainer::iterator > m_endCalo
friend class CaloCompactCellTool
friend class FullCaloCellContMaker
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
std::vector< const CaloCell * > CellVector
type to be used for the internal lookup table, and to return list of cells
bool hasTotalSize() const
tell wether container has total hash id size
void orderWhenIncomplete()
order when container is incomplete
friend class CaloConstCellContainer
void updateCaloEndIterators(int ic, int ind)
fills calo iterators and the index of last cell for a given subcalo
void findCellVector(const std::vector< IdentifierHash > &theVectorHash, CellVector &theCellVector) const
fast find method given vector of identifier hash.
static void print()
dump (obsolete)
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
int indexFirstCellCalo(const CaloCell_ID::SUBCALO caloNum) const
index of first cell of given calorimeter (-1 if none).
void push_back_fast(CaloCell *)
reimplementation of push_back to gain speed in readin
IMessageSvc * msgSvc() const
get message service
bool checkOrdered() const
verify one by one the container is ordered
std::vector< CaloCellContainer::const_iterator > m_endConstCalo
CaloCellContainer::iterator beginCalo(CaloCell_ID::SUBCALO caloNum)
get non const iterators on cell of just one calo
CxxUtils::CachedValue< CxxUtils::PackedArray > m_lookUpTable
look up table of size HashIdentifiermax.
bool m_isOrdered
true if ordered
std::vector< CaloCellContainer::iterator > m_beginCalo
non const iterators for the different calorimeters
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
static void findCellVectorT(CONT &cont, const std::vector< IdentifierHash > &theVectorHash, VECT &theCellVector)
Look up a group of cells by IdentifierHash.
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
void resetLookUpTable()
reset look up table
void push_back(CaloCell *)
reimplementation of const push_back
friend class CaloCellContainerFinalizerTool
std::vector< int > m_indexLastCellCalo
index of first cell of given calo (-2 if none)
void order()
order container
void setHasCalo(const CaloCell_ID::SUBCALO caloNum)
set which calo has been filled.
void setHasTotalSize(const bool)
If @ flag is true, then the container size equals the maximum hash.
std::vector< bool > m_hasCalo
true if given cell from given calo has been filled (even if none)
CaloCellContainer::iterator endCalo(CaloCell_ID::SUBCALO caloNum)
std::vector< CaloCell * > MutableCellVector
Return from non-const findCellVector.
bool isOrdered() const
tell wether container is ordered
void orderWhenComplete()
order when container is complete
bool checkOrderedAndComplete() const
verify one by one the container is complete (i.e.
void updateCaloIteratorsOrdered(CaloCellContainer::iterator beg, CaloCellContainer::iterator end)
Recursively find division points between subcalos in the container.
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...
CaloCellContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Main constructor.
bool m_hasTotalSize
true if size correspond to maximum hash.
void initializeLookUpTable()
initialize look up table.
bool isOrderedAndComplete() const
tell wether container is complete and in order
void setIsOrderedAndComplete(const bool ordered)
indicate that the container is complete and in order
virtual ~CaloCellContainer()
destructor
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
bool m_isOrderedAndComplete
true if complete and in right order
void setIsOrdered(const bool ordered)
indicates that the container is ordered
void updateCaloBeginIterators(int ic, int ind)
fills calo iterators and the index of first cell for a given subcalo
std::vector< CaloCellContainer::const_iterator > m_beginConstCalo
const iterators for the different calorimeters
int nCellsCalo(const CaloCell_ID::SUBCALO caloNum) const
get number of cels of given calorimeter
const CxxUtils::PackedArray & getLookUpTable() const
Retrieve an initialized lookup table.
void updateCaloIterators()
fill calo iterators and the index of first and last cell IT IS THE RESPONSABILITY OF THE PRODUCER TO ...
friend class EmptyCellBuilderTool
friend class CaloCellContCopyTool
std::vector< int > m_indexFirstCellCalo
index of first cell of given calo (-1 if none)
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
Cached value with atomic update.
Definition CachedValue.h:55
An array of unsigned values of some bit size, packed tightly.
Definition PackedArray.h:42
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
typename DataVectorBase< CaloCell >::Base::size_type size_type
Definition DataVector.h:814
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
const_iterator end() const noexcept
SG::OwnershipPolicy ownPolicy() const
This is a "hash" representation of an Identifier.
Define a specializable method for finding the index of an object within a container.
Forward declaration.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements
Definition index.py:1