HdRecValidation.cc
Go to the documentation of this file.
1 #include <evt/Event.h>
2 #include <evt/ShowerFRecData.h>
3 
4 #include <fevt/FEvent.h>
5 #include <fevt/Eye.h>
6 #include <fevt/EyeRecData.h>
7 
8 #include <sevt/SEvent.h>
9 #include <sevt/SortCriteria.h>
10 
11 #include <utl/ErrorLogger.h>
12 #include <utl/Branch.h>
13 #include <utl/Particle.h>
14 #include <utl/Vector.h>
15 #include <utl/Point.h>
16 #include <tst/Validatrix.h>
17 
18 #include <fwk/CentralConfig.h>
19 #include <fwk/LocalCoordinateSystem.h>
20 
21 #include <fdet/FDetector.h>
22 #include <fdet/Eye.h>
23 #include <det/Detector.h>
24 
25 #include <iostream>
26 
27 #include "HdRecValidation.h"
28 
29 using namespace std;
30 using namespace evt;
31 using namespace sevt;
32 using namespace fevt;
33 using namespace fwk;
34 using namespace utl;
35 using namespace tst::Validatrix;
36 
37 
38 namespace HdRecValidationNS {
39 
42  {
43  Branch topB = CentralConfig::GetInstance()->GetTopBranch("HdRecValidation");
44  topB.GetChild("RefFilename").GetData(fRefFileName);
45 
46  fOutputName = fRefFileName + string(".new");
47  fOutput = new ofstream(fOutputName.c_str());
48 
49  return eSuccess;
50  }
51 
52 
54  HdRecValidation::Run(evt::Event& event)
55  {
56  if (!event.HasSEvent()) {
57  ERROR("Event should have SEvent.");
58  return eFailure;
59  }
60 
61  if (!event.HasFEvent()) {
62  ERROR("Event should have FEvent.");
63  return eFailure;
64  }
65 
66  ostringstream eventId;
67  eventId << event.GetHeader().GetId();
68  *fOutput << BeLabel(eventId.str());
69 
70  event.GetSEvent().SortStations(ByIncreasingId());
71  const SEvent& sEvent = event.GetSEvent();
72 
73  for (const auto& s : sEvent.StationsRange()) {
74 
75  if (s.HasRecData()) {
76  ostringstream label;
77  label << "Station_" << s.GetId();
78  *fOutput << BeLabel(label.str());
79  *fOutput << BeLabel("signal");
80  *fOutput << BeCloseRel(s.GetRecData().GetTotalSignal(), 1*percent);
81  }
82 
83  }
84 
85  *fOutput << BeLabel("FD_part");
86 
87  const FEvent& fEvent = event.GetFEvent();
88  for (FEvent::ConstEyeIterator eIt = fEvent.EyesBegin(ComponentSelector::eHasData);
89  eIt != fEvent.EyesEnd(ComponentSelector::eHasData); ++eIt) {
90  ostringstream label;
91 
92  const int eyeId = eIt->GetId();
93  label << "Eye_" << eyeId << endl;
94  *fOutput << BeLabel(label.str());
95 
96  const EyeRecData& eRec = eIt->GetRecData();
97  const ShowerFRecData& sFRec = eRec.GetFRecShower();
98 
99  *fOutput << BeLabel("Rp");
100  *fOutput << BeCloseRel(eRec.GetRp()/kilometer, 1*percent);
101 
102  const Vector sdp = eRec.GetSDP();
103  const Point eyePos = det::Detector::GetInstance().GetFDetector().GetEye(eyeId).GetPosition();
104  const CoordinateSystemPtr eyeCS = LocalCoordinateSystem::Create(eyePos);
105 
106  *fOutput << BeLabel("theta");
107  *fOutput << BeCloseRel(sdp.GetTheta(eyeCS)/degree, 1*percent);
108 
109  *fOutput << BeLabel("phi");
110  *fOutput << BeCloseRel(sdp.GetPhi(eyeCS)/degree, 1*percent);
111 
112  const double Xmax = (sFRec.HasGHParameters() ?
113  sFRec.GetGHParameters().GetXMax()/(g/cm2) : 0);
114  if (Xmax > 0) {
115  *fOutput << BeLabel("Xmax");
116  *fOutput << BeCloseRel(Xmax, 1*percent);
117  }
118 
119  const double energy = sFRec.GetTotalEnergy();
120  if (energy > 0) {
121  *fOutput << BeLabel("total_energy");
122  *fOutput << BeCloseRel(energy/EeV, 1*percent);
123  }
124 
125  const double energyEM = sFRec.GetEmEnergy();
126  if (energyEM > 0) {
127  *fOutput << BeLabel("EM_energy");
128  *fOutput << BeCloseRel(energyEM/EeV, 1*percent);
129  }
130  }
131 
132  return eSuccess;
133  }
134 
135 
137  HdRecValidation::Finish()
138  {
139  delete fOutput;
140  fOutput = nullptr;
141 
142  ifstream oldFile(fRefFileName.c_str());
143  ifstream newFile(fOutputName.c_str());
144 
145  const bool comp = Compare(oldFile, newFile, /*failOnFirst=*/true);
146 
147  return comp ? eSuccess : eFailure;
148  }
149 
150 }
Branch GetTopBranch() const
Definition: Branch.cc:63
const double degree
Point object.
Definition: Point.h:32
std::string BeCloseRel(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:153
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
Definition: FEvent.h:56
double GetTotalEnergy() const
retrieve total energy and its uncertainty
bool HasFEvent() const
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
constexpr double percent
Definition: AugerUnits.h:283
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
const double EeV
Definition: GalacticUnits.h:34
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
std::string BeLabel(const string &tag)
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
constexpr double g
Definition: AugerUnits.h:200
double GetEmEnergy() const
retrieve electromagnetic energy and its uncertainty
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
Eye-specific shower reconstruction data.
Definition: EyeRecData.h:65
bool HasGHParameters() const
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
constexpr double kilometer
Definition: AugerUnits.h:93
Vector object.
Definition: Vector.h:30
Interface class to access to Fluorescence reconstruction of a Shower.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSEvent() const
constexpr double cm2
Definition: AugerUnits.h:118

, generated on Tue Sep 26 2023.