AliPhysics  8bb951a (8bb951a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalIterableContainer Class Reference

Container implementing iterable functionality of the EMCAL containers. More...

#include <AliEmcalIterableContainer.h>

Inheritance diagram for AliEmcalIterableContainer:

Classes

class  iterator
 bidirectional stl iterator over the EMCAL iterable container More...
 

Public Member Functions

 AliEmcalIterableContainer ()
 
 AliEmcalIterableContainer (const AliEmcalContainer *cont, bool useAccept)
 
 AliEmcalIterableContainer (const AliEmcalIterableContainer &ref)
 
AliEmcalIterableContaineroperator= (const AliEmcalIterableContainer &cont)
 
virtual ~AliEmcalIterableContainer ()
 
TObject * operator[] (int index) const
 
 operator int () const
 
const AliEmcalContainerGetContainer () const
 
int GetEntries () const
 
iterator begin () const
 
iterator end () const
 
iterator rbegin () const
 
iterator rend () const
 

Protected Member Functions

void BuildAcceptIndices ()
 

Private Attributes

const AliEmcalContainerfkContainer
 Container to be iterated over. More...
 
TArrayI fAcceptIndices
 Array of accepted indices. More...
 
Bool_t fUseAccepted
 Switch between accepted and all objects. More...
 

Detailed Description

Container implementing iterable functionality of the EMCAL containers.

Author
Markus Fasel marku.nosp@m.s.fa.nosp@m.sel@c.nosp@m.ern..nosp@m.ch, Lawrence Berkeley National Laboratory
Salvatore Aiola, Yale University
Date
March 23rd, 2016

Providing an interface to iterator functionality for the AliEmcalContainer and inheriting objects, iterating over either all or only accepted objects inside the container. The content is specified in the constructor.

EMCAL iterable containers should not be created by hand. Instead, the EMCAL container provides the functionality to create the interface for both cases:

AliEmcalIterableContainer *accepted = cont->accepted(), // iterative container over accepted entries
*all = cont->all(); // iterative container over all entries

Once created, EMCAL iterable containers implement the functions begin(), end(), rbegin() and rend() creating stl iterators (type AliEmcalIterableContainer::iterator). These can be used as normal stl iterators

for(AliEmcalIterableContainer::iterator iter = all.begin(); iter != all.end(); ++iter){
// Do something with the object
}

In case c++11 is used this code simplifies to

for(auto en : all){
// Do something with the object
}

Definition at line 51 of file AliEmcalIterableContainer.h.

Constructor & Destructor Documentation

AliEmcalIterableContainer::AliEmcalIterableContainer ( )

Default (I/O) constructor

Definition at line 25 of file AliEmcalIterableContainer.cxx.

AliEmcalIterableContainer::AliEmcalIterableContainer ( const AliEmcalContainer cont,
bool  useAccept 
)

Standard constructor, to be used by the users. Specifying the type of iteration (all vs. accepted). In case the iterator runs over accepted object, an index map is build inside the constructor.

Parameters
[in]contEMCAL container to iterate over
[in]useAcceptIf true accepted objects are used in the iteration, otherwise all objects

Definition at line 40 of file AliEmcalIterableContainer.cxx.

AliEmcalIterableContainer::AliEmcalIterableContainer ( const AliEmcalIterableContainer ref)

Copy constructor. Initializing all parameters from the reference. As the container is not owner over its input container only pointers are copied.

Parameters
[in]refReference for the copy

Definition at line 54 of file AliEmcalIterableContainer.cxx.

virtual AliEmcalIterableContainer::~AliEmcalIterableContainer ( )
inlinevirtual

Destructor

Definition at line 104 of file AliEmcalIterableContainer.h.

Member Function Documentation

iterator AliEmcalIterableContainer::begin ( ) const
inline

Creating forward iterator at the beginning of the container (first entry).

Returns
Iterator at the beginning of the container.

Definition at line 127 of file AliEmcalIterableContainer.h.

void AliEmcalIterableContainer::BuildAcceptIndices ( )
protected

Build list of accepted indices inside the container. For this all objects inside the container are checked for being accepted or not.

Definition at line 114 of file AliEmcalIterableContainer.cxx.

Referenced by AliEmcalIterableContainer().

iterator AliEmcalIterableContainer::end ( ) const
inline

Creating forward iterator behind the last entry of the container.

Returns
Iterator behind the container.

Definition at line 134 of file AliEmcalIterableContainer.h.

const AliEmcalContainer* AliEmcalIterableContainer::GetContainer ( ) const
inline

Access to underlying EMCAL container

Returns
Underlying EMCAL container

Definition at line 118 of file AliEmcalIterableContainer.h.

int AliEmcalIterableContainer::GetEntries ( ) const

Return the number of objects to iterate over (depending on whether the iterator loops over all or only accepted objects)

Returns
Number of iterable objects in container

Definition at line 84 of file AliEmcalIterableContainer.cxx.

Referenced by end(), operator int(), operator[](), and rbegin().

AliEmcalIterableContainer::operator int ( ) const
inline

Integer conversion operator: Returning the size if the container (number of entries)

Returns
Number of entries in the container

Definition at line 112 of file AliEmcalIterableContainer.h.

AliEmcalIterableContainer & AliEmcalIterableContainer::operator= ( const AliEmcalIterableContainer ref)

Assignment operator. As the container is not owner over the input container only pointers are copied

Parameters
[in]refReference for assignment
Returns
Object after assignment

Definition at line 69 of file AliEmcalIterableContainer.cxx.

TObject * AliEmcalIterableContainer::operator[] ( int  index) const

Array index operator. Returns object of the container at the position provided by the parameter index. The operator distinguishes between all and accepted objects:

  • If accepted was specified in the constructor the index refers to the nth accepted object, neglecting rejected objects in between. For this it relies on its internal index map.
  • If accepted was not specified in the constructor the index refers to the nth object inside the container, based on all objects including rejected objects. The index map is not needed in this case.
    Parameters
    [in]indexIndex of the object inside the container to access
    Returns
    The object at the given index (NULL if the index is out of range)

Definition at line 103 of file AliEmcalIterableContainer.cxx.

iterator AliEmcalIterableContainer::rbegin ( ) const
inline

Creating backward iterator at the end of the container (last entry).

Returns
Iterator at the end of the container

Definition at line 141 of file AliEmcalIterableContainer.h.

iterator AliEmcalIterableContainer::rend ( ) const
inline

Creating backward iterator before the beginning of the container.

Returns
Iterator before the container.

Definition at line 148 of file AliEmcalIterableContainer.h.

Member Data Documentation

TArrayI AliEmcalIterableContainer::fAcceptIndices
private

Array of accepted indices.

Definition at line 155 of file AliEmcalIterableContainer.h.

Referenced by BuildAcceptIndices(), GetEntries(), operator=(), and operator[]().

const AliEmcalContainer* AliEmcalIterableContainer::fkContainer
private

Container to be iterated over.

Definition at line 154 of file AliEmcalIterableContainer.h.

Referenced by BuildAcceptIndices(), GetContainer(), GetEntries(), operator=(), and operator[]().

Bool_t AliEmcalIterableContainer::fUseAccepted
private

Switch between accepted and all objects.

Definition at line 156 of file AliEmcalIterableContainer.h.

Referenced by AliEmcalIterableContainer(), GetEntries(), operator=(), and operator[]().


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