DenseValidation.cc
Go to the documentation of this file.
1 #include <evt/Event.h>
2 #include <sevt/SEvent.h>
3 #include <sevt/SortCriteria.h>
4 #include <sevt/PMTSimData.h>
5 
6 #include <utl/ErrorLogger.h>
7 #include <utl/Branch.h>
8 #include <utl/Particle.h>
9 #include <tst/Validatrix.h>
10 
11 #include <fwk/CentralConfig.h>
12 
13 #include <boost/lexical_cast.hpp>
14 
15 #include <iostream>
16 
17 #include "DenseValidation.h"
18 
19 using namespace std;
20 using namespace evt;
21 using namespace sevt;
22 using namespace fwk;
23 using namespace utl;
24 using namespace tst::Validatrix;
25 
26 
27 namespace DenseValidationNS {
28 
31  {
32  auto topB = CentralConfig::GetInstance()->GetTopBranch("DenseValidation");
33  topB.GetChild("RefFilename").GetData(fRefFileName);
34 
35  fOutputName = fRefFileName + ".new";
36  delete fOutput;
37  fOutput = new ofstream(fOutputName);
38 
39  return eSuccess;
40  }
41 
42 
44  DenseValidation::Run(evt::Event& event)
45  {
46  if (!event.HasSEvent()) {
47  ERROR("Event should have SEvent.");
48  return eFailure;
49  }
50 
51  *fOutput << BeLabel(boost::lexical_cast<string>(event.GetHeader().GetId()));
52 
53  event.GetSEvent().SortStations(ByIncreasingId());
54  const auto& sEvent = event.GetSEvent();
55 
56  for (const auto& station : sEvent.StationsRange()) {
57  if (station.HasRecData()) {
58  *fOutput << BeLabel("Station_" + boost::lexical_cast<string>(station.GetId()));
59  *fOutput << BeCloseRel(station.GetRecData().GetTotalSignal(), 1*percent);
60  }
61  }
62 
63  return eSuccess;
64  }
65 
66 
68  DenseValidation::Finish()
69  {
70  fOutput->close();
71  delete fOutput;
72  fOutput = nullptr;
73 
74  ifstream oldFile(fRefFileName);
75  ifstream newFile(fOutputName);
76 
77  return Compare(oldFile, newFile, /*failOnFirst=*/true) ? eSuccess : eFailure;
78  }
79 
80 }
std::string BeCloseRel(const T &value, const double tolerance=kDefaultTolerance)
Definition: Validatrix.h:153
constexpr double percent
Definition: AugerUnits.h:283
void Init()
Initialise the registry.
bool Compare(const string &oldFilename, const string &newFilename, const bool failOnFirst)
std::string BeLabel(const string &tag)
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.