RdAirShowerReconstruction.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <evt/Event.h>
6 #include <evt/ShowerRecData.h>
7 #include <evt/ShowerRRecData.h>
8 #include <evt/ShowerSRecData.h>
9 
10 #include <revt/REvent.h>
11 
12 #include <utl/config.h>
13 #include <utl/ErrorLogger.h>
14 #include <utl/Reader.h>
15 
16 using namespace fwk;
17 using namespace evt;
18 using namespace utl;
19 using namespace revt;
20 
22 
24  fInfoLevel(eNone),
25  fEnergyFitId(0),
26  fEnergyFitParameter(0),
27  fEnergyKappa(0),
28  fEnergyB(0),
29  fXmaxFitId(0),
30  fXmaxFitParameter(0),
31  fXmaxGroundDepth(0),
32  fXmaxBbar(0),
33  fXmaxParamA(0),
34  fXmaxParamB(0),
35  fZenith(0)
36  { }
37 
38 
41  {
42  INFO("RdAirShowerReconstruction::Init()");
43  utl::Branch topBranch = CentralConfig::GetInstance()->GetTopBranch("RdAirShowerReconstruction");
44 
45  // Read in the configurations of the xml file
46  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
47 
48  // Energy reconstruction parameters
49  topBranch.GetChild("energyFitId").GetData(fEnergyFitId);
50  topBranch.GetChild("energyFitParameter").GetData(fEnergyFitParameter);
51  topBranch.GetChild("energyKappa").GetData(fEnergyKappa);
52  topBranch.GetChild("energyB").GetData(fEnergyB);
53 
54  // Xmax reconstruction parameters
55  topBranch.GetChild("xmaxFitId").GetData(fXmaxFitId);
56  topBranch.GetChild("xmaxFitParameter").GetData(fXmaxFitParameter);
57  topBranch.GetChild("xmaxGroundDepth").GetData(fXmaxGroundDepth);
58  topBranch.GetChild("xmaxBbar").GetData(fXmaxBbar);
59  topBranch.GetChild("xmaxParamA").GetData(fXmaxParamA);
60  topBranch.GetChild("xmaxParamB").GetData(fXmaxParamB);
61 
62  return eSuccess;
63  }
64 
65 
67  RdAirShowerReconstruction::Run(evt::Event& event)
68  {
69  // Checking the existance of the reconstructed shower
70  if (!event.HasRecShower()) {
71  WARNING("No RecShower found!");
72  return eSuccess;
73  }
74  if (!event.GetRecShower().HasRRecShower()) {
75  WARNING("No RRecShowerFound!");
76  return eSuccess;
77  }
78 
79  // Getting variables
80  ShowerRRecData& showerrrec = event.GetRecShower().GetRRecShower();
81  fZenith = showerrrec.GetZenith();
82 
83  // Getting results of the RdLDFMultiFitter module
84  const std::vector<TF1>& fitResult = showerrrec.GetRdLDF();
85 
86  // Checking the existance of functions with required indices
87  // ... for energy
88  if (fitResult.size() < fEnergyFitId + 1) {
89  WARNING("Fit with EnergyFitId does not exist!");
90  return eSuccess;
91  }
92  // ... for Xmax
93  if (fitResult.size() < fXmaxFitId + 1) {
94  WARNING("Fit with XmaxFitId does not exist!");
95  return eSuccess;
96  }
97 
98  // Checking the existance of functions with required indices
99  // ... for energy
100  if (fitResult[fEnergyFitId].GetNpar() < int(fEnergyFitParameter + 1)) {
101  WARNING("EnergyFitParameter does not exist!");
102  return eSuccess;
103  }
105  if (fitResult[fEnergyFitId].GetNpar() < int(fXmaxFitParameter + 1)) {
106  WARNING("XmaxFitParamter does not exist!");
107  return eSuccess;
108  }
109 
110  // Assigning variables
111  const double E0 = fitResult[fEnergyFitId].GetParameter(fEnergyFitParameter);
112  const double eta = fitResult[fXmaxFitId].GetParameter(fXmaxFitParameter);
113  const double E0_err = fitResult[fEnergyFitId].GetParError(fEnergyFitParameter);
114  const double eta_err = fitResult[fXmaxFitId].GetParError(fXmaxFitParameter);
115 
116  // Calculating energy and Xmax
117  double energy_err = 0;
118  const double energy = CalculateEnergy(E0, E0_err, energy_err);
119  double Xmax_err = 0;
120  const double Xmax = CalculateXmax(eta, eta_err, Xmax_err);
121 
124  if (std::isnan(energy) || std::isnan(energy_err)) {
125  WARNING("Can not reconstruct energy!");
126  return eSuccess;
127  }
129  if (std::isnan(Xmax) || std::isnan(Xmax_err)) {
130  WARNING("Can not reconstruct Xmax!");
131  return eSuccess;
132  }
133 
135  showerrrec.SetParameter(eReconstructedEnergyTunkaRex, energy);
136  showerrrec.SetParameter(eReconstructedXmaxTunkaRex, Xmax);
137  showerrrec.SetParameterError(eReconstructedEnergyTunkaRex, energy_err);
138  showerrrec.SetParameterError(eReconstructedXmaxTunkaRex, Xmax_err);
139 
140  return eSuccess;
141  }
142 
143 
144  double
145  RdAirShowerReconstruction::CalculateEnergy(const double E0, const double E0_err, double& energy_err)
146  {
147  energy_err = fabs(fEnergyKappa * fEnergyB * pow(E0, fEnergyB - 1) * E0_err);
148  return fEnergyKappa * pow(E0, fEnergyB);
149  }
150 
151 
152  double
153  RdAirShowerReconstruction::CalculateXmax(const double eta, const double eta_err, double& Xmax_err)
154  {
155  Xmax_err = fabs(fXmaxParamB / (fXmaxBbar - eta) * eta_err);
156  const double distance = fXmaxParamA + fXmaxParamB*log(fXmaxBbar - eta);
157  return fXmaxGroundDepth / cos(fZenith) - distance;
158  }
159 
160 
162  RdAirShowerReconstruction::Finish()
163  {
164  INFO("RdAirShowerReconstruction::Finish()");
165  return eSuccess;
166  }
167 
168 }
unsigned int fXmaxFitParameter
xml settings: index of parameter eta (slope) used for Xmax recontruction
Branch GetTopBranch() const
Definition: Branch.cc:63
unsigned int fEnergyFitId
xml settings: index of parametrization used for energy reconstruction
void SetParameter(Parameter i, double value, bool lock=true)
double CalculateXmax(const double eta, const double eta_err, double &Xmax_err)
return reconstructed Xmax
Report success to RunController.
Definition: VModule.h:62
double fXmaxParamB
xml settings: paramenter B used for Xmax reconstruction
double fXmaxBbar
xml settings: constant bbar used for Xmax reconstruction
bool HasRecShower() const
double fXmaxGroundDepth
xml settings: depth of the detector (in g/cm^2)
ShowerRecData & GetRecShower()
Interface class to access to the RD Reconstruction of a Shower.
double fEnergyKappa
xml settings: constant kappa used for energy reconstruction
#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
double pow(const double x, const unsigned int i)
double fZenith
zenith angle theta of arrival direction of air-shower
Class representing a document branch.
Definition: Branch.h:107
double GetZenith() const
returns the zenith angle (from the wave fit)
bool HasRRecShower() const
unsigned int fXmaxFitId
xml settings: index of parametrization used for Xmax reconstruction
double fXmaxParamA
xml settings: parameter A used for Xmax reconstruction
unsigned int fEnergyFitParameter
xml settings: index of parameter E0 used for energy reconstruction
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
double fEnergyB
xml settings: constant b used for energy reconstruction
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
void SetParameterError(Parameter i, double value, bool lock=true)
double CalculateEnergy(const double E0, const double E0_err, double &energy_err)
return reconstructed energy

, generated on Tue Sep 26 2023.