ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
eflowRec
src
eflowUtil.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/*
6
* eflowUtil.h
7
*
8
* Created on: 09.08.2013
9
* Author: tlodd
10
*/
11
12
#ifndef EFLOWREC_EFLOWUTIL_H
13
#define EFLOWREC_EFLOWUTIL_H
14
15
#include <cmath>
16
#include <string>
17
21
class
eflowAzimuth
{
22
public
:
23
eflowAzimuth
(
double
phi
):
m_value
(
phi
) {
if
(
phi
!= -999. && !std::isnan(
phi
))
adjustRange
(); }
24
25
inline
double
operator ()
()
const
{
return
m_value
; }
26
inline
double
operator =
(
double
phi
) {
27
m_value
=
phi
;
28
adjustRange
();
29
return
m_value
;
30
}
31
32
inline
eflowAzimuth
operator +=
(
double
deltaPhi
) {
33
m_value
+=
deltaPhi
;
34
adjustRange
();
35
return
*
this
;
36
}
37
inline
eflowAzimuth
operator -=
(
double
deltaPhi
) {
38
m_value
-=
deltaPhi
;
39
adjustRange
();
40
return
*
this
;
41
}
42
43
inline
double
getAbsDifference
(
const
eflowAzimuth
& other)
const
{
44
double
plainAbsDifference = std::abs(
m_value
- other.m_value);
45
return
plainAbsDifference <=
M_PI
? plainAbsDifference : 2*
M_PI
- plainAbsDifference;
46
}
47
48
inline
double
cycle
(
const
eflowAzimuth
& other) {
return
cycle
(other.m_value); }
49
inline
double
cycle
(
double
phi
) {
50
double
plainDifference =
phi
-
m_value
;
51
if
(plainDifference >
M_PI
) {
52
return
m_value
+2.0*
M_PI
;
53
}
else
if
(plainDifference < -
M_PI
) {
54
return
m_value
-2.0*
M_PI
;
55
}
else
{
56
return
m_value
;
57
}
58
}
59
60
private
:
61
double
m_value
{};
62
63
inline
double
adjustRange
(
double
a
) {
64
if
(
a
<= -
M_PI
) {
65
return
a
+(2*
M_PI
*std::floor(-(
a
-
M_PI
)/(2*
M_PI
)));
66
}
else
if
(
a
>
M_PI
) {
67
return
a
-(2*
M_PI
*std::floor((
a
+
M_PI
)/(2*
M_PI
)));
68
}
else
{
69
return
a
;
70
}
71
}
72
inline
void
adjustRange
() {
73
if
(
m_value
<= -
M_PI
) {
74
m_value
+=(2*
M_PI
*std::floor(-(
m_value
-
M_PI
)/(2*
M_PI
)));
75
}
else
if
(
m_value
>
M_PI
) {
76
m_value
-=(2*
M_PI
*std::floor((
m_value
+
M_PI
)/(2*
M_PI
)));
77
}
78
}
79
80
};
81
82
class
eflowEtaPhiPosition
{
83
public
:
84
eflowEtaPhiPosition
() =
default
;
85
eflowEtaPhiPosition
(
double
eta
,
double
phi
):
m_eta
(
eta
),
m_phi
(
phi
) {}
86
87
inline
double
getEta
()
const
{
return
m_eta
; }
88
inline
eflowAzimuth
getPhi
()
const
{
return
m_phi
; }
89
inline
double
getPhiD
()
const
{
return
m_phi
(); }
90
91
inline
double
dRSq
(
const
eflowEtaPhiPosition
& other)
const
{
92
double
dEta(
m_eta
-other.m_eta);
93
double
dPhi(
m_phi
.getAbsDifference(other.m_phi));
94
return
dEta*dEta + dPhi*dPhi;
95
}
96
inline
double
dR
(
const
eflowEtaPhiPosition
& other)
const
{
return
std::sqrt(this->
dRSq
(other)); }
97
98
private
:
99
double
m_eta
{NAN};
100
eflowAzimuth
m_phi
{NAN};
101
};
102
106
template
<
class
T>
107
class
eflowRangeBase
{
108
public
:
109
eflowRangeBase
() =
default
;
110
eflowRangeBase
(
const
T&
min
,
const
T&
max
):
m_min
(
min
),
m_max
(
max
) { }
111
112
inline
void
setCenterAndWidth
(T center,
double
width
) {
m_min
= center -
width
/2;
m_max
=
m_min
+
width
; }
113
inline
void
shift
(
double
shift
) {
m_min
+=
shift
;
m_max
+=
shift
; }
114
115
inline
T
getMax
()
const
{
return
m_max
; }
116
inline
T
getMin
()
const
{
return
m_min
; }
117
118
inline
T
getCenter
()
const
{
return
(
m_max
+
m_min
)/2; }
119
inline
T
getWidth
()
const
{
return
(
m_max
-
m_min
); }
120
121
bool
contains
(
const
T&
x
) {
return
( (
m_min
<
x
) && (
m_max
>
x
) ); }
122
123
std::string
print
()
const
{
124
std::string result =
"["
;
125
result += std::to_string(
m_min
);
126
result +=
", "
;
127
result += std::to_string(
m_max
);
128
result +=
']'
;
129
return
result;
130
}
131
132
private
:
133
T
m_min
{NAN};
134
T
m_max
{NAN};
135
};
136
typedef
eflowRangeBase<double>
eflowRange
;
137
138
#endif
/* EFLOWREC_EFLOWUTIL_H */
M_PI
#define M_PI
Definition
ActiveFraction.h:14
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
deltaPhi
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Definition
AmgMatrixBasePlugin.h:112
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
width
const double width
Definition
TTileTripReader.cxx:24
x
#define x
min
#define min(a, b)
Definition
cfImp.cxx:40
max
#define max(a, b)
Definition
cfImp.cxx:41
eflowAzimuth
eflowAzimuth represents phi and has kinematic functions which correctly deal with phi wraparound etc.
Definition
eflowUtil.h:21
eflowAzimuth::operator-=
eflowAzimuth operator-=(double deltaPhi)
Definition
eflowUtil.h:37
eflowAzimuth::cycle
double cycle(const eflowAzimuth &other)
Definition
eflowUtil.h:48
eflowAzimuth::adjustRange
void adjustRange()
Definition
eflowUtil.h:72
eflowAzimuth::operator+=
eflowAzimuth operator+=(double deltaPhi)
Definition
eflowUtil.h:32
eflowAzimuth::m_value
double m_value
Definition
eflowUtil.h:61
eflowAzimuth::getAbsDifference
double getAbsDifference(const eflowAzimuth &other) const
Definition
eflowUtil.h:43
eflowAzimuth::operator=
double operator=(double phi)
Definition
eflowUtil.h:26
eflowAzimuth::operator()
double operator()() const
Definition
eflowUtil.h:25
eflowAzimuth::adjustRange
double adjustRange(double a)
Definition
eflowUtil.h:63
eflowAzimuth::eflowAzimuth
eflowAzimuth(double phi)
Definition
eflowUtil.h:23
eflowAzimuth::cycle
double cycle(double phi)
Definition
eflowUtil.h:49
eflowEtaPhiPosition::getPhi
eflowAzimuth getPhi() const
Definition
eflowUtil.h:88
eflowEtaPhiPosition::eflowEtaPhiPosition
eflowEtaPhiPosition(double eta, double phi)
Definition
eflowUtil.h:85
eflowEtaPhiPosition::dR
double dR(const eflowEtaPhiPosition &other) const
Definition
eflowUtil.h:96
eflowEtaPhiPosition::dRSq
double dRSq(const eflowEtaPhiPosition &other) const
Definition
eflowUtil.h:91
eflowEtaPhiPosition::getPhiD
double getPhiD() const
Definition
eflowUtil.h:89
eflowEtaPhiPosition::eflowEtaPhiPosition
eflowEtaPhiPosition()=default
eflowEtaPhiPosition::m_phi
eflowAzimuth m_phi
Definition
eflowUtil.h:100
eflowEtaPhiPosition::m_eta
double m_eta
Definition
eflowUtil.h:99
eflowEtaPhiPosition::getEta
double getEta() const
Definition
eflowUtil.h:87
eflowRangeBase
eflowRangeBase is an object to represent a length in eta or phi, and this is used in eflowCellIntegra...
Definition
eflowUtil.h:107
eflowRangeBase::getMin
T getMin() const
Definition
eflowUtil.h:116
eflowRangeBase::getMax
T getMax() const
Definition
eflowUtil.h:115
eflowRangeBase::eflowRangeBase
eflowRangeBase()=default
eflowRangeBase::shift
void shift(double shift)
Definition
eflowUtil.h:113
eflowRangeBase::getWidth
T getWidth() const
Definition
eflowUtil.h:119
eflowRangeBase< double >::m_min
double m_min
Definition
eflowUtil.h:133
eflowRangeBase::contains
bool contains(const T &x)
Definition
eflowUtil.h:121
eflowRangeBase::setCenterAndWidth
void setCenterAndWidth(T center, double width)
Definition
eflowUtil.h:112
eflowRangeBase::print
std::string print() const
Definition
eflowUtil.h:123
eflowRangeBase::getCenter
T getCenter() const
Definition
eflowUtil.h:118
eflowRangeBase::eflowRangeBase
eflowRangeBase(const T &min, const T &max)
Definition
eflowUtil.h:110
eflowRangeBase< double >::m_max
double m_max
Definition
eflowUtil.h:134
eflowRange
eflowRangeBase< double > eflowRange
Definition
eflowUtil.h:136
Generated on
for ATLAS Offline Software by
1.17.0