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