Deprecated/UpgradeASCIITests/CachedShowerRegeneratorASCII/StationPositionMatrix.h
Go to the documentation of this file.
1 
10 #ifndef _CachedShowerRegeneratorASCII_StationPositionMatrix_h_
11 #define _CachedShowerRegeneratorASCII_StationPositionMatrix_h_
12 
13 #include <utl/MathConstants.h>
14 #include <sdet/Station.h>
15 #include <sevt/Station.h>
16 
17 
18 namespace CachedShowerRegeneratorASCII {
19 
20  class StationInfo {
21 
32  public:
33  StationInfo(const sdet::Station& dStation, sevt::Station& eStation,
34  const double phi, const double dphi,
35  const double r, const double r1, const double r2,
36  const double area) :
37  fDetStation(&dStation),
38  fEvtStation(&eStation),
39  fR(r),
40  fR1(r1),
41  fR2(r2),
42  fResamplingArea(area)
43  {
44  SetPhiRange(phi, dphi);
45  }
46 
47  bool IsIn(const double phi, const double r) const
48  { return IsPhiIn(phi) && IsRIn(r); }
49 
50  const sdet::Station& GetDetStation() const { return *fDetStation; }
51 
52  sevt::Station& GetEvtStation() const { return *fEvtStation; }
53 
54  double GetResamplingArea() const { return fResamplingArea; }
55 
56  double GetPhi1() const { return fPhi1; }
57 
58  double GetPhi2() const { return fPhi2; }
59 
60  double GetR() const { return fR; }
61 
62  double GetR1() const { return fR1; }
63 
64  double GetR2() const { return fR2; }
65 
66  void Dump() const;
67 
68  private:
69  void
70  SetPhiRange(const double phi, const double dphi)
71  {
72  using namespace utl;
73  fPhi1 = phi - dphi;
74  fPhi2 = phi + dphi;
75  if (fPhi1 < -kPi) {
76  if (fPhi2 > kPi) {
77  fPhi1 = -kPi;
78  fPhi2 = kPi;
79  } else
80  fPhi1 += 2*kPi;
81  } else if (fPhi2 > kPi)
82  fPhi2 -= 2*kPi;
83  }
84 
85  bool
86  IsPhiIn(const double phi)
87  const
88  {
89  if (fPhi1 < fPhi2)
90  return fPhi1 <= phi && phi <= fPhi2;
91  else
92  return fPhi1 <= phi || phi <= fPhi2;
93  }
94 
95  bool IsRIn(const double r) const
96  { return fR1 <= r && r <= fR2; }
97 
98  const sdet::Station* fDetStation;
99  sevt::Station* fEvtStation;
100  bool fPhiCrossing;
101  double fPhi1;
102  double fPhi2;
103  double fR;
104  double fR1;
105  double fR2;
106  double fResamplingArea;
107  };
108 
109 
120  using namespace std;
121  using namespace utl;
122 
124  public:
125  typedef vector<StationInfo> StationInfoList;
126  typedef vector<const StationInfo*> StationInfoPtrList;
127 
128  StationPositionMatrix(const double phiGranularity, const double rGranularity) :
129  fPhiGranularity(phiGranularity),
130  fRGranularity(rGranularity),
131  fNPhi(0),
132  fPhiStep(0),
133  fNR(0),
134  fR1(0),
135  fRStep(0)
136  { }
137 
138  void
139  PushBack(const sdet::Station& dStation, sevt::Station& eStation,
140  const double phi, const double dphi,
141  const double r, const double r1, const double r2,
142  const double area)
143  {
144  const StationInfo info(dStation, eStation, phi, dphi, r, r1, r2, area);
145  fStations.push_back(info);
146  }
147 
148  void CreateMatrix(const bool useSpatialStationMatrix = true);
149 
151  { return fStations; }
152 
153  double GetMinR() const { return fR1; }
154 
155  const StationInfoPtrList&
156  GetStationList(const double phi, const double r)
157  const
158  {
159  const int iR = GetRIndex(r);
160  if (iR < 0 || iR >= fNR)
162  const int iPhi = GetPhiIndex(phi);
163  return fStationMatrix[iPhi][iR];
164  }
165 
166  void Clear();
167 
168  void DumpStats() const;
169 
170  private:
171  int
172  GetPhiIndex(const double phi)
173  const
174  {
175  const int i = int((phi + utl::kPi) / fPhiStep);
176  return (i < fNPhi) ? i : fNPhi - 1;
177  }
178 
179  int GetRIndex(const double r) const
180  { return int((r - fR1) / fRStep); }
181 
182  void Resize(const int nPhi, const int nR);
183 
184  const double fPhiGranularity;
185  const double fRGranularity;
186 
187  int fNPhi;
188  double fPhiStep;
189  int fNR;
190  double fR1;
191  double fRStep;
192 
194 
195  typedef vector<vector<StationInfoPtrList> > StationMatrix;
197 
199  };
200 
201 }
202 
203 
204 #endif
Detector description interface for Station-related data.
class to hold data at Station level
constexpr double kPi
Definition: MathConstants.h:24
StationInfo(const sdet::Station &dStation, sevt::Station &eStation, const double phi, const double dphi, const double r, const double r1, const double r2, const double area)
void PushBack(const sdet::Station &dStation, sevt::Station &eStation, const double phi, const double dphi, const double r, const double r1, const double r2, const double area)

, generated on Tue Sep 26 2023.