3 #include <fevt/EyeRecData.h>
5 #include <evt/GaisserHillas4Parameter.h>
7 #include "../FdEnergyDepositFinderKG/ProfileFitFunctions.h"
8 #include "../FdEnergyDepositFinderKG/GHShapeParameters.h"
11 #include <utl/ErrorLogger.h>
14 #include <fwk/CentralConfig.h>
15 #include <det/Detector.h>
21 namespace FdProfileConstrainedGeometryFit {
26 topBranch.
GetChild(
"antiAliasingFilterCorrection").
GetData(fAafCorrection);
29 info<<
"\n\t leavingAtmoIsError is " << (fLeavingAtmoIsError?
"on":
"off");
30 info<<
"\n\t antiAliasingFilterCorrection is " << (fAafCorrection?
"on":
"off");
31 info<<
"\n\t useNoiseBins is " << (fUseNoiseBins?
"on":
"off");
44 if (kUnivBranch.
GetChild(
"constrained").
Get<
bool>()) {
45 fIsUnivConstrained =
true;
52 ProfileChi2::operator()(
Eye &eyeCopy)
55 fCFMatrixCalculator.SetOnlyDirect(fOnlyDirectLight);
56 fCFMatrixCalculator.SetVerbosity(-1);
59 fCFMatrixCalculator.BuildMatrix(eyeCopy, fLeavingAtmoIsError);
61 return numeric_limits<double>::infinity();
63 if (!fCFMatrixCalculator.HasMatrix()
64 || fCFMatrixCalculator.GetSize() < 2)
66 ERROR(
"No Matrix built.");
67 return numeric_limits<double>::infinity();
70 fProfileCalculator.CalculateProfile(eyeCopy, fCFMatrixCalculator,
true);
76 const double chi2pfl =
81 else return numeric_limits<double>::infinity();
87 const double chi2pfl = fProfileFitter.GetLHChi2();
93 else return numeric_limits<double>::infinity();
99 ProfileChi2::FitProfile(
Eye& eye,
102 using namespace FdEnergyDepositFinderKG;
107 fProfileFitter.ResetStartParameters();
109 if (!shower.HasGHParameters()) {
111 if (!GuessGHParameters(shower))
118 cout<<
"L: "<< gh4Pars.GetShapeParameter(
gh::eUSP_L)/(
g/
cm2)<< endl;
119 cout<<
"R: "<< gh4Pars.GetShapeParameter(
gh::eUSP_R)<< endl;
127 fProfileFitter.SetFitMode(ProfileFitter::eNMax);
130 fProfileFitter.SetStartParameters(gh4Pars);
132 fProfileFitter.SetLightFluxData(fCFMatrixCalculator);
134 fProfileFitter.SetProfileData(shower.GetEnergyDeposit());
135 fProfileFitter.SetFunctionType(type);
140 if(fProfileFitter.Fit()){
142 fProfileFitter.FillGHParameters(gh4Pars);
150 fProfileFitter.SetFitMode(ProfileFitter::eIntegral);
151 fProfileFitter.SetStartParameters(gh4Pars);
152 if (fProfileFitter.Fit())
153 fProfileFitter.GetEnergy(calorEnergy, calorEnergyErr);
157 shower.SetEmEnergy(calorEnergy, calorEnergyErr, ShowerFRecData::eStatistical);
158 shower.SetEmEnergyError(0, ShowerFRecData::eAtmospheric);
161 const double currXmax = gh4Pars.
GetXMax();
162 const double maxDeltaXmax = 10*
g/
cm2;
163 const bool updateCFM =
164 fabs(currXmax-fCFMatrixCalculator.GetXmax()) > maxDeltaXmax &&
168 fCFMatrixCalculator.BuildMatrix(eye, fLeavingAtmoIsError);
170 if (fCFMatrixCalculator.HasMatrix()) {
172 fProfileCalculator.CalculateProfile(eye, fCFMatrixCalculator);
186 using namespace FdEnergyDepositFinderKG;
194 const unsigned int nPoints = energyDeposit.
GetNPoints();
195 const double depthBin = 50*
g/
cm2;
197 bool firstTime =
true;
200 for (
unsigned int i = 0; i < nPoints; ++i) {
201 const double firstDepth = energyDeposit.GetX(i);
202 unsigned int nAverage = 0;
206 for (
unsigned int j = i; j < nPoints; ++j) {
207 const double thisDepth = energyDeposit.GetX(j);
210 const double w = 1 /
pow(energyDeposit.GetYErr(j), 2);
212 ywSum += energyDeposit.GetY(j)*w;
214 if (thisDepth - firstDepth > depthBin) {
215 const double yAverage = ywSum/wSum;
216 if (firstTime || yAverage > dEdXmax) {
218 xMax = xSum / nAverage;
234 gh4Pars.SetShapeParameter(ghPars.Type(
eOne),
235 ghPars.Mean(
eOne,1e18*
eV), ghPars.Sigma(
eOne,1e18*eV));
236 gh4Pars.SetShapeParameter(ghPars.Type(
eTwo),
237 ghPars.Mean(
eTwo,1e18*eV), ghPars.Sigma(
eTwo,1e18*eV));
241 WARNING(
"can not estimate start parameters");
242 gh4Pars.SetXMax(700*
g/
cm2, 0);
243 gh4Pars.SetNMax(1*
PeV/
g*
cm2, 0,
true);
247 gh4Pars.SetXMax(xMax, 0);
248 gh4Pars.SetNMax(dEdXmax, 0,
true);
unsigned int GetNPoints() const
double GetIntegralError() const
return relative error of integral
Fluorescence Detector Eye Event.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
std::string GetFunctionTypeName(const EFunctionType type)
Exception for reporting variable out of valid range.
Class representing a document branch.
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
Interface class to access to Fluorescence reconstruction of a Shower.
double GetIntegral() const
calculate integral
Gaisser Hillas with 4 parameters.
void MakeGHParameters(const VGaisserHillasParameter &gh)
#define ERROR(message)
Macro for logging error messages.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
utl::TabulatedFunctionErrors & GetEnergyDeposit()
retrieve dE/dX
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.