ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellContainer Class Reference

Container class for CaloCell. More...

#include <CaloCellContainer.h>

Inheritance diagram for CaloCellContainer:
Collaboration diagram for CaloCellContainer:

Classes

class  orderWithCaloHash
 functor to order cells according to caloHash More...

Public Types

typedef std::vector< const CaloCell * > CellVector
 type to be used for the internal lookup table, and to return list of cells
typedef std::vector< CaloCell * > MutableCellVector
 Return from non-const findCellVector.
typedef typename DataVectorBase< CaloCell >::Base DataVector_BASE
typedef typename DataVectorBase< CaloCell >::Base DVL_BASE
typedef typename DataVectorBase< CaloCell >::Base::PtrVector PtrVector
 This is the type of the underlying std::vector (what stdcont returns).
typedef typename DataVectorBase< CaloCell >::Base::PtrVector BaseContainer
typedef CaloCell *& reference
typedef CaloCell *const & const_reference
typedef typename DataVectorBase< CaloCell >::Base::size_type size_type
typedef typename DataVectorBase< CaloCell >::Base::difference_type difference_type
typedef CaloCellvalue_type
typedef typename DataVectorBase< CaloCell >::Base::allocator_type allocator_type
typedef CaloCell ** pointer
typedef CaloCell *const * const_pointer
typedef const CaloCellconst_value_type
typedef CaloCell base_value_type
 The T value used as the template parameter.
typedef std::unique_ptr< base_value_typeunique_type
 Type of a unique_ptr that can be used to insert elements into this container.
typedef DataModel_detail::ElementProxy< DataVectorElementProxy
 This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.
typedef DataModel_detail::const_iterator< DataVectorconst_iterator
 Standard const_iterator.
typedef DataModel_detail::iterator< DataVectoriterator
 Standard iterator.
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 Standard const_reverse_iterator.
typedef std::reverse_iterator< iteratorreverse_iterator
 Standard reverse_iterator.
typedef DataVector base_data_vector
using Deleter

