|
ATLAS Offline Software
|
Go to the documentation of this file.
14 #include "CaloDetDescr/CaloDetDescrElement.h"
17 #include "CLHEP/Geometry/Vector3D.h"
42 std::atomic<int> nWarningsToBePrinted = 20;
50 m_hasTotalSize(false),
52 m_isOrderedAndComplete(false)
114 <<
"CaloCellContainer::print not implemented";
130 return m_endCalo[
static_cast<int>(caloNum)];
155 unsigned int index=0;
156 for (;itr!=itrEnd;++itr){
157 if ( ((*itr)->caloDDE())->calo_hash()!=
index) {
175 unsigned int hashPrev=0;
177 for (;itr!=itrEnd;++itr){
183 if (theCell==
nullptr){
185 << MSG::WARNING <<
"CaloCellContainer NULL CELL ";
188 if (theDDE==
nullptr){
190 << MSG::WARNING <<
"CaloCellContainer WARNING NULL DDE ";
194 if (
hash < hashPrev)
return false ;
210 return m_hasCalo[
static_cast<int>(caloNum)];
215 const int iCalo=
static_cast<int>(caloNum);
226 is_calo (
int c) : m_c (
c) {}
228 {
return cell->caloDDE()->getSubCalo() == m_c; }
249 int beg_calo = (*beg)->caloDDE()->getSubCalo();
250 int end_calo = (*(
end-1))->caloDDE()->getSubCalo();
251 if (beg_calo == end_calo) {
261 std::partition_point (
beg,
end, is_calo (beg_calo));
288 int previousCellCalo=-1;
290 for (;itr!=itrEnd;++itr){
291 const int iCalo=
static_cast<int>( (*itr)->caloDDE()->getSubCalo());
292 if (iCalo!=previousCellCalo){
297 <<
" Specific calo cells are split."
298 <<
" Specific calo iterators will be wrong ";
304 if (previousCellCalo>=0){
311 previousCellCalo=iCalo;
317 if (previousCellCalo>=0){
366 const unsigned int theIndex = theHash ;
371 if (this->
empty())
return -1;
374 if (theIndex < lookUpTable.
size() )
375 return (
int)lookUpTable[theIndex] - 1;
388 template <
class CONT,
class VECT>
391 theCellVector.reserve (theCellVector.size() + theVectorHash.size());
392 if (cont.isOrderedAndComplete()) {
395 theCellVector.push_back( cont[
hash] );
400 if (cont.empty()) return ;
406 size_t tbsize = lookUpTable.
size();
409 if (
hash>=tbsize) continue ;
410 int ndx = (
int)lookUpTable[
hash ] - 1;
412 auto theCell = cont[ndx];
413 if (theCell!=
nullptr) {
426 theCellVector.reserve (theCellVector.size() + theVectorHash.size());
430 theCellVector.push_back( (*
this)[
hash] );
435 if (this->
empty()) return ;
441 size_t tbsize = lookUpTable.
size();
444 if (
hash>=tbsize) continue ;
445 int ndx = (
int)lookUpTable[
hash ] - 1;
447 const CaloCell * theCell = (*this)[ndx];
449 theCellVector.push_back( theCell);
498 for (
int i = 0; i < static_cast<int>(
size())-1; ) {
499 if ((*
this)[
i]->caloDDE()->calo_hash() ==
500 (*this)[
i+1]->caloDDE()->calo_hash())
503 <<
"Duplicated cell: hash= " << (*this)[
i]->caloDDE()->calo_hash();
528 <<
"Duplicated cell: hash= " <<
hash;
531 using std::iter_swap;
540 if (*
it !=
nullptr) {
541 using std::iter_swap;
549 assert (itout <=
end());
569 if ((*
this)[
hash] !=
nullptr) {
571 <<
"Duplicated cell: hash= " <<
hash;
574 using std::iter_swap;
598 unsigned int theSize=0;
599 size_t ncells =
size();
616 theSize = max_hash + 1;
618 lookUpTable.
resize (theSize);
625 assert (theHash < theSize);
627 if (nWarningsToBePrinted > 0) {
630 int nwarn = nWarningsToBePrinted--;
631 int iold = (
int)(lookUpTable[theHash])-1;
633 if ((
size_t)iold ==
icell) {
635 <<
"Repeated cell. hash= " << theHash;
637 else if ((*
this)[iold]->
ID()==theCell->
ID()) {
639 <<
"Duplicated cell. hash="
641 <<
" E1=" << (*this)[iold]->e()
642 <<
" E2=" << theCell->
e();
646 <<
"Should be impossible ! Repeated cell. hash= " << theHash;
650 <<
"No more WARNING will be printed";
655 lookUpTable[theHash]=
icell+1;
666 return a->caloDDE()->calo_hash() <
b->caloDDE()->calo_hash(); }
668 return a.caloDDE()->calo_hash() <
b.caloDDE()->calo_hash(); }
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
char data[hepevt_bytes_allocation_ATLAS]
CxxUtils::CachedValue< CxxUtils::PackedArray > m_lookUpTable
look up table of size HashIdentifiermax.
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...
void reset()
Reset the value to invalid.
void initializeLookUpTable()
initialize look up table.
Const iterator class for DataVector/DataList.
const T * ptr() const
Return a pointer to the cached value.
bool checkOrderedAndComplete() const
verify one by one the container is complete (i.e.
bool hasTotalSize() const
tell wether container has total hash id size
void setHasTotalSize(const bool)
If @ flag is true, then the container size equals the maximum hash.
void push_back(value_type x)
Add an element to the end of the collection.
std::vector< Identifier > ID
void findCellVector(const std::vector< IdentifierHash > &theVectorHash, CellVector &theCellVector) const
fast find method given vector of identifier hash.
std::vector< int > m_indexFirstCellCalo
index of first cell of given calo (-1 if none)
bool m_isOrderedAndComplete
true if complete and in right order
bool m_hasTotalSize
true if size correspond to maximum hash.
bool isValid() const
Test to see if the value is valid.
void setIsOrdered(const bool ordered)
indicates that the container is ordered
void setHasCalo(const CaloCell_ID::SUBCALO caloNum)
set which calo has been filled.
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
void updateCaloBeginIterators(int ic, int ind)
fills calo iterators and the index of first cell for a given subcalo
bool m_isOrdered
true if ordered
size_type size() const
Returns the number of elements in the collection.
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
bool isOrdered() const
tell wether container is ordered
functor to order cells according to caloHash
virtual double e() const override final
get energy (data member) (synonym to method energy()
bool operator()(const CaloCell *a, const CaloCell *b) const
static void print()
dump (obsolete)
CaloCellContainer::iterator endCalo(CaloCell_ID::SUBCALO caloNum)
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
Definition of CaloDetDescriptor.
An array of unsigned values of some bit size, packed tightly.
int indexFirstCellCalo(const CaloCell_ID::SUBCALO caloNum) const
index of first cell of given calorimeter (-1 if none).
void orderWhenComplete()
order when container is complete
IdentifierHash calo_hash() const
cell calo hash
CaloCellContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Main constructor.
(Non-const) Iterator class for DataVector/DataList.
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
SUBCALO
enumeration of sub calorimeters
int nCellsCalo(const CaloCell_ID::SUBCALO caloNum) const
get number of cels of given calorimeter
const CaloCell * front() const
Access the first element in the collection as an rvalue.
void resize(size_type sz, value_type c=0)
Resizes the collection to the specified number of elements.
const CaloCell * back() const
Access the last element in the collection as an rvalue.
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
void push_back_fast(CaloCell *)
reimplementation of push_back to gain speed in readin
void resize(size_type sz)
Resizes the collection to the specified number of elements.
std::vector< CaloCell * > MutableCellVector
Return from non-const findCellVector.
void updateCaloIterators()
fill calo iterators and the index of first and last cell IT IS THE RESPONSABILITY OF THE PRODUCER TO ...
Helpers for checking error return status codes and reporting errors.
bool checkOrdered() const
verify one by one the container is ordered
bool findInContainer(const CaloCellContainer &data, CaloCell const *const &element, CaloCellContainer::size_type &index)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void order()
order container
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
void set(const T &val) const
Set the value, assuming it is currently invalid.
std::vector< CaloCellContainer::iterator > m_beginCalo
non const iterators for the different calorimeters
Container class for CaloCell.
const CxxUtils::PackedArray & getLookUpTable() const
Retrieve an initialized lookup table.
CaloCellContainer::iterator beginCalo(CaloCell_ID::SUBCALO caloNum)
get non const iterators on cell of just one calo
std::vector< CaloCellContainer::const_iterator > m_beginConstCalo
const iterators for the different calorimeters
void resetLookUpTable()
reset look up table
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
void sort()
Sort the container.
std::vector< bool > m_hasCalo
true if given cell from given calo has been filled (even if none)
bool isOrderedAndComplete() const
tell wether container is complete and in order
Data object for each calorimeter readout cell.
void orderWhenIncomplete()
order when container is incomplete
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
void push_back(CaloCell *)
reimplementation of const push_back
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
const CaloDetDescriptor * descriptor() const
cell descriptor
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
std::vector< CaloCellContainer::const_iterator > m_endConstCalo
static void iter_swap(iterator a, iterator b)
Swap the referents of two DataVector iterators.
std::vector< CaloCellContainer::iterator > m_endCalo
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
BASE::size_type size_type
iterator erase(iterator position)
Remove element at a given position.
static void findCellVectorT(CONT &cont, const std::vector< IdentifierHash > &theVectorHash, VECT &theCellVector)
Look up a group of cells by IdentifierHash.
size_type size() const noexcept
Returns the number of elements in the collection.
void setIsOrderedAndComplete(const bool ordered)
indicate that the container is complete and in order
bool empty() const noexcept
Returns true if the collection is empty.
std::vector< const CaloCell * > CellVector
type to be used for the internal lookup table, and to return list of cells
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void updateCaloEndIterators(int ic, int ind)
fills calo iterators and the index of last cell for a given subcalo
std::vector< int > m_indexLastCellCalo
index of first cell of given calo (-2 if none)