ATLAS Offline Software
RtCalibrationAnalytic.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef RtCalibrationAnalytic__H
5 #define RtCalibrationAnalytic__H
6 
7 //:::::::::::::::::::::::::::::::::
8 //:: CLASS RtCalibrationAnalytic ::
9 //:::::::::::::::::::::::::::::::::
10 
11 namespace MuonCalib {
19 
28 } // namespace MuonCalib
29 
30 // STL //
31 #include <memory>
32 #include <string>
33 #include <vector>
34 // CLHEP //
35 #include "CLHEP/Matrix/SymMatrix.h"
36 #include "CLHEP/Matrix/Vector.h"
37 #include "CLHEP/Units/PhysicalConstants.h"
38 #include "CLHEP/Units/SystemOfUnits.h"
39 
40 // ROOT //
41 #include "TFile.h"
42 #include "TH1F.h"
43 #include "TH2F.h"
44 
45 // MuonCalib //
48 #include "MdtCalibRt/MeanRMS.h"
49 
50 namespace MuonCalib {
51 
52  class IRtRelation;
53  class RtRelationLookUp;
54  class RtCalibrationOutput;
55  class IMdtCalibrationOutput;
56  class MuonCalibSegment;
57  class BaseFunction;
58 
60  public:
61  // Constructors //
62  RtCalibrationAnalytic(const std::string &name);
72 
73  RtCalibrationAnalytic(const std::string &name, const double &rt_accuracy, const unsigned int &func_type, const unsigned int &ord,
74  const bool &split, const bool &full_matrix, const bool &fix_min, const bool &fix_max, const int &max_it,
75  bool do_smoothing = false, bool do_parabolic_extrapolation = false);
96 
97  // Desctructor //
99 
100  // Methods //
101  // get-methods //
102  double reliability() const;
107  double estimatedRtAccuracy() const;
115  int numberOfSegments() const;
118  int numberOfSegmentsUsed() const;
121  int iteration() const;
124  bool splitIntoMultilayers() const;
130  bool fullMatrix() const;
137  bool smoothing() const;
143 
144  // set-method //
145  void setEstimateRtAccuracy(const double &acc);
147  void splitIntoMultilayers(const bool &yes_or_no);
154  void fullMatrix(const bool &yes_or_no);
163  void switch_on_control_histograms(const std::string &file_name);
172  void forceMonotony();
175  void doNotForceMonotony();
178  void doSmoothing();
183  void noSmoothing();
191 
192  // methods required by the base class "IMdtCalibration" //
198  bool handleSegment(MuonCalibSegment &seg);
202  void setInput(const IMdtCalibrationOutput *rt_input);
206  bool analyse();
209  bool converged() const;
214 
215  private:
216  // options //
217  bool m_control_histograms = false; // = true, if control histograms should be
218  // produces
219  bool m_split_into_ml = false; // = true, if segments should be restricted to the
220  // multilayers;
221  // = false, if segments over both multilayers are
222  // allowed
223  bool m_full_matrix = false; // = true, if the full matrix relating the errors in
224  // the r-t relationship to the residuals
225  // should be used;
226  // = false, if a diagonal matrix should be used;
227  // in this case the algorithm is equivalent
228  // to conventional method
229  bool m_fix_min = false; // = true: fix r(t_min)
230  bool m_fix_max = false; // = true: fix r(t_max)
231  int m_max_it = 0; // maximum number of iterations
232  bool m_force_monotony = false; // = true if r(t) is forced to monotonically
233  // increasing, false otherwise
234 
235  // bookkeeping //
236  int m_nb_segments = 0; // number of segments passed to the algorithm
237  int m_nb_segments_used = 0; // number of segments used by the algorithm
238  int m_iteration = 0; // current iteration
239  std::array<bool, 2> m_multilayer{}; // m_multilayer[k] = true, if there was a segment
240  // extending to multilayer k+1
241 
242  // r-t quality //
243  int m_status = 0; // m_status: 0: no covergence yet,
244  // 1: convergence, r-t is reliable,
245  // 2: convergence, r-t is unreliable
246  double m_rt_accuracy = 0.0; // r-t accuracy (CLHEP::mm) of the input r-t
247  double m_rt_accuracy_previous = 0.0; // r-t accuracy of the previous iteration
248  // (used in the convergence criterion)
249  double m_chi2_previous = 0.0;
250  // average chi^2 per degrees of freedom from the
251  // previous iteration (set to a large initial value
252  // to force at least two iterations);
253  // if an iteration gives a larger average than the
254  // pervious iteration, the algorithm has converged
255  double m_chi2 = 0.0; // average chi^2 per degrees of freedom,
256  // if an iteration gives a larger average than the
257  // pervious iteration, the algorithm has converged
258 
259  // r-t relationship //
260  std::shared_ptr<const IRtRelation> m_rt; // pointer to the input r-t relationship
261  double m_t_length = 0.0; // size of the drift time interval
262  double m_t_mean = 0.0; // mean value of the drift time interval
263 
264  // r-t output //
265  std::shared_ptr<IRtRelation> m_rt_new; // r-t as determined by the autocalibration
266  std::shared_ptr<RtCalibrationOutput> m_output; // class holding the results of the
267  // autocalibration
268 
269  // straight-segment fitting //
270  double m_r_max = 0.0; // maximum value for accepted drift radii
272  // straight-line segment
273  // finder, used because it
274  // performs a pattern
275  // recognition
276 
277  // autocalibration objects //
278  bool m_do_smoothing = false; // = true: the r-t relationship is smoothened after
279  // convergence, no smoothing is done
280  // otherwise
281  bool m_do_parabolic_extrapolation = false; // = true: parabolic extrapolation is
282  // done for small and large radii
283  // = false: no parabolic extrapolation is
284  // done
285  unsigned int m_order = 0U; // order of the polynomial describing the
286  // correction to the r-t relationship
287  std::vector<CLHEP::HepVector> m_U; // vector of base function values
288  CLHEP::HepSymMatrix m_A; // coefficient matrix of the final autocalibration
289  // equation
290  CLHEP::HepVector m_alpha; // vector of fit parameters, i.e. the coefficients
291  // of the correction polynomial
292  CLHEP::HepVector m_b; // m_A*m_alpha = m_b (final autocalibration equation)
293 
294  // Legendre polynomial //
295  std::unique_ptr<BaseFunction> m_base_function; // pointer to the base function u
296 
297  // control histograms //
298  std::unique_ptr<TFile> m_tfile; // ROOT file
299  std::unique_ptr<TH1F> m_cut_evolution; // cut evolution histogram
300  std::unique_ptr<TH1F> m_nb_segment_hits; // number of hits on the segments
301  std::unique_ptr<TH1F> m_CL; // confidence level distribution of the selected segments
302  std::unique_ptr<TH2F> m_residuals; // residual distribution
303 
304  // private methods //
305  void init(const double &rt_accuracy, const unsigned int &func_type, const unsigned int &ord, const bool &split,
306  const bool &full_matrix, const bool &fix_min, const bool &fix_max, const int &max_it, bool do_smoothing,
307  bool do_parabolic_extrapolation);
308  // initialization method:
309  // rt_accuracy = estimated r-t accuracy,
310  // func_type: type of function to be used for
311  // the r-t correction;
312  // = 1: Legendre polynomial,
313  // = 2: Chebyshev polynomial,
314  // = 3: polygon
315  // ord = "order" ot the r-t correction function
316  // split = true forces the algorithm to restrict
317  // segments to multilayers;
318  // full_matrix = true forces the algorithm ti
319  // use the full matrix relating the errors in
320  // in r(t) to the residuals; otherwise a unit
321  // matrix is used;
322  // fix_min, fix_max=true: fix r(t_min), r(t_max);
323  // do_smoothing: smoothen the r-t relationship
324  // after convergence if do_smoothing = true;
325  // do_parabolic_extrapolation: do or not do
326  // parabolic extrapolation for small and large
327  // radii;
328  // max_it: maximum number of iterations
329  double t_from_r(const double &r);
330  // get t(r) for the input r-t relationship,
331  // the method is auxiliary and not optimized;
332  // it will disappear when the t(r) will be
333  // available in the MuonCalib framework
334 
335  void display_segment(MuonCalibSegment *segment, std::ofstream &outfile);
336 
337  std::shared_ptr<RtRelationLookUp> performParabolicExtrapolation(const bool &min, const bool &max, const IRtRelation &in_rt);
338  // use parabolic extrapolations on the given r-t
339  // relationship in_rt;
340  // min: if true, use parabolic extrapolation towards
341  // r=0;
342  // max: if true, use parabolic extrapolation towards
343  // r=r_max;
344 
346  MeanRMS m_track_position; // mean and rms of track slope and position
347  };
348 
349 } // namespace MuonCalib
350 
351 #endif
beamspotman.r
def r
Definition: beamspotman.py:676
MuonCalib::IMdtCalibration::MdtCalibOutputPtr
std::shared_ptr< IMdtCalibrationOutput > MdtCalibOutputPtr
Definition: IMdtCalibration.h:30
MuonCalib::MeanRMS
Definition: MeanRMS.h:9
MuonCalib::RtCalibrationAnalytic::fullMatrix
bool fullMatrix() const
returns true, if the full matrix relating the errors in the r-t relationship to the residuals should ...
Definition: RtCalibrationAnalytic.cxx:292
MuonCalib::RtCalibrationAnalytic::m_full_matrix
bool m_full_matrix
Definition: RtCalibrationAnalytic.h:223
max
#define max(a, b)
Definition: cfImp.cxx:41
MuonCalib::RtCalibrationAnalytic::getResults
MdtCalibOutputPtr getResults() const
returns the final r-t relationship
Definition: RtCalibrationAnalytic.cxx:908
MuonCalib::RtCalibrationAnalytic::m_track_slope
MeanRMS m_track_slope
Definition: RtCalibrationAnalytic.h:345
MuonCalib::RtCalibrationAnalytic::m_residuals
std::unique_ptr< TH2F > m_residuals
Definition: RtCalibrationAnalytic.h:302
MuonCalib::RtCalibrationAnalytic::m_fix_min
bool m_fix_min
Definition: RtCalibrationAnalytic.h:229
MuonCalib::RtCalibrationAnalytic::doNotForceMonotony
void doNotForceMonotony()
do not force r(t) to be monotonically increasing
Definition: RtCalibrationAnalytic.cxx:331
MuonCalib::RtCalibrationAnalytic::m_status
int m_status
Definition: RtCalibrationAnalytic.h:243
MuonCalib::IMdtCalibration
Definition: IMdtCalibration.h:25
MuonCalib::MuonCalibSegment
Definition: MuonCalibSegment.h:39
MuonCalib::RtCalibrationAnalytic::m_base_function
std::unique_ptr< BaseFunction > m_base_function
Definition: RtCalibrationAnalytic.h:295
MuonCalib::RtCalibrationAnalytic::m_chi2_previous
double m_chi2_previous
Definition: RtCalibrationAnalytic.h:249
MuonCalib::RtCalibrationAnalytic
Definition: RtCalibrationAnalytic.h:59
MuonCalib::RtCalibrationAnalytic::m_tfile
std::unique_ptr< TFile > m_tfile
Definition: RtCalibrationAnalytic.h:298
MuonCalib::RtCalibrationAnalytic::m_cut_evolution
std::unique_ptr< TH1F > m_cut_evolution
Definition: RtCalibrationAnalytic.h:299
MuonCalib::RtCalibrationAnalytic::m_U
std::vector< CLHEP::HepVector > m_U
Definition: RtCalibrationAnalytic.h:287
MuonCalib::RtCalibrationAnalytic::switch_on_control_histograms
void switch_on_control_histograms(const std::string &file_name)
this methods requests control histograms from the algorithms; the algorithm will write them to ROOT f...
Definition: RtCalibrationAnalytic.cxx:306
MuonCalib::RtCalibrationAnalytic::display_segment
void display_segment(MuonCalibSegment *segment, std::ofstream &outfile)
Definition: RtCalibrationAnalytic.cxx:170
MuonCalib::RtCalibrationAnalytic::iteration
int iteration() const
get the number of the current iteration
Definition: RtCalibrationAnalytic.cxx:278
MuonCalib::RtCalibrationAnalytic::m_rt
std::shared_ptr< const IRtRelation > m_rt
Definition: RtCalibrationAnalytic.h:260
MuonCalib::RtCalibrationAnalytic::doParabolicExtrapolation
void doParabolicExtrapolation()
requires that parabolic extrapolation will be used for small and large radii
Definition: RtCalibrationAnalytic.cxx:334
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
MuonCalib::RtCalibrationAnalytic::forceMonotony
void forceMonotony()
force r(t) to be monotonically increasing
Definition: RtCalibrationAnalytic.cxx:330
MuonCalib::RtCalibrationAnalytic::m_tracker
QuasianalyticLineReconstruction m_tracker
Definition: RtCalibrationAnalytic.h:271
MuonCalib::RtCalibrationAnalytic::m_r_max
double m_r_max
Definition: RtCalibrationAnalytic.h:270
MuonCalib::RtCalibrationAnalytic::analyse
bool analyse()
perform the autocalibration with the segments acquired so far
Definition: RtCalibrationAnalytic.cxx:740
MuonCalib::RtCalibrationAnalytic::RtCalibrationAnalytic
RtCalibrationAnalytic(const std::string &name)
Default constructor: r-t accuracy is set to 0.5 mm.
Definition: RtCalibrationAnalytic.cxx:38
MuonCalib::RtCalibrationAnalytic::m_iteration
int m_iteration
Definition: RtCalibrationAnalytic.h:238
MuonCalib::RtCalibrationAnalytic::m_track_position
MeanRMS m_track_position
Definition: RtCalibrationAnalytic.h:346
MuonCalib::RtCalibrationAnalytic::noParabolicExtrapolation
void noParabolicExtrapolation()
no parabolic extrapolation is done
Definition: RtCalibrationAnalytic.cxx:335
MuonCalib::RtCalibrationAnalytic::m_nb_segment_hits
std::unique_ptr< TH1F > m_nb_segment_hits
Definition: RtCalibrationAnalytic.h:300
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::RtCalibrationAnalytic::handleSegment
bool handleSegment(MuonCalibSegment &seg)
analyse the segment "seg" (this method was required before MdtCalibInterfaces-00-01-06)
Definition: RtCalibrationAnalytic.cxx:468
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
MuonCalib::RtCalibrationAnalytic::m_rt_accuracy_previous
double m_rt_accuracy_previous
Definition: RtCalibrationAnalytic.h:247
MuonCalib::RtCalibrationAnalytic::m_rt_new
std::shared_ptr< IRtRelation > m_rt_new
Definition: RtCalibrationAnalytic.h:265
MuonCalib::RtCalibrationAnalytic::numberOfSegments
int numberOfSegments() const
get the number of segments which were passed to the algorithm
Definition: RtCalibrationAnalytic.cxx:264
MuonCalib::RtCalibrationAnalytic::m_t_mean
double m_t_mean
Definition: RtCalibrationAnalytic.h:262
QuasianalyticLineReconstruction.h
min
#define min(a, b)
Definition: cfImp.cxx:40
MuonCalib::RtCalibrationAnalytic::m_do_smoothing
bool m_do_smoothing
Definition: RtCalibrationAnalytic.h:278
MuonCalib::RtCalibrationAnalytic::analyseSegments
MdtCalibOutputPtr analyseSegments(const MuonSegVec &seg)
perform the full autocalibration including iterations (required since MdtCalibInterfaces-00-01-06)
Definition: RtCalibrationAnalytic.cxx:339
MuonCalib::IMdtCalibration::name
virtual std::string name() const
returns name (region) of instance
Definition: IMdtCalibration.h:49
MuonCalib::RtCalibrationAnalytic::m_A
CLHEP::HepSymMatrix m_A
Definition: RtCalibrationAnalytic.h:288
MuonCalib::RtCalibrationAnalytic::m_CL
std::unique_ptr< TH1F > m_CL
Definition: RtCalibrationAnalytic.h:301
IMdtCalibration.h
MuonCalib::QuasianalyticLineReconstruction
Definition: QuasianalyticLineReconstruction.h:34
MuonCalib::RtCalibrationAnalytic::m_control_histograms
bool m_control_histograms
Definition: RtCalibrationAnalytic.h:217
MuonCalib::RtCalibrationAnalytic::m_max_it
int m_max_it
Definition: RtCalibrationAnalytic.h:231
MuonCalib::IMdtCalibrationOutput
Definition: IMdtCalibrationOutput.h:28
MuonCalib::RtCalibrationAnalytic::m_nb_segments_used
int m_nb_segments_used
Definition: RtCalibrationAnalytic.h:237
MuonCalib::RtCalibrationAnalytic::setInput
void setInput(const IMdtCalibrationOutput *rt_input)
set the r-t relationship, the internal autocalibration objects are reset
Definition: RtCalibrationAnalytic.cxx:688
MuonCalib::RtCalibrationAnalytic::~RtCalibrationAnalytic
~RtCalibrationAnalytic()
Definition: RtCalibrationAnalytic.cxx:49
MuonCalib::RtCalibrationAnalytic::setEstimateRtAccuracy
void setEstimateRtAccuracy(const double &acc)
set the estimated r-t accuracy =acc
Definition: RtCalibrationAnalytic.cxx:336
MuonCalib::RtCalibrationAnalytic::m_order
unsigned int m_order
Definition: RtCalibrationAnalytic.h:285
MuonCalib::RtCalibrationAnalytic::m_alpha
CLHEP::HepVector m_alpha
Definition: RtCalibrationAnalytic.h:290
MuonCalib::RtCalibrationAnalytic::reliability
double reliability() const
get the reliability of the r-t: 0: no convergence yet 1: convergence, r-t is reliable 2: convergence,...
Definition: RtCalibrationAnalytic.cxx:250
MuonCalib::RtCalibrationAnalytic::converged
bool converged() const
returns true, if the autocalibration has converged
Definition: RtCalibrationAnalytic.cxx:907
MuonCalib::RtCalibrationAnalytic::m_force_monotony
bool m_force_monotony
Definition: RtCalibrationAnalytic.h:232
MuonCalib::RtCalibrationAnalytic::m_rt_accuracy
double m_rt_accuracy
Definition: RtCalibrationAnalytic.h:246
MuonCalib::RtCalibrationAnalytic::t_from_r
double t_from_r(const double &r)
Definition: RtCalibrationAnalytic.cxx:143
MuonCalib::RtCalibrationAnalytic::switch_off_control_histograms
void switch_off_control_histograms()
the algorithm does not produce controll histograms (this is the default)
Definition: RtCalibrationAnalytic.cxx:322
MuonCalib::RtCalibrationAnalytic::numberOfSegmentsUsed
int numberOfSegmentsUsed() const
get the number of segments which are used in the autocalibration
Definition: RtCalibrationAnalytic.cxx:271
MuonCalib::RtCalibrationAnalytic::m_do_parabolic_extrapolation
bool m_do_parabolic_extrapolation
Definition: RtCalibrationAnalytic.h:281
MuonCalib::RtCalibrationAnalytic::m_chi2
double m_chi2
Definition: RtCalibrationAnalytic.h:255
MuonCalib::RtCalibrationAnalytic::m_nb_segments
int m_nb_segments
Definition: RtCalibrationAnalytic.h:236
MuonCalib::IMdtCalibration::MuonSegVec
std::vector< std::shared_ptr< MuonCalibSegment > > MuonSegVec
Definition: IMdtCalibration.h:27
MuonCalib::RtCalibrationAnalytic::estimatedRtAccuracy
double estimatedRtAccuracy() const
get the estimated r-t quality (CLHEP::mm), the accuracy of the input r-t is computed at the end of th...
Definition: RtCalibrationAnalytic.cxx:257
MuonCalib::RtCalibrationAnalytic::m_t_length
double m_t_length
Definition: RtCalibrationAnalytic.h:261
MuonCalib::RtCalibrationAnalytic::doSmoothing
void doSmoothing()
requires that the r-t relationship will be smoothened using the conventional autocalibration after co...
Definition: RtCalibrationAnalytic.cxx:332
MuonCalib::RtCalibrationAnalytic::splitIntoMultilayers
bool splitIntoMultilayers() const
returns true, if segments are internally restricted to single multilayers; returns false,...
Definition: RtCalibrationAnalytic.cxx:285
MuonCalib::RtCalibrationAnalytic::performParabolicExtrapolation
std::shared_ptr< RtRelationLookUp > performParabolicExtrapolation(const bool &min, const bool &max, const IRtRelation &in_rt)
Definition: RtCalibrationAnalytic.cxx:909
MuonCalib::RtCalibrationAnalytic::m_b
CLHEP::HepVector m_b
Definition: RtCalibrationAnalytic.h:292
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
MeanRMS.h
MuonCalib::RtCalibrationAnalytic::m_multilayer
std::array< bool, 2 > m_multilayer
Definition: RtCalibrationAnalytic.h:239
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
MuonCalib::IRtRelation
generic interface for a rt-relation
Definition: IRtRelation.h:14
MuonCalib::RtCalibrationAnalytic::m_output
std::shared_ptr< RtCalibrationOutput > m_output
Definition: RtCalibrationAnalytic.h:266
MuonCalib::RtCalibrationAnalytic::smoothing
bool smoothing() const
returns true, if the r-t relationship will be smoothened using the conventional autocalibration after...
Definition: RtCalibrationAnalytic.cxx:299
MuonCalib::RtCalibrationAnalytic::noSmoothing
void noSmoothing()
do not smoothen the r-t relationship after convergence
Definition: RtCalibrationAnalytic.cxx:333
MuonCalib::RtCalibrationAnalytic::init
void init(const double &rt_accuracy, const unsigned int &func_type, const unsigned int &ord, const bool &split, const bool &full_matrix, const bool &fix_min, const bool &fix_max, const int &max_it, bool do_smoothing, bool do_parabolic_extrapolation)
Definition: RtCalibrationAnalytic.cxx:56
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
MuonCalib::RtCalibrationAnalytic::m_split_into_ml
bool m_split_into_ml
Definition: RtCalibrationAnalytic.h:219
MuonCalib::RtCalibrationAnalytic::m_fix_max
bool m_fix_max
Definition: RtCalibrationAnalytic.h:230