Public Member Functions

 CaloCellContainer (SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
 Main constructor.
 CaloCellContainer (size_t n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
 Sized constructor.
virtual ~CaloCellContainer ()
 destructor
void push_back (CaloCell *)
 reimplementation of const push_back
void push_back (std::unique_ptr< CaloCell >)
 reimplementation of const push_back(unique_ptr>)
void push_back_fast (CaloCell *)
 reimplementation of push_back to gain speed in readin
void push_back_fast (std::unique_ptr< CaloCell > theCell)
 reimplementation of push_back to gain speed in readin (UP version)
CaloCellContainer::const_iterator beginConstCalo (CaloCell_ID::SUBCALO caloNum) const
 get const iterators on cell of just one calo
CaloCellContainer::const_iterator endConstCalo (CaloCell_ID::SUBCALO caloNum) const
CaloCellContainer::iterator beginCalo (CaloCell_ID::SUBCALO caloNum)
 get non const iterators on cell of just one calo
CaloCellContainer::iterator endCalo (CaloCell_ID::SUBCALO caloNum)
bool checkOrderedAndComplete () const
 verify one by one the container is complete (i.e.
void setIsOrderedAndComplete (const bool ordered)
 indicate that the container is complete and in order
bool isOrderedAndComplete () const
 tell wether container is complete and in order
bool checkOrdered () const
 verify one by one the container is ordered
void setIsOrdered (const bool ordered)
 indicates that the container is ordered
bool isOrdered () const
 tell wether container is ordered
bool hasTotalSize () const
 tell wether container has total hash id size
bool hasCalo (const CaloCell_ID::SUBCALO caloNum) const
 tell wether it has been filled with cells (maybe none) of a given calo
int indexFirstCellCalo (const CaloCell_ID::SUBCALO caloNum) const
 index of first cell of given calorimeter (-1 if none).
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 iterators.
int nCellsCalo (const CaloCell_ID::SUBCALO caloNum) const
 get number of cels of given calorimeter
void setHasCalo (const CaloCell_ID::SUBCALO caloNum)
 set which calo has been filled.
void updateCaloIterators ()
 fill calo iterators and the index of first and last cell IT IS THE RESPONSABILITY OF THE PRODUCER TO CALL THIS METHOD ONCE THE FILLING IS FINISHED Please use CaloCellContainerFinalizerTool to make sure the container is properly finalised.
void updateCaloBeginIterators (int ic, int ind)
 fills calo iterators and the index of first cell for a given subcalo
void updateCaloEndIterators (int ic, int ind)
 fills calo iterators and the index of last cell for a given subcalo
const CaloCellfindCell (const IdentifierHash theHash) const
 fast find method given identifier hash.
CaloCellfindCell (const IdentifierHash theHash)
 fast find method given identifier hash.
int findIndex (const IdentifierHash theHash) const
 Return index of the cell with a given hash.
void findCellVector (const std::vector< IdentifierHash > &theVectorHash, CellVector &theCellVector) const
 fast find method given vector of identifier hash.
void findCellVector (const std::vector< IdentifierHash > &theVectorHash, MutableCellVector &theCellVector)
 fast find method given vector of identifier hash.
void initializeLookUpTable ()
 initialize look up table.
void resetLookUpTable ()
 reset look up table
void order ()
 order container
Constructors, destructors, assignment.
void assign (InputIterator first, InputIterator last)
 Assign from iterators.
Size and capacity.
size_type size () const noexcept
 Returns the number of elements in the collection.
void resize (size_type sz)
 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.
Element access.

Change the vector capacity to match the current size.

Note: this does not affect auxiliary data.

const CaloCelloperator[] (size_type n) const
 Access an element, as an rvalue.
const CaloCellget (size_type n) const
 Access an element, as an rvalue.
const CaloCellat (size_type n) const
 Access an element, as an rvalue.
const CaloCellfront () const
 Access the first element in the collection as an rvalue.
const CaloCellback () const
 Access the last element in the collection as an rvalue.
Iterator creation.
const_iterator begin () const noexcept
 Return a const_iterator pointing at the beginning of the collection.
const_iterator end () const noexcept
 Return a const_iterator pointing past the end of the collection.
const_reverse_iterator rbegin () const noexcept
 Return a const_reverse_iterator pointing past the end of the collection.
const_reverse_iterator rend () const noexcept
 Return a const_reverse_iterator pointing at the beginning of the collection.
const_iterator cbegin () const noexcept
 Return a const_iterator pointing at the beginning of the collection.
const_iterator cend () const noexcept
 Return a const_iterator pointing past the end of the collection.
const_reverse_iterator crbegin () const noexcept
 Return a const_reverse_iterator pointing past the end of the collection.
const_reverse_iterator crend () const noexcept
 Return a const_reverse_iterator pointing at the beginning of the collection.
Insertion operations.
value_type push_back (value_type pElem)
 Add an element to the end of the collection.
size_type push_new (size_type n, F alloc)
 Create and add a number of new elements to the end of the container.
value_type emplace_back (value_type pElem)
 Add an element to the end of the collection.
iterator insert (iterator position, value_type pElem)
 Add a new element to the collection.
iterator emplace (iterator position, value_type pElem)
 Add a new element to the collection.
void insertMove (iterator position, DataVector &other)
 Insert the contents of another DataVector, with auxiliary data copied via move semantics.
Erasure operations.
iterator erase (iterator position)
 Remove element at a given position.
void pop_back ()
 Remove the last element from the collection.
void clear ()
 Erase all the elements in the collection.

Static Public Member Functions

static void print ()
 dump (obsolete)

Static Public Attributes

static const bool has_virtual
 This is true for any DataVector class if we need to use virtual derivation to get to the base DataVector class.
static constexpr bool must_own
 If true, then this type must own its contents.

Private Member Functions

IMessageSvc * msgSvc () const
 get message service
void setHasTotalSize (const bool)
 If @ flag is true, then the container size equals the maximum hash.
void updateCaloIteratorsOrdered (CaloCellContainer::iterator beg, CaloCellContainer::iterator end)
 Recursively find division points between subcalos in the container.
void orderWhenIncomplete ()
 order when container is incomplete
void orderWhenComplete ()
 order when container is complete
const CxxUtils::PackedArraygetLookUpTable () const
 Retrieve an initialized lookup table.

Static Private Member Functions

template<class CONT, class VECT>
static void findCellVectorT (CONT &cont, const std::vector< IdentifierHash > &theVectorHash, VECT &theCellVector)
 Look up a group of cells by IdentifierHash.

Private Attributes

CxxUtils::CachedValue< CxxUtils::PackedArraym_lookUpTable
 look up table of size HashIdentifiermax.
bool m_hasTotalSize
 true if size correspond to maximum hash.
bool m_isOrdered
 true if ordered
bool m_isOrderedAndComplete
 true if complete and in right order
std::vector< bool > m_hasCalo
 true if given cell from given calo has been filled (even if none)
std::vector< int > m_indexFirstCellCalo
 index of first cell of given calo (-1 if none)
std::vector< int > m_indexLastCellCalo
 index of first cell of given calo (-2 if none)
std::vector< CaloCellContainer::const_iteratorm_beginConstCalo
 const iterators for the different calorimeters
std::vector< CaloCellContainer::const_iteratorm_endConstCalo
std::vector< CaloCellContainer::iteratorm_beginCalo
 non const iterators for the different calorimeters
std::vector< CaloCellContainer::iteratorm_endCalo

Friends

class CaloConstCellContainer
class CaloCellContainerFinalizerTool
class CaloCompactCellTool
class FullCaloCellContMaker
class EmptyCellBuilderTool
class CaloCellContCopyTool

Internal operations.

SG::IsMostDerivedFlag m_isMostDerived
 This flag is true if this DV instance is the most-derived one.
void resortAux (iterator beg, iterator end)
 Reset indices / reorder aux data after elements have been permuted.
void testInsert (const char *op)
 Test if we can insert; raise an exception if not.
void testInsertOol (const char *op)
 Test if we can insert; raise an exception if not.
static int baseOffset1 (const char *p, const DataVector &dv, const std::type_info &ti)
 Helper for baseOffset.
static const CaloCelldo_cast (const typename PtrVector::value_type p)
 Helper to shorten calls to DataModel_detail::DVLCast.
static CaloCelldo_cast_nc (typename PtrVector::value_type p)
 Helper to shorten calls to DataModel_detail::DVLCast.
void assignElement (typename BaseContainer::iterator pos, value_type newElem)
 Handle element assignment.
void assignBaseElement (typename BaseContainer::iterator pos, typename BaseContainer::value_type newElem)
 Handle element assignment from a base pointer.
void shift (size_t pos, ptrdiff_t offs)
 Shift the auxiliary elements of the container.
virtual const std::type_info & dv_typeid () const override
 Find the most-derived DataVector class in the hierarchy.
typedef ROOT::Meta::Selection::DataVector< CaloCell, DataVector_BASE >::self self
void clearMostDerived ()
 Clear m_isMostDerived for this instance and for all bases.
virtual void setMostDerived () override
 Set m_isMostDerived for this instance and clear it for all bases.

Swap and sort.

void swap (DataVector &rhs)
 Swap this collection with another.
void sort ()
 Sort the container.
static void iter_swap (iterator a, iterator b)
 Swap the referents of two DataVector iterators.

Non-standard operations.

void swapElement (size_type index, value_type newElem, reference oldElem)
 Swap one element out of the container.
virtual const DataModel_detail::DVLInfoBasedvlinfo_v () const override
 Return the DV/DL info struct for this class.
const SG::AuxVectorBaseauxbase () const
 Convert to AuxVectorBase.
size_type max_size () const noexcept
 Returns the size() of the largest possible collection.
size_type capacity () const noexcept
 Returns the total number of elements that the collection can hold before needing to allocate more memory.
bool empty () const noexcept
 Returns true if the collection is empty.
void shrink_to_fit ()
const PtrVectorstdcont () const
 Return the underlying std::vector of the container.
SG::OwnershipPolicy ownPolicy () const
 Return the ownership policy setting for this container.
static const DataModel_detail::DVLInfoBasedvlinfo ()
 Return the DV/DL info struct for this class.
static int baseOffset (const std::type_info &ti)
 Return the offset of a base DataVector class.

Detailed Description

Container class for CaloCell.

CaloCellContainer is a container of all LAr and Tile cells. It derives from DataVector<CaloCell>. Cells from a given calorimeter (LAr e.m., LArHEC, LArFCAl, Tile) can also be accessed individually. It has additional methods to allow fast access to any cell, given its hash identifier. CaloCellContainer is normally built by CaloRec/CaloCellMaker.cxx, and finalized by CaloRec/CaloCellContainerFinalizerTool.cxx. CaloCellContainer is NOT meant to be used for private list of cells, a simple std::vector<const CaloCell*> is best used.

Author
Srini Rajagopalan
David Rousseau

Definition at line 54 of file CaloCellContainer.h.

Member Typedef Documentation

◆ allocator_type

typedef typename DataVectorBase<CaloCell>::Base::allocator_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::allocator_type
inherited

Definition at line 817 of file DataVector.h.

◆ base_data_vector

typedef DataVector DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::base_data_vector
inherited

Definition at line 854 of file DataVector.h.

◆ base_value_type

typedef CaloCell DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::base_value_type
inherited

The T value used as the template parameter.

Note that this is different from value_type (that's T*).

Definition at line 825 of file DataVector.h.

◆ BaseContainer

typedef typename DataVectorBase<CaloCell>::Base::PtrVector DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::BaseContainer
inherited

Definition at line 807 of file DataVector.h.

◆ CellVector

typedef std::vector<const CaloCell*> CaloCellContainer::CellVector

type to be used for the internal lookup table, and to return list of cells

Definition at line 72 of file CaloCellContainer.h.

◆ const_iterator

◆ const_pointer

typedef CaloCell* const* DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::const_pointer
inherited

Definition at line 819 of file DataVector.h.

◆ const_reference

typedef CaloCell* const& DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::const_reference
inherited

Definition at line 813 of file DataVector.h.

◆ const_reverse_iterator

typedef std::reverse_iterator<const_iterator> DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::const_reverse_iterator
inherited

Standard const_reverse_iterator.

Definition at line 847 of file DataVector.h.

◆ const_value_type

typedef const CaloCell* DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::const_value_type
inherited

Definition at line 821 of file DataVector.h.

◆ DataVector_BASE

typedef typename DataVectorBase<CaloCell>::Base DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::DataVector_BASE
inherited

Definition at line 797 of file DataVector.h.

◆ Deleter

using DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::Deleter
inherited

Definition at line 857 of file DataVector.h.

◆ difference_type

typedef typename DataVectorBase<CaloCell>::Base::difference_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::difference_type
inherited

Definition at line 815 of file DataVector.h.

◆ DVL_BASE

typedef typename DataVectorBase<CaloCell>::Base DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::DVL_BASE
inherited

Definition at line 798 of file DataVector.h.

◆ ElementProxy

This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.

Definition at line 833 of file DataVector.h.

◆ iterator

Standard iterator.

Note that lvalue references here will yield an ElementProxy, not a reference.

Definition at line 842 of file DataVector.h.

◆ MutableCellVector

Return from non-const findCellVector.

Definition at line 75 of file CaloCellContainer.h.

◆ pointer

typedef CaloCell** DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::pointer
inherited

Definition at line 818 of file DataVector.h.

◆ PtrVector

typedef typename DataVectorBase<CaloCell>::Base::PtrVector DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::PtrVector
inherited

This is the type of the underlying std::vector (what stdcont returns).

Definition at line 806 of file DataVector.h.

◆ reference

Definition at line 812 of file DataVector.h.

◆ reverse_iterator

typedef std::reverse_iterator<iterator> DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::reverse_iterator
inherited

Standard reverse_iterator.

Note that lvalue references here will yield an ElementProxy, not a reference.

Definition at line 852 of file DataVector.h.

◆ self

Definition at line 2063 of file DataVector.h.

◆ size_type

typedef typename DataVectorBase<CaloCell>::Base::size_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::size_type
inherited

Definition at line 814 of file DataVector.h.

◆ unique_type

typedef std::unique_ptr<base_value_type> DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::unique_type
inherited

Type of a unique_ptr that can be used to insert elements into this container.

Definition at line 829 of file DataVector.h.

◆ value_type

Definition at line 816 of file DataVector.h.

Constructor & Destructor Documentation

◆ CaloCellContainer() [1/2]

CaloCellContainer::CaloCellContainer ( SG::OwnershipPolicy ownPolicy = SG::OWN_ELEMENTS)

Main constructor.

Definition at line 48 of file CaloCellContainer.cxx.

48 :
50 m_hasTotalSize(false),
51 m_isOrdered(false),
53{
54 //initialise with empty iterators
55 for (int iCalo=0; iCalo< static_cast<int>(CaloCell_ID::NSUBCALO); ++iCalo){
56 m_hasCalo.push_back(false);
57 m_indexFirstCellCalo.push_back(-1);
58 m_indexLastCellCalo.push_back(-2);
59 m_beginConstCalo.push_back(this->begin());
60 m_endConstCalo.push_back(this->begin());
61 m_beginCalo.push_back(this->begin());
62 m_endCalo.push_back(this->begin());
63 }
64}
std::vector< CaloCellContainer::iterator > m_endCalo
std::vector< CaloCellContainer::const_iterator > m_endConstCalo
bool m_isOrdered
true if ordered
std::vector< CaloCellContainer::iterator > m_beginCalo
non const iterators for the different calorimeters
std::vector< int > m_indexLastCellCalo
index of first cell of given calo (-2 if none)
std::vector< bool > m_hasCalo
true if given cell from given calo has been filled (even if none)
bool m_hasTotalSize
true if size correspond to maximum hash.
bool m_isOrderedAndComplete
true if complete and in right order
std::vector< CaloCellContainer::const_iterator > m_beginConstCalo
const iterators for the different calorimeters
std::vector< int > m_indexFirstCellCalo
index of first cell of given calo (-1 if none)
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
const_iterator begin() const noexcept
SG::OwnershipPolicy ownPolicy() const

◆ CaloCellContainer() [2/2]

CaloCellContainer::CaloCellContainer ( size_t n,
SG::OwnershipPolicy ownPolicy = SG::OWN_ELEMENTS )

Sized constructor.

Definition at line 67 of file CaloCellContainer.cxx.

69{
70 resize(n);
71}
CaloCellContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Main constructor.
void resize(size_type sz)

◆ ~CaloCellContainer()

virtual CaloCellContainer::~CaloCellContainer ( )
inlinevirtual

destructor

Definition at line 86 of file CaloCellContainer.h.

86{ };

Member Function Documentation

◆ assign()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::assign ( InputIterator first,
InputIterator last )
inherited

Assign from iterators.

Parameters
firstThe start of the range to put in the container.
lastThe end of the range to put in the container.

Any existing owned elements will be released. The DataVector's ownership policy determines whether it will take ownership of the new elements.

◆ assignBaseElement()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::assignBaseElement ( typename BaseContainer::iterator pos,
typename BaseContainer::value_type newElem )
privateinherited

Handle element assignment from a base pointer.

Parameters
posPosition in the container to assign.
newElemThe new element to assign.

The old element is freed if this container owns elements. Auxiliary data are copied if appropriate.

◆ assignElement()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::assignElement ( typename BaseContainer::iterator pos,
value_type newElem )
privateinherited

Handle element assignment.

Parameters
posPosition in the container to assign.
newElemThe new element to assign.

The old element is freed if this container owns elements. Auxiliary data are copied if appropriate.

◆ at()

const CaloCell * DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::at ( size_type n) const
inherited

Access an element, as an rvalue.

Parameters
nArray index to access.
Returns
The element at n.

Will raise std::out_of_range if the index is out-of-bounds. Note that we return a const T* rather than a reference.

◆ auxbase()

const SG::AuxVectorBase & DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::auxbase ( ) const
inherited

Convert to AuxVectorBase.

Needed to get AuxVectorBase from a ConstDataVector. Present in DataVector as well for consistency. We only really need it in the base class; however, root6 fails constructing a TMethodCall for this if there is virtual derivation. A workaround is to redeclare this in the derived classes too.

◆ back()

const CaloCell * DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::back ( ) const
inherited

Access the last element in the collection as an rvalue.

Returns
The last element in the collection.

No checking is done to ensure that the container is not empty. Note that we return a const T* rather than a reference.

◆ baseOffset()

int DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::baseOffset ( const std::type_info & ti)
staticinherited

Return the offset of a base DataVector class.

Parameters
tistd::type_info of the desired class.

If ti represents a DataVector base class of this one, then return the offset of that base class. Otherwise, return -1.

This function is here due to limitations of root 6, which can't calculate these offsets correctly from the dictionary if virtual derivation is used.

◆ baseOffset1()

int DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::baseOffset1 ( const char * p,
const DataVector< CaloCell > & dv,
const std::type_info & ti )
staticinherited

Helper for baseOffset.

Parameters
pPointer to the start of the top-level object.
dvReference to the DataVector object.
tistd::type_info of the desired class.

If ti represents a DataVector base class of this one, then return the offset of that base class. Otherwise, return -1.

◆ begin()

const_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::begin ( ) const
noexceptinherited

Return a const_iterator pointing at the beginning of the collection.

Returns
A const_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ beginCalo()

CaloCellContainer::iterator CaloCellContainer::beginCalo ( CaloCell_ID::SUBCALO caloNum)

get non const iterators on cell of just one calo

Definition at line 123 of file CaloCellContainer.cxx.

124{
125 return m_beginCalo[static_cast<int>(caloNum)];
126}

◆ beginConstCalo()

CaloCellContainer::const_iterator CaloCellContainer::beginConstCalo ( CaloCell_ID::SUBCALO caloNum) const

get const iterators on cell of just one calo

Definition at line 119 of file CaloCellContainer.cxx.

119 {
120 return m_beginConstCalo[static_cast<int>(caloNum)];
121}

◆ capacity()

size_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::capacity ( ) const
noexceptinherited

Returns the total number of elements that the collection can hold before needing to allocate more memory.

◆ cbegin()

const_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::cbegin ( ) const
noexceptinherited

Return a const_iterator pointing at the beginning of the collection.

Returns
A const_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ cend()

const_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::cend ( ) const
noexceptinherited

Return a const_iterator pointing past the end of the collection.

Returns
A const_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ checkOrdered()

bool CaloCellContainer::checkOrdered ( ) const

verify one by one the container is ordered

Definition at line 173 of file CaloCellContainer.cxx.

173 {
174 CaloCellContainer::const_iterator itr=this->begin(),itrEnd=this->end();
175 unsigned int hashPrev=0;
176
177 for (;itr!=itrEnd;++itr){
178
179 const CaloCell * theCell=*itr;
180
181 const CaloDetDescrElement * theDDE = nullptr;
182
183 if (theCell==nullptr){
184 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "CaloCellContainer")
185 << MSG::WARNING << "CaloCellContainer NULL CELL ";
186 } else {
187 theDDE=theCell->caloDDE();
188 if (theDDE==nullptr){
189 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "CaloCellContainer")
190 << MSG::WARNING << "CaloCellContainer WARNING NULL DDE ";
191 }
192 else{
193 unsigned int hash=theDDE->calo_hash();
194 if ( hash < hashPrev) return false ;
195 hashPrev=hash;
196 }
197
198 }
199 }
200
201 return true;
202}
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept

◆ checkOrderedAndComplete()

bool CaloCellContainer::checkOrderedAndComplete ( ) const

verify one by one the container is complete (i.e.

size is equal to the maximum of hash identifier) and in order

Definition at line 150 of file CaloCellContainer.cxx.

150 {
151 //should have maximum hash size in any case
152 if (!this->hasTotalSize()) return false;
153
154 CaloCellContainer::const_iterator itr=this->begin(),itrEnd=this->end();
155 unsigned int index=0;
156 for (;itr!=itrEnd;++itr){
157 if ( ((*itr)->caloDDE())->calo_hash()!=index) {
158 return false;
159 }
160 ++index;
161 }
162 return true;
163}
bool hasTotalSize() const
tell wether container has total hash id size
str index
Definition DeMoScan.py:362

◆ clear()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::clear ( )
inherited

Erase all the elements in the collection.

Erase all the elements in the collection, and reset the ownership mode.

If the container owns its elements, then the removed elements will be deleted. Any duplicates will be removed in this process, but don't rely on this.

Parameters
ownPolicyThe new ownership policy of the container.
trackIndicesThe index tracking policy.

If the container owns its elements, then the removed elements will be deleted. Any duplicates will be removed in this process, but don't rely on this.

◆ clearMostDerived()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::clearMostDerived ( )
protectedinherited

Clear m_isMostDerived for this instance and for all bases.

Called from the constructor after setting m_isMostDerived.

◆ crbegin()

const_reverse_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::crbegin ( ) const
noexceptinherited

Return a const_reverse_iterator pointing past the end of the collection.

Returns
A const_reverse_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ crend()

const_reverse_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::crend ( ) const
noexceptinherited

Return a const_reverse_iterator pointing at the beginning of the collection.

Returns
A const_reverse_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ do_cast()

const CaloCell * DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::do_cast ( const typename PtrVector::value_type p)
staticinherited

Helper to shorten calls to DataModel_detail::DVLCast.

Parameters
pThe value to convert.
Returns
The value as a const T*.

The conversion will be done with static_cast if possible, with dynamic_cast otherwise.

◆ do_cast_nc()

CaloCell * DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::do_cast_nc ( typename PtrVector::value_type p)
staticinherited

Helper to shorten calls to DataModel_detail::DVLCast.

Parameters
pThe value to convert.
Returns
The value as a T*.

The conversion will be done with static_cast if possible, with dynamic_cast otherwise.

◆ dv_typeid()

virtual const std::type_info & DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::dv_typeid ( ) const
overrideprivatevirtualinherited

Find the most-derived DataVector class in the hierarchy.

Returns
The type_info for the class for which this method gets run.

This is used to generate a nice error message when the most-derived check for insertions fails. Every DataVector defines this virtual method, so when it's called, the one corresponding to the most-derived DataVector gets run.

◆ dvlinfo()

const DataModel_detail::DVLInfoBase & DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::dvlinfo ( )
staticinherited

Return the DV/DL info struct for this class.

This can be used to make sure that it's instantiated.

◆ dvlinfo_v()

virtual const DataModel_detail::DVLInfoBase & DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::dvlinfo_v ( ) const
overridevirtualinherited

Return the DV/DL info struct for this class.

This can be used to make sure that it's instantiated.

◆ emplace()

iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::emplace ( iterator position,
value_type pElem )
inherited

Add a new element to the collection.

Parameters
positionIterator before which the element will be added.
pElemThe element to add to the collection.
Returns
An iterator that points to the inserted data.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

For DataVector, this is just the same as insert. It's included just for interface compatibility with std::vector.

◆ emplace_back()

value_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::emplace_back ( value_type pElem)
inherited

Add an element to the end of the collection.

Parameters
pElemThe element to add to the collection.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

For DataVector, this is like the same as push_back, and it returns the pushed element. It's included just for interface compatibility with std::vector.

◆ empty()

bool DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::empty ( ) const
nodiscardnoexceptinherited

Returns true if the collection is empty.

◆ end()

const_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::end ( ) const
noexceptinherited

Return a const_iterator pointing past the end of the collection.

Returns
A const_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ endCalo()

CaloCellContainer::iterator CaloCellContainer::endCalo ( CaloCell_ID::SUBCALO caloNum)

Definition at line 128 of file CaloCellContainer.cxx.

129{
130 return m_endCalo[static_cast<int>(caloNum)];
131}

◆ endConstCalo()

CaloCellContainer::const_iterator CaloCellContainer::endConstCalo ( CaloCell_ID::SUBCALO caloNum) const

Definition at line 133 of file CaloCellContainer.cxx.

133 {
134 return m_endConstCalo[static_cast<int>(caloNum)];
135}

◆ erase()

iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::erase ( iterator position)
inherited

Remove element at a given position.

Parameters
positionIterator pointing to the element to be removed.
Returns
An iterator pointing to the next element (or end()).

If the container owns its elements, then the pointed-to element will be deleted.

◆ findCell() [1/2]

CaloCell * CaloCellContainer::findCell ( const IdentifierHash theHash)

fast find method given identifier hash.

If the container is not ordered and complete a look up map is used, which is build the first time this method of findCellVector is used

Definition at line 354 of file CaloCellContainer.cxx.

355{
356 int ndx = findIndex (theHash);
357 if (ndx >= 0)
358 return (*this)[ndx];
359 return nullptr;
360}
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.

◆ findCell() [2/2]

const CaloCell * CaloCellContainer::findCell ( const IdentifierHash theHash) const

fast find method given identifier hash.

If the container is not ordered and complete a look up map is used, which is build the first time this method of findCellVector is used

Definition at line 345 of file CaloCellContainer.cxx.

346{
347 int ndx = findIndex (theHash);
348 if (ndx >= 0)
349 return (*this)[ndx];
350 return nullptr;
351}

◆ findCellVector() [1/2]

void CaloCellContainer::findCellVector ( const std::vector< IdentifierHash > & theVectorHash,
CellVector & theCellVector ) const

fast find method given vector of identifier hash.

Be careful that the order of cell return may not match the order of the inputs, and that some cells may be missing

Definition at line 422 of file CaloCellContainer.cxx.

423{
424 findCellVectorT (*this, theVectorHash, theCellVector);
425#if 0
426 theCellVector.reserve (theCellVector.size() + theVectorHash.size());
427 if (isOrderedAndComplete()) {
428
429 for (IdentifierHash hash : theVectorHash) {
430 theCellVector.push_back( (*this)[hash] );
431 }
432 return;
433 }
434
435 if (this->empty()) return ;
436
437 const CxxUtils::PackedArray& lookUpTable = getLookUpTable();
438
439 //look in look up table (do not put empty cells)
440
441 size_t tbsize = lookUpTable.size();
442 for (IdentifierHash hash : theVectorHash) {
443 // careful that the look up table might be shorter than the maximum hash
444 if (hash>=tbsize) continue ;
445 int ndx = (int)lookUpTable[ hash ] - 1;
446 if (ndx >= 0) {
447 const CaloCell * theCell = (*this)[ndx];
448 if (theCell!=0) {
449 theCellVector.push_back( theCell);
450 }
451 }
452
453 }
454#endif
455}
static void findCellVectorT(CONT &cont, const std::vector< IdentifierHash > &theVectorHash, VECT &theCellVector)
Look up a group of cells by IdentifierHash.
bool isOrderedAndComplete() const
tell wether container is complete and in order
const CxxUtils::PackedArray & getLookUpTable() const
Retrieve an initialized lookup table.
size_type size() const
Returns the number of elements in the collection.
bool empty() const noexcept

◆ findCellVector() [2/2]

void CaloCellContainer::findCellVector ( const std::vector< IdentifierHash > & theVectorHash,
MutableCellVector & theCellVector )

fast find method given vector of identifier hash.

Be careful that the order of cell return may not match the order of the inputs, and that some cells may be missing

Definition at line 457 of file CaloCellContainer.cxx.

458{
459 findCellVectorT (*this, theVectorHash, theCellVector);
460}

◆ findCellVectorT()

template<class CONT, class VECT>
void CaloCellContainer::findCellVectorT ( CONT & cont,
const std::vector< IdentifierHash > & theVectorHash,
VECT & theCellVector )
staticprivate

Look up a group of cells by IdentifierHash.

This is a templated version that can be instantiated for both const and non-const versions.

Parameters
contThe container from which to fetch cells.
theVectorHashVector of desired IdentifierHash's.
theCellVectorFound cells will be appended to this vector.

Definition at line 389 of file CaloCellContainer.cxx.

390{
391 theCellVector.reserve (theCellVector.size() + theVectorHash.size());
392 if (cont.isOrderedAndComplete()) {
393
394 for (IdentifierHash hash : theVectorHash) {
395 theCellVector.push_back( cont[hash] );
396 }
397 return;
398 }
399
400 if (cont.empty()) return ;
401
402 const CxxUtils::PackedArray& lookUpTable = cont.getLookUpTable();
403
404 //look in look up table (do not put empty cells)
405
406 size_t tbsize = lookUpTable.size();
407 for (IdentifierHash hash : theVectorHash) {
408 // careful that the look up table might be shorter than the maximum hash
409 if (hash>=tbsize) continue ;
410 int ndx = (int)lookUpTable[ hash ] - 1;
411 if (ndx >= 0) {
412 auto theCell = cont[ndx];
413 if (theCell!=nullptr) {
414 theCellVector.push_back( theCell);
415 }
416 }
417
418 }
419}

◆ findIndex()

int CaloCellContainer::findIndex ( const IdentifierHash theHash) const

Return index of the cell with a given hash.

Returns -1 if the cell isn't found.

Definition at line 363 of file CaloCellContainer.cxx.

364{
365 //cache Identifierhash->unsigned int conversion (maybe too much)
366 const unsigned int theIndex = theHash ;
367
368 // if container is complete and in order use directly the container
369 if (isOrderedAndComplete()) return theIndex;
370
371 if (this->empty()) return -1;
372
373 const CxxUtils::PackedArray& lookUpTable = getLookUpTable();
374 if (theIndex < lookUpTable.size() )
375 return (int)lookUpTable[theIndex] - 1;
376 return -1;
377}

◆ front()

const CaloCell * DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::front ( ) const
inherited

Access the first element in the collection as an rvalue.

Returns
The first element in the collection.

No checking is done to ensure that the container is not empty. Note that we return a const T* rather than a reference.

◆ get()

const CaloCell * DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::get ( size_type n) const
inherited

Access an element, as an rvalue.

Parameters
nArray index to access.
Returns
The element at n.

This is a synonym for operator[] const, to be used when calling from root (where we can't readily call just the const version of a method).

◆ getLookUpTable()

const CxxUtils::PackedArray & CaloCellContainer::getLookUpTable ( ) const
private

Retrieve an initialized lookup table.

Definition at line 586 of file CaloCellContainer.cxx.

587{
588 // FIXME should have an argument about duplicates
589 // fill the look up table
590 // note that if CaloCellContainer is not completely filled, there
591 // is no guarantee it has the correct size, hence the size should
592 // be checked at every call
593 // (CaloCellContainer has no way to know the maximum size)
594 // Now (30.07.2008) have it always max number of cells (hardcoded) to speed up.
595
596 if (!m_lookUpTable.isValid()) {
597
598 unsigned int theSize=0;
599 size_t ncells = size();
600 CxxUtils::PackedArray lookUpTable (std::max (1, ilog2 (ncells + 1)));
601
602 if (ncells > 0) {
603
604 // Set the size of the lookup table.
605 // If the cells are sorted, we can look at the last cell to know
606 // the maximum hash we're dealing with. Otherwise, set it to the
607 // maximum cell hash value.
608 if (isOrdered()) {
609 // Set LUT size from the hash of the last cell.
610 theSize = back()->caloDDE()->calo_hash()+1;
611 }
612 else {
613 // Find the maximum hash.
614 const CaloDetDescriptor* desc = front()->caloDDE()->descriptor();
615 IdentifierHash max_hash = desc->get_calo_helper()->calo_cell_hash_max();
616 theSize = max_hash + 1;
617 }
618 lookUpTable.resize (theSize);
619
620 for (size_t icell = 0; icell < ncells; icell++) {
621
622 const CaloCell * theCell = (*this)[icell];
623 const IdentifierHash theHash=theCell->caloDDE()->calo_hash();
624
625 assert (theHash < theSize);
626
627 if (nWarningsToBePrinted > 0) {
628 // We may actually enter here nWarningsToBePrinted times
629 // if multiple threads race here, but it doesn't matter.
630 int nwarn = nWarningsToBePrinted--;
631 int iold = (int)(lookUpTable[theHash])-1;
632 if (iold >= 0) {
633 if ((size_t)iold == icell) {
634 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "CaloCellContainer")
635 << "Repeated cell. hash= " << theHash;
636 }
637 else if ((*this)[iold]->ID()==theCell->ID()) {
638 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "CaloCellContainer")
639 << "Duplicated cell. hash="
640 << theHash
641 << " E1=" << (*this)[iold]->e()
642 << " E2=" << theCell->e();
643 // should delete the cell?
644 } else {
645 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "CaloCellContainer")
646 << "Should be impossible ! Repeated cell. hash= " << theHash;
647 }
648 if (nwarn==0) {
649 REPORT_MESSAGE_WITH_CONTEXT (MSG::INFO, "CaloCellContainer")
650 << "No more WARNING will be printed";
651 }
652 }
653 } // end of print out
654
655 lookUpTable[theHash]=icell+1;
656 }
657 }
658 m_lookUpTable.set (std::move (lookUpTable));
659 }
660
661 return *m_lookUpTable.ptr();
662}
std::vector< Identifier > ID
CxxUtils::CachedValue< CxxUtils::PackedArray > m_lookUpTable
look up table of size HashIdentifiermax.
bool isOrdered() const
tell wether container is ordered
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
const CaloDetDescriptor * descriptor() const
cell descriptor
const CaloCell * back() const
const CaloCell * front() const
size_type size() const noexcept

