HybridSimValidation.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/PMTSimData.h>
7 
8 #include <fevt/FEvent.h>
9 #include <fevt/Eye.h>
10 #include <fevt/Telescope.h>
11 #include <fevt/EyeRecData.h>
12 #include <fevt/TelescopeRecData.h>
13 
14 #include <evt/ShowerFRecData.h>
15 
16 #include <utl/ErrorLogger.h>
17 #include <utl/Branch.h>
18 #include <utl/Particle.h>
19 #include <utl/AugerUnits.h>
20 
21 #include <tst/Validatrix.h>
22 
23 #include <fwk/CentralConfig.h>
24 
25 #include <iostream>
26 
27 #include "HybridSimValidation.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 using namespace HybridSimValidationNS;
37 
38 
41 {
42  const Branch topB =
43  CentralConfig::GetInstance()->GetTopBranch("HybridSimValidation");
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 HybridSimValidation::Run(evt::Event& event)
55 {
56  ostringstream eventId;
57  eventId << event.GetHeader().GetId();
58  *fOutput << BeLabel(eventId.str());
59 
60  // Station/telescope level rec data
61 
62  // SD
63  if (!event.HasSEvent()) {
64  ERROR("Event does not contain an SEvent.");
65  return eFailure;
66  }
67 
68  // FD
69  if (!event.HasFEvent()) {
70  ERROR("Event should contain an FEvent.");
71  return eFailure;
72  }
73 
74  const FEvent& fEvent = event.GetFEvent();
75 
76  *fOutput << BeLabel("FD_rec");
77 
78  for (FEvent::ConstEyeIterator eIt = fEvent.EyesBegin(ComponentSelector::eHasData);
79  eIt != fEvent.EyesEnd(ComponentSelector::eHasData); ++eIt) {
80 
81  if (eIt->HasRecData()) {
82  ostringstream eLabel;
83  eLabel << "Eye_" << eIt->GetId();
84  *fOutput << BeLabel(eLabel.str());
85 
86  if (eIt->HasRecData()) {
87  if (eIt->GetRecData().HasFRecShower()) {
88  const ShowerFRecData& showerRec = eIt->GetRecData().GetFRecShower();
89  *fOutput << BeLabel("Stations_in_fit");
90  *fOutput << BeEqual(showerRec.GetStationIds());
91 
92  *fOutput << BeLabel("TotalEnergy(EeV)");
93  *fOutput << BeCloseRel(showerRec.GetTotalEnergy()/EeV, /*tolerance*/(eIt->GetId() == 4 ? 0.2 : 0.1));
94 
95  *fOutput << BeLabel("Xmax(g/cm2)");
96  *fOutput << BeCloseAbs(showerRec.GetGHParameters().GetXMax()/(g/cm2), (eIt->GetId() == 4 ? 30 : 15));
97  }
98  }
99  }
100 
101  for (Eye::ConstTelescopeIterator tIt = eIt->TelescopesBegin(ComponentSelector::eHasData);
102  tIt != eIt->TelescopesEnd(ComponentSelector::eHasData); ++tIt) {
103 
104  if (tIt->HasRecData()) {
105  ostringstream tLabel;
106  tLabel << "Telescope_" << tIt->GetId();
107  *fOutput << BeLabel(tLabel.str());
108 
109  const TelescopeRecData& tRec = tIt->GetRecData();
110  *fOutput << BeLabel("Rp");
111  *fOutput << BeCloseRel(tRec.GetRp(), /*tolerance*/0.05);
112  }
113  }
114  }
115 
116  *fOutput << BeLabel("Shower_rec");
117 
118  // Shower-level rec data
119 
120  if (!event.HasRecShower())
121  ERROR("Event does not contain a RecShower");
122 
123  const ShowerRecData& showerRec = event.GetRecShower();
124 
125  // SD rec (shower level)
126 
127  if (!showerRec.HasSRecShower())
128  ERROR("RecShower does not have SRecShower");
129 
130  *fOutput << BeLabel("Shower_S_rec");
131 
132  const ShowerSRecData& showerSRec = showerRec.GetSRecShower();
133 
134  *fOutput << BeLabel("S1000");
135  *fOutput << BeCloseRel(showerSRec.GetShowerSize(), 0.1);
136 
137  return eSuccess;
138 }
139 
140 
142 HybridSimValidation::Finish()
143 {
144  fOutput->close();
145  delete fOutput;
146 
147  ifstream oldFile(fRefFileName.c_str());
148  ifstream newFile(fOutputName.c_str());
149 
150  const bool comp = Compare(oldFile, newFile, /*failOnFirst=*/false);
151 
152  oldFile.close();
153  newFile.close();
154 
155  return comp ? eSuccess : eFailure;
156 }
Branch GetTopBranch() const
Definition: Branch.cc:63
std::string BeCloseRel(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:153
Interface class to access to the SD Reconstruction of a Shower.
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
Definition: FEvent.h:56
Interface class to access Shower Reconstructed parameters.
Definition: ShowerRecData.h:33
bool HasRecShower() const
double GetTotalEnergy() const
retrieve total energy and its uncertainty
bool HasFEvent() const
std::vector< unsigned short int > & GetStationIds()
retrieve vector of station IDs used in hybrid fit
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
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
const double EeV
Definition: GalacticUnits.h:34
ShowerSRecData & GetSRecShower()
std::string BeCloseAbs(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:141
Class representing a document branch.
Definition: Branch.h:107
bool Compare(const string &oldFilename, const string &newFilename, const bool failOnFirst)
std::string BeLabel(const string &tag)
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
Telescope-specific shower reconstruction data.
constexpr double g
Definition: AugerUnits.h:200
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
std::string BeEqual(const T &value)
Definition: Validatrix.h:131
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Interface class to access to Fluorescence reconstruction of a Shower.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSRecShower() const
bool HasSEvent() const
boost::filter_iterator< ComponentSelector, ConstAllTelescopeIterator > ConstTelescopeIterator
Definition: FEvent/Eye.h:73
constexpr double cm2
Definition: AugerUnits.h:118

, generated on Tue Sep 26 2023.