ATLAS Offline Software
Loading...
Searching...
No Matches
BTaggingToolUtil Class Reference

#include <BTaggingToolUtil.h>

Collaboration diagram for BTaggingToolUtil:

Public Types

enum class  varType {
  unknown , pT , mass , eta ,
  abseta
}

Static Public Member Functions

static double MeVToGeV (const double x)
static float getExtendedFloat (const nlohmann::json &config)
static std::string getExtendedString (const nlohmann::json &config)
static bool approxEqual (const float a, const float b, const float eps)
static varType getVariableType (const std::string &varName)
static std::string getVariableName (const varType vType)

Detailed Description

Definition at line 11 of file BTaggingToolUtil.h.

Member Enumeration Documentation

◆ varType

enum class BTaggingToolUtil::varType
strong
Enumerator
unknown 
pT 
mass 
eta 
abseta 

Definition at line 22 of file BTaggingToolUtil.h.

22 {
23 unknown,
24 pT,
25 mass,
26 eta,
27 abseta
28 };
Scalar eta() const
pseudorapidity method

Member Function Documentation

◆ approxEqual()

bool BTaggingToolUtil::approxEqual ( const float a,
const float b,
const float eps )
static

Definition at line 39 of file BTaggingToolUtil.cxx.

39 {
40 // Exact equality also covers equal infinities e.g. two "inf" upper bounds
41 if (a == b) return true;
42 // An infinite value is never approximately equal to a different value
43 // otherwise |inf - x| <= eps * inf would be true for any finite x
44 if (!std::isfinite(a) || !std::isfinite(b)) return false;
45 return std::abs(a - b) <= eps * std::max(std::abs(a), std::abs(b));
46}
static Double_t a

◆ getExtendedFloat()

float BTaggingToolUtil::getExtendedFloat ( const nlohmann::json & config)
static

Definition at line 11 of file BTaggingToolUtil.cxx.

11 {
12 if (config.is_string() && (config.get<std::string>() == "inf" || config.get<std::string>() == "+inf")) {
13 // Positive infinity: it is greater than every finite float
14 return std::numeric_limits<float>::infinity();
15 } else if (config.is_string() && config.get<std::string>() == "-inf") {
16 // Negative infinity: it is lower than every finite float
17 return -std::numeric_limits<float>::infinity();
18 }
19 else if (config.is_string() && (config.get<std::string>() == "fmax" || config.get<std::string>() == "+fmax")) {
20 // Largest finite positive float number
21 return std::numeric_limits<float>::max();
22 }
23 else if (config.is_string() && config.get<std::string>() == "-fmax") {
24 // Lowest finite negative float number possible
25 return std::numeric_limits<float>::lowest();
26 }
27
28 return config.get<float>();
29}

◆ getExtendedString()

std::string BTaggingToolUtil::getExtendedString ( const nlohmann::json & config)
static

Definition at line 31 of file BTaggingToolUtil.cxx.

31 {
32 if (config.is_string()){
33 return config.get<std::string>();
34 }
35
36 return config.dump();
37}

◆ getVariableName()

std::string BTaggingToolUtil::getVariableName ( const varType vType)
static

Definition at line 63 of file BTaggingToolUtil.cxx.

64{
65 if (vType == varType::pT) {
66 return "pT";
67 } else if (vType == varType::mass) {
68 return "mass";
69 } else if (vType == varType::eta) {
70 return "eta";
71 } else if (vType == varType::abseta) {
72 return "abseta";
73 } else {
74 throw std::runtime_error("Variable type " + std::to_string(static_cast<int>(vType)) + " not defined in BTaggingToolUtil.");
75 }
76}

◆ getVariableType()

BTaggingToolUtil::varType BTaggingToolUtil::getVariableType ( const std::string & varName)
static

Definition at line 48 of file BTaggingToolUtil.cxx.

49{
50 if (varName == "pT") {
51 return varType::pT;
52 } else if (varName == "mass") {
53 return varType::mass;
54 } else if (varName == "eta") {
55 return varType::eta;
56 } else if (varName == "abseta") {
57 return varType::abseta;
58 } else {
59 throw std::runtime_error("Variable '" + varName + "' not defined in BTaggingToolUtil.");
60 }
61}

◆ MeVToGeV()

double BTaggingToolUtil::MeVToGeV ( const double x)
inlinestatic

Definition at line 15 of file BTaggingToolUtil.h.

15{ return x/1000.;}
#define x

The documentation for this class was generated from the following files: