2 #include <evt/ShowerRecData.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/Branch.h>
6 #include <utl/Particle.h>
7 #include <utl/AugerUnits.h>
9 #include <fwk/CentralConfig.h>
11 #include <revt/REvent.h>
12 #include <revt/Header.h>
13 #include <revt/Station.h>
14 #include <revt/StationRecData.h>
15 #include <revt/StationRRecDataQuantities.h>
16 #include <evt/ShowerRecData.h>
17 #include <evt/ShowerRRecData.h>
19 #include <utl/Trace.h>
20 #include <utl/TraceAlgorithm.h>
21 #include <utl/ErrorLogger.h>
22 #include <utl/Reader.h>
23 #include <utl/config.h>
24 #include <utl/AugerUnits.h>
25 #include <utl/CoordinateSystemPtr.h>
26 #include <utl/CoordinateSystem.h>
27 #include <fwk/LocalCoordinateSystem.h>
28 #include <fwk/CoordinateSystemRegistry.h>
31 #include <tst/Validatrix.h>
40 using namespace VerificationRadio;
42 using namespace tst::Validatrix;
51 const string csString = topB.
GetChild(
"coordinateSystemId").
Get<
string>();
57 unsigned long parameterId = 0;
59 bool useAbsoluteTolerance =
false;
62 if (
b.GetName() ==
"StationQuantity") {
63 b.GetChild(
"ParameterId").GetData(parameterId);
64 b.GetChild(
"ParameterName").GetData(parameterName);
65 b.GetChild(
"UseAbsoluteTolerance").GetData(useAbsoluteTolerance);
66 b.GetChild(
"Tolerance").GetData(tolerance);
67 fStationTests.push_back(TestInformation(parameterId, parameterName, useAbsoluteTolerance, tolerance));
68 }
else if (
b.GetName() ==
"ShowerQuantity") {
69 b.GetChild(
"ParameterId").GetData(parameterId);
70 b.GetChild(
"ParameterName").GetData(parameterName);
71 b.GetChild(
"UseAbsoluteTolerance").GetData(useAbsoluteTolerance);
72 b.GetChild(
"Tolerance").GetData(tolerance);
73 fShowerTests.push_back(TestInformation(parameterId, parameterName, useAbsoluteTolerance, tolerance));
81 const string mode = topB.
GetChild(
"Mode").
Get<
string>();
83 info <<
"Validation mode = " << mode;
86 fMode = Verification::eCreate;
88 fMode = Verification::eCompare;
91 fTestResults =
new stringstream;
101 info <<
"Run validation for radio event E" <<
event.GetREvent().GetHeader().GetId();
104 *fTestResults <<
BeLabel(
"Verification for Radio:");
107 *fTestResults <<
BeLabel(
"No radio event found! Test failed");
108 ERROR(
"No radio event found! Test failed");
111 REvent& rEvent =
event.GetREvent();
114 *fTestResults <<
BeLabel(
"No reconstructed shower found! Test failed");
115 ERROR(
"No reconstructed shower found! Test failed");
120 *fTestResults <<
BeLabel(
"No reconstructed radio shower found! Test failed");
121 ERROR(
"No reconstructed radio shower found! Test failed");
127 *fTestResults <<
BeLabel(
"Run number:")
133 *fTestResults <<
BeLabel(
"Tests on radio shower level:");
135 for (
const auto& info : fShowerTests) {
138 *fTestResults <<
BeLabel(label.str());
139 if (rRecShower.
HasParameter(ShowerRRecDataQuantities(info.fParameterId))) {
140 if (info.fUseAbsoluteTolerance)
141 *fTestResults <<
BeCloseAbs(rRecShower.
GetParameter(ShowerRRecDataQuantities(info.fParameterId)), info.fTolerance);
143 *fTestResults <<
BeCloseRel(rRecShower.
GetParameter(ShowerRRecDataQuantities(info.fParameterId)), info.fTolerance);
148 *fTestResults <<
BeLabel(label.str());
150 if (info.fUseAbsoluteTolerance)
160 *fTestResults <<
BeLabel(
"Tests on radio station level:");
165 *fTestResults <<
BeLabel(
"No radio reconstructed data on station level found! Test failed");
166 ERROR(
"No radio reconstructed data on station level found! Test failed");
170 for (
const auto& info : fStationTests) {
173 *fTestResults <<
BeLabel(label.str());
175 if (info.fUseAbsoluteTolerance)
183 *fTestResults <<
BeLabel(label.str());
185 if (info.fUseAbsoluteTolerance)
200 Verification::Finish()
204 if (fMode == Verification::eCreate) {
205 INFO(
"Writing reference file");
206 ofstream fout(fRefFileName);
207 fout << fTestResults->str();
210 INFO(
"Comparing radio reconstruction results to reference file");
211 ifstream savedFile(fRefFileName);
212 comp =
Compare(*fTestResults, savedFile,
false);
216 INFO(
"radio verification was successful");
218 ERROR(
"radio verification failed");
221 const string newRef = fRefFileName +
".new";
222 ofstream fout(newRef);
223 fout << fTestResults->str();
229 fTestResults =
nullptr;
231 return (comp) ?
eSuccess : eFailure;
Branch GetTopBranch() const
bool HasParameter(const Parameter i) const
std::string BeCloseRel(const T &value, const double tolerance=kDefaultTolerance)
bool HasParameterError(const Parameter i) const
StationRecData & GetRecData()
Get station level reconstructed data.
bool HasRecShower() const
Interface class to access to the Radio part of an event.
ShowerRecData & GetRecShower()
Interface class to access to the RD Reconstruction of a Shower.
double GetParameterError(const Parameter i) const
bool HasParameterError(const Parameter i1) const
#define INFO(message)
Macro for logging informational messages.
StationIterator StationsEnd()
StationIterator StationsBegin()
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
boost::filter_iterator< StationFilter, AllStationIterator > StationIterator
Iterator over all (non-exculded) stations.
std::string BeCloseAbs(const T &value, const double tolerance=kDefaultTolerance)
Class representing a document branch.
bool Compare(const string &oldFilename, const string &newFilename, const bool failOnFirst)
class to hold data at the radio Station level.
std::string BeLabel(const string &tag)
bool HasRRecShower() const
Header & GetHeader()
access to REvent Header
void GetData(bool &b) const
Overloads of the GetData member template function.
int GetId() const
Get the station Id.
std::string BeEqual(const T &value)
double GetParameter(const Parameter i) const
ResultFlag
Flag returned by module methods to the RunController.
bool HasParameter(const Parameter i) const
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
double GetParameter(const Parameter i) const
Branch GetFirstChild() const
Get first child of this Branch.
bool HasRecData() const
Check whether station reconstructed data exists.
#define ERROR(message)
Macro for logging error messages.
double GetParameterError(const Parameter i) const