14#include "CaloDetDescr/CaloDetDescrElement.h"
17#include "CLHEP/Geometry/Vector3D.h"
42std::atomic<int> nWarningsToBePrinted = 20;
93 this->
setHasCalo(theCell->caloDDE()->getSubCalo()) ;
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) {}
227 bool operator() (
const CaloCell* cell)
const
228 {
return cell->caloDDE()->getSubCalo() == m_c; }
248 if (beg ==
end)
return;
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;
388template <
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) {
414 theCellVector.push_back( theCell);
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();
515 IdentifierHash max_hash = desc->get_calo_helper()->calo_cell_hash_max();
524 assert (hash < tmp.size());
526 if (tmp[hash] !=
nullptr) {
528 <<
"Duplicated cell: hash= " << hash;
540 if (*it !=
nullptr) {
549 assert (itout <=
end());
569 if ((*
this)[hash] !=
nullptr) {
571 <<
"Duplicated cell: hash= " << hash;
598 unsigned int theSize=0;
599 size_t ncells =
size();
615 IdentifierHash max_hash = desc->get_calo_helper()->calo_cell_hash_max();
616 theSize = max_hash + 1;
618 lookUpTable.
resize (theSize);
620 for (
size_t icell = 0; icell < ncells; icell++) {
622 const CaloCell * theCell = (*this)[icell];
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(); }
std::vector< Identifier > ID
Definition of CaloDetDescriptor.
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
char data[hepevt_bytes_allocation_ATLAS]
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
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
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
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
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
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 ...
std::vector< int > m_indexFirstCellCalo
index of first cell of given calo (-1 if none)
CaloCell_Base_ID::SUBCALO SUBCALO
Data object for each calorimeter readout cell.
virtual double e() const override final
get energy (data member) (synonym to method energy()
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
This class groups all DetDescr information related to a CaloCell.
IdentifierHash calo_hash() const
cell calo hash
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
const CaloDetDescriptor * descriptor() const
cell descriptor
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
An array of unsigned values of some bit size, packed tightly.
size_type size() const
Returns the number of elements in the collection.
void resize(size_type sz, value_type c=0)
Resizes the collection to the specified number of elements.
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
DataModel_detail::const_iterator< DataVector > const_iterator
void resize(size_type sz)
const CaloCell * back() const
typename DataVectorBase< CaloCell >::Base::size_type size_type
void reserve(size_type n)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
const_iterator end() const noexcept
iterator erase(iterator position)
const_iterator begin() const noexcept
const CaloCell * front() const
SG::OwnershipPolicy ownPolicy() const
size_type size() const noexcept
static void iter_swap(iterator a, iterator b)
bool empty() const noexcept
This is a "hash" representation of an Identifier.
l
Printing final latex table to .tex output file.
bool findInContainer(const CaloCellContainer &data, CaloCell const *const &element, CaloCellContainer::size_type &index)
void iter_swap(typename DataModel_detail::iterator< DV > a, typename DataModel_detail::iterator< DV > b)
Specialization of iter_swap for DataVector/DataList.