File indexing completed on 2023-03-17 11:10:39
0001 #ifndef NPSTAT_CLOSEWITHINTOLERANCE_HH_
0002 #define NPSTAT_CLOSEWITHINTOLERANCE_HH_
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <cmath>
0016 #include <algorithm>
0017 #include "JetMETCorrections/InterpolationTables/interface/NpstatException.h"
0018
0019 namespace npstat {
0020
0021
0022
0023
0024
0025 inline bool closeWithinTolerance(const double& a, const double& b, const double& tol) {
0026 if (tol < 0.0)
0027 throw npstat::NpstatInvalidArgument(
0028 "In npstat::closeWithinTolerance: "
0029 "negative tolerance is not allowed");
0030 if (a == b)
0031 return true;
0032 else
0033 return fabs(a - b) / std::max(fabs(a), fabs(b)) <= tol;
0034 }
0035 }
0036
0037 #endif