ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
EFTracking
FPGATrackSim
FPGATrackSimObjects
FPGATrackSimObjects
FPGATrackSimFunctions.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/*
6
* FPGATrackSimFunctions.h
7
*
8
* Declares several generic utility functions.
9
*/
10
11
#ifndef FPGATrackSimFUNCTIONS_H
12
#define FPGATrackSimFUNCTIONS_H
13
14
15
#include <TString.h>
16
#include <TObjArray.h>
17
#include <TH1.h>
18
#include <TObjString.h>
19
#include <TTreeReader.h>
20
#include <TTreeReaderValue.h>
21
22
#include "
FPGATrackSimObjects/FPGATrackSimTypes.h
"
23
#include "
FPGATrackSimObjects/FPGATrackSimHit.h
"
24
25
26
#include <cmath>
27
#include <vector>
28
#include <sstream>
29
30
31
32
/*****************************************************************************/
33
/* Bit Manipulations and Arithmetic
34
*
35
* Avoid using templates because right-shifts will not work correctly if
36
* accidentally called using a signed type.
37
*/
38
/*****************************************************************************/
39
40
// Returns a list of words, each with one bit set for each bit set in x
41
// Sorted by LSB to MSB.
42
inline
std::vector<uint32_t>
splitSetBits32
(uint32_t
x
)
43
{
44
std::vector<uint32_t> out;
45
uint32_t setbit = 0x1;
46
while
(setbit != 0 &&
x
!= 0)
47
{
48
if
(
x
& 1) out.push_back(setbit);
49
x
=
x
>> 1;
50
setbit = setbit << 1;
51
}
52
return
out;
53
}
54
55
56
// Returns the first set bit of x, starting from the LSB (0 indexed).
57
// Returns -1 if x == 0.
58
inline
int
firstSetBit32
(uint32_t
x
)
59
{
60
unsigned
bit = 0;
61
while
(
x
)
62
{
63
if
(
x
& 1)
return
bit;
64
x
>>= 1;
65
bit++;
66
}
67
return
-1;
68
}
69
70
71
// Divide x/y, rounding up. x,y can not be 0.
72
inline
unsigned
divUp
(
unsigned
x
,
unsigned
y
)
73
{
74
// return (x + y - 1) / y; runs risk of overflow
75
return
1 + ((
x
- 1) /
y
);
76
}
77
78
79
// Gray code: https://en.wikipedia.org/wiki/Gray_code#Converting_to_and_from_Gray_code
80
inline
uint32_t
binaryToGray
(uint32_t num)
81
{
82
return
num ^ (num >> 1);
83
}
84
85
86
inline
uint32_t
grayToBinary32
(uint32_t num)
87
{
88
num = num ^ (num >> 16);
89
num = num ^ (num >> 8);
90
num = num ^ (num >> 4);
91
num = num ^ (num >> 2);
92
num = num ^ (num >> 1);
93
return
num;
94
}
95
96
97
98
/*****************************************************************************/
99
/* Vectors and Indexing */
100
/*****************************************************************************/
101
108
std::vector<std::vector<int>>
getComboIndices
(std::vector<size_t>
const
& sizes);
109
110
111
112
/*****************************************************************************/
113
/* RMS95 Value Calculation */
114
/*****************************************************************************/
115
122
double
rms95
(TH1
const
*
h
);
123
124
// The Hough transform magnetic field correction.
125
// Apply correction due to B != 2T everywhere. This correction should be ADDED to track phi.
126
double
fieldCorrection
(
unsigned
region,
double
qoverpt,
double
r
);
127
128
std::vector<float>
computeIdealCoords
(
const
FPGATrackSimHit
&
hit
,
const
double
hough_x,
const
double
hough_y,
const
double
target_r,
const
bool
doDeltaGPhis,
const
TrackCorrType
trackCorrType);
129
130
#endif
// FPGATrackSimFUNCTIONS_H
getComboIndices
std::vector< std::vector< int > > getComboIndices(std::vector< size_t > const &sizes)
Given a vector of sizes (of arrays), generates a vector of all combinations of indices to index one e...
Definition
FPGATrackSimFunctions.cxx:21
rms95
double rms95(TH1 const *h)
This function is used to calculate RMS95 value for 1D histograms.
Definition
FPGATrackSimFunctions.cxx:60
computeIdealCoords
std::vector< float > computeIdealCoords(const FPGATrackSimHit &hit, const double hough_x, const double hough_y, const double target_r, const bool doDeltaGPhis, const TrackCorrType trackCorrType)
Definition
FPGATrackSimFunctions.cxx:116
divUp
unsigned divUp(unsigned x, unsigned y)
Definition
FPGATrackSimFunctions.h:72
grayToBinary32
uint32_t grayToBinary32(uint32_t num)
Definition
FPGATrackSimFunctions.h:86
binaryToGray
uint32_t binaryToGray(uint32_t num)
Definition
FPGATrackSimFunctions.h:80
firstSetBit32
int firstSetBit32(uint32_t x)
Definition
FPGATrackSimFunctions.h:58
fieldCorrection
double fieldCorrection(unsigned region, double qoverpt, double r)
Definition
FPGATrackSimFunctions.cxx:163
splitSetBits32
std::vector< uint32_t > splitSetBits32(uint32_t x)
Definition
FPGATrackSimFunctions.h:42
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
FPGATrackSimTypes.h
TrackCorrType
TrackCorrType
Definition
FPGATrackSimTypes.h:37
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
y
#define y
x
#define x
h
Header file for AthHistogramAlgorithm.
FPGATrackSimHit
Definition
FPGATrackSimHit.h:42
r
int r
Definition
globals.cxx:22
Generated on
for ATLAS Offline Software by
1.17.0