src
DataFormats
Math
interface
Rounding.h
Go to the documentation of this file.
1
#ifndef DataFormats_Math_Rounding_h
2
#define DataFormats_Math_Rounding_h
3
4
// This file provides utilities for comparing and rounding floating point numbers
5
6
#include <cmath>
7
8
namespace
cms_rounding
{
9
10
template
<
class
valType>
11
inline
constexpr valType
roundIfNear0
(valType
value
,
double
tolerance
= 1.
e
-7) {
12
if
(
std::abs
(
value
) <
tolerance
)
13
return
(0.0);
14
return
(
value
);
15
}
16
17
template
<
class
valType>
18
inline
constexpr valType
roundVecIfNear0
(valType
value
,
double
tolerance
= 1.
e
-7) {
19
auto
xVal{
roundIfNear0
(
value
.x(),
tolerance
)};
20
auto
yVal{
roundIfNear0
(
value
.y(),
tolerance
)};
21
auto
zVal{
roundIfNear0
(
value
.z(),
tolerance
)};
22
return
(valType{xVal, yVal, zVal});
23
}
24
25
}
// namespace cms_rounding
26
27
#endif
cms_rounding::roundVecIfNear0
constexpr valType roundVecIfNear0(valType value, double tolerance=1.e-7)
Definition:
Rounding.h:18
tolerance
const double tolerance
Definition:
HGCalGeomParameters.cc:29
cms_rounding
Definition:
Rounding.h:8
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
funct::abs
Abs< T >::type abs(const T &t)
Definition:
Abs.h:22
value
Definition:
value.py:1
cms_rounding::roundIfNear0
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition:
Rounding.h:11
Generated for CMSSW Reference Manual by
1.8.14