ATLAS Offline Software
Loading...
Searching...
No Matches
Conversions.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef L1TopoSimulationUtils_Conversions
6#define L1TopoSimulationUtils_Conversions
7
8#include <math.h>
9#include <string>
10
11namespace TSU {
12
13 static constexpr float phiRescaleFactor = 3.2/M_PI;
14 static constexpr unsigned int phiIntegerResolution = 20; // only correct after(!) multiplying float values with phiRescaleFactor
15 static constexpr unsigned int etaIntegerResolution = 40;
16
17 /*
18 @brief calculate the eta and phi L1Topo indices
19
20 The exact eta and phi coordinates are rounded according to a particular L1Topo granularity
21 Using product instead of division avoids unexpected rounding errors due to precision
22 Also, LUTs for the firmware are built using Python 3.x numpy.round(), which is different from std::round()
23 Input: value = float values, resolution = inverse of intended step size
24 Output: integer L1Topo values
25 */
26 int toTopoInteger(float value, unsigned int resolution);
27
28 /* @brief convert a floating point phi coordinate (in radians) to L1Topo's internal integer representation */
29 unsigned int toTopoPhi(float phi);
30
31 /* @brief convert a floating point eta coordinate to L1Topo's internal integer representation */
32 int toTopoEta(float eta);
33
34 /* @brief convert an (unsigned) representation of a bit string into a signed value assuming a given length of the bit string (incl. possible sign bit) */
35 int toSigned(unsigned bits, unsigned length);
36 /* @brief convert string representation of a bit string into a signed value assuming a given length of the bit string (incl. possible sign bit) */
37 int toSigned(const std::string& bits);
38
39
40}
41#endif
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
double length(const pvec &v)
static constexpr unsigned int phiIntegerResolution
Definition Conversions.h:14
int toTopoEta(float eta)
unsigned int toTopoPhi(float phi)
static constexpr float phiRescaleFactor
Definition Conversions.h:13
int toTopoInteger(float value, unsigned int resolution)
static constexpr unsigned int etaIntegerResolution
Definition Conversions.h:15
int toSigned(unsigned bits, unsigned length)