testEVAFile.cc
Go to the documentation of this file.
1 
9 #include <io/EVAFile.h>
10 #include <io/EVAIOException.h>
11 #include <io/IoCodes.h>
12 
13 #include <evt/Event.h>
14 #include <evt/ShowerSimData.h>
15 #include <evt/VGaisserHillasParameter.h>
16 #include <evt/RadioSimulation.h>
17 #include <evt/SimRadioPulse.h>
18 
19 #include <utl/AugerUnits.h>
20 #include <utl/Particle.h>
21 
22 #include <fwk/CentralConfig.h>
23 
24 #include <det/Detector.h>
25 
26 #include <tst/Verify.h>
27 #include <cppunit/extensions/HelperMacros.h>
28 
29 #include <iostream>
30 
31 using io::EVAFile;
32 using namespace fwk;
33 using namespace utl;
34 using namespace tst;
35 
36 class testEVAFile : public CppUnit::TestFixture {
37 private:
38  CPPUNIT_TEST_SUITE (testEVAFile);
39  CPPUNIT_TEST (testConstruct);
40  CPPUNIT_TEST (testGetNEvents);
41  CPPUNIT_TEST (testRead);
42  CPPUNIT_TEST_SUITE_END();
43 
44 public:
45  // shared data for tests
48 
49  void setUp() {
50  f = new EVAFile();
51  event = evt::Event();
52  }
53 
54  void tearDown() {
55  delete f;
56  }
57 
58  void testConstruct() {
59  EVAFile* file;
60  CPPUNIT_ASSERT (file = new EVAFile (TESTFILE));
61  delete file;
62  }
63 
64  void testGetNEvents() {
65  f->Open (TESTFILE);
66  CPPUNIT_ASSERT (f->GetNEvents() == 1);
67  }
68 
69  void testRead() {
70 
71  fwk::CentralConfig::GetInstance(BOOTSTRAPFILE);
72 
73  // Some numbers for checking the data
74  const double start_times[6] = {1.0824, 0.8214, 1.0596, 0.1590, 0.9667, 0.8041};
75  const double field_sample1[6][3] = {
76  { 9.7513824668E-05, 1.6809870176E-05, -3.1268147325E-05}, // station1
77  {-1.0457331050E-01, -2.1307854418E-02, 3.5102479773E-02}, // station2
78  {-1.3048007407E+00, -2.9347374586E-01, 4.3270475183E-01}, // station3
79  {-2.7832267828E+03, -5.0633607442E+02, 8.5908390450E+02}, // station4
80  {-1.5242416513E-02, -2.8939296207E-03, 3.6363917902E-03}, // station5
81  {-9.3780203407E+02, -2.1832715112E+02, 2.7429037668E+02} // station6
82  };
83  const double field_sample2[6][3] = {
84  { 1.8118094038E+02, 2.7474426401E+01, -7.2966177649E+01}, // station1
85  { 4.2307544703E+02, 8.6342326262E+01, -1.0922502801E+02}, // station2
86  { 4.5767736476E+02, 1.0886486729E+02, -9.2860815629E+01}, // station3
87  { 4.0576623131E+02, 7.0267573388E+01, -1.2122706669E+02}, // station4
88  { 4.8185477571E+02, 1.1248897768E+02, -8.8667336289E+01}, // station5
89  { 4.5953447261E+02, 1.0833208790E+02, -8.7527963838E+01} // station6
90  };
91  const double field_sample3[6][3] = {
92  { 3.4397880870E-03, -1.0811865284E-02, 1.1460809613E-02}, // station1
93  { 5.1979536749E-03, -8.6519291944E-03, 6.9117284726E-03}, // station2
94  { 7.0621774784E-03, -9.2785115705E-03, 7.5364749611E-03}, // station3
95  { 0.0000000000E+00, -0.0000000000E+00, 0.0000000000E+00}, // station4
96  { 1.1726113640E-02, -6.6024960407E-03, 8.2778160319E-03}, // station5
97  { 6.3571980942E-06, 1.0960432053E-06, -2.0383258957E-06} // station6
98  };
99 
100  f->Open (TESTFILE);
101  int num_events_in_file = f->GetNEvents();
102  int num_pulses = 0;
103  int num_events = 0;
104 
105  CPPUNIT_ASSERT (Verify<Equal>(num_events_in_file, 1));
106 
107  while (f->Read (event) != io::eEOF) {
108  evt::ShowerSimData& shower = event.GetSimShower();
109 
110  const CoordinateSystemPtr refCS = det::Detector::GetInstance().GetReferenceCoordinateSystem();
111  shower.MakeGeometry(utl::Point(0,0,0,refCS));
112 
113  CPPUNIT_ASSERT (Verify <Less> (num_events, 1));
114 
115  /* Primary particle not implemented yet. This is however something
116  That needs to become part of the EVA Model.
117  CPPUNIT_ASSERT (Verify <Equal> (shower.GetPrimaryParticle(),
118  int(Particle::eProton)));
119  */
120 
121  CPPUNIT_ASSERT (Verify <CloseTo> (shower.GetEnergy(), 1.0919*EeV));
122 
123  const utl::CoordinateSystemPtr localCS = shower.GetLocalCoordinateSystem();
124  const double zenith = (-shower.GetDirection()).GetTheta(localCS);
125  const double azimuth = (-shower.GetDirection()).GetPhi(localCS);
126 
127  CPPUNIT_ASSERT (Verify <CloseTo> (zenith, 58.357683919*deg));
128  CPPUNIT_ASSERT (Verify <CloseTo> (azimuth, -68.990120994*deg));
129  CPPUNIT_ASSERT (Verify<Equal>(shower.GetShowerNumber(), num_events));
130 
131  // test if EVA contents are set up correctly
132  CPPUNIT_ASSERT (Verify<Equal>(shower.HasRadioSimulation(), true));
133  evt::RadioSimulation& radsim = shower.GetRadioSimulation();
134  CPPUNIT_ASSERT (Verify<Equal>(radsim.GetNumPulses(), (long)6));
135  CPPUNIT_ASSERT (Verify<Equal>(radsim.HasCorePosition(), true));
136 
137  while (true) {
138  bool ok;
139  const evt::SimRadioPulse& simpulse = radsim.GetNextSimRadioPulse(ok);
140  if (not ok) break;
141 
142  CPPUNIT_ASSERT (Verify<Less> (num_pulses, 6));
143 
144  CPPUNIT_ASSERT (Verify<Equal>(simpulse.GetEfieldTimeSeries().GetSize(),
145  (TraceV3D::SizeType)1047));
146  CPPUNIT_ASSERT (Verify<Equal>(simpulse.GetEfieldTimeSeries().GetBinning(),
147  2.5*nanosecond));
148  CPPUNIT_ASSERT (Verify<Equal> (simpulse.GetBinning(), 2.5 * nano * second));
149  CPPUNIT_ASSERT (Verify<CloseTo>(simpulse.GetStartTime(),
150  start_times[num_pulses] * micro * second));
151 
152  Vector3D sample = simpulse.GetEfieldTimeSeries()[1];
153  CPPUNIT_ASSERT (Verify<CloseTo>(sample[0],
154  field_sample1[num_pulses][0] * micro * volt / meter));
155  CPPUNIT_ASSERT (Verify<CloseTo>(sample[1],
156  field_sample1[num_pulses][1] * micro * volt / meter));
157  CPPUNIT_ASSERT (Verify<CloseTo>(sample[2],
158  field_sample1[num_pulses][2] * micro * volt / meter));
159 
160  sample = simpulse.GetEfieldTimeSeries()[9];
161  CPPUNIT_ASSERT (Verify<CloseTo>(sample[0],
162  field_sample2[num_pulses][0] * micro * volt / meter));
163  CPPUNIT_ASSERT (Verify<CloseTo>(sample[1],
164  field_sample2[num_pulses][1] * micro * volt / meter));
165  CPPUNIT_ASSERT (Verify<CloseTo>(sample[2],
166  field_sample2[num_pulses][2] * micro * volt / meter));
167 
168  sample = simpulse.GetEfieldTimeSeries()[199];
169  CPPUNIT_ASSERT (Verify<CloseTo>(sample[0],
170  field_sample3[num_pulses][0] * micro * volt / meter));
171  CPPUNIT_ASSERT (Verify<CloseTo>(sample[1],
172  field_sample3[num_pulses][1] * micro * volt / meter));
173  CPPUNIT_ASSERT (Verify<CloseTo>(sample[2],
174  field_sample3[num_pulses][2] * micro * volt / meter));
175 
176  sample = simpulse.GetEfieldTimeSeries()[0];
177  CPPUNIT_ASSERT (Verify<CloseTo>(sample[0], 0 * micro * volt / meter));
178  CPPUNIT_ASSERT (Verify<CloseTo>(sample[1], 0 * micro * volt / meter));
179  CPPUNIT_ASSERT (Verify<CloseTo>(sample[2], 0 * micro * volt / meter));
180 
181  ++num_pulses;
182  }
183  CPPUNIT_ASSERT (Verify<Equal>(num_pulses, 6));
184  ++num_events;
185  }
186  CPPUNIT_ASSERT (Verify<Equal>(num_events, 1));
187  }
188 };
189 
191 
192 // Configure (x)emacs for this file ...
193 // Local Variables:
194 // mode:c++
195 // compile-command: "make -C .. -k testEVA && (cd ..; testEVA)"
196 // End:
197 
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
double GetBinning() const
Get the sampling time scale.
Definition: SimRadioPulse.h:34
Point object.
Definition: Point.h:32
void tearDown()
Definition: testEVAFile.cc:54
void testRead()
Definition: testEVAFile.cc:69
Data structure for simulated Radio pulses.
Definition: SimRadioPulse.h:29
void setUp()
Definition: testEVAFile.cc:49
Data structure for a radio simulation (including several SimRadioPulses)
double GetBinning() const
size of one slot
Definition: Trace.h:138
const double meter
Definition: GalacticUnits.h:29
bool HasRadioSimulation() const
Check initialization of the RadioSimulation.
bool ok(bool okay)
Definition: testlib.cc:89
const double EeV
Definition: GalacticUnits.h:34
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
constexpr double deg
Definition: AugerUnits.h:140
EVAFile * f
Definition: testEVAFile.cc:46
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
int GetShowerNumber() const
Get the number of the shower in the file.
Definition: ShowerSimData.h:72
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
std::vector< T >::size_type SizeType
Definition: Trace.h:58
bool HasCorePosition() const
RadioSimulation & GetRadioSimulation()
Get the radio simulation data.
constexpr double nanosecond
Definition: AugerUnits.h:143
void testConstruct()
Definition: testEVAFile.cc:58
const double second
Definition: GalacticUnits.h:32
evt::Event event
Definition: testEVAFile.cc:47
double GetEnergy() const
Get the energy of the shower primary particle.
Definition: ShowerSimData.h:89
SizeType GetSize() const
Definition: Trace.h:156
const string file
void testGetNEvents()
Definition: testEVAFile.cc:64
Read EVA simulation output.
Definition: EVAFile.h:44
const SimRadioPulse & GetNextSimRadioPulse(bool &ok)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
void MakeGeometry(const utl::Point &pointOnShowerAxis)
initialize the shower geometry. Pos is a point on the shower axis, but not necessarily the core ...
constexpr double micro
Definition: AugerUnits.h:65
long GetNumPulses() const
Get the number of radio pulses contained in the RadioSimulation.
constexpr double nano
Definition: AugerUnits.h:64
const utl::TraceV3D & GetEfieldTimeSeries() const
Get the Trace of the simulated electric field.
Definition: SimRadioPulse.h:44
const double volt
Definition: GalacticUnits.h:38
double GetStartTime() const
Get the timestamp of the first sample.
Definition: SimRadioPulse.h:39

, generated on Tue Sep 26 2023.