ATLAS Offline Software
Loading...
Searching...
No Matches
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
11namespace MuonCalib {
19
27
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
50namespace MuonCalib {
51
52 class IRtRelation;
53 class RtRelationLookUp;
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" //
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
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
This is an abstract base class for a set of base functions for fits to sample points.
Interface to pass calibration output during calibration.
IMdtCalibration(const std::string &name)
constructor, string used to identify the instance
virtual std::string name() const
returns name (region) of instance
std::shared_ptr< IMdtCalibrationOutput > MdtCalibOutputPtr
std::vector< std::shared_ptr< MuonCalibSegment > > MuonSegVec
generic interface for a rt-relation
Definition IRtRelation.h:19
A MuonCalibSegment is a reconstructed three dimensional track segment in the MuonSpectrometer.
std::vector< CLHEP::HepVector > m_U
MdtCalibOutputPtr getResults() const
returns the final r-t relationship
void doNotForceMonotony()
do not force r(t) to be monotonically increasing
void setEstimateRtAccuracy(const double acc)
set the estimated r-t accuracy =acc
int numberOfSegmentsUsed() const
get the number of segments which are used in the autocalibration
bool splitIntoMultilayers() const
returns true, if segments are internally restricted to single multilayers; returns false,...
MdtCalibOutputPtr analyseSegments(const MuonSegVec &seg)
perform the full autocalibration including iterations (required since MdtCalibInterfaces-00-01-06)
std::shared_ptr< IRtRelation > m_rt_new
double reliability() const
get the reliability of the r-t: 0: no convergence yet 1: convergence, r-t is reliable 2: convergence,...
void display_segment(MuonCalibSegment *segment, std::ofstream &outfile)
int numberOfSegments() const
get the number of segments which were passed to the algorithm
void doSmoothing()
requires that the r-t relationship will be smoothened using the conventional autocalibration after co...
void noParabolicExtrapolation()
no parabolic extrapolation is done
void switch_off_control_histograms()
the algorithm does not produce controll histograms (this is the default)
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...
std::shared_ptr< const IRtRelation > m_rt
std::unique_ptr< BaseFunction > m_base_function
void doParabolicExtrapolation()
requires that parabolic extrapolation will be used for small and large radii
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)
bool converged() const
returns true, if the autocalibration has converged
QuasianalyticLineReconstruction m_tracker
bool fullMatrix() const
returns true, if the full matrix relating the errors in the r-t relationship to the residuals should ...
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...
RtCalibrationAnalytic(const std::string &name)
Default constructor: r-t accuracy is set to 0.5 mm.
std::shared_ptr< RtCalibrationOutput > m_output
int iteration() const
get the number of the current iteration
void setInput(const IMdtCalibrationOutput *rt_input)
set the r-t relationship, the internal autocalibration objects are reset
void noSmoothing()
do not smoothen the r-t relationship after convergence
bool analyse()
perform the autocalibration with the segments acquired so far
std::shared_ptr< RtRelationLookUp > performParabolicExtrapolation(const bool &min, const bool &max, const IRtRelation &in_rt)
bool handleSegment(MuonCalibSegment &seg)
analyse the segment "seg" (this method was required before MdtCalibInterfaces-00-01-06)
bool smoothing() const
returns true, if the r-t relationship will be smoothened using the conventional autocalibration after...
void forceMonotony()
force r(t) to be monotonically increasing
std::unique_ptr< TH1F > m_nb_segment_hits
Class for communication between event loop and rt calibration algorithm contains only a rt relation f...
Equidistant look up table for rt-relations with the time as key.
int r
Definition globals.cxx:22
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.