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