//-*- Mode: C++ -*- // ***************************************************************************** // * // @Autors: I.Kulakov; M.Zyzak; I.Kisel * // @e-mail: I.Kulakov@gsi.de; M.Zyzak@gsi.de; I.Kisel@compeng.uni-frankfurt.de * // * // ***************************************************************************** #ifndef ITSCASTATIONARRAY_H #define ITSCASTATIONARRAY_H #include using std::cout; #include using std::vector; #include "ITSCAHits.h" #include "ITSCATES.h" template< typename T > class ITSCAElementsOnStation: public vector { public: ITSCAElementsOnStation():fHitsRef(0),fISta(-1){} ITSCAElementsOnStation( const ITSCAHits* hits ):fHitsRef(hits){} char& IStation() { return fISta; } const char& IStation() const { return fISta; } const ITSCAHit& GetHit( int iV, int IH, int i ) const { return (*fHitsRef)[ (*this)[i].IHit(IH)[iV] ]; } const ITSCAHit& GetHit( int IH, int i ) const { return (*fHitsRef)[ (*this)[i].IHit(IH) ]; } const ITSCAHits* HitsRef() const { return fHitsRef; } ITSCAElementsOnStation& operator=( const ITSCAElementsOnStation& a ) { // do not copy fHitsRef vector::operator=( a ); fHitsRef = (a.fHitsRef == 0 ) ? fHitsRef : a.fHitsRef; // copy only of set fISta = (a.fISta == -1 ) ? fISta : a.fISta; return *this; } ITSCAElementsOnStation operator+( const ITSCAElementsOnStation& a ) { ITSCAElementsOnStation r( fHitsRef ); r.resize( this->size() + a.size() ); int iR = 0; for( unsigned int i = 0; i < this->size(); ++i ) { r[iR++] = (*this)[i]; } for( unsigned int i = 0; i < a.size(); ++i ) { r[iR++] = a[i]; } r.IStation() = fISta; return r; } private: const ITSCAHits* fHitsRef; char fISta; }; template< typename T > class ITSCAStationArray { public: ITSCAElementsOnStation& OnStation(char i) { assert((unsigned char)i& OnStation(char i) const { assert((unsigned char)i& operator[](char i) { assert((unsigned char)i < fElement.size() ); return fElement[i]; } const ITSCAElementsOnStation& operator[](char i) const { assert((unsigned char)i( hits ) ); for( int i = 0; i < nSta; ++i ) fElement[i].IStation() = i; } char NStations() const { return fElement.size(); } T& operator[]( TES i ) { return fElement[i.s][i.e]; } const T& operator[]( TES i ) const { return fElement[i.s][i.e]; } void Add( const T& hit ) { const int iSta = hit.Station(); fElement[iSta].push_back( hit ); } protected: vector< ITSCAElementsOnStation > fElement; // hits on stations }; #endif