FairRoot/PandaRoot
PndCAHits.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 PNDCAHITS_H
10 #define PNDCAHITS_H
11 
12 #include <vector>
13 using std::vector;
14 
15 #include "PndCADef.h"
16 #include "PndCAGBHit.h"
17 #include "PndCATES.h"
18 #include "PndCAParameters.h"
19 
20 class PndCAHit {
21  public:
23  PndCAHit( PndCAGBHit& h, int id ):fIStation(h.IRow()), fId(id), fErr2X1(h.Err2X1()), fErrX12(h.ErrX12()), fErr2X2(h.Err2X2()),
24  fR(h.R()), fErr2R(h.Err2R()), fErr2A(h.Err2A()), fIsLeft(h.IsLeft()),
25  fAngle(h.Angle()), fCAHit( &h ) {
26  h.GetLocalX0X1X2( fX0, fX1, fX2 );
27  };
28  char IStation() const { return fIStation; }
29  void SetId( int id ) { fId = id; }
30  int Id() const { return fId; };
31 
32  float_v X1Corrected( float_v sinPhi ) const;
33 
34  float X0() const { return fX0; }
35  float X1() const { return fX1; }
36  float X2() const { return fX2; }
37 
38  float Err2X1() const { return fErr2X1; }
39  float ErrX12() const { return fErrX12; }
40  float Err2X2() const { return fErr2X2; }
41 
42  float R() const { return fR; }
43  float DR() const { return fDR; }
44  float U() const { return fU; }
45  float Err2R() const { return fErr2R; }
46  float Err2A() const { return fErr2A; }
47 
48  bool IsLeft() const { return fIsLeft; }
49  int ISec() const { return fISec; }
50 
51  float Angle() const { return fAngle; }
52 
53  bool IsUsed() const { return fCAHit->IsUsed();}
54  void SetAsUsed() { fCAHit->SetAsUsed(); }
55 
56  // comparison of hits on one station, needed for std::sort, returns true if a must be before b.
57  friend bool operator<(const PndCAHit& a, const PndCAHit& b) {
59  return (a.Angle() < b.Angle()) || ((a.Angle() == b.Angle()) && (a.X1() < b.X1()));
60  else
61  return a.X2()/abs(a.X0()) < b.X2()/abs(b.X0()); // check why x0 < 0 is possible
62  }
63 
64  //private:
65  char fIStation; //index of the station
66  int fId; // index of hits in an input array
67 
68  float fX1, fX2, fX0; // local coordinates. fX2 is vertical, along radial direction
69  float fErr2X1, fErrX12, fErr2X2; // errors squared
70 
71  float fR;
72  float fErr2R;
73  float fErr2A; // error along the tube
74  float fU, fDR;
75  bool fIsLeft; // left side or right side
76  int fISec;
77 
78  float fAngle; // direction of hit station. Angle between normal and vertical axis. This angle defines local CS of the hit
79 
81 };
82 
83 
84 inline float_v PndCAHit::X1Corrected( float_v sinPhi ) const {
85  const float_v xCorr = fR - fR*rsqrt( 1 - sinPhi*sinPhi );
86  // xCorr /= cos(3.f/180.f*3.141592); // currently neglect stereo angle
87  return (fIsLeft) ? fX1 + xCorr : fX1 - xCorr;
88 }
89 
90 template <typename T> class PndCAElementsOnStation;
91 
92 template<>
93 class PndCAElementsOnStation<PndCAHit>: public vector<PndCAHit> {
94  public:
95 
96  char& IStation() { return fISta; }
97  const char& IStation() const { return fISta; }
98 
99  private:
100  char fISta;
101 };
102 
103 class PndCAHits { // same as in PndCAStationArray
104  public:
105  typedef PndCAHit T;
106 
107  PndCAElementsOnStation<T>& OnStation(char i) { assert((unsigned char)i<fElement.size() ); return fElement[i]; }
108  const PndCAElementsOnStation<T>& OnStation(char i) const { assert((unsigned char)i<fElement.size() ); return fElement[i]; }
109  const PndCAElementsOnStation<T>& OnStationConst(char i) const { assert((unsigned char)i<fElement.size() ); return fElement[i]; }
110  PndCAElementsOnStation<T>& operator[](char i) { assert((unsigned char)i < fElement.size() ); return fElement[i]; }
111  const PndCAElementsOnStation<T>& operator[](char i) const { assert((unsigned char)i<fElement.size() ); return fElement[i]; }
112 
114  PndCAHits( int nSta, int nHitsPerStation = 1 ) {
115  fElement.resize( nSta );
116  for( int i = 0; i < nSta; ++i ) {
117  fElement[i].IStation() = i;
118  fElement[i].reserve(nHitsPerStation);
119  }
120  }
121 
122  T& operator[]( PndCATES i ) { return fElement[i.s][i.e]; }
123  const T& operator[]( PndCATES i ) const { return fElement[i.s][i.e]; }
124 
125  char NStations() const { return fElement.size(); }
126 
127  void Add( const T& hit ) {
128  const int iSta = hit.IStation();
129  fElement[iSta].push_back( hit );
130  }
131 
132  void Sort() {
133  for( unsigned int i = 0; i < fElement.size(); ++i ) {
135  std::sort( hits.begin(), hits.end() );
136  }
137  }
138 
139  void Clean() { // remove used hits
140  for( unsigned int i = 0; i < fElement.size(); ++i ) {
143  tmp.IStation() = i;
144  // tmp.reserve( hits.size() );
145  for( unsigned int iH = 0; iH < hits.size(); ++iH ) {
146  if ( hits[iH].IsUsed() ) continue;
147  tmp.push_back( hits[iH] );
148  }
149  hits.clear();
150  hits = tmp;
151  tmp.clear();
152  }
153  }
154 
155  protected:
156  vector< PndCAElementsOnStation<T> > fElement; // hits on stations
157 
158 };
159 
160 #endif
161 
float fAngle
Definition: PndCAHits.h:78
float Angle() const
Definition: PndCAHits.h:51
PndCAHit()
Definition: PndCAHits.h:22
float fErrX12
Definition: PndCAHits.h:69
float X0() const
Definition: PndCAHits.h:34
Int_t i
Definition: run_full.C:25
void Clean()
Definition: PndCAHits.h:139
TTree * b
PndCAGBHit * fCAHit
Definition: PndCAHits.h:80
char NStations() const
Definition: PndCAHits.h:125
int fId
Definition: PndCAHits.h:66
float X2() const
Definition: PndCAHits.h:36
float U() const
Definition: PndCAHits.h:44
bool IsUsed() const
Definition: PndCAGBHit.h:129
const PndCAElementsOnStation< T > & OnStation(char i) const
Definition: PndCAHits.h:108
PndCAElementsOnStation< T > & OnStation(char i)
Definition: PndCAHits.h:107
const char & IStation() const
const T & operator[](PndCATES i) const
Definition: PndCAHits.h:123
float DR() const
Definition: PndCAHits.h:43
float Err2A() const
Definition: PndCAHits.h:46
char s
Definition: PndCATES.h:24
void SetAsUsed()
Definition: PndCAHits.h:54
float X1() const
Definition: PndCAHits.h:35
const char & IStation() const
Definition: PndCAHits.h:97
int Id() const
Definition: PndCAHits.h:30
float Err2X1() const
Definition: PndCAHits.h:38
Int_t a
Definition: anaLmdDigi.C:126
const PndCAElementsOnStation< T > & operator[](char i) const
Definition: PndCAHits.h:111
vector< PndCAElementsOnStation< T > > fElement
Definition: PndCAHits.h:156
float fDR
Definition: PndCAHits.h:74
float fErr2R
Definition: PndCAHits.h:72
const PndCAElementsOnStation< T > & OnStationConst(char i) const
Definition: PndCAHits.h:109
float Err2X2() const
Definition: PndCAHits.h:40
void GetLocalX0X1X2(float &x0, float &x1, float &x2) const
Definition: PndCAGBHit.cxx:27
friend F32vec4 rsqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:32
char fIStation
Definition: PndCAHits.h:65
float fX2
Definition: PndCAHits.h:68
float fU
Definition: PndCAHits.h:74
float fErr2A
Definition: PndCAHits.h:73
float fR
Definition: PndCAHits.h:71
void SetId(int id)
Definition: PndCAHits.h:29
float fX1
Definition: PndCAHits.h:68
float_v X1Corrected(float_v sinPhi) const
Definition: PndCAHits.h:84
void Add(const T &hit)
Definition: PndCAHits.h:127
int ISec() const
Definition: PndCAHits.h:49
bool IsUsed() const
Definition: PndCAHits.h:53
void SetAsUsed()
Definition: PndCAGBHit.h:130
float fErr2X2
Definition: PndCAHits.h:69
int fISec
Definition: PndCAHits.h:76
PndCAElementsOnStation< T > & operator[](char i)
Definition: PndCAHits.h:110
PndCAHit T
Definition: PndCAHits.h:105
bool IsLeft() const
Definition: PndCAHits.h:48
PndCAHits(int nSta, int nHitsPerStation=1)
Definition: PndCAHits.h:114
float fX0
Definition: PndCAHits.h:68
friend bool operator<(const PndCAHit &a, const PndCAHit &b)
Definition: PndCAHits.h:57
float fErr2X1
Definition: PndCAHits.h:69
float R() const
Definition: PndCAHits.h:42
bool fIsLeft
Definition: PndCAHits.h:75
PndSdsMCPoint * hit
Definition: anasim.C:70
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
void Sort()
Definition: PndCAHits.h:132
PndCAHit(PndCAGBHit &h, int id)
Definition: PndCAHits.h:23
float ErrX12() const
Definition: PndCAHits.h:39
char IStation() const
Definition: PndCAHits.h:28
float Err2R() const
Definition: PndCAHits.h:45
T & operator[](PndCATES i)
Definition: PndCAHits.h:122
unsigned int e
Definition: PndCATES.h:25