11 #include <evt/Event.h>
12 #include <fevt/FEvent.h>
14 #include <fevt/EyeRecData.h>
15 #include <evt/ShowerFRecData.h>
16 #include <evt/GaisserHillas4Parameter.h>
17 #include <fwk/CentralConfig.h>
18 #include <utl/TabulatedFunctionErrors.h>
19 #include <utl/AugerUnits.h>
20 #include <utl/PhysicalConstants.h>
21 #include <utl/Reader.h>
22 #include <utl/ErrorLogger.h>
24 #include <utl/PhysicalFunctions.h>
31 using namespace FdEnergyFinderOG;
83 eyeiter !=
event.GetFEvent().EyesEnd();
99 if (! eyeiter->HasRecData() )
continue;
100 if (! eyeiter->GetRecData().HasFRecShower() )
continue;
101 ShowerFRecData& frecshower = eyeiter->GetRecData().GetFRecShower();
105 cout <<
"Energy cutoff = " << fEnergyCutoff/
MeV <<
" [MeV]" << endl;
112 fLongProfile = &long_profile;
123 if (fGHParameters==0) {
124 WARNING (
"ShowerFRecData of this eye already contains GH parameters.");
132 fGHParameters->SetXMax(fXmaxGH,fXmaxGH_error );
133 fGHParameters->SetShapeParameter(
gh::eX0, fX0GH, fX0GH_error);
134 fGHParameters->SetChiSquare( fChisqGH, (
unsigned int)fNdof);
135 fGHParameters->SetNMax(fNmaxGH,fNmaxGH_error );
138 fGHParameters->SetXMax (-999,0);
139 fGHParameters->SetShapeParameter(
gh::eX0, -999, 0);
140 fGHParameters->SetChiSquare( -999, 0);
141 fGHParameters->SetNMax(-999, 0 );
144 this->FindEmEnergy();
146 this->FindEmEnergyError();
148 this->FindTotalEnergy();
155 cout <<
"Em energy [GeV]" << fEemGH/
GeV <<
" +- "
156 << fEemGH_error/
GeV << endl;
157 cout <<
"Total Energy [GeV] " << fEtotalGH/
GeV << endl;
168 TMinuit theMinuit(npar);
170 theMinuit.SetPrintLevel(-1);
173 double arglist[
npar];
178 theMinuit.mnexcm(
"SET ERR", arglist,1,ierflag);
180 if (ierflag)
ERROR (
"Minuit SET ERR failed");
182 static double vstart[
npar];
183 static double step[
npar];
185 double log_n_max = 20.7;
186 double x_max = 700 * (
g/
cm2);
187 double x0 = 0.0 * (
g/
cm2);
191 vstart[0] = log_n_max;
198 step[1] = 10 * (
g/
cm2);
199 step[2] = 10 * (
g/
cm2);
201 if (fFixX0) step[2] = 0.0;
203 cout <<
" x0 step " << step[2] << endl;
205 theMinuit.mnparm(0,
"log_n_max",vstart[0], step[0],0,0,ierflag);
206 theMinuit.mnparm(1,
"x_max", vstart[1], step[1],0,0,ierflag);
207 theMinuit.mnparm(2,
"x0", vstart[2], step[2],0,0,ierflag);
212 theMinuit.mnexcm(
"MIGRAD", arglist , 2, ierflag);
215 ERROR (
"Minuit MIGRAD failed");
220 theMinuit.GetParameter(0, p[0], p[3]);
221 theMinuit.GetParameter(1, p[1], p[4]);
222 theMinuit.GetParameter(2, p[2], p[5]);
228 fNmaxGH_error = p[3]* fNmaxGH;
229 fXmaxGH_error = p[4];
233 cout << endl <<
"Gaisser-Hillas Fit result:" << endl;
234 cout <<
"n_max " << fNmaxGH <<
" +/- " << fNmaxGH_error <<
"\n"
235 <<
" X_max [g/cm2] " << fXmaxGH / (
g/
cm2)
236 <<
" +/- " << fXmaxGH_error / (
g/
cm2) <<
"\n"
237 <<
" X0 " << fX0GH / (
g/
cm2)
238 <<
" +/- " << fX0GH_error / (
g/
cm2) << endl;
240 cout <<
"Energy Estimate from Nmax[Gev] " << fNmaxGH / 1.3 << endl;
262 double Nmax= exp(par[0]);;
263 double Xmax= par[1]; ;
269 const unsigned int npoints = fLongProfile->GetNPoints();
270 for (
unsigned int i=4; i<npoints; i++){
272 double X = fLongProfile->GetX(i);
273 double n_e = fLongProfile->GetY(i);
274 double n_e_err = fLongProfile->GetYErr(i);
276 if (X>X0 && Xmax>0) {
278 chisq +=
pow((n_e - size)/ n_e_err,2);
284 if (ndof_chisq < 1) chisq = 9999;
289 fNdof = (ndof_chisq - 3);
317 for (
unsigned int i=0; i<50; i++){
318 double X = i*40.*(
g/
cm2);
319 if (X>fX0GH && fXmaxGH>0) {
329 mean_dEdX = sum_dEdX/sum_size;
330 cout <<
"Mean dEdX " << mean_dEdX/(
MeV/(
g/
cm2)) << endl;
336 fEemGH = fGHParameters->GetIntegral() * mean_dEdX;
344 fEemGH_error = 9.9e99;
348 fEemGH_error = fEemGH * fGHParameters->GetIntegralError();
394 using namespace utl::InvisibleEnergy;
399 if (fComposition == 1)
401 else if (fComposition == 2)
406 double dummycostheta=0.7071067;
407 fEtotalGH = fEemGH *
Factor(fEemGH, model, compo,dummycostheta);
double Factor(const double energyEM, const EInteractionModel intMod, const ECompositionModel compMod, const double cosTheta)
invisible energy factor, finv=Etot/Eem, given Eem. CosTheta only needed when using data driven estima...
static void MinuitFitFunction(int &npar, double *gin, double &f, double *par, int iflag)
static const utl::TabulatedFunctionErrors * fLongProfile
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Class representing a document branch.
bool HasLongitudinalProfile() const
EyeIterator EyesBegin(const ComponentSelector::Status status)
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetEmEnergy(const double energy, const double energyError, const EUncertaintyType type=eTotal)
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
double GaisserHillas(const double x, const double x0, const double xMax, const double nMax, const double lambda)
Calculate the Gaisser-Hillas function.
fevt::FEvent & GetFEvent()
bool HasGHParameters() const
ResultFlag
Flag returned by module methods to the RunController.
utl::TabulatedFunctionErrors & GetLongitudinalProfile()
retrieve longitudinal profile information (size vs depth)
constexpr double kLambdaGH
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
double EnergyDeposit(const double age, const double enCut)
Parametrization for the average energy deposit per particle.
Interface class to access to Fluorescence reconstruction of a Shower.
Main configuration utility.
Gaisser Hillas with 4 parameters.
void SetTotalEnergy(const double energy, const double energyError, const EUncertaintyType type=eTotal)
void MakeGHParameters(const VGaisserHillasParameter &gh)
#define ERROR(message)
Macro for logging error messages.
double GetEnergyCutoff() const
retrieve energy cutoff for which the profile of charged particles was calculated. ...
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)