Analyzer.cc
Go to the documentation of this file.
1 #include <evt/Event.h>
2 #include <sevt/SEvent.h>
3 #include <sevt/PMTSimData.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/Branch.h>
6 #include <utl/TimeDistribution.h>
7 #include <utl/Particle.h>
8 #include <utl/ParticlePropertiesFactory.h>
9 #include <fwk/CentralConfig.h>
10 
11 #include "Analyzer.h"
12 
13 using namespace std;
14 using namespace evt;
15 using namespace sevt;
16 using namespace fwk;
17 using namespace utl;
18 
19 
20 namespace AnalyzerNS {
21 
24  {
25  // sneak-peek into other module's config
26  Branch topB = CentralConfig::GetInstance()->GetTopBranch("ParticleInjector");
27 
28  const int stationId = topB.GetChild("StationId").Get<int>();
29 
30  ostringstream info;
31  info << "\n StationId = " << stationId << '\n';
32 
33  const int particleType = topB.GetChild("NumberOfParticles").GetChild("Type").Get<int>();
34  const string particleName = ParticlePropertiesFactory::Create(particleType)->GetName();
35  info << " Particle = " << particleType << " (" << particleName << ")\n";
36 
37  const double energy = topB.GetChild("Energy").GetChild("Fixed").Get<double>();
38  info << " Energy = " << energy/GeV << " GeV\n";
39 
40  ostringstream filename("PE_");
41  filename << particleName << '_' << energy/GeV << "GeV_3x800ns.txt";
42 
43  fOutput.open(filename.str().c_str());
44 
45  info << " Filename = " << filename.str();
46  INFO(info);
47 
48  return eSuccess;
49  }
50 
51 
53  Analyzer::Run(evt::Event& event)
54  {
55  if (!event.HasSEvent()) {
56  ERROR("Event should have SEvent!");
57  return eFailure;
58  }
59 
60  const SEvent& sEvent = event.GetSEvent();
61 
62  int nStations = 0;
63 
64  for (const auto& st : sEvent.StationsRange()) {
65 
66  int bins800ns[3] = { 0 };
67  int bins800nsSSD[3] = { 0 };
68 
69  for (const auto& pmt : st.PMTsRange()) {
70 
71  if (!pmt.HasSimData())
72  continue;
73 
74  const auto& sim = pmt.GetSimData();
75  if (!sim.HasPETimeDistribution())
76  continue;
77 
78  cerr << "PE " << st.GetId() << ' ' << pmt.GetId() << "->";
79 
80  int peTotal = 0;
81 
82  const auto& peTD = sim.GetPETimeDistribution();
83 
84  for (const auto& tb : peTD.SparseRange()) {
85  const int t = tb.get<0>();
86  const int npe = tb.get<1>();
87  const int bin =
88  t < 800 ? 0 :
89  t < 1600 ? 1 : 2;
90  if (pmt.GetId() < 3)
91  bins800ns[bin] += npe;
92  else
93  bins800nsSSD[bin] += npe;
94  peTotal += npe;
95  cerr << ' ' << t << ':' << npe;
96  }
97 
98  cerr << " total: " << peTotal << '\n';
99 
100  }
101 
102  fOutput << bins800ns[0] << ' ' << bins800ns[1] << ' ' << bins800ns[2] << " "
103  << bins800nsSSD[0] << ' ' << bins800nsSSD[1] << ' ' << bins800nsSSD[2]
104  << '\n';
105 
106  ++nStations;
107  }
108 
109  cerr << "** nStations " << nStations << endl;
110 
111  return eSuccess;
112  }
113 
114 
116  Analyzer::Finish()
117  {
118  fOutput.close();
119  return eSuccess;
120  }
121 
122 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
T Get() const
Definition: Branch.h:271
Class representing a document branch.
Definition: Branch.h:107
SEventSimData & GetSimData()
Get the object with simulated data, throw if n.a.
Definition: SEvent.h:138
constexpr double GeV
Definition: AugerUnits.h:187
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
char * filename
Definition: dump1090.h:266
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSEvent() const

, generated on Tue Sep 26 2023.