G4StationSim/TankValidation.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/TimeDistribution.h>
9 #include <utl/Particle.h>
10 #include <tst/Validatrix.h>
11 
12 #include <fwk/CentralConfig.h>
13 
14 #include "TankValidation.h"
15 
16 using namespace std;
17 using namespace evt;
18 using namespace sevt;
19 using namespace fwk;
20 using namespace utl;
21 using namespace tst::Validatrix;
22 using namespace TankValidationNS;
23 
24 
27 {
28  auto topB = CentralConfig::GetInstance()->GetTopBranch("TankValidation");
29  topB.GetChild("RefFilename").GetData(fRefFile);
30 
31  return eSuccess;
32 }
33 
34 
36 TankValidation::Run(evt::Event& event)
37 {
38  if (!event.HasSEvent()) {
39  ERROR("Event should have SEvent.");
40  return eFailure;
41  }
42 
43  const auto newRefFile = fRefFile + string(".new");
44  {
45  ofstream outFile(newRefFile);
46 
47  event.GetSEvent().SortStations(ByIncreasingId());
48  const auto& sEvent = event.GetSEvent();
49 
50  for (const auto& s : sEvent.StationsRange()) {
51 
52  for (const auto& pmt : s.PMTsRange()) {
53 
54  if (!pmt.HasSimData())
55  continue;
56 
57  const auto& pmtSim = pmt.GetSimData();
58 
59  for (const auto& pe : pmtSim.PETimeDistributionsRange()) {
60 
61  INFO(fRefFile);
62  ostringstream label;
63  label << "Station_" << s.GetId() << "_PMT_" << pmt.GetId() << "_label_" << pe.GetLabel();
64  outFile << BeLabel(label.str()) << BeEqual(pe.GetTimeDistribution());
65 
66  }
67  }
68  }
69  }
70 
71  ifstream newFile(newRefFile);
72  ifstream oldFile(fRefFile);
73 
74  return Compare(oldFile, newFile, /*failOnFirst=*/true) ? eSuccess : eFailure;
75 }
76 
77 
79 TankValidation::Finish()
80 {
81  return eSuccess;
82 }
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
bool Compare(const string &oldFilename, const string &newFilename, const bool failOnFirst)
constexpr double s
Definition: AugerUnits.h:163
std::string BeLabel(const string &tag)
std::string BeEqual(const T &value)
Definition: Validatrix.h:131
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.