◆ hasCalo()

bool CaloCellContainer::hasCalo ( const CaloCell_ID::SUBCALO caloNum) const

tell wether it has been filled with cells (maybe none) of a given calo

Definition at line 209 of file CaloCellContainer.cxx.

209 {
210 return m_hasCalo[static_cast<int>(caloNum)];
211}

◆ hasTotalSize()

bool CaloCellContainer::hasTotalSize ( ) const
inline

tell wether container has total hash id size

Definition at line 289 of file CaloCellContainer.h.

289 {
290 return m_hasTotalSize ;
291}

◆ indexFirstCellCalo()

int CaloCellContainer::indexFirstCellCalo ( const CaloCell_ID::SUBCALO caloNum) const

index of first cell of given calorimeter (-1 if none).

Note that it is normally more efficient to use iterators

Definition at line 137 of file CaloCellContainer.cxx.

137 {
138 return m_indexFirstCellCalo[static_cast<int>(caloNum)];
139}

◆ indexLastCellCalo()

int CaloCellContainer::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 iterators.

Definition at line 141 of file CaloCellContainer.cxx.

141 {
142 return m_indexLastCellCalo[static_cast<int>(caloNum)];
143}

◆ initializeLookUpTable()

void CaloCellContainer::initializeLookUpTable ( )

