testSDenseDetectorBasic.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/TimeStamp.h>
17 #include <utl/UTCDateTime.h>
18 #include <utl/AugerException.h>
19 #include <utl/ErrorLogger.h>
20 
21 #include <fwk/CoordinateSystemRegistry.h>
22 #include <fwk/RunController.h>
23 
24 #include <evt/Event.h>
25 #include <evt/ShowerSimData.h>
26 #include <evt/DefaultShowerGeometryProducer.h>
27 
28 #include <sevt/SEvent.h>
29 #include <sevt/Station.h>
30 
31 #include <cppunit/extensions/HelperMacros.h>
32 #include <tst/Verify.h>
33 
34 using namespace det;
35 using namespace std;
36 using namespace fwk;
37 using namespace utl;
38 using namespace tst;
39 using namespace sdet;
40 using namespace evt;
41 
42 
43 class SDenseDetectorTestBasic : public CppUnit::TestFixture {
44 
45  CPPUNIT_TEST_SUITE(SDenseDetectorTestBasic);
46  CPPUNIT_TEST_EXCEPTION(testNoSimShower, MissingEventDataException);
47  CPPUNIT_TEST_EXCEPTION(testNoCorePosition, MissingEventDataException);
48  CPPUNIT_TEST(testBasic1);
49  CPPUNIT_TEST_SUITE_END();
50 
51 public:
52  void
54  {
55  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
56 
57  // CentralConfig must be created first.
58  //
59  CentralConfig::GetInstance(BOOTSTRAPFILE);
60 
61  // Create a detector
62  //
63  Detector::GetInstance().Update(UTCDateTime(2005,1,1).GetTimeStamp());
64  }
65 
66  void tearDown() { }
67 
68  void
70  {
71  const Detector& theDetector = Detector::GetInstance();
72 
73  /*const SDetector& sDet = theDetector.GetSDetector();
74  cout << "stations:";
75  for (const auto& id : sDet.GetFullStationList())
76  cout << ' ' << id;
77  cout << endl;*/
78  const CoordinateSystemPtr pampaCS = theDetector.GetReferenceCoordinateSystem();
79  const CoordinateSystemPtr malargueCS = theDetector.GetSiteCoordinateSystem();
80 
81  // Set a sim shower data so that dense station position can
82  // be computed relative to it
83  //
84  Event& evt = RunController::GetInstance().GetCurrentEvent();
85  if (!evt.HasSimShower())
87 
88  ShowerSimData& simShower = evt.GetSimShower();
91  const double x = 123*m;
92  const double y = 456*m;
93  const double z = -13*m;
94  //const PointUTM coreUTM(
95  simShower.MakeGeometry(Point(x, y, z, pampaCS));
96  const double tolerance = 1*m;
97 
98  // Check that non-dense stations are not screwed up by presence
99  // of the dense manager.
100  const Station& nonDense = theDetector.GetSDetector().GetStation(57);
101  CPPUNIT_ASSERT(Verify<CloseTo>(nonDense.GetPosition().GetX(malargueCS), 14563.7, 1*mm));
102  CPPUNIT_ASSERT(Verify<Equal>(nonDense.GetName(), string("Skeeter")));
103  CPPUNIT_ASSERT(Verify<Equal>(nonDense.IsDense(), false));
104  CPPUNIT_ASSERT(Verify<Equal>(nonDense.IsInGrid(), true));
105 
106  // Check basics of dense stations
107  const Station& stat1 = theDetector.GetSDetector().GetStation(99999); // a dense-array station
108  CPPUNIT_ASSERT(Verify<Equal>(stat1.GetId(), 99999));
109  CPPUNIT_ASSERT(Verify<Equal>(stat1.GetName(), string("DenseStation99999")));
110  CPPUNIT_ASSERT(Verify<Equal>(stat1.IsDense(), true));
111  CPPUNIT_ASSERT(Verify<Equal>(stat1.IsInGrid(), false)); // dense stations are off grid
112 
113  const Point pos1 = stat1.GetPosition();
114  CPPUNIT_ASSERT(Verify<CloseTo>(pos1.GetX(pampaCS), x, tolerance));
115  CPPUNIT_ASSERT(Verify<CloseTo>(pos1.GetY(pampaCS), y, tolerance));
116  CPPUNIT_ASSERT(Verify<CloseTo>(pos1.GetZ(pampaCS), z, tolerance));
117 
118  const Station& stat2 = theDetector.GetSDetector().GetStation(99998);
119  const Point pos2 = stat2.GetPosition();
120  CPPUNIT_ASSERT(Verify<CloseTo>(pos2.GetX(pampaCS), x + 1000*m, tolerance));
121  CPPUNIT_ASSERT(Verify<CloseTo>(pos2.GetY(pampaCS), y, tolerance));
122  CPPUNIT_ASSERT(Verify<CloseTo>(pos2.GetZ(pampaCS), z, tolerance));
123 
124  const Station& stat3 = theDetector.GetSDetector().GetStation(99996);
125  const Point pos3 = stat3.GetPosition();
126  CPPUNIT_ASSERT(Verify<CloseTo>(pos3.GetX(pampaCS), x, tolerance));
127  CPPUNIT_ASSERT(Verify<CloseTo>(pos3.GetY(pampaCS), y + 1000*m, tolerance));
128  CPPUNIT_ASSERT(Verify<CloseTo>(pos3.GetZ(pampaCS), z, tolerance));
129 
130  const Station& stat4 = theDetector.GetSDetector().GetStation(99990);
131  const Point pos4 = stat4.GetPosition();
132  CPPUNIT_ASSERT(Verify<CloseTo>(pos4.GetX(pampaCS), x + 1000*m, tolerance));
133  CPPUNIT_ASSERT(Verify<CloseTo>(pos4.GetY(pampaCS), y, tolerance));
134  CPPUNIT_ASSERT(Verify<CloseTo>(pos4.GetZ(pampaCS), z, tolerance));
135  }
136 
137  void
139  {
140  Detector& theDetector = Detector::GetInstance();
141 
142  // should throw exception, since no SimShower exists.
143  Point pos = theDetector.GetSDetector().GetStation(99999).GetPosition();
144  }
145 
146  void
148  {
149  Event& evt = RunController::GetInstance().GetCurrentEvent();
150  if (!evt.HasSimShower())
152 
153  Detector& theDetector = Detector::GetInstance();
154 
155  // should throw exception, since shower core position is not set
156  Point pos = theDetector.GetSDetector().GetStation(99999).GetPosition();
157  }
158 
159 };
160 
161 
constexpr double mm
Definition: AugerUnits.h:113
Point object.
Definition: Point.h:32
Detector description interface for Station-related data.
bool HasSimShower() const
void SetGroundParticleCoordinateSystemAzimuth(const double azimuth)
Set the azimuth angle of the shower. Angle in x-y plane wrt. to the x axis (0 is from east)...
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.
utl::CoordinateSystemPtr GetSiteCoordinateSystem() const
Get the coordinate system for the site.
Definition: Detector.h:137
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
const std::string & GetName() const
Station name.
utl::Point GetPosition() const
Tank position.
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
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
ShowerSimData & GetSimShower()
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
Base class for exceptions arising because required info not present in the Event. ...
void SetGroundParticleCoordinateSystemZenith(const double zenith)
Set the zenith angle of the shower. Room angle between z-axis and direction from where the shower is ...
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
Get the reference coordinate system used for analysis (usually PampaAmarilla for Auger) ...
Definition: Detector.h:141
void MakeGeometry(const utl::Point &pointOnShowerAxis)
initialize the shower geometry. Pos is a point on the shower axis, but not necessarily the core ...
bool IsDense() const
Tells whether the station belongs to set of hypothetical &quot;dense&quot; stations.
void MakeSimShower(const evt::VShowerGeometryProducer &p)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192
int GetId() const
Station ID.
constexpr double m
Definition: AugerUnits.h:121

, generated on Tue Sep 26 2023.