ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsData
src
BinnedRtRelation.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TRT_ConditionsData/BinnedRtRelation.h
"
6
#include <algorithm>
7
#include <climits>
8
9
namespace
TRTCond
10
{
11
12
13
14
bool
BinnedRtRelation::isequal
(
const
RtRelation
& rhs)
const
15
{
16
const
BinnedRtRelation
* rhscast=
dynamic_cast<
const
BinnedRtRelation
*
>
(&rhs) ;
17
return
rhscast!=
nullptr
&& *
this
==*rhscast ;
18
}
19
20
21
float
BinnedRtRelation::radius
(
float
time )
const
22
{
23
float
r
(0) ;
24
if
( time <=
m_tmin
)
r
=
m_values
.front() ;
25
else
if
(time >=
m_tmax
)
r
=
m_values
.back() ;
26
else
{
27
// interpolate
28
float
rtimebin = (time -
m_tmin
) /
binsize
() ;
29
size_t
timebin = int(rtimebin) ;
30
float
fracbin = rtimebin - timebin ;
31
r
= (1-fracbin)*
m_values
[timebin] + fracbin*
m_values
[timebin+1] ;
32
}
33
return
r
;
34
}
35
36
float
BinnedRtRelation::drdt
(
float
time )
const
37
{
38
float
dt =
binsize
() ;
39
int
timebin = int((time -
m_tmin
) / dt) ;
40
if
( time <=
m_tmin
)
return
0 ;
41
else
if
(time >=
m_tmax
)
return
0 ;
42
else
return
(
m_values
[timebin+1]-
m_values
[timebin])/dt ;
43
}
44
45
float
BinnedRtRelation::drifttime
(
float
r
)
const
46
{
47
double
t ;
48
if
(
r
<=
m_values
.front()) t =
m_tmin
;
49
else
if
(
r
>=
m_values
.back()) t =
m_tmax
;
50
else
{
51
// first find the bin with a binary search
52
std::vector<float>::const_iterator it = std::lower_bound(
m_values
.begin(),
m_values
.end(),
r
) ;
53
size_t
timebin = it -
m_values
.begin() - 1 ;
54
// fraction in this bin
55
float
fracbin = (
r
-
m_values
[timebin])/(
m_values
[timebin+1]-
m_values
[timebin]) ;
56
// now get the time
57
t =
m_tmin
+
binsize
() * (timebin + fracbin) ;
58
}
59
return
t ;
60
}
61
62
std::ostream&
BinnedRtRelation::write
( std::ostream& os )
const
63
{
64
os <<
m_tmin
<<
" "
<<
m_tmax
<<
" "
<<
m_values
.size() <<
" "
;
65
for
(
float
value :
m_values
) os << value <<
" "
;
66
return
os ;
67
}
68
69
std::istream&
BinnedRtRelation::read
( std::istream& is )
70
{
71
size_t
n(0) ;
72
is >>
m_tmin
>>
m_tmax
>> n ;
73
if
(n<UINT_MAX){
74
m_values
.resize(n) ;
75
for
(
size_t
i=0; i<n; ++i) is >>
m_values
[i] ;
76
}
77
return
is ;
78
}
79
80
}
BinnedRtRelation.h
TRTCond::BinnedRtRelation::read
virtual std::istream & read(std::istream &)
read from to ascii ostream
Definition
BinnedRtRelation.cxx:69
TRTCond::BinnedRtRelation::m_values
std::vector< float > m_values
number of elements
Definition
BinnedRtRelation.h:87
TRTCond::BinnedRtRelation::isequal
virtual bool isequal(const RtRelation &rhs) const
equality operator
Definition
BinnedRtRelation.cxx:14
TRTCond::BinnedRtRelation::m_tmin
float m_tmin
minimum drifttime
Definition
BinnedRtRelation.h:85
TRTCond::BinnedRtRelation::m_tmax
float m_tmax
maximum drifttime
Definition
BinnedRtRelation.h:86
TRTCond::BinnedRtRelation::binsize
float binsize() const
get access to bin size
Definition
BinnedRtRelation.h:81
TRTCond::BinnedRtRelation::drdt
virtual float drdt(float driftime) const
driftvelocity for given drifttime
Definition
BinnedRtRelation.cxx:36
TRTCond::BinnedRtRelation::radius
virtual float radius(float driftime) const
radius for given drifttime
Definition
BinnedRtRelation.cxx:21
TRTCond::BinnedRtRelation::write
virtual std::ostream & write(std::ostream &) const
write to ascii ostream
Definition
BinnedRtRelation.cxx:62
TRTCond::BinnedRtRelation::drifttime
virtual float drifttime(float radius) const
drifttime for given radius
Definition
BinnedRtRelation.cxx:45
TRTCond::BinnedRtRelation::BinnedRtRelation
BinnedRtRelation()
default constructor
Definition
BinnedRtRelation.h:30
TRTCond::RtRelation::RtRelation
RtRelation()=default
constructors, desctructors, cloners
r
int r
Definition
globals.cxx:22
TRTCond
Definition
BasicRtRelation.cxx:8
Generated on
for ATLAS Offline Software by
1.17.0