ATLAS Offline Software
Public Member Functions | Private Member Functions | List of all members
MuonCalib::RtParabolicExtrapolation Class Reference

#include <RtParabolicExtrapolation.h>

Collaboration diagram for MuonCalib::RtParabolicExtrapolation:

Public Member Functions

 RtParabolicExtrapolation (void)
 Default constructor. More...
 
RtRelationLookUp getRtWithParabolicExtrapolation (const IRtRelation &in_rt, const double &r_min=13.0, const double &r_max=14.0) const
 get an r-t relationship which is equivalent to the input relationship in_rt for r<r_min and has r(t) for r>r_max according to a parabola fitted in [r_min, r_max]; this method is there for backward compatibility More...
 
RtRelationLookUp getRtWithParabolicExtrapolation (const IRtRelation &in_rt, const double &r_min, const double &r_max, const double &r_ext, const std::vector< SamplePoint > &add_fit_points) const
 The method fits a parabola to the r-t points in $[r_{min}, r_{max}]$ and the additional user points add_fit_points. More...
 

Private Member Functions

double t_from_r (const double &r, const IRtRelation &in_rt) const
 
double get_max_t_at_r (const double &r, const IRtRelation &in_rt) const
 

Detailed Description

Definition at line 27 of file RtParabolicExtrapolation.h.

Constructor & Destructor Documentation

◆ RtParabolicExtrapolation()

RtParabolicExtrapolation::RtParabolicExtrapolation ( void  )

Default constructor.

Definition at line 16 of file RtParabolicExtrapolation.cxx.

16 {}

Member Function Documentation

◆ get_max_t_at_r()

double RtParabolicExtrapolation::get_max_t_at_r ( const double &  r,
const IRtRelation in_rt 
) const
private

Definition at line 185 of file RtParabolicExtrapolation.cxx.

185  {
186  for (double t = in_rt.tUpper(); t >= in_rt.tLower(); t = t - 1.0) {
187  if (in_rt.radius(t) < r) { return t + 1.0; }
188  }
189  return in_rt.tLower();
190 }

◆ getRtWithParabolicExtrapolation() [1/2]

RtRelationLookUp RtParabolicExtrapolation::getRtWithParabolicExtrapolation ( const IRtRelation in_rt,
const double &  r_min,
const double &  r_max,
const double &  r_ext,
const std::vector< SamplePoint > &  add_fit_points 
) const

The method fits a parabola to the r-t points in $[r_{min}, r_{max}]$ and the additional user points add_fit_points.

The input r-t relationship in_rt is replaced by the parabola in $[r_{ext}, r_{min}]$ is $r_{ext}<r_{min}$ and in $[r_{max}, r_{ext}]$ if $r_{ext}>r_{max}$.

Definition at line 72 of file RtParabolicExtrapolation.cxx.

74  {
76  // VARIABLES //
78 
79  // double t_min(t_from_r(r_min, in_rt));
80  double t_min(get_max_t_at_r(r_min, in_rt));
81  double t_max(t_from_r(r_max, in_rt));
82  std::vector<SamplePoint> t_r(10);
85  std::vector<double> rt_param(102); // parameters of the output r-t relationship
86  double r, t; // drift radius, drift time
87 
89  // FILL SAMPLE POINTS //
91 
92  double step_size((t_max - t_min) / static_cast<double>(t_r.size() - 1));
93 
94  // r-t-points in fit region
95  for (unsigned int k = 0; k < t_r.size(); k++) {
96  t_r[k].set_x1(t_min + k * step_size);
97  t_r[k].set_x2(in_rt.radius(t_min + k * step_size));
98  t_r[k].set_error(1.0);
99  }
100 
101  // addtional points for the fit
102  for (const auto & add_fit_point : add_fit_points) { t_r.push_back(add_fit_point); }
103 
104  // perform fit //
105  fitter.fit_parameters(t_r, 1, t_r.size(), &pol);
106 
107  // bring r-t-points in the right format for RtRelationLookUp and fill non
108  // modified and extrapolated points in the r-t
109  rt_param[0] = in_rt.tLower();
110  rt_param[1] = (in_rt.tUpper() - in_rt.tLower()) / 99.0;
111  for (unsigned int k = 0; k < 100; k++) {
112  t = rt_param[0] + rt_param[1] * k;
113  r = in_rt.radius(t);
114 
115  // distinguish if extrapolation area is right or left from fit region
116  if (r_ext < r_min) {
117  if (r > r_min && t > t_min) {
118  rt_param[k + 2] = r; // fill original values
119  } else {
120  rt_param[k + 2] = 0.0;
121  for (unsigned int l = 0; l < 3; l++) { // fill extrapolated values
122  rt_param[k + 2] = rt_param[k + 2] + fitter.coefficients()[l] * pol.value(l, t);
123  }
124  if (rt_param[k + 2] < 0.0) { rt_param[k + 2] = 0.0; }
125  }
126  } else if (r_ext > r_max) {
127  if (r < r_max) {
128  rt_param[k + 2] = r; // fill original values
129  } else {
130  rt_param[k + 2] = 0.0;
131  for (unsigned int l = 0; l < 3; l++) { // fill extrapolated values
132  rt_param[k + 2] = rt_param[k + 2] + fitter.coefficients()[l] * pol.value(l, t);
133  }
134  }
135  }
136  // fill only original values if the radius where we want to extrapolate to is
137  // within the fit region
138  else if (r_ext <= r_max && r_ext >= r_min) {
139  rt_param[k + 2] = r;
140  MsgStream log(Athena::getMessageSvc(), "RtParabolicExtrapolation");
141  log << MSG::WARNING << "getRtWithParabolicExtrapolation() - Extrapolated radius withing fit region - Nothing to be done."
142  << endmsg;
143  }
144  }
145 
146  return RtRelationLookUp(rt_param);
147 }

