FairRoot/PandaRoot
PndCAStationArray.h
Go to the documentation of this file.
1  //-*- Mode: C++ -*-
2  // *****************************************************************************
3  // *
4  // @Autors: I.Kulakov; M.Zyzak; I.Kisel *
5  // @e-mail: I.Kulakov@gsi.de; M.Zyzak@gsi.de; I.Kisel@compeng.uni-frankfurt.de *
6  // *
7  // *****************************************************************************
8 
9 #ifndef PNDCASTATIONARRAY_H
10 #define PNDCASTATIONARRAY_H
11 
12 #include <iostream>
13 using std::cout;
14 
15 #include <vector>
16 using std::vector;
17 
18 #include "PndCAHits.h"
19 #include "PndCATES.h"
20 
21 
22 template< typename T >
23 class PndCAElementsOnStation: public vector<T> {
24  public:
27 
28  void SetStation( char s ) { fISta = s; }
29 
30  const char& IStation() const { return fISta; }
31 
32  const PndCAHit& GetHit( int iV, int IH, int i ) const {
33  return (*fHitsRef)[ (*this)[i].IHit(IH)[iV] ];
34  }
35 
36  const PndCAHit& GetHit( int IH, int i ) const {
37  return (*fHitsRef)[ (*this)[i].IHit(IH) ];
38  }
39 
40  const PndCAHits* HitsRef() const { return fHitsRef; }
41 
42  PndCAElementsOnStation<T>& operator=( const PndCAElementsOnStation<T>& a ) { // do not copy fHitsRef
43  vector<T>::operator=( a );
44  fHitsRef = (a.fHitsRef == 0 ) ? fHitsRef : a.fHitsRef; // copy only of set
45  fISta = (a.fISta == -1 ) ? fISta : a.fISta;
46  return *this;
47  }
48 
51  r.resize( this->size() + a.size() );
52  int iR = 0;
53  for( unsigned int i = 0; i < this->size(); ++i ) {
54  r[iR++] = (*this)[i];
55  }
56  for( unsigned int i = 0; i < a.size(); ++i ) {
57  r[iR++] = a[i];
58  }
59  r.SetStation(fISta);
60  assert(0); // TODO combine fFirstElementIByHit0
61  return r;
62  }
63 
64  // private:
66  char fISta;
67 };
68 
69 template< typename T >
71  public:
72  PndCAElementsOnStation<T>& OnStation(char i) { assert((unsigned char)i<fElement.size() ); return fElement[i]; }
73  const PndCAElementsOnStation<T>& OnStation(char i) const { assert((unsigned char)i<fElement.size() ); return fElement[i]; }
74  PndCAElementsOnStation<T>& operator[](char i) { assert((unsigned char)i < fElement.size() ); return fElement[i]; }
75  const PndCAElementsOnStation<T>& operator[](char i) const { assert((unsigned char)i<fElement.size() ); return fElement[i]; }
76 
78 
79  PndCAStationArray( int nSta, const PndCAHits* hits ){
80  Renew( nSta, hits );
81  }
82 
83  void Renew( int nSta, const PndCAHits* hits ){
84  fElement.clear();
85  fElement.resize( nSta, PndCAElementsOnStation<T>( hits ) );
86  for( int i = 0; i < nSta; ++i )
87  fElement[i].SetStation( i );
88  }
89 
90  char NStations() const { return fElement.size(); }
91 
92  const PndCAHits* HitsRef() const {
93  if ( fElement.size() ) return fElement[0].fHitsRef;
94  else return 0;
95  }
96 
97  unsigned int Size() const {
98  unsigned int s = 0;
99  for( int i = 0; i < NStations(); ++i )
100  s += fElement[i].size();
101  return s;
102  }
103 
104  T& operator[]( PndCATES i ) { return fElement[i.s][i.e]; }
105  const T& operator[]( PndCATES i ) const { return fElement[i.s][i.e]; }
106 
107  void Add( const T& hit ) {
108  const int iSta = hit.Station();
109  fElement[iSta].push_back( hit );
110  }
111 
112  protected:
113  vector< PndCAElementsOnStation<T> > fElement; // hits on stations
114 
115 };
116 
117 
118 #endif
PndCAElementsOnStation< T > operator+(const PndCAElementsOnStation< T > &a)
PndCAElementsOnStation< T > & operator=(const PndCAElementsOnStation< T > &a)
double r
Definition: RiemannTest.C:14
Int_t i
Definition: run_full.C:25
PndCAElementsOnStation< T > & operator[](char i)
void Add(const T &hit)
const PndCAElementsOnStation< T > & OnStation(char i) const
TLorentzVector s
Definition: Pnd2DStar.C:50
const char & IStation() const
char s
Definition: PndCATES.h:24
const PndCAHits * fHitsRef
const T & operator[](PndCATES i) const
TTree * T
Definition: anaLmdReco.C:32
Int_t a
Definition: anaLmdDigi.C:126
const PndCAHits * HitsRef() const
PndCAElementsOnStation< T > & OnStation(char i)
const PndCAElementsOnStation< T > & operator[](char i) const
const PndCAHit & GetHit(int IH, int i) const
void Renew(int nSta, const PndCAHits *hits)
T & operator[](PndCATES i)
unsigned int Size() const
char NStations() const
const PndCAHits * HitsRef() const
PndSdsMCPoint * hit
Definition: anasim.C:70
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
const PndCAHit & GetHit(int iV, int IH, int i) const
PndCAElementsOnStation(const PndCAHits *hits)
vector< PndCAElementsOnStation< T > > fElement
PndCAStationArray(int nSta, const PndCAHits *hits)
unsigned int e
Definition: PndCATES.h:25