RdSdSimCheck/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  const Branch 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  // SD
46  if (!event.HasSEvent()) {
47  ERROR("Event should contain an SEvent.");
48  return eFailure;
49  }
50 
51  event.GetSEvent().SortStations(ByIncreasingId());
52  const SEvent& sEvent = event.GetSEvent();
53 
54  const string eventId = event.GetHeader().GetId();
55 
56  *fResults << BeLabel("SD_rec");
57 
58  for (const auto& s : sEvent.StationsRange()) {
59  if (s.HasRecData()) {
60  ostringstream label;
61  label << "E" << eventId << "_S" << s.GetId();
62  *fResults << BeLabel(label.str());
63  *fResults << BeCloseRel(s.GetRecData().GetTotalSignal(), /*tolerance*/0.05);
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 tolerance = 1e-3;
92 
93  ostringstream label;
94 
95  label << eventId << "_ShowerSize";
96  *fResults << BeLabel(label.str());
97  *fResults << BeCloseRel(showerSRec.GetShowerSize(), tolerance);
98  label.str("");
99 
100  label << eventId << "_ShowerSizeError";
101  *fResults << BeLabel(label.str());
102  *fResults << BeCloseRel(showerSRec.GetShowerSizeError(), tolerance);
103  label.str("");
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  label << eventId << "_CoreXVariance";
156  *fResults << BeLabel(label.str());
157  *fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisX, sevt::eShowerAxisX), tolerance);
158  label.str("");
159 
160  label << eventId << "_CoreYVariance";
161  *fResults << BeLabel(label.str());
162  *fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisY, sevt::eShowerAxisY), tolerance);
163  label.str("");
164 
165  label << eventId << "_CoreXYCovariance";
166  *fResults << BeLabel(label.str());
167  *fResults << BeCloseRel(showerSRec.GetParameterCovariance(sevt::eShowerAxisX, sevt::eShowerAxisY), tolerance);
168  label.str("");
169 
170  label << eventId << "_CoreTSecond";
171  *fResults << BeLabel(label.str());
172  *fResults << BeCloseRel(showerSRec.GetCoreTime().GetGPSSecond(), tolerance);
173  label.str("");
174 
175  label << eventId << "_CoreTNanoSecond";
176  *fResults << BeLabel(label.str());
177  *fResults << BeCloseRel(showerSRec.GetCoreTime().GetGPSNanoSecond(), tolerance);
178  label.str("");
179 
180  label << eventId << "_CoreXError";
181  *fResults << BeLabel(label.str());
182  *fResults << BeCloseRel(showerSRec.GetCoreError().GetX(baryCS), tolerance);
183  label.str("");
184 
185  label << eventId << "_CoreYError";
186  *fResults << BeLabel(label.str());
187  *fResults << BeCloseRel(showerSRec.GetCoreError().GetY(baryCS), tolerance);
188  label.str("");
189 
190  label << eventId << "_CoreTError";
191  *fResults << BeLabel(label.str());
192  *fResults << BeCloseRel(showerSRec.GetCoreTimeError().GetInterval(), tolerance);
193  label.str("");
194 
195  return eSuccess;
196  }
197 
198 
200  Validation::Finish()
201  {
202  delete fResults;
203  fResults = nullptr;
204 
205  const bool comp = Compare(fRefFileName, fRefFileName + ".new", /*failOnFirst=*/false);
206 
207  return comp ? eSuccess : eFailure;
208  }
209 
210 }
Branch GetTopBranch() const
Definition: Branch.cc:63
double GetCorrelationXY() const
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 utl::Vector & GetCoreError() const
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)
constexpr double s
Definition: AugerUnits.h:163
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.