ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoSimulationUtils
Root
Conversions.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
L1TopoSimulationUtils/Conversions.h
"
6
7
int
TSU::toTopoInteger
(
float
value,
unsigned
int
resolution) {
8
float
tmp = value*resolution;
9
float
index
;
10
if
( (abs(tmp)-0.5)/2. == std::round((abs(tmp)-0.5)/2.) ) {
11
if
( tmp>0 ) {
index
= std::floor(tmp); }
12
else
{
index
= std::ceil(tmp); }
13
}
else
{
14
index
= std::round(tmp);
15
}
16
17
return
static_cast<
int
>
(
index
);
18
}
19
20
unsigned
int
TSU::toTopoPhi
(
float
phi
) {
21
if
(
phi
< 0) {
phi
+= 2*
M_PI
; }
//Convert to [0,2pi) range so phi can eventually be treated as unsigned
22
phi
*=
TSU::phiRescaleFactor
;
23
int
phiInt =
toTopoInteger
(
phi
,
TSU::phiIntegerResolution
) % 128;
24
return
static_cast<
unsigned
int
>
(phiInt);
25
}
26
27
int
TSU::toTopoEta
(
float
eta
) {
28
return
toTopoInteger
(
eta
,
TSU::etaIntegerResolution
);
29
}
30
31
32
int
TSU::toSigned
(
unsigned
bits,
unsigned
length
) {
33
if
( ((bits >> (
length
-1)) & 1) == 0) {
//sign bit not set
34
return
bits & ((1<<
length
)-1);
35
}
36
//sign bit set, convert assuming twos complement
37
return
(bits & ((1<<
length
)-1)) - (1<<
length
);
38
}
39
40
int
TSU::toSigned
(
const
std::string& bits) {
41
return
TSU::toSigned
(std::stoi(bits,
nullptr
, 2), bits.length());
42
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
Conversions.h
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
TSU::phiIntegerResolution
static constexpr unsigned int phiIntegerResolution
Definition
Conversions.h:14
TSU::toTopoEta
int toTopoEta(float eta)
Definition
Conversions.cxx:27
TSU::toTopoPhi
unsigned int toTopoPhi(float phi)
Definition
Conversions.cxx:20
TSU::phiRescaleFactor
static constexpr float phiRescaleFactor
Definition
Conversions.h:13
TSU::toTopoInteger
int toTopoInteger(float value, unsigned int resolution)
Definition
Conversions.cxx:7
TSU::etaIntegerResolution
static constexpr unsigned int etaIntegerResolution
Definition
Conversions.h:15
TSU::toSigned
int toSigned(unsigned bits, unsigned length)
Definition
Conversions.cxx:32
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0