RdSdCheck/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 using namespace ValidationNS;
27 
28 
31 {
32  const Branch topB = CentralConfig::GetInstance()->GetTopBranch("Validation");
33  topB.GetChild("RefFilename").GetData(fRefFileName);
34 
35  fResults = new ofstream(fRefFileName + ".new");
36 
37  return eSuccess;
38 }
39 
40 
42 Validation::Run(evt::Event& event)
43 {
44  if (!event.HasSEvent()) {
45  ERROR("Event should contain an SEvent.");
46  return eFailure;
47  }
48 
49  event.GetSEvent().SortStations(ByIncreasingId());
50  const SEvent& sEvent = event.GetSEvent();
51 
52  const string eventId = event.GetHeader().GetId();
53 
54  *fResults << BeLabel("SD_rec");
55 
56  const double sigEps = 0.05;
57 
58  for (const auto& station : sEvent.StationsRange()) {
59  if (station.HasRecData()) {
60  ostringstream label;
61  label << "E" << eventId << "_S" << station.GetId();
62  *fResults << BeLabel(label.str());
63  *fResults << BeCloseRel(station.GetRecData().GetTotalSignal(), sigEps);
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 ShowerRecData& showerRec = event.GetRecShower();
74 
75  // SD rec (shower level)
76 
77  if (!showerRec.HasSRecShower())
78  ERROR("RecShower does not have SRecShower");
79 
80  *fResults << BeLabel("Shower_S_rec");
81 
82  const ShowerSRecData& showerSRec = showerRec.GetSRecShower();
83 
84  const Point& corePos = showerSRec.GetCorePosition();
85  const Point& baryPos = showerSRec.GetBarycenter();
86 
87  const CoordinateSystemPtr coreCS = LocalCoordinateSystem::Create(corePos);
88 
89  const CoordinateSystemPtr baryCS = LocalCoordinateSystem::Create(baryPos);
90 
91  const double relEps = 1e-3;
92 
93  ostringstream label;
94 
95  label << eventId << "_ShowerSize";
96  *fResults << BeLabel(label.str());
97  *fResults << BeCloseRel(showerSRec.GetShowerSize(), relEps);
98  label.str("");
99 
100  label << eventId << "_ShowerSizeError";
101  *fResults << BeLabel(label.str());
102  *fResults << BeCloseRel(showerSRec.GetShowerSizeError(), relEps);
103  label.str("");
104 
105  label << eventId << "_LDFChi2";
106  *fResults << BeLabel(label.str());
107  *fResults << BeCloseRel(showerSRec.GetLDFChi2(), relEps);
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), relEps);
118  label.str("");
119 
120  label << eventId << "_Phi";
121  *fResults << BeLabel(label.str());
122  *fResults << BeCloseRel(showerSRec.GetAxis().GetPhi(coreCS), relEps);
123  label.str("");
124 
125  label << eventId << "_ThetaError";
126  *fResults << BeLabel(label.str());
127  *fResults << BeCloseRel(showerSRec.GetThetaError(), relEps);
128  label.str("");
129 
130  label << eventId << "_PhiError";
131  *fResults << BeLabel(label.str());
132  *fResults << BeCloseRel(showerSRec.GetPhiError(), relEps);
133  label.str("");
134 
135  const double posEps = 0.1*meter;
136 
137  label << eventId << "_CoreX";
138  *fResults << BeLabel(label.str());
139  *fResults << BeCloseAbs(corePos.GetX(baryCS), posEps);
140  label.str("");
141 
142  label << eventId << "_CoreY";
143  *fResults << BeLabel(label.str());
144  *fResults << BeCloseAbs(corePos.GetY(baryCS), posEps);
145  label.str("");
146 
147  label << eventId << "_CoreZ";
148  *fResults << BeLabel(label.str());
149  *fResults << BeCloseAbs(corePos.GetZ(baryCS), posEps);
150  label.str("");
151 
152  /* comment out because for events that only have a barycenter reconstruction, comparison of 0 with 0 fails
153  label << eventId << "_CorrelationXY";
154  *fResults << BeLabel(label.str());
155  *fResults << BeCloseRel(showerSRec.GetCorrelationXY(), relEps);
156  label.str("");*/
157 
158  label << eventId << "_CoreXVariance";
159  *fResults << BeLabel(label.str());
160  *fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisX, sevt::eShowerAxisX), relEps);
161  label.str("");
162 
163  label << eventId << "_CoreYVariance";
164  *fResults << BeLabel(label.str());
165  *fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisY, sevt::eShowerAxisY), relEps);
166  label.str("");
167 
168  label << eventId << "_CoreXYCovariance";
169  *fResults << BeLabel(label.str());
170  *fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisX, sevt::eShowerAxisY), relEps);
171  label.str("");
172 
173  label << eventId << "_CoreTSecond";
174  *fResults << BeLabel(label.str());
175  *fResults << BeCloseRel(showerSRec.GetCoreTime().GetGPSSecond(), relEps);
176  label.str("");
177 
178  label << eventId << "_CoreTNanoSecond";
179  *fResults << BeLabel(label.str());
180  *fResults << BeCloseRel(showerSRec.GetCoreTime().GetGPSNanoSecond(), relEps);
181  label.str("");
182 
183  label << eventId << "_CoreXError";
184  *fResults << BeLabel(label.str());
185  *fResults << BeCloseAbs(showerSRec.GetCoreError().GetX(baryCS), posEps);
186  label.str("");
187 
188  label << eventId << "_CoreYError";
189  *fResults << BeLabel(label.str());
190  *fResults << BeCloseAbs(showerSRec.GetCoreError().GetY(baryCS), posEps);
191  label.str("");
192 
193  label << eventId << "_CoreZError";
194  *fResults << BeLabel(label.str());
195  *fResults << BeCloseAbs(showerSRec.GetCoreError().GetZ(baryCS), posEps);
196  label.str("");
197 
198  label << eventId << "_CoreTError";
199  *fResults << BeLabel(label.str());
200  *fResults << BeCloseRel(showerSRec.GetCoreTimeError().GetInterval(), relEps);
201  label.str("");
202 
203  return eSuccess;
204 }
205 
206 
208 Validation::Finish()
209 {
210  fResults->close();
211 
212  ifstream newFile(fRefFileName + ".new");
213  ifstream oldFile(fRefFileName);
214 
215  const bool comp = Compare(oldFile, newFile, /*failOnFirst=*/true);
216 
217  if (comp) {
218  INFO("\n"
219  "#--------------------------------#\n"
220  ":all SD tests were successful:\n"
221  "#--------------------------------#");
222  } else {
223  INFO("\n"
224  "#------------------------------#\n"
225  ":one or more SD tests failed:\n"
226  "#------------------------------#");
227  }
228 
229  return comp ? eSuccess : eFailure;
230 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Point object.
Definition: Point.h:32
std::string BeCloseRel(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:153
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
Interface class to access to the SD Reconstruction of a Shower.
Interface class to access Shower Reconstructed parameters.
Definition: ShowerRecData.h:33
bool HasRecShower() const
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
double GetParameterCovariance(const Parameter q1, const Parameter q2) const
const double meter
Definition: GalacticUnits.h:29
const utl::Vector & GetCoreError() const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
int GetId() const
Definition: SEvent/Header.h:20
double GetShowerSize() const
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
ShowerSRecData & GetSRecShower()
std::string BeCloseAbs(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:141
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
bool Compare(const string &oldFilename, const string &newFilename, const bool failOnFirst)
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
const utl::TimeStamp & GetCoreTime() const
time when shower front passes through the core point
std::string BeLabel(const string &tag)
const utl::Point & GetBarycenter() const
double GetThetaError() const
const utl::Vector & GetAxis() const
double GetPhiError() const
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
double GetLDFChi2() const
double GetInterval() const
Get the time interval as a double (in Auger base units)
Definition: TimeInterval.h:69
std::string BeEqual(const T &value)
Definition: Validatrix.h:131
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
const utl::TimeInterval & GetCoreTimeError() const
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
unsigned long GetGPSSecond() const
GPS second.
Definition: TimeStamp.h:124
double GetGPSNanoSecond() const
GPS nanosecond.
Definition: TimeStamp.h:127
double GetShowerSizeError() const
const utl::Point & GetCorePosition() const
sevt::Header & GetHeader()
Definition: SEvent.h:155
double GetLDFNdof() const
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSRecShower() const
bool HasSEvent() const

, generated on Tue Sep 26 2023.