ATLAS Offline Software
Loading...
Searching...
No Matches
JetPileupTag Namespace Reference

Classes

class  JetVertexNNTagger
struct  NNJvtBinning
 Helper struct to hold the bin edges for the NN Jvt cut maps. More...
struct  NNJvtCutMap
 The NNJvt cut maps. More...

Functions

template<typename T>
std::string vectorToString (const std::vector< T > &vec)
void to_json (nlohmann::json &j, const NNJvtBinning &binning)
void from_json (const nlohmann::json &j, NNJvtBinning &binning)
void to_json (nlohmann::json &j, const NNJvtCutMap &cutMap)
void from_json (const nlohmann::json &j, NNJvtCutMap &cutMap)

Variables

constexpr float GeV =1e3

Function Documentation

◆ from_json() [1/2]

void JetPileupTag::from_json ( const nlohmann::json & j,
NNJvtBinning & binning )

Definition at line 24 of file NNJvtBinning.cxx.

24 {
25 j.at("ptbin_edges").get_to(binning.ptEdges);
26 j.at("etabin_edges").get_to(binning.etaEdges);
27 // pT values are stored in GeV but we should use CLHEP values wherever possible
28 for (float &value : binning.ptEdges)
29 value *= GeV;
30 }
constexpr float GeV

◆ from_json() [2/2]

void JetPileupTag::from_json ( const nlohmann::json & j,
NNJvtCutMap & cutMap )

Definition at line 42 of file NNJvtBinning.cxx.

42 {
43 j.get_to(cutMap.edges);
44 cutMap.cutMap.resize(cutMap.edges.ptEdges.size() - 1);
45 for (auto &v : cutMap.cutMap)
46 v.resize(cutMap.edges.etaEdges.size() - 1);
47 std::regex expr(R"(\‍((\d+),\s*(\d+)\))");
48 for (const auto &[bin, cut] : j["cuts"].get<std::map<std::string, float>>()) {
49 std::smatch sm;
50 if (!std::regex_match(bin, sm, expr))
51 throw std::invalid_argument("Invalid bin descriptor: " + bin);
52 cutMap.cutMap.at(std::stoi(sm[1])).at(std::stoi(sm[2])) = cut;
53 }
54 }
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
std::vector< float > ptEdges
std::vector< float > etaEdges
std::vector< std::vector< float > > cutMap

◆ to_json() [1/2]

void JetPileupTag::to_json ( nlohmann::json & j,
const NNJvtBinning & binning )

Definition at line 20 of file NNJvtBinning.cxx.

20 {
21 j = nlohmann::json{{"ptbin_edges", binning.ptEdges}, {"etabin_edges", binning.etaEdges}};
22 }

◆ to_json() [2/2]

void JetPileupTag::to_json ( nlohmann::json & j,
const NNJvtCutMap & cutMap )

Definition at line 32 of file NNJvtBinning.cxx.

32 {
33 to_json(j, cutMap.edges);
34 std::map<std::string, float> cuts;
35 for (std::size_t ptIdx = 0; ptIdx < cutMap.cutMap.size(); ++ptIdx)
36 for (std::size_t etaIdx = 0; etaIdx < cutMap.cutMap.at(ptIdx).size(); ++etaIdx)
37 cuts["(" + std::to_string(ptIdx) + ", " + std::to_string(etaIdx) + ")"] =
38 cutMap.cutMap.at(ptIdx).at(etaIdx);
39 j["cuts"] = cutMap;
40 }
void to_json(nlohmann::json &j, const NNJvtBinning &binning)

◆ vectorToString()

template<typename T>
std::string JetPileupTag::vectorToString ( const std::vector< T > & vec)

Definition at line 305 of file JetVertexNNTagger.cxx.

305 {
306 std::ostringstream oss;
307 for (const auto& val : vec) {
308 oss << val << " ";
309 }
310 return oss.str();
311 }
std::vector< size_t > vec

Variable Documentation

◆ GeV

float JetPileupTag::GeV =1e3
constexpr

Definition at line 44 of file JetVertexNNTagger.h.