PandaRoot
FTSCAHitsV.h
Go to the documentation of this file.
1 //-*- Mode: C++ -*-
2 // *****************************************************************************
3 // *
4 // @Autors: I.Kulakov; M.Pugach; M.Zyzak; I.Kisel *
5 // @e-mail: I.Kulakov@gsi.de; M.Pugach@gsi.de; M.Zyzak@gsi.de; I.Kisel@compeng.uni-frankfurt.de *
6 // *
7 // *****************************************************************************
8 
9 #ifndef FTSCAHITSV_H
10 #define FTSCAHITSV_H
11 
12 #include <vector>
13 using std::vector;
14 
15 // #include "FTSCAStationArray.h"
16 #include "PndFTSCAGBHit.h"
17 #include "FTSCATES.h"
18 #include "FTSCAHits.h"
19 #include "PndFTSCAParameters.h"
21 
22 class FTSCAHitV {
23  public:
25  : fIStation(-1), fId(Vc::Zero), fX0(Vc::Zero), fX1(Vc::Zero), fX2(Vc::Zero), fErr2X1(Vc::Zero), fErrX12(Vc::Zero), fErr2X2(Vc::Zero),
26 #ifdef DRIFT_TUBES
27  fR(Vc::Zero), fErr2R(Vc::Zero), fErr2A(Vc::Zero), fBeta(Vc::Zero), fIsLeft(true),
28 #endif
29  fAngle(Vc::Zero)
30  {
31  }
32 
33  FTSCAHitV(const PndFTSCAGBHit **hits, const uint_v &ids, const float_m &valid);
34 
35  FTSCAHitV(const FTSCAHit *hits, const float_m &valid);
36 
37  FTSCAHitV(const FTSCAHit *hits, const float_m &valid, bool OneHit);
38 
39  float_m IsValid() const { return fIStation >= 0; }
40 
41  char IStation() const
42  {
43  const float_m v = IsValid();
44  assert(!v.isEmpty());
45  return fIStation[v.firstOne()];
46  }
47  int_v IStations() const { return fIStation; } // is not needed by tracker
48 
49  uint_v Id() const { return fId; };
50 
51  float_v X0() const { return fX0; }
52  float_v X1() const { return fX1; }
53  float_v X2() const { return fX2; }
54 
55  float_v FStrip() const { return GetStripsValue(fFStripP); };
56  float_v BStrip() const { return GetStripsValue(fBStripP); };
57 
58  float_v Err2X1() const { return fErr2X1; }
59  float_v ErrX12() const { return fErrX12; }
60  float_v Err2X2() const { return fErr2X2; }
61 
62 #ifdef DRIFT_TUBES
63  float_v XWire0() const { return fX0; }
64  float_v XWire1() const { return fX1; }
65  float_v XWire2() const { return fX2; }
66 
67  float_v R() const { return fR; }
68  float_v RSigned() const
69  {
70  float_v r = fR;
71  r(fIsLeft) = -r;
72  return r;
73  }
74  float_v Err2R() const { return fErr2R; }
75  float_v Err2A() const { return fErr2A; }
76  float_v Beta() const { return fBeta; }
77  float_m IsLeft() const { return fIsLeft; }
78 #endif
79 
80  float_v Angle() const { return fAngle; }
81 
82  void GetGlobalCoor(int iV, float &x, float &y, float &z) const
83  {
84  PndFTSCAParameters::CALocalToGlobal(float(X0()[iV]), float(X1()[iV]), float(X2()[iV]), float(Angle()[iV]), x, y, z);
85  }
86 
87  void InitValuesByZeros();
88 
89  private:
90  float_v GetStripsValue(FTSCAStrip *const strip[float_v::Size]) const
91  {
92  float_v::Memory r;
93  foreach_bit(unsigned short iV, IsValid()) { r[iV] = *(strip[iV]); }
94  return float_v(r);
95  };
96 
97  FTSCAStrip *fFStripP[float_v::Size]; // TODO simdize
98  FTSCAStrip *fBStripP[float_v::Size];
99 
100  int_v fIStation;
101  uint_v fId; // index of hits in an input array
102 
103  float_v fX0, fX1, fX2; // local coordinates. X0 is normal to module, X2 is paralel to magnetic field
104  float_v fErr2X1, fErrX12, fErr2X2; // cov matrix
105 
106 #ifdef DRIFT_TUBES
107  float_v fR;
108  float_v fErr2R;
109  float_v fErr2A;
110  float_v fBeta;
111  float_m fIsLeft;
112 #endif
113 
114  float_v fAngle; // direction of hit station. Angle between normal and vertical axis. This angle defines local CS of the hit
115 };
116 
117 template <typename T>
119 
120 template <>
121 class FTSCAElementsOnStation<FTSCAHitV> : public vector<FTSCAHitV> {
122  public:
123  char &IStation() { return fISta; }
124  const char &IStation() const { return fISta; }
125 
126  private:
127  char fISta;
128 };
129 
130 class FTSCAHitsV { // same as in FTSCAStationArray
131  public:
132  typedef FTSCAHitV T;
133 
135  {
136  assert((unsigned char)i < fElement.size());
137  return fElement[i];
138  }
140  {
141  assert((unsigned char)i < fElement.size());
142  return fElement[i];
143  }
145  {
146  assert((unsigned char)i < fElement.size());
147  return fElement[i];
148  }
150  {
151  assert((unsigned char)i < fElement.size());
152  return fElement[i];
153  }
154 
155  FTSCAHitsV(const FTSCAHits &hits);
156 
157  FTSCAHitsV(int nSta)
158  {
159  fElement.resize(nSta);
160  for (int i = 0; i < nSta; ++i)
161  fElement[i].IStation() = i;
162  }
163 
164  int NStations() const { return fElement.size(); }
165 
166  T &operator[](TES i) { return fElement[i.s][i.e]; }
167  const T &operator[](TES i) const { return fElement[i.s][i.e]; }
168 
169  void Add(const T &hit)
170  {
171  const int iSta = hit.IStation();
172  fElement[iSta].push_back(hit);
173  }
174 
175  void Clean();
176 
177  protected:
178  vector<FTSCAElementsOnStation<T>> fElement; // hits on stations
179 };
180 
181 inline FTSCAHitV::FTSCAHitV(const PndFTSCAGBHit **hits, const uint_v &ids, const float_m &valid) : fId(ids)
182 {
183  int_v::Memory mIStation;
184  mIStation = int_v(-1);
185 
186  float_v::Memory mX1, mX2, mX0;
187  float_v::Memory mErr2X1, mErrX12, mErr2X2;
188 
189 #ifdef DRIFT_TUBES
190  float_v::Memory mR, mErr2R, mErr2A, mBeta, mIsLeft;
191 #endif
192  float_v::Memory mAlpha;
193 
194  foreach_bit(unsigned short iV, valid)
195  {
196  const PndFTSCAGBHit &h = *(hits[iV]);
197 
198  mIStation[iV] = h.IRow();
199  h.GetLocalX0X1X2(mX0[iV], mX1[iV], mX2[iV]);
200 
201  mErr2X1[iV] = h.Err2X1();
202  mErrX12[iV] = h.ErrX12();
203  mErr2X2[iV] = h.Err2X2();
204 #ifdef DRIFT_TUBES
205  mR[iV] = h.R();
206  mErr2R[iV] = h.Err2R();
207  mErr2A[iV] = h.Err2A();
208  mBeta[iV] = h.Beta();
209  mIsLeft[iV] = h.IsLeft() ? 1.f : 0.f;
210 #endif
211  mAlpha[iV] = h.Angle();
212  fFStripP[iV] = h.FStripP();
213  fBStripP[iV] = h.BStripP();
214  }
215 
216  fIStation = int_v(mIStation);
217  fX1 = float_v(mX1);
218  fX2 = float_v(mX2);
219  fX0 = float_v(mX0);
220  fErr2X1 = float_v(mErr2X1);
221  fErrX12 = float_v(mErrX12);
222  fErr2X2 = float_v(mErr2X2);
223 #ifdef DRIFT_TUBES
224  fR = float_v(mR);
225  fErr2R = float_v(mErr2R);
226  fErr2A = float_v(mErr2A);
227  fBeta = float_v(mBeta);
228  fIsLeft = (float_v(mIsLeft) == 1.f);
229 #endif
230  fAngle = float_v(mAlpha);
231 }
232 
233 inline FTSCAHitV::FTSCAHitV(const FTSCAHit *hits, const float_m &valid, bool /*OneHit*/) //[R.K. 9/2018] unused
234 {
236  float_v::Memory mIsLeft;
237  foreach_bit(unsigned short iV, valid)
238  {
239  const FTSCAHit &h = hits[0];
240 
241  fId[iV] = h.Id();
242  fIStation[iV] = h.IStation();
243  fX1[iV] = h.X1();
244  fX2[iV] = h.X2();
245  fX0[iV] = h.X0();
246 
247  fErr2X1[iV] = h.Err2X1();
248  fErrX12[iV] = h.ErrX12();
249  fErr2X2[iV] = h.Err2X2();
250 
251  fR[iV] = h.R();
252  fErr2R[iV] = h.Err2R();
253  fErr2A[iV] = h.Err2A();
254  fBeta[iV] = h.Beta();
255  mIsLeft[iV] = h.IsLeft() ? 1.f : 0.f;
256 
257  fAngle[iV] = h.Angle();
258  fFStripP[iV] = h.FStripP();
259  fBStripP[iV] = h.BStripP();
260  // mIsUsed[iV] = h.IsUsed() ? 1.f : 0.f;
261  }
262  fIsLeft = (float_v(mIsLeft) == 1.f);
263  // cout<<"FTSCAHitV constructor\n";
264  // cout<<"fX0 "<<fX0<<" fX1 "<<fX1<<endl;
265 }
266 
267 inline FTSCAHitV::FTSCAHitV(const FTSCAHit *hits, const float_m &valid)
268 {
270 
271  float_v::Memory mIsLeft;
272  foreach_bit(unsigned short iV, valid)
273  {
274  const FTSCAHit &h = hits[iV];
275 
276  fId[iV] = h.Id();
277  fIStation[iV] = h.IStation();
278  fX1[iV] = h.X1();
279  fX2[iV] = h.X2();
280  fX0[iV] = h.X0();
281 
282  fErr2X1[iV] = h.Err2X1();
283  fErrX12[iV] = h.ErrX12();
284  fErr2X2[iV] = h.Err2X2();
285 
286  fR[iV] = h.R();
287  fErr2R[iV] = h.Err2R();
288  fErr2A[iV] = h.Err2A();
289  fBeta[iV] = h.Beta();
290  mIsLeft[iV] = h.IsLeft() ? 1.f : 0.f;
291 
292  fAngle[iV] = h.Angle();
293  fFStripP[iV] = h.FStripP();
294  fBStripP[iV] = h.BStripP();
295  // mIsUsed[iV] = h.IsUsed() ? 1.f : 0.f;
296  }
297  fIsLeft = (float_v(mIsLeft) == 1.f);
298 
299  /*int_v::Memory mIStation;
300  mIStation = int_v( -1 );
301 
302  uint_v::Memory mId;
303  float_v::Memory mX1, mX2, mX0;
304  float_v::Memory mErr2X1, mErrX12, mErr2X2;
305 #ifdef DRIFT_TUBES
306  float_v::Memory mR, mErr2R, mErr2A, mBeta, mIsLeft;
307 #endif
308  float_v::Memory mAlpha;
309  //float_v::Memory mIsUsed;
310 
311  foreach_bit(unsigned short iV, valid) {
312  const FTSCAHit& h = hits[iV];
313 
314  mId[iV] = h.Id();
315  mIStation[iV] = h.IStation();
316  mX1[iV] = h.X1();
317  mX2[iV] = h.X2();
318  mX0[iV] = h.X0();
319 
320  mErr2X1[iV] = h.Err2X1();
321  mErrX12[iV] = h.ErrX12();
322  mErr2X2[iV] = h.Err2X2();
323 #ifdef DRIFT_TUBES
324  mR[iV] = h.R();
325  mErr2R[iV] = h.Err2R();
326  mErr2A[iV] = h.Err2A();
327  mBeta[iV] = h.Beta();
328  mIsLeft[iV] = h.IsLeft() ? 1.f : 0.f;
329 #endif
330  mAlpha[iV] = h.Angle();
331  fFStripP[iV] = h.FStripP();
332  fBStripP[iV] = h.BStripP();
333  //mIsUsed[iV] = h.IsUsed() ? 1.f : 0.f;
334  }
335  fId = uint_v(mId);
336  fIStation = int_v(mIStation);
337  fX1 = float_v(mX1); fX2 = float_v(mX2); fX0 = float_v(mX0);
338  fErr2X1 = float_v(mErr2X1); fErrX12 = float_v(mErrX12); fErr2X2 = float_v(mErr2X2);
339 #ifdef DRIFT_TUBES
340  fR = float_v(mR); fErr2R = float_v(mErr2R); fErr2A = float_v(mErr2A); fBeta = float_v(mBeta); fIsLeft = ( float_v(mIsLeft) == 1.f );
341 #endif
342  fAngle = float_v(mAlpha);
343  */
344  // fIsUsed = ( float_v(mIsUsed) == 1.f ); // CHECKME what to do with isUsed?
345 }
346 
348 {
349  fIStation = -1;
350  fId = Vc::Zero;
351  fX0 = Vc::Zero;
352  fX1 = Vc::Zero;
353  fX2 = Vc::Zero;
354  fErr2X1 = Vc::Zero;
355  fErrX12 = Vc::Zero;
356  fErr2X2 = Vc::Zero;
357  fR = Vc::Zero;
358  fErr2R = Vc::Zero;
359  fErr2A = Vc::Zero;
360  fBeta = Vc::Zero;
361  fIsLeft = static_cast<float_m>(true);
362  fAngle = Vc::Zero;
363 }
364 
366 {
367  fElement.resize(hits.NStations());
368  for (int i = 0; i < hits.NStations(); ++i) {
369  fElement[i].IStation() = i;
370  const FTSCAElementsOnStation<FTSCAHit> &hs = hits.OnStation(i);
371  for (unsigned int iH = 0; iH < hs.size(); iH += float_v::Size) {
372  float_m valid = static_cast<float_m>(uint_v::IndexesFromZero() < uint_v(hs.size() - iH));
373  fElement[i].push_back(FTSCAHitV(&(hs[iH]), valid));
374  }
375  }
376 }
377 
378 inline void FTSCAHitsV::Clean()
379 { // remove used hits TODO
380  // for( unsigned int i = 0; i < fElement.size(); ++i ) {
381  // FTSCAElementsOnStation<T>& hits = fElement[i];
382  // FTSCAElementsOnStation<T> tmp;
383  // tmp.IStation() = i;
384  // tmp.resize( hits.size() );
385  // for( unsigned int iH = 0; iH < hits.size(); ++iH ) {
386  // if ( hits[iH].IsUsed() ) continue;
387  // tmp.push_back( hits[iH] );
388  // }
389  // hits = tmp;
390  // tmp.clear();
391  // }
392 }
393 
394 #endif
FTSCAHitsV(int nSta)
Definition: FTSCAHitsV.h:157
float_v X2() const
Definition: FTSCAHitsV.h:53
float_v ErrX12() const
Definition: FTSCAHitsV.h:59
float Err2X1() const
Definition: PndFTSCAGBHit.h:51
FTSCAHitsV(const FTSCAHits &hits)
Definition: FTSCAHitsV.h:365
float Err2X2() const
Definition: PndFTSCAGBHit.h:53
int Id() const
Definition: FTSCAHits.h:37
vector< FTSCAElementsOnStation< T > > fElement
Definition: FTSCAHitsV.h:178
T & operator[](TES i)
Definition: FTSCAHitsV.h:166
float_v FStrip() const
Definition: FTSCAHitsV.h:55
int NStations() const
Definition: FTSCAHitsV.h:164
float_v Err2X1() const
Definition: FTSCAHitsV.h:58
FTSCAStrip * BStripP() const
Definition: FTSCAHits.h:50
const FTSCAElementsOnStation< T > & OnStation(char i) const
Definition: FTSCAHitsV.h:139
FTSCAStrip * FStripP() const
Definition: PndFTSCAGBHit.h:86
FTSCAElementsOnStation< T > & operator[](char i)
Definition: FTSCAHitsV.h:144
const T & operator[](TES i) const
Definition: FTSCAHitsV.h:167
float_v Angle() const
Definition: FTSCAHitsV.h:80
FTSCAHitV T
Definition: FTSCAHitsV.h:132
__m128 v
Definition: P4_F32vec4.h:3
const char & IStation() const
Definition: FTSCAHitsV.h:124
unsigned int i
Definition: P4_F32vec4.h:21
char IStation() const
Definition: FTSCAHitsV.h:41
float ErrX12() const
Definition: PndFTSCAGBHit.h:52
FTSCAStrip * FStripP() const
Definition: FTSCAHits.h:49
void GetLocalX0X1X2(float &x0, float &x1, float &x2) const
char NStations() const
Definition: FTSCAHits.h:179
FTSCAElementsOnStation< T > & OnStation(char i)
Definition: FTSCAHits.h:145
float X2() const
Definition: FTSCAHits.h:45
float_v X0() const
Definition: FTSCAHitsV.h:51
int IRow() const
Definition: PndFTSCAGBHit.h:55
void Clean()
Definition: FTSCAHitsV.h:378
float_m IsValid() const
Definition: FTSCAHitsV.h:39
const FTSCAElementsOnStation< T > & operator[](char i) const
Definition: FTSCAHitsV.h:149
FTSCAElementsOnStation< T > & OnStation(char i)
Definition: FTSCAHitsV.h:134
float X1() const
Definition: FTSCAHits.h:44
float Angle() const
Definition: FTSCAHits.h:72
char s
Definition: FTSCATES.h:21
int_v IStations() const
Definition: FTSCAHitsV.h:47
void Add(const T &hit)
Definition: FTSCAHitsV.h:169
uint_v Id() const
Definition: FTSCAHitsV.h:49
static void CALocalToGlobal(T x0, T x1, T angle, T &x, T &y)
float_v BStrip() const
Definition: FTSCAHitsV.h:56
float Err2X2() const
Definition: FTSCAHits.h:54
float ErrX12() const
Definition: FTSCAHits.h:53
char IStation() const
Definition: FTSCAHits.h:35
float Angle() const
float_v X1() const
Definition: FTSCAHitsV.h:52
float X0() const
Definition: FTSCAHits.h:43
void GetGlobalCoor(int iV, float &x, float &y, float &z) const
Definition: FTSCAHitsV.h:82
unsigned int e
Definition: FTSCATES.h:22
FTSCAStrip * BStripP() const
Definition: PndFTSCAGBHit.h:85
float_v Err2X2() const
Definition: FTSCAHitsV.h:60
float Err2X1() const
Definition: FTSCAHits.h:52
Definition: FTSCATES.h:12
void InitValuesByZeros()
Definition: FTSCAHitsV.h:347