SdReconstruction/LDFFinderKG/LDFFinder.h
Go to the documentation of this file.
1 
14 #ifndef _LDFFinderKG_LDFFinder_h_
15 #define _LDFFinderKG_LDFFinder_h_
16 
17 #include <fwk/VModule.h>
18 #include <utl/Point.h>
19 #include <utl/Vector.h>
20 #include <utl/TimeStamp.h>
21 #include <utl/CovarianceMatrix.h>
22 #include <sdet/ArrayType.h>
23 
24 #include <cmath>
25 #include <sstream>
26 
27 #include "LDF.h"
28 #include "EnergyConversion.h"
29 #include "LikelihoodFunctions.h"
30 
31 
32 namespace evt {
33  class Event;
34 }
35 
36 namespace sevt {
37  class SEvent;
38 }
39 
40 namespace LDFFinderKG {
41 
42  utl::CoordinateSystemPtr gBaryCS; // is used by LikelihoodFunctions, too
43 
44 
71  class LDFFinder : public fwk::VModule {
72  public:
73  fwk::VModule::ResultFlag Init() override;
74  fwk::VModule::ResultFlag Run(evt::Event& event) override;
75  fwk::VModule::ResultFlag Finish() override { return eSuccess; }
76 
77  enum InfoLevel {
78  eNone = 0,
79  eFinal = 1,
81  eObscure = 3,
82  eMinuit = 4
83  };
84 
85  enum LDFParameter {
87  eCoreX = 1,
88  eCoreY = 2,
90  };
91 
92  struct LDFFitResult {
93 
94  LDFFitResult(const LDFFitConfig& config) :
95  fPar(eShapeParameters + config.fLDF.GetNShapeParameters()),
96  fCov(fPar.size())
97  { }
98 
99  std::vector<double> fPar;
101 
102  double fChi2 = 0;
103  int fNdof = 0;
104  double fLogLikelihood = 0;
105  double fRecStage = 0;
106 
107  // for convenience
108 
110  { return utl::Point(fPar[eCoreX], fPar[eCoreY], 0, gBaryCS); }
111 
112  std::vector<double> GetLDFShapeParameters() const
113  { return std::vector<double>(fPar.begin() + eShapeParameters, fPar.end()); }
114 
115  };
116 
118  eU = 0, // u = sin(theta)*cos(phi)
119  eV = 1, // v = sin(theta)*sin(phi)
120  eRCore = 2,
122  };
123 
124  struct CurvFitResult {
125 
126  std::vector<double> fPar = std::vector<double>(4);
128  double fChi2 = 0;
129  int fNdof = 0;
130 
131  // for convenience
132 
133  double
134  GetTheta()
135  const
136  {
137  const double u = fPar[eU];
138  const double v = fPar[eV];
139  const double w = std::sqrt(1 - u*u - v*v);
140  return std::acos(w);
141  }
142 
144  GetAxis()
145  const
146  {
147  const double u = fPar[eU];
148  const double v = fPar[eV];
149  const double w = std::sqrt(1 - u*u - v*v);
150  return utl::Vector(u, v, w, gBaryCS);
151  }
152 
153  };
154 
155  private:
156  // LDF part
157  bool FixBeta(const LDFFitResult& result,
158  const utl::Vector& showerAxis,
159  const std::vector<StationFitData>& data) const;
160 
161  bool FixGamma(const LDFFitResult& result,
162  const utl::Vector& showerAxis,
163  const std::vector<StationFitData>& data) const;
164 
165  void FitLDFSimplified(LDFFitResult& result,
166  LDFFitConfig& config,
167  const utl::Vector& showerAxis,
168  const std::vector<StationFitData>& data) const;
169 
170  bool FitLDF(LDFFitResult& result,
171  LDFFitConfig& config,
172  const utl::Vector& showerAxis,
173  const std::vector<StationFitData>& data) const;
174 
175  // Curvature part
176  double ParameterizedRc(const double cosTheta, const double showerSize) const;
177 
178  double FitCurvature(CurvFitResult& result,
179  const utl::Point& core,
180  const std::vector<StationFitData>& data) const;
181 
182  // other
183  std::vector<StationFitData> MakeStationFitData(const sevt::SEvent& sEvent) const;
184 
185  bool FixCore(utl::Point& core,
186  utl::TimeStamp& coreTime,
187  utl::Vector& showerAxis,
188  const evt::Event& event) const;
189 
190  void SetRecData(evt::Event& event,
191  const LDFFitResult& lresult,
192  const CurvFitResult& cresult) const;
193 
194  void OutputResults(const evt::Event& event) const;
195 
196  bool FitGlobal(CurvFitResult& cres, LDFFitResult& lres,
197  const LDFFitConfig& config,
198  const std::vector<StationFitData>& data) const;
199  std::vector<int> CleanSilentStation(const LDFFitResult& ldfres,
200  const LDFFitConfig& config,
201  const utl::Vector& showerAxis,
202  std::vector<StationFitData>& stationFitData) const;
203  // vars
204  int fInfoLevel = 0;
206  double fMaxTheta = 0;
208  double fMaxChi2 = 0;
209  bool fUseMaxLikelihood = false;
212  bool fFixedAxis = false;
213  bool fFixedCurvature = false;
214  bool fGlobalFit = false;
219  int fRoptN = 0;
220  std::vector<int> fBadSilents;
221 
222  struct Stage0 {
224  bool fUseCorePosition = false;
225  } fStage0;
226 
227  struct Stage1 {
229  } fStage1;
230 
231  struct Stage2 {
233  std::vector<double> fFixBetaRange;
234  std::vector<double> fFixBetaLeverArmRange;
236  std::vector<double> fFixGammaRange;
237  std::vector<double> fFixGammaLeverArmRange;
238  } fStage2;
239 
240  struct Stage3 {
244  bool fOutliersRejection = false;
245  } fStage3;
246 
247  struct Silents {
249  double fMaxLDFValue = 0;
250  double fMaxDistance = 0;
251  } fSilentsVars;
252 
253  REGISTER_MODULE("LDFFinderKG", LDFFinder);
254 
255  };
256 
257 }
258 
259 
260 #endif
void OutputResults(const evt::Event &event) const
bool FixBeta(const LDFFitResult &result, const utl::Vector &showerAxis, const std::vector< StationFitData > &data) const
Point object.
Definition: Point.h:32
Report success to RunController.
Definition: VModule.h:62
std::vector< StationFitData > MakeStationFitData(const sevt::SEvent &sEvent) const
Init station data used by LDF fit.
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
bool FitLDF(LDFFitResult &result, LDFFitConfig &config, const utl::Vector &showerAxis, const std::vector< StationFitData > &data) const
bool FixGamma(const LDFFitResult &result, const utl::Vector &showerAxis, const std::vector< StationFitData > &data) const
Criterion if gamma can be fitted analogue to beta must be checked/updated.
void FitLDFSimplified(LDFFitResult &result, LDFFitConfig &config, const utl::Vector &showerAxis, const std::vector< StationFitData > &data) const
Early estimate of shower size.
fwk::VModule::ResultFlag Finish() override
Finish: invoked at end of the run (NOT end of the event)
void SetRecData(evt::Event &event, const LDFFitResult &lresult, const CurvFitResult &cresult) const
struct LDFFinderKG::LDFFinder::Stage0 fStage0
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
utl::CoordinateSystemPtr gBaryCS
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
fwk::VModule::ResultFlag Run(evt::Event &event) override
Run: invoked once per event.
const Data result[]
bool FitGlobal(CurvFitResult &cres, LDFFitResult &lres, const LDFFitConfig &config, const std::vector< StationFitData > &data) const
double FitCurvature(CurvFitResult &result, const utl::Point &core, const std::vector< StationFitData > &data) const
struct LDFFinderKG::LDFFinder::Stage2 fStage2
Module interface.
Definition: VModule.h:53
bool FixCore(utl::Point &core, utl::TimeStamp &coreTime, utl::Vector &showerAxis, const evt::Event &event) const
fwk::VModule::ResultFlag Init() override
Initialize: invoked at beginning of run (NOT beginning of event)
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
struct LDFFinderKG::LDFFinder::Stage3 fStage3
uint16_t * data
Definition: dump1090.h:228
Vector object.
Definition: Vector.h:30
struct LDFFinderKG::LDFFinder::Stage1 fStage1
struct LDFFinderKG::LDFFinder::Silents fSilentsVars
REGISTER_MODULE("LDFFinderKG", LDFFinder)
std::vector< int > CleanSilentStation(const LDFFitResult &ldfres, const LDFFitConfig &config, const utl::Vector &showerAxis, std::vector< StationFitData > &stationFitData) const
double ParameterizedRc(const double cosTheta, const double showerSize) const

, generated on Tue Sep 26 2023.