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>();
82 stringstream infoString;
83 infoString <<
"Validation mode = " << mode;
84 INFO(infoString.str());
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 << info.fParameterId <<
"->" << info.fParameterName;
139 *fTestResults <<
BeLabel(label.str());
140 if (rRecShower.
HasParameter(ShowerRRecDataQuantities(info.fParameterId))) {
141 if (info.fUseAbsoluteTolerance)
151 *fTestResults <<
BeLabel(label.str());
153 if (info.fUseAbsoluteTolerance)
165 *fTestResults <<
BeLabel(
"Tests on radio station level:");
166 for (
const auto& station : rEvent.StationsRange()) {
168 if (!station.HasRecData()) {
169 *fTestResults <<
BeLabel(
"No radio reconstructed data on station level found! Test failed");
170 ERROR(
"No radio reconstructed data on station level found! Test failed");
174 for (
const auto& info : fStationTests) {
177 << station.GetId() <<
"-" << info.fParameterId <<
"->" << info.fParameterName;
178 *fTestResults <<
BeLabel(label.str());
179 if (station.GetRecData().HasParameter(StationRRecDataQuantities(info.fParameterId))) {
180 if (info.fUseAbsoluteTolerance)
181 *fTestResults <<
BeCloseAbs(station.GetRecData().GetParameter(StationRRecDataQuantities(info.fParameterId)),
184 *fTestResults <<
BeCloseRel(station.GetRecData().GetParameter(StationRRecDataQuantities(info.fParameterId)),
190 *fTestResults <<
BeLabel(label.str());
191 if (station.GetRecData().HasParameterError(StationRRecDataQuantities(info.fParameterId))) {
192 if (info.fUseAbsoluteTolerance)
193 *fTestResults <<
BeCloseAbs(station.GetRecData().GetParameterError(StationRRecDataQuantities(info.fParameterId)),
196 *fTestResults <<
BeCloseRel(station.GetRecData().GetParameterError(StationRRecDataQuantities(info.fParameterId)),
209 Verification::Finish()
213 if (fMode == Verification::eCreate) {
214 INFO(
"Writing reference file");
215 ofstream fout(fRefFileName);
216 fout << fTestResults->str();
219 INFO(
"Comparing radio reconstruction results to reference file");
220 ifstream savedFile(fRefFileName);
221 comp =
Compare(*fTestResults, savedFile,
false);
226 INFO(
"#--------------------------------#");
227 INFO(
":all radio tests were successful:");
228 INFO(
"#--------------------------------#");
232 INFO(
"#------------------------------#");
233 INFO(
":one or more radio tests failed:");
234 INFO(
"#------------------------------#");
239 const string newRef = fRefFileName +
".new";
240 ofstream fout(newRef);
241 fout << fTestResults->str();
247 fTestResults =
nullptr;
249 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
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.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
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)
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.
std::string BeEqual(const T &value)
ResultFlag
Flag returned by module methods to the RunController.
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.
#define ERROR(message)
Macro for logging error messages.
double GetParameterError(const Parameter i) const