ATLAS Offline Software
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
24
#include <cmath>
25
#include <vector>
26
#include <sstream>
27
28
29
30
/*****************************************************************************/
31
/* Bit Manipulations and Arithmetic
32
*
33
* Avoid using templates because right-shifts will not work correctly if
34
* accidentally called using a signed type.
35
*/
36
/*****************************************************************************/
37
38
// Returns a list of words, each with one bit set for each bit set in x
39
// Sorted by LSB to MSB.
40
inline
std::vector<uint32_t>
splitSetBits32
(
uint32_t
x
)
41
{
42
std::vector<uint32_t>
out
;
43
uint32_t
setbit = 0x1;
44
while
(setbit != 0 &&
x
!= 0)
45
{
46
if
(
x
& 1)
out
.push_back(setbit);
47
x
=
x
>> 1;
48
setbit = setbit << 1;
49
}
50
return
out
;
51
}
52
53
54
// Returns the first set bit of x, starting from the LSB (0 indexed).
55
// Returns -1 if x == 0.
56
inline
int
firstSetBit32
(
uint32_t
x
)
57
{
58
unsigned
bit = 0;
59
while
(
x
)
60
{
61
if
(
x
& 1)
return
bit;
62
x
>>= 1;
63
bit++;
64
}
65
return
-1;
66
}
67
68
69
// Divide x/y, rounding up. x,y can not be 0.
70
inline
unsigned
divUp
(
unsigned
x
,
unsigned
y
)
71
{
72
// return (x + y - 1) / y; runs risk of overflow
73
return
1 + ((
x
- 1) /
y
);
74
}
75
76
77
// Gray code: https://en.wikipedia.org/wiki/Gray_code#Converting_to_and_from_Gray_code
78
inline
uint32_t
binaryToGray
(
uint32_t
num
)
79
{
80
return
num
^ (
num
>> 1);
81
}
82
83
84
inline
uint32_t
grayToBinary32
(
uint32_t
num
)
85
{
86
num
=
num
^ (
num
>> 16);
87
num
=
num
^ (
num
>> 8);
88
num
=
num
^ (
num
>> 4);
89
num
=
num
^ (
num
>> 2);
90
num
=
num
^ (
num
>> 1);
91
return
num
;
92
}
93
94
95
96
/*****************************************************************************/
97
/* Vectors and Indexing */
98
/*****************************************************************************/
99
106
std::vector<std::vector<int>>
getComboIndices
(std::vector<size_t>
const
& sizes);
107
108
109
110
/*****************************************************************************/
111
/* RMS95 Value Calculation */
112
/*****************************************************************************/
113
120
double
rms95
(
TH1
const
*
h
);
121
122
123
124
#endif // FPGATrackSimFUNCTIONS_H
xAOD::uint32_t
setEventNumber uint32_t
Definition:
EventInfo_v1.cxx:127
grayToBinary32
uint32_t grayToBinary32(uint32_t num)
Definition:
FPGATrackSimFunctions.h:84
python.AthDsoLogger.out
out
Definition:
AthDsoLogger.py:71
x
#define x
splitSetBits32
std::vector< uint32_t > splitSetBits32(uint32_t x)
Definition:
FPGATrackSimFunctions.h:40
firstSetBit32
int firstSetBit32(uint32_t x)
Definition:
FPGATrackSimFunctions.h:56
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
binaryToGray
uint32_t binaryToGray(uint32_t num)
Definition:
FPGATrackSimFunctions.h:78
trigbs_pickEvents.num
num
Definition:
trigbs_pickEvents.py:76
divUp
unsigned divUp(unsigned x, unsigned y)
Definition:
FPGATrackSimFunctions.h:70
rms95
double rms95(TH1 const *h)
This function is used to calculate RMS95 value for 1D histograms.
Definition:
FPGATrackSimFunctions.cxx:60
y
#define y
h
TH1
Definition:
rootspy.cxx:268
FPGATrackSimTypes.h
Generated on Tue Jul 2 2024 21:15:52 for ATLAS Offline Software by
1.8.18