RootCFMatrixOutput.cc
Go to the documentation of this file.
1 #include "RootCFMatrixOutput.h"
5 #include "diagonalMatrix.h"
8 
9 #include <TFile.h>
10 #include <TGraph.h>
11 #include <TH2D.h>
12 
13 #include <boost/format.hpp>
14 #include <evt/Event.h>
15 #include <evt/ShowerFRecData.h>
16 #include <evt/GaisserHillas4Parameter.h>
17 #include <sevt/SEvent.h>
18 #include <sevt/Header.h>
19 #include <fevt/Eye.h>
20 #include <fevt/EyeRecData.h>
21 #include <fevt/EyeHeader.h>
22 #include <utl/PhysicalConstants.h>
23 #include <utl/PhysicalFunctions.h>
24 #include <utl/AugerUnits.h>
25 #include <utl/UTMPoint.h>
26 #include <utl/Reader.h>
27 #include <det/Detector.h>
28 #include <atm/Atmosphere.h>
29 #include <atm/ProfileResult.h>
30 #include <atm/InclinedAtmosphericProfile.h>
31 #include <fwk/CentralConfig.h>
32 
33 #include <sstream>
34 #include <iostream>
35 #include <string>
36 #include <cmath>
37 
38 using namespace FdProfileReconstructorKG;
39 using namespace oBLAS;
40 using namespace fevt;
41 using namespace sevt;
42 using namespace evt;
43 using namespace utl;
44 using namespace atm;
45 using namespace det;
46 using namespace fwk;
47 using namespace boost;
48 using namespace std;
49 
50 
52 {
53  Init();
54 }
55 
56 
57 void
59 {
60  CentralConfig* const cc = CentralConfig::GetInstance();
61  const Branch topB = cc->GetTopBranch("FdProfileReconstructor");
62  const Branch rootB = topB.GetChild("rootOutput");
63  rootB.GetChild("verbosity").GetData(fVerbosity);
64  string outputFileName;
65  rootB.GetChild("outputFileName").GetData(outputFileName);
66  fOutputFile = new TFile(outputFileName.c_str(),"RECREATE");
67  if (fVerbosity >- 1) {
68  std::ostringstream info;
69  info << "\n\t saving matrix visualization to "
70  << outputFileName << endl;
71  INFO(info);
72  }
73 }
74 
75 
76 void
78  const fevt::Eye& eye,
80 {
81  if (fVerbosity > -1)
82  cout << "\n writing ROOT output" << endl;
83 
84  if (!event.HasSEvent())
85  return;
86  const SEvent& sEvent = event.GetSEvent();
87 
88  const int eventId = sEvent.GetHeader().GetId();
89  const int eyeId = eye.GetId();
90 
91  const string eventDirName = (format("Event_%04d_eye%1d") % eventId % eyeId ).str();
92 
93  fOutputFile->mkdir(eventDirName.c_str(), " ");
94  fOutputFile->cd(eventDirName.c_str());
95 
96  WriteLateral(eye, chfl);
97 }
98 
99 
100 void
103 {
104  namespace ublas = boost::numeric::ublas;
105 
106  const evt::ShowerFRecData& showerFRecData = eye.GetRecData().GetFRecShower();
107  const evt::GaisserHillas4Parameter* const gh4 =
108  dynamic_cast<const evt::GaisserHillas4Parameter*>(&showerFRecData.GetGHParameters());
109 
110  const double Xmax = gh4->GetXMax();
111  const double dEdXmax = gh4->GetNMax();
112  const double lambda = gh4->GetShapeParameter(gh::eLambda);
113  const double X0 = gh4->GetShapeParameter(gh::eX0);
114 
116  unsigned int n = chFlMatrix.size1();
117 
118  const std::deque<double>& depth = *ChFl.GetDepth();
119 
120  ublas::vector<double> dEdX(n);
121  for (unsigned int i = 0; i < n; ++i)
122  dEdX(i) = GaisserHillas(depth[i], X0, Xmax, dEdXmax, lambda);
123 
124  // all light
125  double zeta = 90.*degree;
126  ChFl.SetZeta(zeta);
127  ublas::vector<double> allFluo = ublas::prod(*ChFl.GetFluorescenceMatrix(), dEdX);
128  ublas::vector<double> allChMScat =ublas::prod(*ChFl.GetMieScatteredCherenkovMatrix(), dEdX);
129  ublas::vector<double> allChRScat =ublas::prod(*ChFl.GetRayleighScatteredCherenkovMatrix(), dEdX);
130  ublas::vector<double> allScat = allChMScat + allChRScat;
131 
132  vector<double> groundLevelDistance(1, 0.);
133  vector<double> groundLevelScattered(1, 0.);
134  vector<double> groundLevelFluo(1, 0.);
135  vector<double> xmaxLevelDistance(1, 0.);
136  vector<double> xmaxLevelScattered(1, 0.);
137  vector<double> xmaxLevelFluo(1, 0.);
138 
139  int iGround = n - 1;
140  int iXmax = -1;
141  double minDist = 0;
142  for (unsigned int i = 0; i < depth.size(); ++i) {
143  if (i == 0 || fabs(Xmax - depth[i]) < minDist) {
144  iXmax = i;
145  minDist = fabs(Xmax - depth[i]);
146  }
147  }
148 
149  zeta = 0.05*degree;
150  while (zeta < 10.*degree) {
151  ChFl.SetZeta(zeta);
152  ublas::vector<double> vFluo = ublas::prod(*ChFl.GetFluorescenceMatrix(), dEdX);
153  ublas::vector<double> vChMScat = ublas::prod(*ChFl.GetMieScatteredCherenkovMatrix(), dEdX);
154  ublas::vector<double> vChRScat = ublas::prod(*ChFl.GetRayleighScatteredCherenkovMatrix(), dEdX);
155 
156  groundLevelDistance.push_back(ChFl.GetZetaDistance(iGround));
157  groundLevelFluo.push_back(vFluo[iGround] / allFluo[iGround]);
158  groundLevelScattered.push_back((vChMScat[iGround] + vChRScat[iGround]) / allScat[iGround]);
159 
160  if (iXmax >= 0) {
161  xmaxLevelDistance.push_back(ChFl.GetZetaDistance(iXmax));
162  xmaxLevelFluo.push_back(vFluo[iXmax] / allFluo[iXmax]);
163  xmaxLevelScattered.push_back((vChMScat[iXmax] + vChRScat[iXmax]) / allScat[iXmax]);
164  }
165 
166  if (fVerbosity > -1)
167  cout << "calc. zeta " << zeta/degree << endl;
168 
169  zeta += 0.1*degree;
170  }
171 
172  double ageAtGround = floor(ShowerAge(depth[iGround], Xmax)*10. + 0.5) / 10.;
173  const string groundAge = (format("s=%3.1f") % ageAtGround).str();
174 
175  TGraph groundFluoGraph(groundLevelDistance.size(),
176  &groundLevelDistance.front(),
177  &groundLevelFluo.front());
178  groundFluoGraph.SetName("groundFluo");
179  groundFluoGraph.SetTitle(groundAge.c_str());
180  groundFluoGraph.Write();
181 
182  TGraph groundScatteredGraph(groundLevelDistance.size(),
183  &groundLevelDistance.front(),
184  &groundLevelScattered.front());
185  groundScatteredGraph.SetName("groundScattered");
186  groundScatteredGraph.SetTitle(groundAge.c_str());
187  groundScatteredGraph.Write();
188 
189  TGraph xmaxFluoGraph(xmaxLevelDistance.size(),
190  &xmaxLevelDistance.front(),
191  &xmaxLevelFluo.front());
192  xmaxFluoGraph.SetName("xmaxFluo");
193  xmaxFluoGraph.SetTitle("s=1");
194  xmaxFluoGraph.Write();
195 
196  TGraph xmaxScatteredGraph(xmaxLevelDistance.size(),
197  &xmaxLevelDistance.front(),
198  &xmaxLevelScattered.front());
199  xmaxScatteredGraph.SetName("xmaxScattered");
200  xmaxScatteredGraph.SetTitle("s=1");
201  xmaxScatteredGraph.Write();
202 }
203 
204 
206 {
207  fOutputFile->Write();
208  fOutputFile->Close();
209 
210  delete fOutputFile;
211 }
double GetShapeParameter(const gh::EShapeParameter par) const
access to all variants of shape parameters (see GaisserHillasTypes.h)
unsigned int GetId() const
Definition: FEvent/Eye.h:54
const oBLAS::lowerTriangularMatrix * GetMieScatteredCherenkovMatrix() const
returns Mie scattered Cherenkov light matrix
void Write(const evt::Event &event, const fevt::Eye &eye, CherenkovFluorescenceMatrix chfl)
const double degree
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
const oBLAS::lowerTriangularMatrix * GetRayleighScatteredCherenkovMatrix() const
returns Rayleigh scattered Cherenkov light matrix
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
int GetId() const
Definition: SEvent/Header.h:20
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
void WriteLateral(const fevt::Eye &eye, CherenkovFluorescenceMatrix &chfl)
Class representing a document branch.
Definition: Branch.h:107
double GetZetaDistance(const int) const
get distance to shower axis corresponding to zeta
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
Definition: EyeRecData.h:323
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
const oBLAS::lowerTriangularMatrix * GetCherenkovFluorescenceMatrix() const
returns total light matrix (not const as we eventually want to invert it ...)
double GaisserHillas(const double x, const double x0, const double xMax, const double nMax, const double lambda)
Calculate the Gaisser-Hillas function.
double ShowerAge(const double slantDepth, const double showerMax)
General definition of shower age.
const std::deque< double > * GetDepth() const
returns depth
Calculation of Cherenkov and Fluorescence matrix.
Interface class to access to Fluorescence reconstruction of a Shower.
sevt::Header & GetHeader()
Definition: SEvent.h:155
Main configuration utility.
Definition: CentralConfig.h:51
const oBLAS::diagonalMatrix * GetFluorescenceMatrix() const
returns fluorescence light matrix
Gaisser Hillas with 4 parameters.
bool HasSEvent() const
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
Definition: FEvent/Eye.cc:130

, generated on Tue Sep 26 2023.