ATLAS Offline Software
Loading...
Searching...
No Matches
RtCalibrationCurved.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MuonCalib_RtCalibrationCurvedH
6#define MuonCalib_RtCalibrationCurvedH
7
14
15#include <list>
16#include <memory>
17#include <string>
18#include <vector>
19
20// CLHEP //
21#include "CLHEP/Matrix/SymMatrix.h"
22#include "CLHEP/Matrix/Vector.h"
23
24// ROOT //
25#include "TFile.h"
26#include "TH1F.h"
27#include "TH2F.h"
28
29// MuonCalib //
32
33namespace MuonCalib {
34
35 class IMdtCalibrationOutput;
36 class IRtRelation;
37 class RtRelationLookUp;
38 class RtCalibrationOutput;
39 class CurvedPatRec;
40 class MuonCalibSegment;
41 class BaseFunction;
42 class CurvedLine;
43 class MultilayerRtDifference;
44
46 public:
47 // Constructors //
48 RtCalibrationCurved(const std::string &name);
59
60 RtCalibrationCurved(const std::string &name, const double rt_accuracy, const unsigned int &func_type, const unsigned int &ord,
61 const bool &fix_min, const bool &fix_max, const int &max_it, bool do_parabolic_extrapolation = false,
62 bool do_smoothing = false, bool do_multilayer_rt_scale = false);
79
80 // Destructor //
83
84 // Methods //
85 // get-methods //
86 double reliability() const;
92 double estimatedRtAccuracy() const;
100 int numberOfSegments() const;
103 int numberOfSegmentsUsed() const;
106 int iteration() const;
109 bool smoothing() const;
115
116 // set-method //
117 void setEstimateRtAccuracy(const double acc);
119 void fullMatrix(const bool &yes_or_no);
128 void switch_on_control_histograms(const std::string &file_name);
137 void forceMonotony();
140 void doNotForceMonotony();
148 void doSmoothing();
153 void noSmoothing();
156
157 // methods required by the base class "IMdtCalibration" //
158 MdtCalibOutputPtr analyseSegments(const MuonSegVec &seg) override;
167 void setInput(const IMdtCalibrationOutput *rt_input) override;
171 bool analyse(const MuonSegVec &seg);
174 bool converged() const;
177 virtual MdtCalibOutputPtr getResults() const override;
179
180 private:
181 // options //
182 bool m_control_histograms = false; // = true, if control histograms should be
183 // produces
184 bool m_fix_min = false; // = true: fix r(t_min)
185 bool m_fix_max = false; // = true: fix r(t_max)
186 int m_max_it = 0; // maximum number of iterations
187 bool m_force_monotony = false; // = true if r(t) is forced to monotonically
188 // increasing, false otherwise
189 bool m_do_multilayer_rt_scale = false; // determine multilayer rt scaling
190
191 // bookkeeping //
192 int m_nb_segments = 0; // number of segments passed to the algorithm
193 int m_nb_segments_used = 0; // number of segments used by the algorithm
194 int m_iteration = 0; // current iteration
195 std::array<bool, 2> m_multilayer{}; // m_multilayer[k] = true, if there was a segment
196 // extending to multilayer k+1
197
198 // r-t quality //
199 int m_status = 0; // m_status: 0: no covergence yet,
200 // 1: convergence, r-t is reliable,
201 // 2: convergence, r-t is unreliable
202 double m_rt_accuracy = 0.0; // r-t accuracy (CLHEP::mm) of the input r-t
203 double m_rt_accuracy_previous; // r-t accuracy of the previous iteration
204 // (used in the convergence criterion)
205 double m_chi2_previous = 0.0;
206 // average chi^2 per degrees of freedom from the
207 // previous iteration (set to a large initial value
208 // to force at least two iterations);
209 // if an iteration gives a larger average than the
210 // pervious iteration, the algorithm has converged
211 double m_chi2 = 0.0; // average chi^2 per degrees of freedom,
212 // if an iteration gives a larger average than the
213 // pervious iteration, the algorithm has converged
214
215 // r-t relationship //
216 std::shared_ptr<const IRtRelation> m_rt; // pointer to the input r-t relationship
217 double m_t_length = 0.0; // size of the drift time interval
218 double m_t_mean = 0.0; // mean value of the drift time interval
219
220 // r-t output //
221 std::shared_ptr<IRtRelation> m_rt_new; // r-t as determined by the autocalibration
222 std::shared_ptr<RtCalibrationOutput> m_output; // class holding the results of the
223 // autocalibration
224 std::unique_ptr<MultilayerRtDifference> m_multilayer_rt_difference;
225 // curved-segment fitting //
226 double m_r_max = 0.0; // maximum value for accepted drift radii
227 std::unique_ptr<CurvedPatRec> m_tracker; // curved segment finder (used for track fitting)
228 // The following three objects are needed for autocalibration formulae.
229
230 CLHEP::HepSymMatrix m_M_track; // segment parameters = m_M_track^-1*m_b_track
231 CLHEP::HepSymMatrix m_M_track_inverse; // inverse of m_M_track
232
233 // autocalibration objects //
234 bool m_do_parabolic_extrapolation = false; // = true: parabolic extrapolation is
235 // done for small and large radii
236 // = false: no parabolic extrapolation is
237 // done
238 bool m_do_smoothing = false; // = true: the r-t relationship is smoothened after
239 // convergence, no smoothing is done
240 // otherwise
241 unsigned int m_order = 0U; // order of the polynomial describing the
242 // correction to the r-t relationship
243 std::vector<CLHEP::HepVector> m_U; // vector of base correction function values
244 std::vector<CLHEP::HepVector> m_U_weighted; // vector of base correction function
245 // values weighted by the inverse
246 // standard deviation of the radius
247 // measurements
248 CLHEP::HepSymMatrix m_A; // coefficient matrix of the final autocalibration
249 // equation
250 CLHEP::HepVector m_alpha; // vector of fit parameters, i.e. the coefficients
251 // of the correction polynomial
252 CLHEP::HepVector m_b; // m_A*m_alpha = m_b (final autocalibration equation)
253
254 // correction functions //
255 std::unique_ptr<BaseFunction> m_base_function; // pointer to the base function u
256
257 // control histograms //
258 std::unique_ptr<TFile> m_tfile{}; // ROOT file
259 std::unique_ptr<TH1F> m_cut_evolution{}; // cut evolution histogram
260 std::unique_ptr<TH1F> m_nb_segment_hits{}; // number of hits on the segments
261 std::unique_ptr<TH1F> m_pull_initial{}; // initial pull distribution
262 std::unique_ptr<TH1F> m_pull_final{}; // final pull distribution after convergence
263 std::unique_ptr<TH2F> m_residuals_initial{}; // initial residual distribution
264 std::unique_ptr<TH2F> m_residuals_initial_all{}; // initial residual distribution before convergence
265 std::unique_ptr<TH2F> m_residuals_final{}; // final residual distribution after convergence
266 std::unique_ptr<TH2F> m_driftTime_initial{}; // final residual distribution after convergence
267 std::unique_ptr<TH2F> m_driftTime_final{}; // final residual distribution after convergence
268 std::unique_ptr<TH2F> m_adc_vs_residual_final{}; // final residual distribution after convergence
269
270 // private methods //
271 void init(const double rt_accuracy, const unsigned int &func_type, const unsigned int &ord, const bool &fix_min,
272 const bool &fix_max, const int &max_it, bool do_parabolic_extrapolation, bool do_smoothing, bool do_multilayer_rt_scale);
273 // initialization method:
274 // rt_accuracy = estimated r-t accuracy,
275 // func_type: type of function to be used for
276 // the r-t correction;
277 // = 1: Legendre polynomial,
278 // = 2: Chebyshev polynomial,
279 // = 3: polygon
280 // ord = "order" ot the r-t correction function
281 // split = true forces the algorithm to restrict
282 // segments to multilayers;
283 // fix_min, fix_max=true: fix r(t_min), r(t_max)
284 // max_it: maximum number of iterations
285 // do_parabolic_extrapolation: do or do not use
286 // parabolic extrapolations for small and large
287 // radii;
288 // do_smoothing: smoothen the r-t relationship
289 // after convergence if do_smoothing = true
290 double t_from_r(const double r);
291 // get t(r) for the input r-t relationship,
292 // the method is auxiliary and not optimized;
293 // it will disappear when the t(r) will be
294 // available in the MuonCalib framework
295 void display_segment(MuonCalibSegment *segment, std::ofstream &outfile, const CurvedLine *curved_segment);
296 // write out a simple PAW macro displaying the
297 // segment; if the pointer "curved_segment" equals
298 // 0, a straight line as stored in segment is drawn;
299 // the curved line is used otherwise
300 std::shared_ptr<RtRelationLookUp> performParabolicExtrapolation(const bool &min, const bool &max, const IRtRelation &in_rt);
301 // use parabolic extrapolations on the given r-t
302 // relationship in_rt;
303 // min: if true, use parabolic extrapolation towards
304 // r=0;
305 // max: if true, use parabolic extrapolation towards
306 // r=r_max;
307 };
308
309} // namespace MuonCalib
310
311#endif
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
This class describes a curved line in an MDT chamber.
This class searches for the best hit combination for a parabolic curved segment fit and fits a parabo...
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::unique_ptr< TH2F > m_residuals_initial_all
std::unique_ptr< TH2F > m_driftTime_initial
std::unique_ptr< TH1F > m_pull_final
bool converged() const
returns true, if the autocalibration has converged
int iteration() const
get the number of the current iteration
virtual MdtCalibOutputPtr getResults() const override
returns the final r-t relationship
void setEstimateRtAccuracy(const double acc)
set the estimated r-t accuracy =acc
std::unique_ptr< MultilayerRtDifference > m_multilayer_rt_difference
void setInput(const IMdtCalibrationOutput *rt_input) override
set the r-t relationship, the internal autocalibration objects are reset
int numberOfSegments() const
get the number of segments which were passed to the algorithm
std::unique_ptr< TH1F > m_pull_initial
bool smoothing() const
returns true, if the r-t relationship will be smoothened using the conventional autocalibration after...
void switch_off_control_histograms()
the algorithm does not produce controll histograms (this is the default)
void noParabolicExtrapolation()
no parabolic extrapolation is done
std::unique_ptr< BaseFunction > m_base_function
bool handleSegment(MuonCalibSegment &seg)
analyse the segment "seg" (this method was required before MdtCalibInterfaces-00-01-06)
std::shared_ptr< RtCalibrationOutput > m_output
std::unique_ptr< TH2F > m_residuals_final
std::unique_ptr< TFile > m_tfile
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...
void noSmoothing()
do not smoothen the r-t relationship after convergence
void doNotForceMonotony()
do not force r(t) to be monotonically increasing
void init(const double rt_accuracy, const unsigned int &func_type, const unsigned int &ord, const bool &fix_min, const bool &fix_max, const int &max_it, bool do_parabolic_extrapolation, bool do_smoothing, bool do_multilayer_rt_scale)
std::vector< CLHEP::HepVector > m_U
std::unique_ptr< TH2F > m_residuals_initial
double reliability() const
get the reliability of the final r-t relationship: 0: no convergence yet 1: convergence,...
bool analyse(const MuonSegVec &seg)
perform the autocalibration with the segments acquired so far
void forceMonotony()
force r(t) to be monotonically increasing (this is default)
std::shared_ptr< RtRelationLookUp > performParabolicExtrapolation(const bool &min, const bool &max, const IRtRelation &in_rt)
std::unique_ptr< TH1F > m_nb_segment_hits
MdtCalibOutputPtr analyseSegments(const MuonSegVec &seg) override
perform the full autocalibration including iterations (required since MdtCalibInterfaces-00-01-06)
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...
std::unique_ptr< TH2F > m_driftTime_final
void doParabolicExtrapolation()
requires that parabolic extrapolation will be used for small and large radii
void fullMatrix(const bool &yes_or_no)
yes_or_no=true: the full matrix relating the errors in the r-t relationship to the residuals is used ...
void doSmoothing()
requires that the r-t relationship will be smoothened using the conventional autocalibration after co...
std::unique_ptr< TH1F > m_cut_evolution
std::unique_ptr< CurvedPatRec > m_tracker
RtCalibrationCurved(const std::string &name)
Default constructor: r-t accuracy is set to 0.5 mm.
int numberOfSegmentsUsed() const
get the number of segments which are used in the autocalibration
void display_segment(MuonCalibSegment *segment, std::ofstream &outfile, const CurvedLine *curved_segment)
std::vector< CLHEP::HepVector > m_U_weighted
std::unique_ptr< TH2F > m_adc_vs_residual_final
std::shared_ptr< const IRtRelation > m_rt
std::shared_ptr< IRtRelation > m_rt_new
int r
Definition globals.cxx:22
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.