GeometryFitter.h
Go to the documentation of this file.
1 #ifndef _MdGeometryFitterAG_GeometryFitter_h_
2 #define _MdGeometryFitterAG_GeometryFitter_h_
3 
4 #include <vector>
5 #include <memory>
6 #include <bitset>
7 
8 #include <TVector3.h>
9 #include <TMatrixDSym.h>
10 #include <Minuit2/MnUserParameters.h>
11 #include <Minuit2/MnUserCovariance.h>
12 
13 #include "TimeData.h"
14 
15 namespace MdGeometryFitterAG {
16 
29 
30  public:
31 
33 
44  // Add a detector to the data used in the fitting
45  void AddDetector(int id, TVector3 pos, double time, double sigma);
46 
47  void RemoveDetectors() {timeData.clear();}
48  int GetNDetectors() const {return timeData.size();}
49  bool HasDetector(int detectorId) const;
50 
51  // Parameter configuration
52  void SetRadius(double radius) {parSeed.SetValue("radius", radius);}
53  void SetCurvatureFree() {parSeed.Release("radius");}
54  void SetCurvatureFix() {parSeed.Fix("radius");}
55  bool IsCurvatureFix() const;
56 
57  void SetCore(const TVector3 &core);
58  void SetCoreFree();
59  void SetCoreFix();
60  bool IsCoreFix() const;
61 
62  int Fit();
63  void SetMinuitOutput(bool flag=true) {minuitOutput=flag;}
64 
65  // After the minimisation the fit parameters are saved in the parFitted data member of this class
66  // Fitter parameters and their errors can be retrieved afterwards using the following getters
67  double GetU() const {return parFitted->Value("u");}
68  double GetV() const {return parFitted->Value("v");}
69  double GetW() const {return sqrt(1-GetU()*GetU()-GetV()*GetV());}
70 
71  TVector3 GetAxis() const;
72  double GetTheta() const {return acos(GetW());}
73  double GetThetaError() const;
74  double GetPhi() const {return atan2(GetV(),GetU());}
75  double GetPhiError() const;
76  double GetThetaPhiCorrelation() const;
77 
78  double GetCt0() const {return parFitted->Value("ct0");}
79  double GetCt0Error() const {return parFitted->Error("ct0");}
80 
81  double GetRadius() const {return parFitted->Value("radius");}
82  double GetRadiusError() const;
83 
84  TVector3 GetCore() const;
85 
86  // Residual stuff
87  double GetTimeResidual(int detectorId) const;
88  double GetTimeError(int detectorId) const;
89  double GetMeanTimeResidual() const;
90  double GetChi2() const;
91  double GetNdof() const;
92  double GetTimeResidualSpread() const;
93 
94  // Delay in nanoseconds of a detector signal wrt to a plane shower front passing through the core position
95  // and oriented with the reconstructed axis.
96  double GetPlaneFrontDelay(int detectorId) const;
97 
98  private:
99 
100  // List of detector data used in the geometrical reconstruction: id, position, time observable value, and time observable error
101  std::vector<TimeData> timeData;
102 
104 
105  // Fit parameters and their errors
107  typedef std::unique_ptr<ROOT::Minuit2::MnUserParameters> ParameterPtr;
108  ParameterPtr parFitted; // seed and fitted parameters
109  ROOT::Minuit2::MnUserParameters parSeed;
110 
111  typedef std::unique_ptr<ROOT::Minuit2::MnUserCovariance> CovariancePtr;
113 
114  // analytic linear fit in local CS; approximation by neglecting
115  // z-coordinate, since z ~ 0 in local bary coordinate system,
116  // therefore loosing the w component of the axis.
117  int FitPlane(double &u, double &v, double &ct0) const;
118  double GetTimeResidual(const TimeData& data) const;
119 
120  // Studentised residual (i.e. residual over sigma)
121  double GetTimeResidualSigmas(const TimeData& data) const
122  { return GetTimeResidual(data)/data.sigma; }
123 
124  double GetPlaneFrontDelay(const TimeData& data) const;
125 
126  }; // end GeometryFitter class
127 
128 
129 } // end namespace MdGeometryFitterAG
130 
131 #endif
void SetCore(const TVector3 &core)
double GetTimeResidual(int detectorId) const
bool HasDetector(int detectorId) const
double GetPlaneFrontDelay(int detectorId) const
std::unique_ptr< ROOT::Minuit2::MnUserCovariance > CovariancePtr
double GetTimeResidualSigmas(const TimeData &data) const
void SetMinuitOutput(bool flag=true)
std::unique_ptr< ROOT::Minuit2::MnUserParameters > ParameterPtr
Reconstruction of the shower geometry.
ROOT::Minuit2::MnUserParameters parSeed
uint16_t * data
Definition: dump1090.h:228
double GetTimeError(int detectorId) const
int FitPlane(double &u, double &v, double &ct0) const
std::vector< TimeData > timeData
void AddDetector(int id, TVector3 pos, double time, double sigma)
Note about vectors The TVector3 class is used here instead of the utl::Vector and utl::Point classses...

, generated on Tue Sep 26 2023.