CachedShowerRegeneratorOG/StationPositionMatrix.cc
Go to the documentation of this file.
1 #include <utl/Accumulator.h>
3 
4 using namespace std;
5 using namespace utl;
6 
7 
9 
10  void
12  const
13  {
14  std::cerr
15  << "ds " << fDetStation->GetId() << " es " << fEvtStation->GetId() << " "
16  "phi " << fPhi1 << ' ' << fPhi2 << " "
17  "r " << fR << " "
18  "lnSqrR " << fLnSqrR1 << ' ' << fLnSqrR2 << " "
19  "a " << fResamplingArea << "\n";
20  }
21 
22 
23  void
24  StationPositionMatrix::Clear()
25  {
26  // ensure negative index is returned for all possible R
27  fLnSqrR1 = -1000;
28  fLnSqrRStep = -1;
29  fStations.clear();
30  fStationMatrix.clear();
31  fEmptyStationInfoPtrList.clear();
32  }
33 
34 
35  void
36  StationPositionMatrix::CreateMatrix(const bool useSpatialStationMatrix)
37  {
38  const double tpi = 2*utl::kPi;
39  if (!useSpatialStationMatrix || fStations.empty()) {
40  Clear();
41  // "empty" list of stations will be returned
42  fEmptyStationInfoPtrList.clear();
43  for (const auto& s : fStations)
44  fEmptyStationInfoPtrList.push_back(&s);
45  return;
46  }
47  // find range
48  Accumulator::Min<double> lnSqrR1(fStations[0].GetLnSqrR1());
49  Accumulator::Max<double> lnSqrR2(fStations[0].GetLnSqrR2());
50  Accumulator::Average deltaPhi;
51  Accumulator::Average deltaLnSqrR;
52  for (const auto& s : fStations) {
53  lnSqrR1(s.GetLnSqrR1());
54  lnSqrR2(s.GetLnSqrR2());
55  deltaLnSqrR(s.GetLnSqrR2() - s.GetLnSqrR1());
56  const double dphi = s.GetPhi2() - s.GetPhi1();
57  deltaPhi((dphi >= 0) ? dphi : tpi-dphi);
58  }
59  fNPhi = ceil(tpi / deltaPhi.GetAverage() * fPhiGranularity);
60  fPhiStep = tpi / fNPhi;
61  const double dLnSqrR = lnSqrR2.GetMax() - lnSqrR1.GetMin();
62  fNR = ceil(dLnSqrR / deltaLnSqrR.GetAverage() * fLnSqrRGranularity);
63  fLnSqrR1 = lnSqrR1.GetMin();
64  fLnSqrRStep = dLnSqrR / fNR;
65 
66  Resize(fNPhi, fNR);
67 
68  // fill matrix with station info pointers
69  for (const auto& s : fStations) {
70  const int iPhi1 = GetPhiIndex(s.GetPhi1());
71  const int iPhi2 = GetPhiIndex(s.GetPhi2());
72  const int iR1 = GetLnSqrRIndex(s.GetLnSqrR1());
73  int iR2 = GetLnSqrRIndex(s.GetLnSqrR2());
74  if (iR2 == fNR)
75  iR2 = fNR - 1;
76  if (iPhi1 <= iPhi2) {
77  for (int i = iPhi1; i <= iPhi2; ++i)
78  for (int j = iR1; j <= iR2; ++j)
79  fStationMatrix[i][j].push_back(&s);
80  } else {
81  for (int j = iR1; j <= iR2; ++j) {
82  for (int i = 0; i <= iPhi2; ++i)
83  fStationMatrix[i][j].push_back(&s);
84  for (int i = iPhi1; i < fNPhi; ++i)
85  fStationMatrix[i][j].push_back(&s);
86  }
87  }
88  }
89  }
90 
91 
92  void
93  StationPositionMatrix::DumpStats()
94  const
95  {
96  Accumulator::MinMax<int> minmax(fStationMatrix[0][0].size());
98  for (int i = 0; i < fNPhi; ++i) {
99  for (int j = 0; j < fNR; ++j) {
100  const int s = fStationMatrix[i][j].size();
101  minmax(s);
102  size(s);
103  }
104  }
105  cerr
106  << "\n"
107  "nPhi = " << fNPhi << "\n"
108  "lnSqrR = " << fLnSqrR1 << " : " << fLnSqrR1 + fNR * fLnSqrRStep << ", " << fNR << "\n"
109  "matrix = " << minmax.GetMin() << ", " << size.GetAverage() << ", "
110  << minmax.GetMax() << '\n';
111  for (const auto& s : fStations)
112  s.Dump();
113  }
114 
115 
116  void
117  StationPositionMatrix::Resize(const int nPhi, const int nR)
118  {
119  fStationMatrix.clear();
120  fStationMatrix.resize(nPhi);
121  for (auto& s : fStationMatrix)
122  s.resize(nR);
123  }
124 
125 }
constexpr double s
Definition: AugerUnits.h:163
constexpr double kPi
Definition: MathConstants.h:24
Regenerate thinned MC showers.
void Dump(const FEvent &fevent)

, generated on Tue Sep 26 2023.