StRoot
1
|
StHitIter is an abstract base class, establishing the interface between hit collections in StEvent and the Stv track reconstruction machinery. More...
#include <StEventHitIter.h>
Public Member Functions | |
virtual const TObject * | Reset (const TObject *cont) |
virtual const TObject * | operator++ () |
Increments the iterator, returning the next object in the collection. | |
virtual const TObject * | Get () const |
Gets the current object in the collection. | |
virtual const TObject * | GetObject (int idx) const =0 |
Gets an object at a specified position in the collection. | |
virtual int | GetSize () const =0 |
Returns the number of entries in the collection. | |
virtual StDetectorId | DetectorId () const |
Returns the STAR ID of the detector. | |
void | SetDowIter (StHitIter *it) |
For the case of nested collections, sets the iterator over another collection. | |
virtual void | UPath (ULong64_t &upath) const |
Protected Attributes | |
const TObject * | fCont |
StHitIter * | fDowIter |
int | fJIter |
int | fNIter |
StHitIter is an abstract base class, establishing the interface between hit collections in StEvent and the Stv track reconstruction machinery.
Integrating hits into the Stv framework begins here. The devolper needs to implement one or more iterators based on StHitIter.
The simple case: Iteration over a container of hits
When iterating over a container of hits, you only need to implement two methods: StYourHitIter::GetObject() and StYourHitIter::GetSize(). Indeed, since these have no implementation in StHitIter, you will not be able to compile your code without them.
GetObject(I) should return the Ith hit in your collection. GetSize() should return the number of hits in your collection.
In addition, if this is your top-level iterator you should override the behavior of DetectorId() and implement Reset(). DetectorId() needs to return the detector id of your detector. Reset needs to take a pointer to an object. If the object exists, it is recast to StEvent and your hit collection is obtained from it. Then the base method StHitIter::Reset( ) is invoked on your collection. (Basically you follow the example provided by StTpcHitIter::Reset(), substituting your classes for the TPC ones).
The hard case: Iteration over a container of hit containers
Slightly harder is the case where your hit collections are nested, e.g. you have a top level collection which contains sector collections, which contain your actual hits (or even another collection).
To handle this case, you will need to implement an iterator for each of the nested collections.
Probably the best way to describe this process is by example. Examine StTpcHitIter.
The TPC collections are nested three deep: tpc, sectors, padrows.
The top-level TPC hit iterator is StTpcHitIter. It implements four methods, as described for the simple case above.
Examining the constructor for StTpcHitIter, we see that two hit iterators are created. First a new StTpcSectorHitIter is created. This is registered with StHitIter using the SetDowIter method. This tells StTpcHitIter that it will use a nested iterator. After StTpcSectorHitIter is created, we create StTpcPadrowIter and register it with StTpcSectorHitIter.
StTpcHitIter::GetObject( Int_t idx ) returns the sector collection. StTpcSectorIter::GetObject( Int_t idx ) returns the padrow collection StTpcPadrowHitIter::GetObject( Int_t idx ) returns a hit within the padrow
The Size() methods return the size of the corresponding collections.
Definition at line 91 of file StEventHitIter.h.