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

, generated on Tue Sep 26 2023.