ATLAS Offline Software
MuonSpectrometer
MuonCalib
MuonCalibUtils
MuonCalibMath
src
PolygonBase.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 <iostream>
6
#include <cstdlib>
7
#include "
MuonCalibMath/PolygonBase.h
"
8
#include <TString.h>
// for Form
9
10
using namespace
MuonCalib
;
11
12
void
PolygonBase::init
(
const
std::vector<double> &
x
) {
13
15
// CHECK FOR CORRECT FILLING //
17
18
for
(
unsigned
int
k
=0;
k
<
x
.size()-1;
k
++) {
19
if
(
x
[
k
]>=
x
[
k
+1]) {
20
throw
std::runtime_error(Form(
"File: %s, Line: %d\nPolygonBase::init - Abscissae not in increasing order!"
, __FILE__, __LINE__));
21
}
22
}
23
25
// TRANSFER THE INPUT DATA //
27
28
m_x
=
x
;
29
30
return
;
31
32
}
33
34
//*****************************************************************************
35
36
//::::::::::::::::::
37
//:: METHOD value ::
38
//::::::::::::::::::
39
40
double
PolygonBase::value
(
const
int
&
k
,
const
double
&
x
)
const
{
41
43
// CHECK THE BASE FUNCTION INDEX //
45
46
if
(k<0 || k>
static_cast<
int
>
(
m_x
.size()-1)) {
47
throw
std::runtime_error(Form(
"File: %s, Line: %d\nPolygonBase::value - Illegal function index %i! Should be >0 and <%lu"
, __FILE__, __LINE__,
k
,
m_x
.size()));
48
}
49
51
// CALCULATE THE VALUE OF THE BASE FUNCTION //
53
54
// outside the domain of the polygon //
55
if
(
x
<
m_x
[0] ||
x
>
m_x
[
m_x
.size()-1]) {
56
return
0.0;
57
}
58
59
// inside the domain of the polygon //
60
if
(
k
==0 &&
x
<
m_x
[0]) {
61
return
0.0;
62
}
63
if
(
k
==0 &&
x
<=
m_x
[1]) {
64
return
(
m_x
[1]-
x
)/(
m_x
[1]-
m_x
[0]);
65
}
66
if
(
k
==0 &&
x
>
m_x
[1]) {
67
return
0.0;
68
}
69
70
if
(
static_cast<
unsigned
int
>
(
k
)==
m_x
.size()-1 &&
71
x
<=
m_x
[
m_x
.size()-2]) {
72
return
0.0;
73
}
74
if
(
static_cast<
unsigned
int
>
(
k
)==
m_x
.size()-1 &&
75
x
<=
m_x
[
m_x
.size()-1]) {
76
return
(
x
-
m_x
[
k
-1])/(
m_x
[
k
]-
m_x
[
k
-1]);
77
}
78
if
(
static_cast<
unsigned
int
>
(
k
)==
m_x
.size()-1 &&
79
x
>
m_x
[
m_x
.size()-1]) {
80
return
0.0;
81
}
82
83
if
(
x
<
m_x
[
k
-1] ||
x
>
m_x
[
k
+1]) {
84
return
0.0;
85
}
86
87
if
(
x
<
m_x
[
k
]) {
88
return
(
x
-
m_x
[
k
-1])/(
m_x
[
k
]-
m_x
[
k
-1]);
89
}
90
91
return
(
m_x
[
k
+1]-
x
)/(
m_x
[
k
+1]-
m_x
[
k
]);
92
93
}
MuonCalib::PolygonBase::init
void init(const std::vector< double > &x)
Definition:
PolygonBase.cxx:12
x
#define x
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition:
CscCalcPed.cxx:22
MuonCalib::PolygonBase::value
double value(const int &k, const double &x) const
get the value of the k-th base
Definition:
PolygonBase.cxx:40
MuonCalib::PolygonBase::m_x
std::vector< double > m_x
Definition:
PolygonBase.h:59
PolygonBase.h
fitman.k
k
Definition:
fitman.py:528
Generated on Thu Jul 4 2024 21:24:46 for ATLAS Offline Software by
1.8.18