ShowerInventorAnalyzer.cc
Go to the documentation of this file.
1 #include <sstream>
2 
4 
5 #include <utl/ErrorLogger.h>
6 #include <utl/TimeDistribution.h>
7 #include <utl/TimeDistributionAlgorithm.h>
8 #include <utl/Point.h>
9 #include <utl/Math.h>
10 #include <utl/Particle.h>
11 
12 #include <evt/Event.h>
13 
14 #include <sevt/SEvent.h>
15 #include <sevt/Station.h>
16 #include <sevt/PMT.h>
17 #include <sevt/PMTSimData.h>
18 #include <sevt/StationSimData.h>
19 
20 #include <det/Detector.h>
21 #include <sdet/SDetector.h>
22 #include <sdet/Station.h>
23 
24 #include <evt/ShowerSimData.h>
25 
26 #include <fwk/CentralConfig.h>
27 
28 using namespace std;
29 using namespace utl;
30 using namespace fwk;
31 using namespace evt;
32 using namespace sevt;
33 
34 using namespace ShowerInventorAnalyzerNS;
35 
36 
39 {
40  INFO("ShowerInventorAnalyzer::Init()");
41 
42  Branch topB =
43  CentralConfig::GetInstance()->GetTopBranch("ShowerInventorAnalyzer");
44 
45  topB.GetChild("OutputFilename").GetData(fOutFile);
46 
47  return eSuccess;
48 }
49 
50 
52 ShowerInventorAnalyzer::Run(evt::Event& event)
53 {
54  INFO("ShowerInventorAnalyzer::Run()");
55 
56  ShowerSimData& shower = event.GetSimShower();
59 
60  double zen = shower.GetZenith();
61  cout << "----> in analyzer: zenith = " << zen/deg << endl;
62 
63  // histogram of total number of pe vs radius (in shower plane) for this zenith
64 
65  ostringstream peHistTitleSm;
66  peHistTitleSm << "integrated pe number for zenith : " << zen/deg;
67  string peHistTitle(peHistTitleSm.str());
68 
69  TH1F* peHist;
70  if (fTankHistos.find(peHistTitle) == fTankHistos.end()) {
71  peHist = new TH1F(peHistTitle.c_str(),
72  peHistTitle.c_str(),
73  501, 0*m, 5000*m);
74  } else {
75  peHist = fTankHistos[peHistTitle];
76  }
77 
78  // histogram of number of muons vs radius (in shower plane) for this zenith
79 
80  ostringstream nMuHistTitleSr;
81  nMuHistTitleSr << "muon number for zenith : " << zen/deg;
82  string nMuHistTitle(nMuHistTitleSr.str());
83 
84  TH1F* nMuHist;
85  if (fTankHistos.find(nMuHistTitle) == fTankHistos.end()) {
86  nMuHist = new TH1F(nMuHistTitle.c_str(),
87  nMuHistTitle.c_str(),
88  501, 0*m, 5000*m);
89  } else {
90  nMuHist = fTankHistos[nMuHistTitle];
91  }
92 
93  const SEvent& sevent = event.GetSEvent();
94  for (SEvent::ConstStationIterator sIt = sevent.StationsBegin();
95  sIt != sevent.StationsEnd(); ++sIt) {
96 
97  if (sIt->HasSimData()) {
98 
99  // Check if any PMT has sim data rather than checking to see
100  // if there are particles in the station since it is more convenient
101  // to not export particles into the offline file
102 
103  bool stationIsHit = false;
104  const StationSimData& sim = sIt->GetSimData();
105  for (Station::ConstPMTIterator pmtIt = sIt->PMTsBegin();
106  pmtIt != sIt->PMTsEnd(); ++pmtIt) {
107  if (pmtIt->HasSimData())
108  stationIsHit = true;
109  }
110 
111  if (!stationIsHit)
112  continue;
113 
114  const unsigned int nMu = sim.GetNumberOfMuons();
115  cout << "number of muons " << nMu << endl;
116 
117  double sumPe = 0;
118  for (Station::ConstPMTIterator pmtIt = sIt->PMTsBegin();
119  pmtIt != sIt->PMTsEnd(); ++pmtIt) {
120 
121  if (!pmtIt->HasSimData())
122  continue;
123 
124  const PMTSimData& pmtSim = pmtIt->GetSimData();
125 
126  if (!pmtSim.HasPETimeDistribution())
127  continue;
128 
129  const TimeDistributionI peDistro = pmtSim.GetPETimeDistribution();
130 
131  sumPe += TimeDistributionAlgorithm::Sum(peDistro, peDistro.GetStart(), peDistro.GetStop());
132 
133  } // loop on pmts
134 
135  // fill in histo with number pe's observed at distance from
136  // shower axis (distance is in the shower frame).
137 
139  const sdet::Station& detStat = det::Detector::GetInstance().GetSDetector().GetStation(*sIt);
140 
142 
143  Point::Triple xyz = detStat.GetPosition().GetCoordinates(scs);
144  double radius2 = Sqr(xyz.get<0>()) + Sqr(xyz.get<1>());
145 
146  peHist->Fill(sqrt(radius2), sumPe);
147  nMuHist->Fill(sqrt(radius2), nMu);
148 
149  }
150 
151  }
152 
153  fTankHistos[peHistTitle] = peHist;
154  fTankHistos[nMuHistTitle] = nMuHist;
155 
156  return eSuccess;
157 }
158 
159 
161 ShowerInventorAnalyzer::Finish()
162 {
163  INFO("ShowerInventorAnalyzer::Finish()");
164 
165  cout << "creating file : " << fOutFile << endl;
166 
167  TFile fOutputFile(fOutFile.c_str() ,"recreate");
168 
169  for (map<string, TH1F*>::iterator lIt = fTankHistos.begin();
170  lIt != fTankHistos.end(); ++lIt) {
171  lIt->second->Write();
172  }
173 
174  fOutputFile.cd();
175  fOutputFile.Close();
176 
177  return eSuccess;
178 }
Branch GetTopBranch() const
Definition: Branch.cc:63
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
int GetStart() const
First slot with data.
Station Level Simulated Data
StationIterator StationsEnd()
End of all stations.
Definition: SEvent.h:59
constexpr T Sqr(const T &x)
Detector description interface for Station-related data.
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
Histogram class for time distributions with suppressed empty bins.
#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
bool HasPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a PE release time distribution exists (optionally for a given source)
Definition: PMTSimData.h:65
utl::Point GetPosition() const
Tank position.
constexpr double deg
Definition: AugerUnits.h:140
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
boost::tuple< double, double, double > Triple
Coordinate triple for easy getting or setting of coordinates.
Definition: Triple.h:15
int GetStop() const
Last slot with data (1 less than First slot if no data)
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
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
unsigned int GetNumberOfMuons() const
Get the number of muons whose trajectories intersected the WCD.
utl::TimeDistributionI & GetPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Simulated photoelectron time distribution.
Definition: PMTSimData.h:54
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
Definition: SEvent.h:54
constexpr double m
Definition: AugerUnits.h:121
utl::CoordinateSystemPtr GetShowerCoordinateSystem() const

, generated on Tue Sep 26 2023.