ATLAS Offline Software
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 
11 namespace 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
TSU::toSigned
int toSigned(unsigned bits, unsigned length)
Definition: Conversions.cxx:32
TSU::toTopoEta
int toTopoEta(float eta)
Definition: Conversions.cxx:27
M_PI
#define M_PI
Definition: ActiveFraction.h:11
athena.value
value
Definition: athena.py:124
TSU
Definition: Conversions.h:11
Dedxcorrection::resolution
double resolution[nGasTypes][nParametersResolution]
Definition: TRT_ToT_Corrections.h:46
TSU::toTopoInteger
int toTopoInteger(float value, unsigned int resolution)
Definition: Conversions.cxx:7
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
TSU::toTopoPhi
unsigned int toTopoPhi(float phi)
Definition: Conversions.cxx:20