3 #include <fevt/EyeRecData.h>
5 #include <evt/GaisserHillas4Parameter.h>
7 #include "../FdEnergyDepositFinderKG/ProfileFitFunctions.h"
8 #include "../FdEnergyDepositFinderKG/GHShapeParameters.h"
9 #include "../FdEnergyDepositFinderKG/LateralLightCalculator.h"
12 #include <utl/ErrorLogger.h>
15 #include <fwk/CentralConfig.h>
16 #include <det/Detector.h>
22 namespace FdProfileConstrainedGeometryFitPG {
27 topBranch.
GetChild(
"antiAliasingFilterCorrection").
GetData(fAafCorrection);
31 info<<
"\n\t leavingAtmoIsError is " << (fLeavingAtmoIsError?
"on":
"off");
32 info<<
"\n\t antiAliasingFilterCorrection is " << (fAafCorrection?
"on":
"off");
33 info<<
"\n\t useNoiseBins is " << (fUseNoiseBins?
"on":
"off");
34 info<<
"\n\t denseMatrixDim set to " << (fDenseMatrixDim);
47 if (kUnivBranch.
GetChild(
"constrained").
Get<
bool>()) {
48 fIsUnivConstrained =
true;
55 ProfileChi2::operator()(
Eye &eyeCopy,
bool precise)
57 fCFMatrixCalculator.SetLDFMethod(FdEnergyDepositFinderKG::LateralLightCalculator::ECalculationMethod::eCircle);
58 fCFMatrixCalculatorDense.SetLDFMethod(FdEnergyDepositFinderKG::LateralLightCalculator::ECalculationMethod::eCircle);
60 fCFMatrixCalculator.SetOnlyDirect(fOnlyDirectLight);
61 fCFMatrixCalculator.SetVerbosity(-1);
63 fCFMatrixCalculatorDense.SetOnlyDirect(fOnlyDirectLight);
64 fCFMatrixCalculatorDense.SetVerbosity(-1);
66 fProfileFitter.SetAafCorrection(fAafCorrection, fUseNoiseBins);
68 fProfileFitter.SetAafCorrection(0,
false);
72 fCFMatrixCalculator.BuildMatrix(eyeCopy, fLeavingAtmoIsError);
73 fCFMatrixCalculatorDense.BuildMatrix(eyeCopy, fLeavingAtmoIsError, (precise && fCFMatrixCalculator.GetFOVSize() > 0 && fDenseMatrixDim/fCFMatrixCalculator.GetFOVSize() > 0) ? fDenseMatrixDim/fCFMatrixCalculator.GetFOVSize() : 1);
75 }
catch (std::exception&) {
76 return numeric_limits<double>::infinity();
78 if (!fCFMatrixCalculator.HasMatrix() || !fCFMatrixCalculatorDense.HasMatrix()
79 || fCFMatrixCalculator.GetSize() < 2)
81 ERROR(
"No Matrix built.");
82 return numeric_limits<double>::infinity();
85 fProfileCalculator.CalculateProfile(eyeCopy, fCFMatrixCalculator,
true);
91 const double chi2pfl =
96 else return numeric_limits<double>::infinity();
102 const double chi2pfl = fProfileFitter.GetLHChi2();
108 else return numeric_limits<double>::infinity();
114 ProfileChi2::FitProfile(
Eye& eye,
117 using namespace FdEnergyDepositFinderKG;
122 fProfileFitter.ResetStartParameters();
124 if (!shower.HasGHParameters()) {
126 if (!GuessGHParameters(shower))
142 fProfileFitter.SetFitMode(ProfileFitter::eNMax);
145 fProfileFitter.SetStartParameters(gh4Pars);
147 fProfileFitter.SetLightFluxData(fCFMatrixCalculator, fCFMatrixCalculatorDense);
149 fProfileFitter.SetProfileData(shower.GetEnergyDeposit());
150 fProfileFitter.SetFunctionType(type);
155 if(fProfileFitter.Fit()){
157 fProfileFitter.FillGHParameters(gh4Pars);
165 fProfileFitter.SetFitMode(ProfileFitter::eIntegral);
166 fProfileFitter.SetStartParameters(gh4Pars);
167 if (fProfileFitter.Fit())
168 fProfileFitter.GetEnergy(calorEnergy, calorEnergyErr);
172 shower.SetEmEnergy(calorEnergy, calorEnergyErr, ShowerFRecData::eStatistical);
173 shower.SetEmEnergyError(0, ShowerFRecData::eAtmospheric);
176 const double currXmax = gh4Pars.
GetXMax();
177 const double maxDeltaXmax = 10*
g/
cm2;
178 const bool updateCFM =
179 fabs(currXmax-fCFMatrixCalculatorDense.GetXmax()) > maxDeltaXmax &&
184 fCFMatrixCalculator.BuildMatrix(eye, fLeavingAtmoIsError);
185 fCFMatrixCalculatorDense.BuildMatrix(eye, fLeavingAtmoIsError, (precise && fCFMatrixCalculator.GetFOVSize() > 0 && fDenseMatrixDim/fCFMatrixCalculator.GetFOVSize() > 0) ? fDenseMatrixDim/fCFMatrixCalculator.GetFOVSize() : 1);
190 if (fCFMatrixCalculator.HasMatrix()) {
192 fProfileCalculator.CalculateProfile(eye, fCFMatrixCalculator);
206 using namespace FdEnergyDepositFinderKG;
214 WARNING(
"can not estimate start parameters");
215 gh4Pars.SetXMax(700*
g/
cm2, 0);
216 gh4Pars.SetNMax(1*
PeV/
g*
cm2, 0,
true);
222 const unsigned int nPoints = energyDeposit.
GetNPoints();
223 const double depthBin = 50*
g/
cm2;
225 bool firstTime =
true;
228 for (
unsigned int i = 0; i < nPoints; ++i) {
229 const double firstDepth = energyDeposit.GetX(i);
230 unsigned int nAverage = 0;
234 for (
unsigned int j = i; j < nPoints; ++j) {
235 const double thisDepth = energyDeposit.GetX(j);
238 const double w = 1 /
pow(energyDeposit.GetYErr(j), 2);
240 ywSum += energyDeposit.GetY(j)*w;
242 if (thisDepth - firstDepth > depthBin) {
243 const double yAverage = ywSum/wSum;
244 if (firstTime || yAverage > dEdXmax) {
246 xMax = xSum / nAverage;
262 gh4Pars.SetShapeParameter(ghPars.Type(
eOne),
263 ghPars.Mean(
eOne,1e18*
eV), ghPars.Sigma(
eOne,1e18*eV));
264 gh4Pars.SetShapeParameter(ghPars.Type(
eTwo),
265 ghPars.Mean(
eTwo,1e18*eV), ghPars.Sigma(
eTwo,1e18*eV));
269 gh4Pars.SetShapeParameter(
gh::eAsym, 0.455, 0);
273 WARNING(
"can not estimate start parameters");
274 gh4Pars.SetXMax(700*
g/
cm2, 0);
275 gh4Pars.SetNMax(1*
PeV/
g*
cm2, 0,
true);
279 gh4Pars.SetXMax(xMax, 0);
280 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)
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.
bool HasEnergyDeposit() const
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.