MdLDFFinder.h
Go to the documentation of this file.
1 #ifndef _MdLDFFinderAG_MdLDFFinder_h_
2 #define _MdLDFFinderAG_MdLDFFinder_h_
3 
4 #include <utl/config.h> // before all
5 #include <utl/Point.h>
6 #include <utl/Vector.h>
7 #include <fwk/VModule.h>
8 //
9 #include <evt/ShowerRecData.h>
10 #include <mevt/MEvent.h>
11 #include <mevt/ModuleRecData.h>
12 #include <mdet/MDetector.h>
13 //
14 #include <boost/utility.hpp>
15 #include <utility>
16 //
17 #include "VMinMethodFunctor.h"
18 
19 namespace mdet {
20  class Counter;
21 }
22 
23 namespace evt {
24  class ShowerMRecData;
25 }
26 
27 namespace MdLDFFinderAG {
28 
30  class VLDFFunctor;
31  class VMinMethodFunctor;
32 
33  class MdLDFFinder : public boost::noncopyable,
34  public fwk::VModule {
35  public:
37  enum LDFType {
41  };
43  static const char* const kLDFTags[];
44 
50  };
52  static const char* const kMinMethodTags[];
53 
54  MdLDFFinder();
55  ~MdLDFFinder();
56  VModule::ResultFlag Init();
57  VModule::ResultFlag Run(evt::Event& e);
58  VModule::ResultFlag Finish();
59 
60 
61 
62  private:
63 
64  /*
65  * \brief The MD reconstructor state
66  * This class was designed to keep the same state after
67  * processing each event. This implies that its members
68  * do not refer to invidual events but to the
69  * module configuration. This design prevents passing
70  * unwanted data between events.
71  *
72  */
73 
81 
83  double CalculateRho0Seed( const CounterList counters, const utl::Point rCore, const utl::Vector rAxis) const;
84  double CalculateBeta( const double theta) const;
85 
86 // From Pierre Billoir Thoughts....(same as SdReconstruction)
87 // - if there are enough stations (especially at distances around ReferenceDistance), a fit
88 // with a variable LDF slope (beta) is attempted; the conditions are:
89 // * at least fCountersToFixBeta counters, with one of the following requirements:
90 // * at least 2 within (fLowLimToRelaxBeta, fUppLimToRelaxBeta), with a difference at least fCounterSpacings1 in between
91 // * at least 3 within (fLowLimToRelaxBeta, fUppLimToRelaxBeta), with a maximal difference at fCounterSpacings2
92 // * at least 4 within (fLowLimToRelaxBeta, fUppLimToRelaxBeta), with a maximal difference at fCounterSpacings3
93 
94  bool FixBetaFlag( const CounterList, const utl::Point&, const utl::Vector& ) const;
95 
96 /*
97 * The fit residuals
98 * The residuals of the muon LDF fit are calculated for each candidate module that is not saturated.
99 * The fit residuals are the measured density minus the density according the LDF. All densities
100 * are referred to the shower plane.
101 */
102  void SetLdfResiduals(CounterList counters, const std::vector<double> parameters,
103  const utl::Point rCore, const utl::Vector rAxis) const;
104 
105 /*
106 The fit chi2
107 The chi2 of the fit is calculated from candidates modules that are not saturated.
108 This chi2 should not be used for any serious analysis as it is just a raw approximation. For a better
109 estimator of the goodness of the fit use instead the value of the likelihood minimum.
110 For each module the chi2 is calculated from the number of measured muons and the number of muons expected
111 from the LDF. A Poisson variance equal to the number of muons from the LDF is assumed. However this approximation
112 fails for the limits of few and many muons. In the case of few muons the approximation is invalid because Poisson
113 cannot be approximated by a Gaussian. For many muons the problem is that the variance of the segmented counter is
114 greater than the Poisson variance (see Appendix A of GAP-2014-37).
115 */
116  double CalculateChi2(const CounterList counters, const std::vector<double> parameters,
117  const utl::Point rCore, const utl::Vector rAxis) const;
118 
119  size_t CalculateDegreesOfFreedom(const CounterList, const std::vector<bool>) const;
120 
121  void FillTabulatedFunction(evt::ShowerMRecData&, const std::vector<double>& fPars,
122  const std::vector<double>& fErrPars);
123 
124  // Fill reconstructed shower with parameters
125  void FillReconstructedParameters( evt::ShowerMRecData&, const ROOT::Minuit2::MnUserParameterState& , double );
126 
127  // Helper method to get the index of a free fit parameter skipping the fixed parameters
128  // It is required to select elements in the covariance matrix provided by Minuit
129  unsigned int GetFreeParIndex(const std::vector<ROOT::Minuit2::MinuitParameter>, unsigned int) const;
130 
131  // Filling the SP distances of the mevt::ModuleRecData objects
133 
134  bool fFixBeta; // Beta flag setting from the configuration. Input to all events
135  unsigned int fCountersToFixBeta;
136 
137 
140 
148  double fA0;
149  double fA1;
150  double fA2;
151 
154  size_t fSilentLimit;
155 
158 
160 
169  std::unique_ptr<VLDFFunctor> fLDF;
170  std::unique_ptr<VMinMethodFunctor> fMinimizer;
171 
177 
178  REGISTER_MODULE("MdLDFFinderAG", MdLDFFinder);
179  };
180 }
181 
182 #endif // _MdLDFFinderAG_MdLDFFinder_h_
void FillReconstructedParameters(evt::ShowerMRecData &, const ROOT::Minuit2::MnUserParameterState &, double)
Definition: MdLDFFinder.cc:412
void FillModulesShowerPlaneDistances(const evt::ShowerSRecData &, const mdet::MDetector &, mevt::MEvent &)
Definition: MdLDFFinder.cc:722
REGISTER_MODULE("MdLDFFinderAG", MdLDFFinder)
double CalculateChi2(const CounterList counters, const std::vector< double > parameters, const utl::Point rCore, const utl::Vector rAxis) const
Definition: MdLDFFinder.cc:643
Point object.
Definition: Point.h:32
VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Definition: MdLDFFinder.cc:67
void FillTabulatedFunction(evt::ShowerMRecData &, const std::vector< double > &fPars, const std::vector< double > &fErrPars)
Definition: MdLDFFinder.cc:380
Interface class to access to the SD Reconstruction of a Shower.
MinMethodType
Kind of possible minimization criteria to be used.
Definition: MdLDFFinder.h:46
unsigned int fCountersToFixBeta
Definition: MdLDFFinder.h:135
utl::CoordinateSystemPtr siteCS
Make detector data and coordinate system available to all methods.
Definition: MdLDFFinder.h:175
std::unique_ptr< VLDFFunctor > fLDF
Object performing the LDF and MinMethod evaluation.
Definition: MdLDFFinder.h:169
double CalculateBeta(const double theta) const
Definition: MdLDFFinder.cc:504
Detector associated to muon detector hierarchy.
Definition: MDetector.h:32
CounterList SelectCandidateCounters(mevt::MEvent &)
Fill the minimizer with the candidate modules from the event No efforr is made hare that the statuses...
Definition: MdLDFFinder.cc:571
const mdet::MDetector * mDetector
Definition: MdLDFFinder.h:176
size_t CalculateDegreesOfFreedom(const CounterList, const std::vector< bool >) const
Definition: MdLDFFinder.cc:696
VModule::ResultFlag Run(evt::Event &e)
Run: invoked once per event.
Definition: MdLDFFinder.cc:147
LDFType fLDFType
LDF and Minimization Method Types.
Definition: MdLDFFinder.h:164
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
LDFType
Kind of possible ldf functions to be used.
Definition: MdLDFFinder.h:37
void SetLdfResiduals(CounterList counters, const std::vector< double > parameters, const utl::Point rCore, const utl::Vector rAxis) const
Definition: MdLDFFinder.cc:600
std::unique_ptr< VMinMethodFunctor > fMinimizer
Definition: MdLDFFinder.h:170
CounterList SelectSilentCounters(mevt::MEvent &)
Definition: MdLDFFinder.cc:552
double CalculateRho0Seed(const CounterList counters, const utl::Point rCore, const utl::Vector rAxis) const
Estimate inital parameters.
Definition: MdLDFFinder.cc:512
VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
Definition: MdLDFFinder.cc:298
bool FixBetaFlag(const CounterList, const utl::Point &, const utl::Vector &) const
Definition: MdLDFFinder.cc:307
double fA0
For beta parameterization: beta(theta) = a0 + a1 * sec(theta) + a2 * sec^2(theta) ...
Definition: MdLDFFinder.h:148
Module interface.
Definition: VModule.h:53
MinMethodType fMinMethodType
Definition: MdLDFFinder.h:165
static const char *const kMinMethodTags[]
Tags for the types of MinMethod.
Definition: MdLDFFinder.h:52
Vector object.
Definition: Vector.h:30
static const char *const kLDFTags[]
Tags for the types of LDF.
Definition: MdLDFFinder.h:43
Interface class to access to the Muon Reconstruction of a Shower.
unsigned int GetFreeParIndex(const std::vector< ROOT::Minuit2::MinuitParameter >, unsigned int) const
Definition: MdLDFFinder.cc:483
Root of the Muon event hierarchy.
Definition: MEvent.h:25

, generated on Tue Sep 26 2023.