testSDetector.cc
Go to the documentation of this file.
1 #include <map>
2 #include <sstream>
3 #include <iostream>
4 #include <string>
5 #include <vector>
6 
7 #include <det/Detector.h>
8 #include <sdet/SDetector.h>
9 #include <fwk/CentralConfig.h>
10 #include <utl/TimeStamp.h>
11 #include <utl/UTCDateTime.h>
12 #include <utl/TabulatedFunction.h>
13 #include <utl/Reader.h>
14 #include <utl/CoordinateSystem.h>
15 #include <utl/Point.h>
16 #include <utl/AugerException.h>
17 #include <utl/ErrorLogger.h>
18 #include <fwk/CoordinateSystemRegistry.h>
19 
20 #include <evt/Event.h>
21 #include <sevt/SEvent.h>
22 #include <sevt/Station.h>
23 
24 #include <cppunit/extensions/HelperMacros.h>
25 #include <tst/Verify.h>
26 
27 using namespace det;
28 using namespace std;
29 using namespace fwk;
30 using namespace utl;
31 using namespace tst;
32 using namespace sdet;
33 
34 #define ASSERT_CLOSE(x, y, eps) CPPUNIT_ASSERT(Verify<CloseTo>(x, y, eps))
35 #define ASSERT_EQUAL(x, y) CPPUNIT_ASSERT(Verify<Equal>(x, y))
36 
37 
38 class SDetectorTest : public CppUnit::TestFixture {
39 
40  CPPUNIT_TEST_SUITE(SDetectorTest);
41  CPPUNIT_TEST(testBasic);
42  CPPUNIT_TEST(testGroups);
43  CPPUNIT_TEST(testOffGridStations);
44  CPPUNIT_TEST_EXCEPTION(testStationNotCommissioned, AugerException);
45  CPPUNIT_TEST(testStationListManager);
46  CPPUNIT_TEST(testCrowns);
47  CPPUNIT_TEST(testSModelsXMLManager);
48  CPPUNIT_TEST(testSdSimCalibrationManager);
49  //CPPUNIT_TEST(testGroups);
50  CPPUNIT_TEST_SUITE_END();
51 
52 public:
53  void
55  {
56  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
57 
58  // CentralConfig must be created first.
59  //
60  /*CentralConfig* fCentralConfig =*/
61  CentralConfig::GetInstance(BOOTSTRAPFILE);
62 
63  // Create a detector
64  //
65  /*Detector& theDetector =*/
66  Detector::GetInstance();
67  }
68 
69  void tearDown() { }
70 
71  void
73  {
74  Detector& detector = Detector::GetInstance();
75  const TimeStamp t = UTCDateTime(2005,1,1).GetTimeStamp();
76  detector.Update(t);
77 
78  evt::Event event;
79  event.MakeSEvent();
80  sevt::SEvent& sEvent = event.GetSEvent();
81 
82  sEvent.MakeStation(57);
83  sevt::Station& station = sEvent.GetStation(57);
84 
85  const CoordinateSystemPtr cs = detector.GetSiteCoordinateSystem();
86  const SDetector& sDetector = detector.GetSDetector();
87  const Station& dStation = sDetector.GetStation(station);
88 
89  ASSERT_CLOSE(dStation.GetPosition().GetX(cs), 14563.7, 1e-3*m);
90  ASSERT_CLOSE(dStation.GetPosition().GetY(cs), 27864.1, 1e-3*m);
91  ASSERT_CLOSE(dStation.GetPosition().GetZ(cs), 1322.34, 1e-3*m);
92 
93  // check that PMT id's are set going from 1 to 3
94  int i = 1;
95  for (const auto& pmt : dStation.PMTsRange()) {
96  ASSERT_EQUAL(pmt.GetId(), i);
97  ++i;
98  }
99  }
100 
101  void
103  {
104  Detector& detector = Detector::GetInstance();
105  const TimeStamp t = UTCDateTime(2004,6,26).GetTimeStamp();
106  detector.Update(t);
107 
108  const SDetector& sDetector = detector.GetSDetector();
109 
110  const SDetector::StationGroups& groups = sDetector.GetStationGroups();
111 
112  ASSERT_EQUAL(int(groups.size()), 6);
113 
114  // Carmen - Miranda
115  const Station& st49 = sDetector.GetStation(49);
116  CPPUNIT_ASSERT(st49.GetGroupId() == 1);
117  const Station& st64 = sDetector.GetStation(64);
118  CPPUNIT_ASSERT(st64.GetGroupId() == 1);
119 
120  CPPUNIT_ASSERT(groups.find(1) != groups.end());
121  const set<int>& group1 = groups.find(1)->second;
122  CPPUNIT_ASSERT(group1.find(49) != group1.end());
123  CPPUNIT_ASSERT(group1.find(64) != group1.end());
124 
125  const vector<int>& partners = st49.GetPartnerIds();
126  const vector<int>::const_iterator find64 =
127  find(partners.begin(), partners.end(), 64);
128  CPPUNIT_ASSERT(find64 != partners.end());
129 
130  const Station& st61 = sDetector.GetStation(61);
131  CPPUNIT_ASSERT(!st61.GetGroupId());
132  const vector<int>& partners61 = st61.GetPartnerIds();
133  CPPUNIT_ASSERT(!partners61.size());
134  }
135 
136  void
138  {
139  Detector& detector = Detector::GetInstance();
140  const TimeStamp t = UTCDateTime(2005,1,1).GetTimeStamp();
141  detector.Update(t);
142 
143  const SDetector& sDetector = detector.GetSDetector();
144 
145  CPPUNIT_ASSERT(!sDetector.GetStation(36).IsInGrid()); // Ursula
146  CPPUNIT_ASSERT(!sDetector.GetStation(139).IsInGrid()); // Dia
147  CPPUNIT_ASSERT(!sDetector.GetStation(140).IsInGrid()); // Moulin
148  CPPUNIT_ASSERT(sDetector.GetStation(184).IsInGrid()); // Tokci
149  CPPUNIT_ASSERT(sDetector.GetStation(185).IsInGrid()); // Rouge
150  CPPUNIT_ASSERT(sDetector.GetStation(186).IsInGrid()); // Noche
151 
152  // off-grid infill station
153  CPPUNIT_ASSERT(!sDetector.GetStation(1570).IsInGrid());
154  CPPUNIT_ASSERT(sDetector.GetStation(1570).IsInGrid(SDetectorConstants::eInfill750));
155 
156  // Regular station in infill:
157  CPPUNIT_ASSERT(sDetector.GetStation(608).IsInGrid(SDetectorConstants::eInfill750));
158  CPPUNIT_ASSERT(sDetector.GetStation(608).IsInGrid());
159 
160  // A completely off-grid station (radio):
161  CPPUNIT_ASSERT(!sDetector.GetStation(1325).IsInGrid(SDetectorConstants::eInfill750));
162  CPPUNIT_ASSERT(!sDetector.GetStation(1325).IsInGrid());
163 
164  }
165 
166  void
168  {
169  Detector& detector = Detector::GetInstance();
170  const TimeStamp detTime = UTCDateTime(2002,11,10,16,45,12).GetTimeStamp();
171  detector.Update(detTime);
172  const string name = detector.GetSDetector().GetStation(100000).GetName();
173  }
174 
175  void
177  {
178  Detector& detector = Detector::GetInstance();
179  const TimeStamp detTime = UTCDateTime(2002,11,10,16,45,12).GetTimeStamp();
180  detector.Update(detTime);
181 
182  const SDetector& sDetector = detector.GetSDetector();
183 
184  CPPUNIT_ASSERT(sDetector.GetStation(57).GetName() == string("Skeeter"));
185  CPPUNIT_ASSERT(sDetector.GetStation(14).GetName() == string("Chigua"));
186  CPPUNIT_ASSERT(sDetector.GetStation(46).GetName() == string("Tamara"));
187 
188  for (const auto& station : sDetector.StationsRange())
189  for (const auto& pmt : station.PMTsRange())
190  CPPUNIT_ASSERT(pmt.GetCollectionEfficiency() == 0.6);
191  }
192 
193  void
195  {
196  Detector& detector = Detector::GetInstance();
197  const TimeStamp t = UTCDateTime(2005,1,1).GetTimeStamp();
198  detector.Update(t);
199  const SDetector& sDetector = detector.GetSDetector();
200 
201  // checking crowns
202  const Station& st133 = sDetector.GetStation(133);
203  CPPUNIT_ASSERT(st133.GetName() == "Uli");
204  vector<int> crown;
205 
206  crown = st133.GetCrown(0);
207  CPPUNIT_ASSERT(crown.size() == 1);
208  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 133) != crown.end());
209 
210  crown = st133.GetCrown(1);
211  CPPUNIT_ASSERT(crown.size() == 5);
212  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 142) != crown.end());
213  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 106) != crown.end());
214  // this one is moved out
215  //CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 132) != crown.end());
216  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 147) != crown.end());
217  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 146) != crown.end());
218  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 135) != crown.end());
219 
220  crown = st133.GetCrown(2);
221  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 143) != crown.end());
222  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 144) != crown.end());
223  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 145) != crown.end());
224  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 105) != crown.end());
225  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 134) != crown.end());
226  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 113) != crown.end());
227  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 111) != crown.end());
228  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 219) != crown.end());
229  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 232) != crown.end());
230  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 222) != crown.end());
231  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 194) != crown.end());
232  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 191) != crown.end());
233 
234  crown = st133.GetCrown(3);
235  CPPUNIT_ASSERT(crown.size() == 18);
236  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 192) != crown.end());
237  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 193) != crown.end());
238  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 198) != crown.end());
239  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 195) != crown.end());
240  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 148) != crown.end());
241  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 149) != crown.end());
242  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 150) != crown.end());
243  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 102) != crown.end());
244  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 138) != crown.end());
245  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 185) != crown.end()); //this is a paired station
246  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 112) != crown.end());
247  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 229) != crown.end());
248  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 223) != crown.end());
249  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 220) != crown.end());
250  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 225) != crown.end());
251  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 231) != crown.end());
252  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 224) != crown.end());
253  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 316) != crown.end());
254 
255 
256  crown = st133.GetCrown(4);
257  CPPUNIT_ASSERT(crown.size() == 24);
258  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 101) != crown.end());
259  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 186) != crown.end()); // this is a paired station
260  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 119) != crown.end());
261  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 122) != crown.end());
262  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 218) != crown.end());
263  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 226) != crown.end());
264  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 207) != crown.end());
265  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 227) != crown.end());
266  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 233) != crown.end());
267  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 243) != crown.end());
268  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 241) != crown.end());
269  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 246) != crown.end());
270  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 274) != crown.end());
271  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 295) != crown.end());
272  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 202) != crown.end());
273  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 200) != crown.end());
274  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 201) != crown.end());
275  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 121) != crown.end());
276  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 167) != crown.end());
277  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 169) != crown.end());
278  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 170) != crown.end());
279  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 158) != crown.end());
280  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 151) != crown.end());
281  CPPUNIT_ASSERT(find(crown.begin(), crown.end(), 131) != crown.end());
282 
283  CPPUNIT_ASSERT(sDetector.GetStation(36).GetCrown(1).size() == 0);
284  }
285 
286  void
288  {
289  const SDetector& sDetector = Detector::GetInstance().GetSDetector();
290  const sdet::Station& firstStation = sDetector.GetStation(46);
291  CPPUNIT_ASSERT(firstStation.GetRadius() == 1.8);
292  CPPUNIT_ASSERT(firstStation.GetPMT(2).GetCollectionEfficiency() == 0.6);
293  CPPUNIT_ASSERT(sDetector.GetStation(57).GetRadius() == 1.8);
294  CPPUNIT_ASSERT(sDetector.GetStation(46).GetRadius() == 1.8);
295 
296  // Note that you should not request values at the exact bounds originally defined for the tabulated
297  // functions. Small roundouff errors in the units conversions while reading from XML files can
298  // move you slightly beyond the defined bounds for the function, and thus cause an exception.
299 
306  CPPUNIT_ASSERT(Verify<CloseTo>(qe.Y(2.081*eV), 0.020124859073964059, 1e-5));
307  CPPUNIT_ASSERT(Verify<CloseTo>(qe.Y(2.16), 0.030, 1e-5));
308  CPPUNIT_ASSERT(Verify<CloseTo>(wal.Y(2.081*eV), 4.6256*m, 0.01*mm));
309 
310 
311  CPPUNIT_ASSERT(Verify<CloseTo>(wal.Y(2.1*eV), 5.11247*m, 0.01*mm));
312  CPPUNIT_ASSERT(Verify<CloseTo>(wal.Y(2.16*eV), 6.64997*m, 0.01*mm));
313  CPPUNIT_ASSERT(Verify<CloseTo>(wal.Y(2.79*eV), 49.6499*m, 0.01*mm));
314 
315  CPPUNIT_ASSERT(Verify<CloseTo>(r.Y(.0921*eV), 1.33, 1e-5));
316  CPPUNIT_ASSERT(Verify<CloseTo>(r.Y(.102*eV), 1.33, 1e-5));
317 
318  CPPUNIT_ASSERT(Verify<CloseTo>(lr.Y(2.5*eV), 0.94563, 1e-5));
319  CPPUNIT_ASSERT(Verify<CloseTo>(lr.Y(4.07*eV), 0.776911, 1e-5));
320 
321  CPPUNIT_ASSERT(sDetector.GetStation(46).GetLinerSigmaAlpha() == 0.17);
322 
323  CPPUNIT_ASSERT(Verify<CloseTo>(sl.Y(2.1*eV), 0.2, 1e-5));
324 
325  CPPUNIT_ASSERT(Verify<CloseTo>(ss.Y(2.1*eV), 0.0, 1e-5));
326  }
327 
328  void
330  {
331  const auto& pmt = Detector::GetInstance().GetSDetector().GetStation(14).GetPMT(1);
332 
333  CPPUNIT_ASSERT(Verify<CloseTo>(pmt.GetVEMPeak("G4TankSimulatorOG"), 10.));
334  CPPUNIT_ASSERT(Verify<CloseTo>(pmt.GetVEMCharge("G4TankSimulatorOG"), 20.));
335 
336  CPPUNIT_ASSERT(Verify<CloseTo>(pmt.GetGainRatio(), 70.));
337  CPPUNIT_ASSERT(Verify<CloseTo>(pmt.GetBaseline(PMTConstants::eHighGain), 30.));
338  CPPUNIT_ASSERT(Verify<CloseTo>(pmt.GetBaseline(PMTConstants::eLowGain), 40.));
339  CPPUNIT_ASSERT(Verify<CloseTo>(pmt.GetBaselineRMS(PMTConstants::eHighGain), 50.));
340  CPPUNIT_ASSERT(Verify<CloseTo>(pmt.GetBaselineRMS(PMTConstants::eLowGain), 60.));
341  }
342 
343 };
344 
345 
const double eV
Definition: GalacticUnits.h:35
const StationGroups & GetStationGroups() const
Definition: SDetector.h:157
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
Definition: Detector.cc:179
std::map< int, std::set< int > > StationGroups
StationGroups: map key = groupId, value = stationId set.
Definition: SDetector.h:154
const StationIdCollection & GetCrown(const int level) const
Returns a list of station id&#39;s in the crown. If the argument is 0, it returns the station id...
constexpr double mm
Definition: AugerUnits.h:113
Detector description interface for Station-related data.
const std::vector< int > & GetPartnerIds() const
returns vector of partner station ids
int GetGroupId() const
returns unique identifier of a group of stations or zero (if single)
void testOffGridStations()
Base class for all exceptions used in the auger offline code.
void testStationListManager()
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
Class to hold collection (x,y) points and provide interpolation between them.
void testSdSimCalibrationManager()
const utl::TabulatedFunction & GetLinerSpecularLobe() const
Tyvek liner specular lobe constant as a function of photon energy.
Traditional name.
Definition: Verbosity.h:17
bool IsInGrid(const SDetectorConstants::GridIndex index=SDetectorConstants::eStandard) const
Tells whether the station is in the regular triangular grid.
int crown(double x1, double x2, double y1, double y2)
Definition: XbArray.cc:14
const PMT & GetPMT(const int id) const
Get specified PMT by id.
utl::CoordinateSystemPtr GetSiteCoordinateSystem() const
Get the coordinate system for the site.
Definition: Detector.h:137
const utl::TabulatedFunction & GetWaterAbsorptionLength() const
Water absorption length as a function of photon energy.
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
const std::string & GetName() const
Station name.
utl::Point GetPosition() const
Tank position.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
class to hold data at Station level
const utl::TabulatedFunction & GetLinerReflectivity() const
Tyvek liner reflectivity as a function of photon energy.
double GetCollectionEfficiency() const
Collection efficiency.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
const sdet::SDetector & GetSDetector() const
Definition: Detector.cc:119
double GetRadius() const
Radius of the tank (water only)
void MakeStation(const int stationId)
make a station with specifying Id, throw if invalid stationId
Definition: SEvent.cc:65
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
Definition: SEvent.h:116
const utl::TabulatedFunction & GetLinerSpecularSpike() const
Tyvek liner specular spike constant as a function of photon energy.
#define ASSERT_CLOSE(x, y, eps)
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
void testSModelsXMLManager()
void testStationNotCommissioned()
const utl::TabulatedFunction & GetQuantumEfficiency() const
Quantum efficiency.
const utl::TabulatedFunction & GetWaterRefractionIndex() const
Water refraction index as a function of photon energy.
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
double GetLinerSigmaAlpha() const
Tyvek liner sigma_alpha roughness parameter.
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
constexpr double m
Definition: AugerUnits.h:121
TimeStamp GetTimeStamp() const
Definition: UTCDateTime.cc:115
#define ASSERT_EQUAL(x, y)

, generated on Tue Sep 26 2023.