Go to the documentation of this file.00001 #ifndef NPSTAT_CLOSEWITHINTOLERANCE_HH_
00002 #define NPSTAT_CLOSEWITHINTOLERANCE_HH_
00003
00015 #include <cmath>
00016 #include <algorithm>
00017 #include "JetMETCorrections/InterpolationTables/interface/NpstatException.h"
00018
00019 namespace npstat {
00025 inline bool closeWithinTolerance(const double& a, const double& b,
00026 const double& tol)
00027 {
00028 if (tol < 0.0)
00029 throw npstat::NpstatInvalidArgument("In npstat::closeWithinTolerance: "
00030 "negative tolerance is not allowed");
00031 if (a == b)
00032 return true;
00033 else
00034 return fabs(a - b)/std::max(fabs(a), fabs(b)) <= tol;
00035 }
00036 }
00037
00038 #endif // NPSTAT_CLOSEWITHINTOLERANCE_HH_
00039