RdSdSimCheckHAS/Validation.cc
Go to the documentation of this file.
1 #include <evt/Event.h>
2 #include <evt/ShowerRecData.h>
3 #include <evt/ShowerSRecData.h>
4 
5 #include <sevt/SEvent.h>
6 #include <sevt/SortCriteria.h>
7 
8 #include <utl/ErrorLogger.h>
9 #include <utl/Branch.h>
10 #include <utl/AugerUnits.h>
11 
12 #include <tst/Validatrix.h>
13 
14 #include <fwk/CentralConfig.h>
15 #include <fwk/LocalCoordinateSystem.h>
16 
17 #include "Validation.h"
18 
19 using namespace std;
20 using namespace evt;
21 using namespace sevt;
22 using namespace fevt;
23 using namespace fwk;
24 using namespace utl;
25 using namespace tst::Validatrix;
26 
27 
28 namespace ValidationNS {
29 
32  {
33  auto topB = CentralConfig::GetInstance()->GetTopBranch("Validation");
34  topB.GetChild("RefFilename").GetData(fRefFileName);
35 
36  fResults = new ofstream(fRefFileName + ".new");
37 
38  return eSuccess;
39  }
40 
41 
43  Validation::Run(evt::Event& event)
44  {
45  if (!event.HasSEvent()) {
46  ERROR("Event should contain an SEvent.");
47  return eFailure;
48  }
49 
50  event.GetSEvent().SortStations(ByIncreasingId());
51  const auto& sEvent = event.GetSEvent();
52 
53  const auto eventId = event.GetHeader().GetId();
54 
55  *fResults << BeLabel("SD_rec");
56 
57  for (const auto& s : sEvent.StationsRange()) {
58  if (s.HasRecData()) {
59  ostringstream label;
60  label << "E" << eventId << "_S" << s.GetId();
61  *fResults << BeLabel(label.str());
62  *fResults << BeCloseRel(s.GetRecData().GetTotalSignal(), /*tolerance*/0.05);
63 
64  }
65  }
66 
67  *fResults << BeLabel("Shower_rec");
68 
69  // Shower-level rec data
70  if (!event.HasRecShower())
71  ERROR("Event does not contain a RecShower");
72 
73  const auto& showerRec = event.GetRecShower();
74  if (!showerRec.HasSRecShower())
75  ERROR("RecShower does not have SRecShower");
76 
77  *fResults << BeLabel("Shower_S_rec");
78 
79  const auto& showerSRec = showerRec.GetSRecShower();
80 
81  const auto& corePos = showerSRec.GetCorePosition();
82  //const auto& baryPos = showerSRec.GetBarycenter();
83 
84  const auto& coreCS = LocalCoordinateSystem::Create(corePos);
85 
86  const auto& baryCS = LocalCoordinateSystem::Create(corePos);
87 
88  ostringstream label;
89 
90  const double tolerance = 1e-3;
91 
92  label << eventId << "_ShowerSize";
93  *fResults << BeLabel(label.str());
94  *fResults << BeCloseRel(showerSRec.GetShowerSize(), tolerance);
95  label.str("");
96 
97  label << eventId << "_ShowerSizeError";
98  *fResults << BeLabel(label.str());
99  *fResults << BeCloseRel(showerSRec.GetShowerSizeError(), tolerance);
100  label.str("");
101 
102  //SCOMPARE(Curvature, tolerance);
103  //SCOMPARE(CurvatureError, tolerance);
104 
105  label << eventId << "_LDFChi2";
106  *fResults << BeLabel(label.str());
107  *fResults << BeCloseRel(showerSRec.GetLDFChi2(), tolerance);
108  label.str("");
109 
110  label << eventId << "_LDFNdof";
111  *fResults << BeLabel(label.str());
112  *fResults << BeEqual(showerSRec.GetLDFNdof());
113  label.str("");
114 
115  label << eventId << "_Theta";
116  *fResults << BeLabel(label.str());
117  *fResults << BeCloseRel(showerSRec.GetAxis().GetTheta(coreCS), tolerance);
118  label.str("");
119 
120  label << eventId << "_Phi";
121  *fResults << BeLabel(label.str());
122  *fResults << BeCloseRel(showerSRec.GetAxis().GetPhi(coreCS), tolerance);
123  label.str("");
124 
125  label << eventId << "_ThetaError";
126  *fResults << BeLabel(label.str());
127  *fResults << BeCloseRel(showerSRec.GetThetaError(), tolerance);
128  label.str("");
129 
130  label << eventId << "_PhiError";
131  *fResults << BeLabel(label.str());
132  *fResults << BeCloseRel(showerSRec.GetPhiError(), tolerance);
133  label.str("");
134 
135  label << eventId << "_CoreX";
136  *fResults << BeLabel(label.str());
137  *fResults << BeCloseAbs(corePos.GetX(baryCS), tolerance);
138  label.str("");
139 
140  label << eventId << "_CoreY";
141  *fResults << BeLabel(label.str());
142  *fResults << BeCloseAbs(corePos.GetY(baryCS), tolerance);
143  label.str("");
144 
145  label << eventId << "_CoreZ";
146  *fResults << BeLabel(label.str());
147  *fResults << BeCloseAbs(corePos.GetZ(baryCS), tolerance);
148  label.str("");
149 
150  label << eventId << "_CorrelationXY";
151  *fResults << BeLabel(label.str());
152  *fResults << BeCloseAbs(showerSRec.GetCorrelationXY(), tolerance);
153  label.str("");
154 
155  // FS: Not available in HAS reconstruction
156  //label << eventId << "_CoreXVariance";
157  //*fResults << BeLabel(label.str());
158  //*fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisX, sevt::eShowerAxisX), tolerance);
159  //label.str("");
160 
161  //label << eventId << "_CoreYVariance";
162  //*fResults << BeLabel(label.str());
163  //*fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisY, sevt::eShowerAxisY), tolerance);
164  //label.str("");
165 
166  //label << eventId << "_CoreXYCovariance";
167  //*fResults << BeLabel(label.str());
168  //*fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisX, sevt::eShowerAxisY), tolerance);
169  //label.str("");
170 
171  label << eventId << "_CoreTSecond";
172  *fResults << BeLabel(label.str());
173  *fResults << BeCloseRel(showerSRec.GetCoreTime().GetGPSSecond(), tolerance);
174  label.str("");
175 
176  label << eventId << "_CoreTNanoSecond";
177  *fResults << BeLabel(label.str());
178  *fResults << BeCloseRel(showerSRec.GetCoreTime().GetGPSNanoSecond(), tolerance);
179  label.str("");
180 
181  label << eventId << "_CoreXError";
182  *fResults << BeLabel(label.str());
183  *fResults << BeCloseRel(showerSRec.GetCoreError().GetX(baryCS), tolerance);
184  label.str("");
185 
186  label << eventId << "_CoreYError";
187  *fResults << BeLabel(label.str());
188  *fResults << BeCloseRel(showerSRec.GetCoreError().GetY(baryCS), tolerance);
189  label.str("");
190 
191  label << eventId << "_CoreTError";
192  *fResults << BeLabel(label.str());
193  *fResults << BeCloseRel(showerSRec.GetCoreTimeError().GetInterval(), tolerance);
194  label.str("");
195 
196  return eSuccess;
197  }
198 
199 
201  Validation::Finish()
202  {
203  delete fResults;
204  fResults = nullptr;
205 
206  const bool comp = Compare(fRefFileName, fRefFileName + ".new", /*failOnFirst=*/false);
207 
208  return comp ? eSuccess : eFailure;
209  }
210 
211 }
std::string BeCloseRel(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:153
bool HasRecShower() const
void Init()
Initialise the registry.
std::string BeCloseAbs(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:141
bool Compare(const string &oldFilename, const string &newFilename, const bool failOnFirst)
constexpr double s
Definition: AugerUnits.h:163
std::string BeLabel(const string &tag)
std::string BeEqual(const T &value)
Definition: Validatrix.h:131
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSEvent() const

, generated on Tue Sep 26 2023.