initialize look up table.

Note that the look up table is initialized the first time findcell is called. If new cells are added afterwards (should not be the case) the lookuptable need be reinitialized by hand

Definition at line 467 of file CaloCellContainer.cxx.

468{
469 this->resetLookUpTable();
471}
void resetLookUpTable()
reset look up table

◆ insert()

iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::insert ( iterator position,
value_type pElem )
inherited

Add a new element to the collection.

Parameters
positionIterator before which the element will be added.
pElemThe element to add to the collection.
Returns
An iterator that points to the inserted data.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

◆ insertMove()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::insertMove ( iterator position,
DataVector< CaloCell > & other )
inherited

Insert the contents of another DataVector, with auxiliary data copied via move semantics.

Parameters
positionIterator before which the new elements will be added.
otherThe vector to add.

The ownership mode of this vector must be the same as other; otherwise, an exception will be thrown.

If both vectors are view vectors, then this is the same as insert (position, other.begin(), other.end()) .

Otherwise, the elements from other will be inserted into this vector. This vector will take ownership of the elements, and the ownership mode of other will be changed to VIEW_ELEMENTS. Auxiliary data for these elements will be transferred, using move semantics if possible. (Thus, the auxiliary store for other may be modified and must not be locked.) Finally, the auxiliary store pointer for other will be cleared (but the store itself will not be deleted since it's not owned by the vector).

Note: this method may only be called using the most derived DataVector in the hierarchy.

◆ isOrdered()

bool CaloCellContainer::isOrdered ( ) const
inline

tell wether container is ordered

Definition at line 293 of file CaloCellContainer.h.

293 {
294 return m_isOrdered ;
295}

◆ isOrderedAndComplete()

bool CaloCellContainer::isOrderedAndComplete ( ) const
inline

tell wether container is complete and in order

Definition at line 298 of file CaloCellContainer.h.

298 {
300}

◆ iter_swap()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::iter_swap ( iterator a,
iterator b )
staticinherited

Swap the referents of two DataVector iterators.

Parameters
aThe first iterator for the swap.
bThe second iterator for the swap.

◆ max_size()

size_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::max_size ( ) const
noexceptinherited

Returns the size() of the largest possible collection.

◆ msgSvc()

IMessageSvc * CaloCellContainer::msgSvc ( ) const
private

get message service

◆ nCellsCalo()

int CaloCellContainer::nCellsCalo ( const CaloCell_ID::SUBCALO caloNum) const

get number of cels of given calorimeter

Definition at line 145 of file CaloCellContainer.cxx.

145 {
146 return this->indexLastCellCalo(caloNum)-this->indexFirstCellCalo(caloNum)+1;
147}
int indexFirstCellCalo(const CaloCell_ID::SUBCALO caloNum) const
index of first cell of given calorimeter (-1 if none).
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...

◆ operator[]()

const CaloCell * DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::operator[] ( size_type n) const
inherited

Access an element, as an rvalue.

Parameters
nArray index to access.
Returns
The element at n.

No bounds checking is done. Note that we return a const T* rather than a reference.

◆ order()

void CaloCellContainer::order ( )

order container

Definition at line 474 of file CaloCellContainer.cxx.

475{
476 if (this->hasTotalSize()){
477 this->orderWhenComplete();
478 }
479 else{
480 this->orderWhenIncomplete();
481 }
482
483}
void orderWhenIncomplete()
order when container is incomplete
void orderWhenComplete()
order when container is complete

◆ orderWhenComplete()

void CaloCellContainer::orderWhenComplete ( )
private

order when container is complete

Definition at line 556 of file CaloCellContainer.cxx.

557{
559 tmp.swap (*this);
560 reserve (tmp.size());
561
562 DataVector<CaloCell>::iterator tmpend = tmp.end();
563 for (DataVector<CaloCell>::iterator it = tmp.begin(); it != tmpend; ++it) {
564 IdentifierHash hash = (*it)->caloDDE()->calo_hash();
565
566 if (hash >= size())
567 resize (hash + 1);
568
569 if ((*this)[hash] != nullptr) {
570 REPORT_MESSAGE_WITH_CONTEXT (MSG::ERROR, "CaloCellContainer")
571 << "Duplicated cell: hash= " << hash;
572 }
573 else {
574 using std::iter_swap;
575 iter_swap (begin() + hash, it);
576 }
577 }
578
579 // set the Ordered And Complete flag
580 this->setIsOrderedAndComplete(true);
581
582 // look up table is not necessary anymore
583 this->resetLookUpTable();
584}
void setIsOrderedAndComplete(const bool ordered)
indicate that the container is complete and in order
void reserve(size_type n)
static void iter_swap(iterator a, iterator b)
void iter_swap(typename DataModel_detail::iterator< DV > a, typename DataModel_detail::iterator< DV > b)
Specialization of iter_swap for DataVector/DataList.

◆ orderWhenIncomplete()

void CaloCellContainer::orderWhenIncomplete ( )
private

order when container is incomplete

Definition at line 485 of file CaloCellContainer.cxx.

486{
487 // If the number of cells is small compared to the maximum number
488 // of cells, best to just use the STL sort and then remove duplicates.
489 // Otherwise, sort by inserting into a table based on the hash code.
490 // Break point chosen pretty much arbitrarily. Could be further
491 // tuned, but it probably doesn't really make much difference.
492 if (size() < 500) {
493 // Small number of cells. Use STL sort.
495
496 // Nb. Need to convert to int --- otherwise, 0-1 will wrap around
497 // to maxuint.
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())
501 {
502 REPORT_MESSAGE_WITH_CONTEXT (MSG::ERROR, "CaloCellContainer")
503 << "Duplicated cell: hash= " << (*this)[i]->caloDDE()->calo_hash();
504 erase (begin() + i);
505 }
506 else
507 ++i;
508 }
509 }
510 else {
511 // Sort for large container.
512
513 // Find the maximum possible hash code.
514 const CaloDetDescriptor* desc = front()->caloDDE()->descriptor();
515 IdentifierHash max_hash = desc->get_calo_helper()->calo_cell_hash_max();
516
517 // Make a temporary container that can hold all possible cells.
518 DataVector<CaloCell> tmp (max_hash+1, ownPolicy());
519
520 // Move cells into the temporary container, according to hashes.
522 for (DataVector<CaloCell>::iterator it = begin(); it != itend; ++it) {
523 IdentifierHash hash = (*it)->caloDDE()->calo_hash();
524 assert (hash < tmp.size());
525
526 if (tmp[hash] != nullptr) {
527 REPORT_MESSAGE_WITH_CONTEXT (MSG::ERROR, "CaloCellContainer")
528 << "Duplicated cell: hash= " << hash;
529 }
530 else {
531 using std::iter_swap;
532 iter_swap (tmp.begin() + hash, it);
533 }
534 }
535
536 // Now, move the cells back, eliminating spaces.
537 itend = tmp.end();
539 for (DataVector<CaloCell>::iterator it = tmp.begin(); it != itend; ++it) {
540 if (*it != nullptr) {
541 using std::iter_swap;
542 iter_swap (itout, it);
543 ++itout;
544 }
545 }
546
547 // May be less, if there were duplicates.
548 // cppcheck-suppress assertWithSideEffect
549 assert (itout <= end());
550 resize (itout - begin());
551 }
553 setIsOrdered(true);
554}
functor to order cells according to caloHash
void initializeLookUpTable()
initialize look up table.
void setIsOrdered(const bool ordered)
indicates that the container is ordered
iterator erase(iterator position)

