ATLAS Offline Software
RtFromPoints.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 #include "GaudiKernel/MsgStream.h"
13 
14 using namespace MuonCalib;
15 
16 //*****************************************************************************
17 
18 //::::::::::::::::::::::::
19 //:: METHOD get_min_max ::
20 //::::::::::::::::::::::::
21 void RtFromPoints::get_min_max(const std::vector<SamplePoint> &sample_points, double &x_min, double &x_max) {
22  for (unsigned int k = 0; k < sample_points.size(); k++) {
23  if (k == 0) {
24  x_min = sample_points[k].x1();
25  x_max = x_min;
26  }
27  if (x_min > sample_points[k].x1()) { x_min = sample_points[k].x1(); }
28  if (x_max < sample_points[k].x1()) { x_max = sample_points[k].x1(); }
29  }
30 
31  return;
32 }
33 
34 //*****************************************************************************
35 
36 //:::::::::::::::::::::::::::
37 //:: METHOD getRtChebyshev ::
38 //:::::::::::::::::::::::::::
39 RtChebyshev RtFromPoints::getRtChebyshev(const std::vector<SamplePoint> &sample_points, const unsigned int &order) {
41  // VARIABLES //
43  std::vector<double> rt_param(order + 3); // input parameters of RtChebyshev
44  BaseFunctionFitter fitter(order + 1); // Chebyshev fitter
45  ChebyshevPolynomial chebyshev; // Chebyshev polynomial
46  std::vector<SamplePoint> my_points(sample_points); // copy of the sample to add reduced times
47 
49  // GET THE MINIMUM AND MAXIMUM TIMES AND CALCULATE REDUCED TIMES //
51  get_min_max(sample_points, rt_param[0], rt_param[1]);
52 
53  double mean(0.5 * (rt_param[1] + rt_param[0]));
54  double length(rt_param[1] - rt_param[0]);
55  for (unsigned int k = 0; k < my_points.size(); k++) { my_points[k].set_x1(2 * (sample_points[k].x1() - mean) / length); }
56 
58  // PERFORM A CHEBYSHEV FIT TO THE SAMPLE POINTS //
60  fitter.fit_parameters(my_points, 1, sample_points.size(), chebyshev);
61 
62  for (unsigned int k = 0; k < order + 1; k++) { rt_param[k + 2] = fitter.coefficients()[k]; }
63 
65  // CREATE AN RtChebyshev OBJECT WITH THE CORRECT PARAMETERS //
67  RtChebyshev rt_chebyshev(rt_param);
68  return rt_chebyshev;
69 } // end RtFromPoints::getRtChebyshev
70 
71 //*****************************************************************************
72 
73 //::::::::::::::::::::::::::::::::
74 //:: METHOD getRtRelationLookUp ::
75 //::::::::::::::::::::::::::::::::
76 RtRelationLookUp RtFromPoints::getRtRelationLookUp(const std::vector<SamplePoint> &sample_points) {
77  // create spline rt relation
78  CalibFunc ::ParVec pars(2 * sample_points.size());
79  for (unsigned int i = 0; i < sample_points.size(); i++) {
80  pars[2 * i] = sample_points[i].x1();
81  pars[2 * i + 1] = sample_points[i].x2();
82  }
83  RtSpline rt(pars);
84 
85  // variables
86  unsigned int nb_points(100); // number of (r, t) points
87  double bin_width((rt.tUpper() - rt.tLower()) / static_cast<double>(nb_points - 1)); // step size
88  std::vector<double> rt_param(nb_points + 2); // r-t parameters
89 
91  // CREATE AN RtRelationLookUp OBJECT WITH THE CORRECT PARAMETERS //
93  rt_param[0] = rt.tLower();
94  rt_param[1] = bin_width;
95  for (unsigned int k = 0; k < nb_points; k++) { rt_param[k + 2] = rt.radius(rt.tLower() + k * bin_width); }
96  RtRelationLookUp rt_relation_look_up(rt_param);
97 
98  return rt_relation_look_up;
99 }
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MuonCalib::ChebyshevPolynomial
Definition: ChebyshevPolynomial.h:17
CheckAppliedSFs.bin_width
bin_width
Definition: CheckAppliedSFs.py:242
MuonCalib::RtChebyshev
Definition: RtChebyshev.h:29
RtSpline.h
MuonCalib::RtSpline::tLower
virtual double tLower() const override final
get the lower drift-time bound
Definition: RtSpline.cxx:55
MuonCalib::RtRelationLookUp
Equidistant look up table for rt-relations with the time as key.
Definition: RtRelationLookUp.h:23
MuonCalib::BaseFunctionFitter
Definition: BaseFunctionFitter.h:39
MuonCalib::RtFromPoints::getRtRelationLookUp
static RtRelationLookUp getRtRelationLookUp(const std::vector< SamplePoint > &sample_points)
Definition: RtFromPoints.cxx:76
lumiFormat.i
int i
Definition: lumiFormat.py:85
RtFromPoints.h
mc.order
order
Configure Herwig7.
Definition: mc.Herwig7_Dijet.py:12
MuonCalib::RtSpline::tUpper
virtual double tUpper() const override final
get the upper drift-time bound
Definition: RtSpline.cxx:57
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::CalibFunc::ParVec
std::vector< double > ParVec
Definition: CalibFunc.h:35
MuonCalib::RtFromPoints::getRtChebyshev
static RtChebyshev getRtChebyshev(const std::vector< SamplePoint > &sample_points, const unsigned int &order)
< get an RtChebyshev resembling the r(t) function as described by the sample points in the vector "sa...
Definition: RtFromPoints.cxx:39
BaseFunctionFitter.h
MuonCalib::RtSpline
Definition: RtSpline.h:45
ChebyshevPolynomial.h
MuonCalib::RtFromPoints::get_min_max
static void get_min_max(const std::vector< SamplePoint > &sample_points, double &x_min, double &x_max)
Definition: RtFromPoints.cxx:21
PolygonBase.h
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
fitman.k
k
Definition: fitman.py:528
MuonCalib::RtSpline::radius
virtual double radius(double t) const override final
get the radius corresponding to the drift time t; 0 or 14.6 is returned if t is outside the range
Definition: RtSpline.cxx:42