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