G4TankSim/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 #include <boost/range/iterator_range.hpp>
17 
18 using namespace std;
19 using namespace evt;
20 using namespace sevt;
21 using namespace fwk;
22 using namespace utl;
23 using namespace tst::Validatrix;
24 using namespace TankValidationNS;
25 
26 
29 {
30  const Branch topB = CentralConfig::GetInstance()->GetTopBranch("TankValidation");
31  topB.GetChild("RefFilename").GetData(fRefFile);
32 
33  return eSuccess;
34 }
35 
36 
38 TankValidation::Run(evt::Event& event)
39 {
40  if (!event.HasSEvent()) {
41  ERROR("Event should have SEvent.");
42  return eFailure;
43  }
44 
45  const string newRefFile = fRefFile + string(".new");
46  {
47  ofstream outFile(newRefFile);
48 
49  event.GetSEvent().SortStations(ByIncreasingId());
50  const SEvent& sEvent = event.GetSEvent();
51 
52  for (const Station& s : boost::make_iterator_range(sEvent.StationsBegin(), sEvent.StationsEnd())) {
53 
54  for (const PMT& pmt : boost::make_iterator_range(s.PMTsBegin(), s.PMTsEnd())) {
55 
56  if (!pmt.HasSimData())
57  continue;
58 
59  const PMTSimData& pmtSim = pmt.GetSimData();
60 
61  for (const auto& pe :
62  boost::make_iterator_range(pmtSim.PETimeDistributionsBegin(), pmtSim.PETimeDistributionsEnd())) {
63 
64  ostringstream label;
65  label << "Station_" << s.GetId() << "_PMT_" << pmt.GetId() << "_label_" << pe.GetLabel();
66  outFile << BeLabel(label.str()) << BeEqual(pe.GetTimeDistribution());
67 
68  }
69  }
70  }
71  }
72 
73  ifstream newFile(newRefFile);
74  ifstream oldFile(fRefFile);
75 
76  return Compare(oldFile, newFile, /*failOnFirst=*/true) ? eSuccess : eFailure;
77 }
78 
79 
81 TankValidation::Finish()
82 {
83  return eSuccess;
84 }
Branch GetTopBranch() const
Definition: Branch.cc:63
StationIterator StationsEnd()
End of all stations.
Definition: SEvent.h:59
class to hold data at PMT level
Definition: SEvent/PMT.h:28
PETimeDistributionsIterator PETimeDistributionsBegin()
Begin iterator over PE time distribution sources.
Definition: PMTSimData.h:75
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
Class representing a document branch.
Definition: Branch.h:107
class to hold data at Station level
bool Compare(const string &oldFilename, const string &newFilename, const bool failOnFirst)
constexpr double s
Definition: AugerUnits.h:163
std::string BeLabel(const string &tag)
PETimeDistributionsIterator PETimeDistributionsEnd()
End iterator over PE time distribution sources.
Definition: PMTSimData.h:79
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
std::string BeEqual(const T &value)
Definition: Validatrix.h:131
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
StationIterator StationsBegin()
Beginning of all stations.
Definition: SEvent.h:57
Class to hold simulated data at PMT level.
Definition: PMTSimData.h:40
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSEvent() const

, generated on Tue Sep 26 2023.