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  if (fitter.fit_parameters(my_points, 1, sample_points.size(), &chebyshev)) {
61  MsgStream log(Athena::getMessageSvc(), "RtFromPoints");
62  log << MSG::WARNING << "Class RtFromPoints, method getRtChebyshev: Could not determine Chebyshev coefficients." << endmsg;
63  }
64  for (unsigned int k = 0; k < order + 1; k++) { rt_param[k + 2] = fitter.coefficients()[k]; }
65 
67  // CREATE AN RtChebyshev OBJECT WITH THE CORRECT PARAMETERS //
69  RtChebyshev rt_chebyshev(rt_param);
70  return rt_chebyshev;
71 } // end RtFromPoints::getRtChebyshev
72 
73 //*****************************************************************************
74 
75 //::::::::::::::::::::::::::::::::
76 //:: METHOD getRtRelationLookUp ::
77 //::::::::::::::::::::::::::::::::
78 RtRelationLookUp RtFromPoints::getRtRelationLookUp(const std::vector<SamplePoint> &sample_points) {
79  // create spline rt relation
80  CalibFunc ::ParVec pars(2 * sample_points.size());
81  for (unsigned int i = 0; i < sample_points.size(); i++) {
82  pars[2 * i] = sample_points[i].x1();
83  pars[2 * i + 1] = sample_points[i].x2();
84  }
85  RtSpline rt(pars);
86 
87  // variables
88  unsigned int nb_points(100); // number of (r, t) points
89  double bin_width((rt.tUpper() - rt.tLower()) / static_cast<double>(nb_points - 1)); // step size
90  std::vector<double> rt_param(nb_points + 2); // r-t parameters
91 
93  // CREATE AN RtRelationLookUp OBJECT WITH THE CORRECT PARAMETERS //
95  rt_param[0] = rt.tLower();
96  rt_param[1] = bin_width;
97  for (unsigned int k = 0; k < nb_points; k++) { rt_param[k + 2] = rt.radius(rt.tLower() + k * bin_width); }
98  RtRelationLookUp rt_relation_look_up(rt_param);
99 
100  return rt_relation_look_up;
101 }
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:29
CheckAppliedSFs.bin_width
bin_width
Definition: CheckAppliedSFs.py:242
MuonCalib::RtChebyshev
Definition: RtChebyshev.h:52
RtSpline.h
MuonCalib::RtRelationLookUp
Equidistant look up table for rt-relations with the time as key.
Definition: RtRelationLookUp.h:24
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::RtSpline::radius
double radius(double t) const
get the radius corresponding to the drift time t; 0 or 14.6 is returned if t is outside the range
Definition: RtSpline.cxx:49
MuonCalib::BaseFunctionFitter
Definition: BaseFunctionFitter.h:47
MuonCalib::RtFromPoints::getRtRelationLookUp
static RtRelationLookUp getRtRelationLookUp(const std::vector< SamplePoint > &sample_points)
Definition: RtFromPoints.cxx:78
MuonCalib::CalibFunc::ParVec
std::vector< double > ParVec
Definition: CalibFunc.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
RtFromPoints.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
mc.order
order
Configure Herwig7.
Definition: mc.Herwig7_Dijet.py:12
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
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
MuonCalib::RtSpline::tLower
double tLower(void) const
get the lower drift-time bound
Definition: RtSpline.cxx:59
BaseFunctionFitter.h
MuonCalib::RtSpline
Definition: RtSpline.h:45
ChebyshevPolynomial.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::RtSpline::tUpper
double tUpper(void) const
get the upper drift-time bound
Definition: RtSpline.cxx:61
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