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