3 #include <evt/ShowerRecData.h>
5 #include <utl/ErrorLogger.h>
6 #include <utl/Branch.h>
7 #include <utl/Particle.h>
8 #include <utl/AugerUnits.h>
10 #include <fwk/CentralConfig.h>
12 #include <revt/REvent.h>
13 #include <revt/Header.h>
14 #include <revt/Station.h>
15 #include <revt/StationRecData.h>
16 #include <revt/StationRRecDataQuantities.h>
17 #include <evt/ShowerRecData.h>
18 #include <evt/ShowerRRecData.h>
20 #include <utl/Trace.h>
21 #include <utl/TraceAlgorithm.h>
22 #include <utl/ErrorLogger.h>
23 #include <utl/Reader.h>
24 #include <utl/config.h>
25 #include <utl/AugerUnits.h>
26 #include <utl/CoordinateSystemPtr.h>
27 #include <utl/CoordinateSystem.h>
28 #include <fwk/LocalCoordinateSystem.h>
29 #include <fwk/CoordinateSystemRegistry.h>
32 #include <tst/Validatrix.h>
41 using namespace VerificationRadio;
43 using namespace tst::Validatrix;
52 const string csString = topB.
GetChild(
"coordinateSystemId").
Get<
string>();
58 unsigned long parameterId = 0;
60 bool useAbsoluteTolerance =
false;
63 if (
b.GetName() ==
"StationQuantity") {
64 b.GetChild(
"ParameterId").GetData(parameterId);
65 b.GetChild(
"ParameterName").GetData(parameterName);
66 b.GetChild(
"UseAbsoluteTolerance").GetData(useAbsoluteTolerance);
67 b.GetChild(
"Tolerance").GetData(tolerance);
68 fStationTests.push_back(
TestInformation(parameterId, parameterName, useAbsoluteTolerance, tolerance));
69 }
else if (
b.GetName() ==
"ShowerQuantity") {
70 b.GetChild(
"ParameterId").GetData(parameterId);
71 b.GetChild(
"ParameterName").GetData(parameterName);
72 b.GetChild(
"UseAbsoluteTolerance").GetData(useAbsoluteTolerance);
73 b.GetChild(
"Tolerance").GetData(tolerance);
74 fShowerTests.push_back(
TestInformation(parameterId, parameterName, useAbsoluteTolerance, tolerance));
82 const string mode = topB.
GetChild(
"Mode").
Get<
string>();
83 stringstream infoString;
84 infoString <<
"Validation mode = " << mode;
85 INFO(infoString.str());
87 fMode = Verification::eCreate;
89 fMode = Verification::eCompare;
92 fTestResults =
new stringstream;
102 info <<
"Run validation for radio event E" <<
event.GetREvent().GetHeader().GetId();
105 *fTestResults <<
BeLabel(
"Verification for Radio:");
108 *fTestResults <<
BeLabel(
"No radio event found! Test failed");
109 ERROR(
"No radio event found! Test failed");
112 REvent& rEvent =
event.GetREvent();
115 *fTestResults <<
BeLabel(
"No reconstructed shower found! Test failed");
116 ERROR(
"No reconstructed shower found! Test failed");
121 *fTestResults <<
BeLabel(
"No reconstructed radio shower found! Test failed");
122 ERROR(
"No reconstructed radio shower found! Test failed");
128 *fTestResults <<
BeLabel(
"Run number:")
134 *fTestResults <<
BeLabel(
"Tests on radio shower level:");
136 for (
const auto& info : fShowerTests) {
139 << info.fParameterId <<
"->" << info.fParameterName;
140 *fTestResults <<
BeLabel(label.str());
141 if (rRecShower.
HasParameter(ShowerRRecDataQuantities(info.fParameterId))) {
142 if (info.fUseAbsoluteTolerance)
152 *fTestResults <<
BeLabel(label.str());
154 if (info.fUseAbsoluteTolerance)
166 *fTestResults <<
BeLabel(
"Tests on radio station level:");
167 for (
const auto& station : rEvent.StationsRange()) {
169 if (!station.HasRecData()) {
170 *fTestResults <<
BeLabel(
"No radio reconstructed data on station level found! Test failed");
171 ERROR(
"No radio reconstructed data on station level found! Test failed");
175 for (
const auto& info : fStationTests) {
178 << station.GetId() <<
"-" << info.fParameterId <<
"->" << info.fParameterName;
179 *fTestResults <<
BeLabel(label.str());
180 if (station.GetRecData().HasParameter(StationRRecDataQuantities(info.fParameterId))) {
181 if (info.fUseAbsoluteTolerance)
182 *fTestResults <<
BeCloseAbs(station.GetRecData().GetParameter(StationRRecDataQuantities(info.fParameterId)),
185 *fTestResults <<
BeCloseRel(station.GetRecData().GetParameter(StationRRecDataQuantities(info.fParameterId)),
191 *fTestResults <<
BeLabel(label.str());
192 if (station.GetRecData().HasParameterError(StationRRecDataQuantities(info.fParameterId))) {
193 if (info.fUseAbsoluteTolerance)
194 *fTestResults <<
BeCloseAbs(station.GetRecData().GetParameterError(StationRRecDataQuantities(info.fParameterId)),
197 *fTestResults <<
BeCloseRel(station.GetRecData().GetParameterError(StationRRecDataQuantities(info.fParameterId)),
210 Verification::Finish()
214 if (fMode == Verification::eCreate) {
215 INFO(
"Writing reference file");
216 ofstream fout(fRefFileName);
217 fout << fTestResults->str();
220 INFO(
"Comparing radio reconstruction results to reference file");
221 ifstream savedFile(fRefFileName);
222 comp =
Compare(*fTestResults, savedFile,
false);
227 INFO(
"#--------------------------------#");
228 INFO(
":all radio tests were successful:");
229 INFO(
"#--------------------------------#");
233 INFO(
"#------------------------------#");
234 INFO(
":one or more radio tests failed:");
235 INFO(
"#------------------------------#");
240 const string newRef = fRefFileName +
".new";
241 ofstream fout(newRef);
242 fout << fTestResults->str();
248 fTestResults =
nullptr;
250 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