◆ getRtWithParabolicExtrapolation() [2/2]

RtRelationLookUp RtParabolicExtrapolation::getRtWithParabolicExtrapolation ( const IRtRelation in_rt,
const double &  r_min = 13.0,
const double &  r_max = 14.0 
) const

get an r-t relationship which is equivalent to the input relationship in_rt for r<r_min and has r(t) for r>r_max according to a parabola fitted in [r_min, r_max]; this method is there for backward compatibility

Definition at line 24 of file RtParabolicExtrapolation.cxx.

25  {
27  // VARIABLES //
29 
30  double t_min(t_from_r(r_min, in_rt));
31  double t_max(t_from_r(r_max, in_rt));
32  std::vector<SamplePoint> t_r(10);
35  std::vector<double> rt_param(102); // parameters of the output r-t relationship
36  double r, t; // drift radius
37 
39  // FILL SAMPLE POINTS //
41 
42  double step_size((t_max - t_min) / static_cast<double>(t_r.size() - 1));
43  for (unsigned int k = 0; k < t_r.size(); k++) {
44  t_r[k].set_x1(t_min + k * step_size);
45  t_r[k].set_x2(in_rt.radius(t_min + k * step_size));
46  t_r[k].set_error(1.0);
47  }
48  fitter.fit_parameters(t_r, 1, t_r.size(), &pol);
49 
50  rt_param[0] = in_rt.tLower();
51  rt_param[1] = (in_rt.tUpper() - in_rt.tLower()) / 99.0;
52  for (unsigned int k = 0; k < 100; k++) {
53  t = rt_param[0] + rt_param[1] * k;
54  r = in_rt.radius(t);
55  if (r < r_min) {
56  rt_param[k + 2] = r;
57  } else {
58  rt_param[k + 2] = 0.0;
59  for (unsigned int l = 0; l < 3; l++) { rt_param[k + 2] = rt_param[k + 2] + fitter.coefficients()[l] * pol.value(l, t); }
60  }
61  }
62 
63  return RtRelationLookUp(rt_param);
64 }

◆ t_from_r()

double RtParabolicExtrapolation::t_from_r ( const double &  r,
const IRtRelation in_rt 
) const
private

Definition at line 155 of file RtParabolicExtrapolation.cxx.

155  {
157  // VARIABLES //
159 
160  double precision(0.010); // spatial precision of the inversion
161  double t_max(in_rt.tUpper()); // upper time search limit
162  double t_min(in_rt.tLower()); // lower time search limit
163 
165  // SEARCH FOR THE CORRESPONDING DRIFT TIME //
167 
168  while (t_max - t_min > 0.1 && std::abs(in_rt.radius(0.5 * (t_min + t_max)) - r) > precision) {
169  if (in_rt.radius(0.5 * (t_min + t_max)) > r) {
170  t_max = 0.5 * (t_min + t_max);
171  } else {
172  t_min = 0.5 * (t_min + t_max);
173  }
174  }
175 
176  return 0.5 * (t_min + t_max);
177 }

The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
MuonCalib::RtParabolicExtrapolation::t_from_r
double t_from_r(const double &r, const IRtRelation &in_rt) const
Definition: RtParabolicExtrapolation.cxx:155
MuonCalib::IRtRelation::tUpper
virtual double tUpper(void) const =0
MuonCalib::RtParabolicExtrapolation::get_max_t_at_r
double get_max_t_at_r(const double &r, const IRtRelation &in_rt) const
Definition: RtParabolicExtrapolation.cxx:185
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
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::BaseFunctionFitter
Definition: BaseFunctionFitter.h:47
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib::IRtRelation::tLower
virtual double tLower(void) const =0
MuonCalib::LegendrePolynomial
Definition: LegendrePolynomial.h:39
MuonCalib::IRtRelation::radius
virtual double radius(double t) const =0
returns drift radius for a given time
MuonCalib::LegendrePolynomial::value
double value(const int &k, const double &x) const
get the value of the k-th base function at x
Definition: LegendrePolynomial.cxx:32
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
fitman.k
k
Definition: fitman.py:528