◆ ownPolicy()

SG::OwnershipPolicy DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::ownPolicy ( ) const
inherited

Return the ownership policy setting for this container.

◆ pop_back()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::pop_back ( )
inherited

Remove the last element from the collection.

If the container owns its elements, then the removed element will be deleted.

◆ print()

void CaloCellContainer::print ( )
static

dump (obsolete)

Definition at line 112 of file CaloCellContainer.cxx.

112 {
113 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "CaloCellContainer")
114 << "CaloCellContainer::print not implemented";
115}

◆ push_back() [1/3]

void CaloCellContainer::push_back ( CaloCell * theCell)

reimplementation of const push_back

Definition at line 74 of file CaloCellContainer.cxx.

75{
77
78 // only allow const push_back if view cells
79 // if (ownPolicy()==SG::VIEW_ELEMENTS){
80 // std::cout << "ERROR Should not push_back non const cell in VIEW CaloCellContainer" << std::endl;
81 // }
82
83
84 this->setHasCalo(theCell->caloDDE()->getSubCalo()) ;
85
87
88}
void setHasCalo(const CaloCell_ID::SUBCALO caloNum)
set which calo has been filled.
value_type push_back(value_type pElem)
Add an element to the end of the collection.

◆ push_back() [2/3]

void CaloCellContainer::push_back ( std::unique_ptr< CaloCell > theCell)

reimplementation of const push_back(unique_ptr>)

Definition at line 90 of file CaloCellContainer.cxx.

91{
93 this->setHasCalo(theCell->caloDDE()->getSubCalo()) ;
94
95 DataVector<CaloCell>::push_back(std::move(theCell));
96
97}

◆ push_back() [3/3]

value_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::push_back ( value_type pElem)
inherited

Add an element to the end of the collection.

Parameters
pElemThe element to add to the collection.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

Returns the pushed pointer.

◆ push_back_fast() [1/2]

void CaloCellContainer::push_back_fast ( CaloCell * theCell)

reimplementation of push_back to gain speed in readin

Definition at line 102 of file CaloCellContainer.cxx.

103{
105}

◆ push_back_fast() [2/2]

void CaloCellContainer::push_back_fast ( std::unique_ptr< CaloCell > theCell)

reimplementation of push_back to gain speed in readin (UP version)

Definition at line 107 of file CaloCellContainer.cxx.

108{
109 DataVector<CaloCell>::push_back(std::move(theCell));
110}

◆ push_new()

size_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::push_new ( size_type n,
F alloc )
inherited

Create and add a number of new elements to the end of the container.

Parameters
nThe number of new elements to add.
allocFunctional to call to allocate a new element to push. Should be callable like T* = alloc(); For example:
dv.push_new (n, [](){ return new Foo; });
Definition FooBar.h:9
It may also be useful to allocate from a DataPool.

