3 #include <utl/PhysicalConstants.h>
4 #include <fevt/Pixel.h>
5 #include <fevt/PixelRecData.h>
7 #include <det/Detector.h>
8 #include <fdet/FDetector.h>
10 #include <utl/CoordinateSystemPtr.h>
11 #include <fdet/FTimeFitModel.h>
14 #include "../../General/RecDataWriterNG/ConversionUtil.h"
16 namespace FdProfileConstrainedGeometryFit {
63 std::vector<double> xs(
chii.size());
67 for (
unsigned int i = 0, n =
chii.size(); i < n; ++i)
68 xs[i] = tan(0.5*(chi0 -
chii[i]));
85 double& rp,
double &rpErr,
86 double& t0,
double &t0Err)
89 std::vector<double> xs(
chii.size());
91 for (
unsigned int i = 0, n =
chii.size(); i < n; ++i)
92 xs[i] = tan(0.5*(chi0 -
chii[i]));
105 double& Chi0 = par[0];
110 double logLikeSum = 0.;
111 for (
int i = 0, n =
chii.size(); i < n; ++i) {
120 double& T0,
double& T0err,
121 double& Rp,
double& Rperr,
125 TMinuit theMinuit(npar);
126 theMinuit.SetPrintLevel(-1);
128 double arglist[
npar];
132 theMinuit.mnexcm(
"SET ERR", arglist,1,ierflag);
133 if (ierflag)
ERROR(
"Minuit SET ERR failed");
134 static double vstart[
npar];
135 static double step[
npar];
142 theMinuit.mnparm(0,
"Chi0", vstart[0], step[0], 0,0,ierflag);
143 theMinuit.FixParameter(0);
144 theMinuit.mnparm(1,
"T0", vstart[1], step[1], vstart[1]-300, vstart[1]+300.,ierflag);
145 theMinuit.mnparm(2,
"Rp", vstart[2], step[2], vstart[2]-300., vstart[2]+300.,ierflag);
148 theMinuit.mnexcm(
"MIGRAD", arglist, 2, ierflag);
150 ERROR(
"Minuit MIGRAD failed");
152 theMinuit.GetParameter(1, T0, T0err);
153 theMinuit.GetParameter(2, Rp, Rperr);
154 chi2 = theMinuit.fAmin;
159 const std::vector<double>& y,
160 const std::vector<double>& ey,
161 double& a0,
double& a0err,
162 double& a1,
double& a1err,
172 for (
unsigned int i = 0; i<x.size(); ++i) {
174 const double wi = 1.0 / (ey[i]*ey[i]);
177 sxx += wi * x[i] * x[i];
179 sxy += wi * x[i] * y[i];
180 syy += wi * y[i] * y[i];
184 const double dinv = 1.0/(sw*sxx - sx*sx);
186 a0 = (sxx*sy - sx * sxy) * dinv;
187 a1 = (-sx*sy + sw * sxy) * dinv;
188 a0err =
sqrt (sxx * dinv);
189 a1err =
sqrt (sw * dinv);
192 chi2 = syy - a0*sy - a1*sxy;
194 double logLikeSum = 0;
195 for (
unsigned int i = 0; i<x.size(); ++i) {
196 logLikeSum += (-0.5*log(ey[i]*ey[i]) - 0.5*
pow( (y[i]-(a0+a1*x[i]))/ey[i] , 2));
198 chi2 = -2.*logLikeSum;
void MinuitFitErrors(const double Chi0, double &T0, double &T0err, double &Rp, double &Rperr, double &chi2) const
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
void SetRealAtm(bool realAtm, bool deex)
unsigned int GetEyeId() const
double pow(const double x, const unsigned int i)
boost::indirect_iterator< ConstInternalPixelIterator, const Pixel & > ConstPixelIterator
Const iterator over pixels used in reconstruction.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
void PrepParams(const fevt::EyeRecData &eyeRec)
void LinearFitErrors(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &ey, double &a0, double &a0err, double &a1, double &a1err, double &chi2) const
static void MinuitFitFunc(int &npar, double *gin, double &f, double *par, int iflag)
utl::TimeInterval GetT_i() const
static std::vector< double > times
static std::vector< double > timeErrs
Eye-specific shower reconstruction data.
const utl::AxialVector & GetSDP() const
constexpr double kSpeedOfLight
PixelIterator TimeFitPixelsEnd()
utl::TimeInterval GetT_iError() const
double GetTimeAtAperture(const double t0, const double rp, const double chi0, const double chi_i, const double thetaSDP, const int eye, const int tel) const
static std::vector< double > chii
void LinearFit(const vector< double > &x, const vector< double > &y, const vector< double > &ey, double &a0, double &a1, double &chi2)
Do a linear fit and return coefficients and chi2.
PixelIterator TimeFitPixelsBegin()
#define ERROR(message)
Macro for logging error messages.
Fluorescence Detector Pixel Reconstructed Data.
void operator()(const double chi0, double &chi2, double &rp, double &t0) const