Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
relativeConstraints.value
tuple value
Definition:
relativeConstraints.py:55
tolerance
const double tolerance
Definition:
HGCalGeomParameters.cc:29
funct::abs
Abs< T >::type abs(const T &t)
Definition:
Abs.h:22
cms_rounding::roundIfNear0
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition:
Rounding.h:11
alignCSCRings.e
list e
Definition:
alignCSCRings.py:91
Generated for CMSSW Reference Manual by
1.8.5