Note: this method may only be called using the most derived DataVector in the hierarchy.

Returns the original size of the vector.

◆ rbegin()

const_reverse_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::rbegin ( ) const
noexceptinherited

Return a const_reverse_iterator pointing past the end of the collection.

Returns
A const_reverse_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ rend()

const_reverse_iterator DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::rend ( ) const
noexceptinherited

Return a const_reverse_iterator pointing at the beginning of the collection.

Returns
A const_reverse_iterator.

Note that dereferencing the iterator will yield a const T* rather than a reference.

◆ reserve()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::reserve ( size_type n)
inherited

Attempt to preallocate enough memory for a specified number of elements.

Parameters
nNumber of elements required.

◆ resetLookUpTable()

void CaloCellContainer::resetLookUpTable ( )

reset look up table

Definition at line 462 of file CaloCellContainer.cxx.

463 {
464 m_lookUpTable.reset();
465 }

◆ resize()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::resize ( size_type sz)
inherited

Resizes the collection to the specified number of elements.

Parameters
szThe new size of the collection.

Note that this function differs from the standard in that it does not allow specifying the value of any inserted elements. They will always be 0.

If the container is shrunk, elements will be deleted as with erase().

◆ resortAux()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::resortAux ( iterator beg,
iterator end )
inherited

Reset indices / reorder aux data after elements have been permuted.

Parameters
begStart of the range of elements to process.
endEnd of the range of elements to process.

Call this after some operation that has permuted the elements in the container (such as sort). The index information in the elements will be used to permute all auxiliary data in the same way. Finally, all the indices will be reset in the correct order.

◆ setHasCalo()

void CaloCellContainer::setHasCalo ( const CaloCell_ID::SUBCALO caloNum)

set which calo has been filled.

Definition at line 213 of file CaloCellContainer.cxx.

213 {
214
215 const int iCalo=static_cast<int>(caloNum);
216
217 m_hasCalo[iCalo] = true;
218}

◆ setHasTotalSize()

void CaloCellContainer::setHasTotalSize ( const bool hasTotalSize)
private

If @ flag is true, then the container size equals the maximum hash.

Only CaloCellContainerFinalizer tool is allowed to set this. Now, set this in EmptyCellBuilderTool as it is always true.

Definition at line 169 of file CaloCellContainer.cxx.

169 {
171}

◆ setIsOrdered()

void CaloCellContainer::setIsOrdered ( const bool ordered)

indicates that the container is ordered

Definition at line 204 of file CaloCellContainer.cxx.

204 {
205 m_isOrdered = ordered;
206}

◆ setIsOrderedAndComplete()

void CaloCellContainer::setIsOrderedAndComplete ( const bool ordered)

indicate that the container is complete and in order

Definition at line 165 of file CaloCellContainer.cxx.

165 {
166 m_isOrderedAndComplete = orderedAndComplete ;
167}

◆ setMostDerived()

virtual void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::setMostDerived ( )
overrideprotectedvirtualinherited

Set m_isMostDerived for this instance and clear it for all bases.

Called from testInsert if the test fails. The flag may not have been set if this container was made via copy construction, so set it appropriately now so we can test again.

◆ shift()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::shift ( size_t pos,
ptrdiff_t offs )
privateinherited

Shift the auxiliary elements of the container.

Parameters
posThe starting index for the shift.
offsThe (signed) amount of the shift.

The elements in the container should have already been shifted; this operation will then adjust the element indices and also shift the elements in the vectors for all aux data items. offs may be either positive or negative.

If offs is positive, then the container is growing. The container size should be increased by offs, the element at pos moved to pos + offs, and similarly for following elements. The elements between pos and pos + offs should be default-initialized.

If offs is negative, then the container is shrinking. The element at pos should be moved to pos + offs, and similarly for following elements. The container should then be shrunk by -offs elements (running destructors as appropriate).

◆ shrink_to_fit()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::shrink_to_fit ( )
inherited

◆ size()

size_type DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::size ( ) const
noexceptinherited

Returns the number of elements in the collection.

Could in principle be inherited from the base class, but redeclared in the derived class to avoid root6 bugs.

◆ sort()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::sort ( )
inherited

Sort the container.

This just sorts by pointer value, so it's probably not very useful.

◆ stdcont()

const PtrVector & DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::stdcont ( ) const
inherited

Return the underlying std::vector of the container.

Returns
Reference to the std::vector actually holding the collection.

Note that DataVector<T>::stdcont does not necessarily return a std::vector<T*> if DataVector inheritance is being used.

◆ swap()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::swap ( DataVector< CaloCell > & rhs)
inherited

Swap this collection with another.

Parameters
rhsThe collection with which to swap.

Ownership is swapped along with the collection content.

Note: this method may only be called using the most-derived DataVector in the hierarchy. The rhs must also be referenced using the most-derived DataVector.

◆ swapElement()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::swapElement ( size_type index,
value_type newElem,
reference oldElem )
inherited

Swap one element out of the container.

Parameters
indexIndex of the element in the container to swap.
newElemNew element to put in the container. May be 0.
oldElemReference to receive the element removed from the container.

Reference oldElem is initialized with element index of the collection (no bounds checking). Then element index is set to newElem. If the collection owns its elements, then it will take ownership of newElem and release (without deleting) the element returned through oldElem.

Note: this method may only be called using the most derived DataVector in the hierarchy.

◆ testInsert()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::testInsert ( const char * op)
inherited

Test if we can insert; raise an exception if not.

Parameters
opDescription of the attempted operation.

In order to maintain type-safety, we can only allow insertions using the most-derived instance of DataVector. This checks this by testing the m_isMostDerived, which is set by the constructors to true only for the most-derived instance. If the test fails, we call to potentially out-of-line code to continue.

◆ testInsertOol()

void DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::testInsertOol ( const char * op)
inherited

Test if we can insert; raise an exception if not.

Parameters
opDescription of the attempted operation.

This continues the test of testInsert. There is one case where m_isMostDerived may not be set correctly. If this container was made via copy construction, then all the m_isMostDerived flags will be false. So we call setMostDerived to set the flags correctly and test again. If the test fails again, then we raise an exception.

◆ updateCaloBeginIterators()

void CaloCellContainer::updateCaloBeginIterators ( int ic,
int ind )

fills calo iterators and the index of first cell for a given subcalo

Definition at line 326 of file CaloCellContainer.cxx.

