ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCalib
MdtCalib
MdtCalibRt
src
RtParabolicExtrapolation.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MdtCalibRt/RtParabolicExtrapolation.h
"
6
7
#include "
AthenaKernel/getMessageSvc.h
"
8
#include "GaudiKernel/MsgStream.h"
9
#include "
MdtCalibData/IRtRelation.h
"
10
#include "
MdtCalibData/RtRelationLookUp.h
"
11
#include "
MuonCalibMath/BaseFunctionFitter.h
"
12
#include "
MuonCalibMath/LegendrePolynomial.h
"
13
14
using namespace
MuonCalib
;
15
16
RtParabolicExtrapolation::RtParabolicExtrapolation
() =
default
;
17
18
//*****************************************************************************
19
20
//:::::::::::::::::::::::::::::::::::::::::::::::::::
21
//:: METHOD getRtWithParabolicExtrapolation(.,.,.) ::
22
//:::::::::::::::::::::::::::::::::::::::::::::::::::
23
24
RtRelationLookUp
RtParabolicExtrapolation::getRtWithParabolicExtrapolation
(
const
IRtRelation
& in_rt,
const
double
r_min,
25
const
double
r_max)
const
{
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);
33
BaseFunctionFitter
fitter(3);
34
LegendrePolynomial
pol;
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
}
65
66
//*****************************************************************************
67
68
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::
69
//:: METHOD getRtWithParabolicExtrapolation(.,.,.,.,.) ::
70
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::
71
72
RtRelationLookUp
RtParabolicExtrapolation::getRtWithParabolicExtrapolation
(
const
IRtRelation
& in_rt,
const
double
r_min,
73
const
double
r_max,
const
double
r_ext,
74
const
std::vector<SamplePoint>& add_fit_points)
const
{
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);
83
BaseFunctionFitter
fitter(3);
84
LegendrePolynomial
pol;
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
}
148
149
//*****************************************************************************
150
151
//:::::::::::::::::::::
152
//:: METHOD t_from_r ::
153
//:::::::::::::::::::::
154
155
double
RtParabolicExtrapolation::t_from_r
(
const
double
r
,
const
IRtRelation
& in_rt)
const
{
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
}
178
179
//*****************************************************************************
180
181
//:::::::::::::::::::::::::::
182
//:: METHOD get_max_t_at_r ::
183
//:::::::::::::::::::::::::::
184
185
double
RtParabolicExtrapolation::get_max_t_at_r
(
const
double
r
,
const
IRtRelation
& in_rt)
const
{
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
BaseFunctionFitter.h
IRtRelation.h
LegendrePolynomial.h
RtParabolicExtrapolation.h
RtRelationLookUp.h
MuonCalib::BaseFunctionFitter
This class performs a fit of a linear combination of base functions to a set of sample points.
Definition
BaseFunctionFitter.h:39
MuonCalib::IRtRelation
generic interface for a rt-relation
Definition
IRtRelation.h:19
MuonCalib::IRtRelation::tLower
virtual double tLower() const =0
Returns the lower time covered by the r-t.
MuonCalib::IRtRelation::radius
virtual double radius(double t) const =0
returns drift radius for a given time
MuonCalib::IRtRelation::tUpper
virtual double tUpper() const =0
Returns the upper time covered by the r-t.
MuonCalib::LegendrePolynomial
This class provides a legendre polynomial of order k.
Definition
LegendrePolynomial.h:19
MuonCalib::LegendrePolynomial::value
double value(const int k, const double x) const override final
get the value of the k-th base function at x
Definition
LegendrePolynomial.cxx:10
MuonCalib::RtParabolicExtrapolation::t_from_r
double t_from_r(const double r, const IRtRelation &in_rt) const
Definition
RtParabolicExtrapolation.cxx:155
MuonCalib::RtParabolicExtrapolation::RtParabolicExtrapolation
RtParabolicExtrapolation()
Default constructor.
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
MuonCalib::RtParabolicExtrapolation::getRtWithParabolicExtrapolation
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) ...
Definition
RtParabolicExtrapolation.cxx:24
MuonCalib::RtRelationLookUp
Equidistant look up table for rt-relations with the time as key.
Definition
RtRelationLookUp.h:23
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
r
int r
Definition
globals.cxx:22
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition
CscCalcPed.cxx:21
Generated on
for ATLAS Offline Software by
1.17.0