ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRecGPU
src
CaloRecUtilities.h
Go to the documentation of this file.
1
4
#ifndef CaloRecGPU_CaloRecUtilities_h
5
#define CaloRecGPU_CaloRecUtilities_h
6
7
#include <cstring>
//std::memcpy
8
#include <utility>
//std::forward
9
10
namespace
CaloRecGPU
{
11
15
template
<
class
...
Args
>
16
struct
multi_class_holder
{
17
static
constexpr
size_t
size
(){
18
return
sizeof
...(Args);
19
}
20
};
21
22
// Apply: f(Types{}, index, args...)
23
template
<
class
F
,
class
... Types,
class
...
Args
>
24
void
apply_to_multi_class
(
F
&& f,
multi_class_holder<Types...>
,
Args
&... args){
25
auto
&& func = std::forward<F>(f);
// avoid forwarding F multiple times
26
[&]<std::size_t...
I
>(std::index_sequence<
I
...>) {
27
(func(Types{},
I
, args...), ...);
// avoid forwarding args multiple times
28
}(std::make_index_sequence<
sizeof
...(Types)>{});
29
}
30
31
inline
float
float_unhack
(
const
unsigned
int
bits){
32
float
res
;
33
std::memcpy(&
res
, &bits,
sizeof
(
float
));
34
//In C++20, we should bit-cast. For now, for our platform, works.
35
return
res
;
36
}
37
38
inline
double
protect_from_zero
(
const
double
x
){
39
return
x
== 0 ? 1e-15 :
x
;
40
}
41
42
inline
float
protect_from_zero
(
const
float
x
){
43
return
x
== 0 ? 1e-7 :
x
;
44
}
45
}
46
#endif
res
std::pair< std::vector< unsigned int >, bool > res
Definition
JetGroupProductTest.cxx:11
F
#define F(x, y, z)
Definition
MD5.cxx:112
I
#define I(x, y, z)
Definition
MD5.cxx:116
x
#define x
CaloRecGPU
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
Definition
BaseDefinitions.h:11
CaloRecGPU::protect_from_zero
double protect_from_zero(const double x)
Definition
CaloRecUtilities.h:38
CaloRecGPU::apply_to_multi_class
void apply_to_multi_class(F &&f, multi_class_holder< Types... >, Args &... args)
Definition
CaloRecUtilities.h:24
CaloRecGPU::float_unhack
float float_unhack(const unsigned int bits)
Definition
CaloRecUtilities.h:31
TrigInDetValidation_Base.Args
str Args
Definition
TrigInDetValidation_Base.py:93
Args
Definition
test_lwtnn_fastgraph.cxx:12
CaloRecGPU::multi_class_holder
A convenient way to handle a compile-time list of types, useful for several metaprogramming technique...
Definition
CaloRecUtilities.h:16
CaloRecGPU::multi_class_holder::size
static constexpr size_t size()
Definition
CaloRecUtilities.h:17
Generated on
for ATLAS Offline Software by
1.17.0