326 {
327 if (ic==0) {
328 m_beginConstCalo[ic]=this->begin();
329 m_beginCalo[ic]=this->begin();
331 }else{
332 m_beginConstCalo[ic]=this->end();
333 m_beginCalo[ic]=this->end();
335 }
336}
int ic
Definition grepfile.py:33

◆ updateCaloEndIterators()

void CaloCellContainer::updateCaloEndIterators ( int ic,
int ind )

fills calo iterators and the index of last cell for a given subcalo

Definition at line 338 of file CaloCellContainer.cxx.

338 {
339 m_endConstCalo[ic]=this->end();
340 m_endCalo[ic]=this->end();
341 m_indexLastCellCalo[ic]=ind-1;
342}

◆ updateCaloIterators()

void CaloCellContainer::updateCaloIterators ( )

fill calo iterators and the index of first and last cell IT IS THE RESPONSABILITY OF THE PRODUCER TO CALL THIS METHOD ONCE THE FILLING IS FINISHED Please use CaloCellContainerFinalizerTool to make sure the container is properly finalised.

Definition at line 268 of file CaloCellContainer.cxx.

269{
270
271 //initialise
272 for (int iCalo=0; iCalo< static_cast<int>(CaloCell_ID::NSUBCALO); ++iCalo){
273 m_indexFirstCellCalo[iCalo]=-1;
274 m_indexLastCellCalo[iCalo]=-2;
275 m_beginConstCalo[iCalo]=this->begin();
276 m_endConstCalo[iCalo]=this->begin();
277 m_beginCalo[iCalo]=this->begin();
278 m_endCalo[iCalo]=this->begin();
279 }
280
283 return;
284 }
285
286 CaloCellContainer::const_iterator itr=this->begin(),itrEnd=this->end();
287 CaloCellContainer::iterator itrNonConst=this->begin();
288 int previousCellCalo=-1;
289 int index=0;
290 for (;itr!=itrEnd;++itr){
291 const int iCalo= static_cast<int>( (*itr)->caloDDE()->getSubCalo());
292 if (iCalo!=previousCellCalo){
293
294 // new calo domain
295 if (m_indexFirstCellCalo[iCalo]>=0){
296 REPORT_MESSAGE_WITH_CONTEXT (MSG::ERROR, "CaloCellContainer")
297 << " Specific calo cells are split."
298 << " Specific calo iterators will be wrong ";
299 }
301 m_beginConstCalo[iCalo]=itr;
302 m_beginCalo[iCalo]=itrNonConst;
303
304 if (previousCellCalo>=0){
305 m_indexLastCellCalo[previousCellCalo]=index-1;
306 m_endConstCalo[previousCellCalo]=itr;
307 m_endCalo[previousCellCalo]=itrNonConst;
308
309 }
310 }
311 previousCellCalo=iCalo;
312 ++itrNonConst;
313 ++index;
314 }
315
316 //case the calo is the last filled
317 if (previousCellCalo>=0){
318 m_indexLastCellCalo[previousCellCalo]=index-1;
319 m_endConstCalo[previousCellCalo]=itr;
320 m_endCalo[previousCellCalo]=itrNonConst;
321 }
322
323}
void updateCaloIteratorsOrdered(CaloCellContainer::iterator beg, CaloCellContainer::iterator end)
Recursively find division points between subcalos in the container.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842

◆ updateCaloIteratorsOrdered()

void CaloCellContainer::updateCaloIteratorsOrdered ( CaloCellContainer::iterator beg,
CaloCellContainer::iterator end )
private

Recursively find division points between subcalos in the container.

Should run in ~ m log n time, where n is the number of cells and m is the number of subcalos.

The cells need to be sorted for this to work.

Definition at line 245 of file CaloCellContainer.cxx.

247{
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) {
252 m_beginCalo[beg_calo] = beg;
253 m_endCalo[beg_calo] = end;
254 m_beginConstCalo[beg_calo] = beg;
255 m_endConstCalo[beg_calo] = end;
256 m_indexFirstCellCalo[beg_calo] = beg - this->begin();
257 m_indexLastCellCalo[beg_calo] = end - this->begin() - 1;
258 }
259 else {
261 std::partition_point (beg, end, is_calo (beg_calo));
262 updateCaloIteratorsOrdered (beg, beg2);
264 }
265}

◆ CaloCellContainerFinalizerTool

friend class CaloCellContainerFinalizerTool
friend

Definition at line 63 of file CaloCellContainer.h.

◆ CaloCellContCopyTool

friend class CaloCellContCopyTool
friend

Definition at line 67 of file CaloCellContainer.h.

◆ CaloCompactCellTool

friend class CaloCompactCellTool
friend

Definition at line 64 of file CaloCellContainer.h.

◆ CaloConstCellContainer

friend class CaloConstCellContainer
friend

Definition at line 62 of file CaloCellContainer.h.

◆ EmptyCellBuilderTool

friend class EmptyCellBuilderTool
friend

Definition at line 66 of file CaloCellContainer.h.

◆ FullCaloCellContMaker

friend class FullCaloCellContMaker
friend

Definition at line 65 of file CaloCellContainer.h.

Member Data Documentation

◆ has_virtual

const bool DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::has_virtual
staticinherited

This is true for any DataVector class if we need to use virtual derivation to get to the base DataVector class.

Definition at line 802 of file DataVector.h.

◆ m_beginCalo

std::vector< CaloCellContainer::iterator > CaloCellContainer::m_beginCalo
private

non const iterators for the different calorimeters

Definition at line 286 of file CaloCellContainer.h.

◆ m_beginConstCalo

std::vector< CaloCellContainer::const_iterator > CaloCellContainer::m_beginConstCalo
private

const iterators for the different calorimeters

Definition at line 284 of file CaloCellContainer.h.

◆ m_endCalo

std::vector< CaloCellContainer::iterator > CaloCellContainer::m_endCalo
private

Definition at line 286 of file CaloCellContainer.h.

◆ m_endConstCalo

std::vector< CaloCellContainer::const_iterator > CaloCellContainer::m_endConstCalo
private

Definition at line 284 of file CaloCellContainer.h.

◆ m_hasCalo

std::vector<bool> CaloCellContainer::m_hasCalo
private

true if given cell from given calo has been filled (even if none)

Definition at line 275 of file CaloCellContainer.h.

◆ m_hasTotalSize

bool CaloCellContainer::m_hasTotalSize
private

true if size correspond to maximum hash.

only CaloCellContainerFinalizer tool is allowed to set this

Definition at line 265 of file CaloCellContainer.h.

◆ m_indexFirstCellCalo

std::vector<int> CaloCellContainer::m_indexFirstCellCalo
private

index of first cell of given calo (-1 if none)

Definition at line 278 of file CaloCellContainer.h.

◆ m_indexLastCellCalo

std::vector<int> CaloCellContainer::m_indexLastCellCalo
private

index of first cell of given calo (-2 if none)

Definition at line 281 of file CaloCellContainer.h.

◆ m_isMostDerived

SG::IsMostDerivedFlag DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::m_isMostDerived
privateinherited

This flag is true if this DV instance is the most-derived one.

We set this to true in the top-level constructor; the constructor then calls clearMostDerived on the base classes.

Definition at line 2059 of file DataVector.h.

◆ m_isOrdered

bool CaloCellContainer::m_isOrdered
private

true if ordered

Definition at line 269 of file CaloCellContainer.h.

◆ m_isOrderedAndComplete

bool CaloCellContainer::m_isOrderedAndComplete
private

true if complete and in right order

Definition at line 272 of file CaloCellContainer.h.

◆ m_lookUpTable

CxxUtils::CachedValue<CxxUtils::PackedArray> CaloCellContainer::m_lookUpTable
private

look up table of size HashIdentifiermax.

Definition at line 261 of file CaloCellContainer.h.

◆ must_own

bool DataVector< CaloCell, typename DataVectorBase<CaloCell>::Base >::must_own
staticconstexprinherited

If true, then this type must own its contents.

Definition at line 860 of file DataVector.h.


The documentation for this class was generated from the following files: