ATLAS Offline Software
Loading...
Searching...
No Matches
HIEventSelectionToolRun3.cxx File Reference
#include "HIEventUtils/HIEventSelectionToolRun3.h"
#include <fstream>
#include <nlohmann/json.hpp>
#include "PathResolver/PathResolver.h"
Include dependency graph for HIEventSelectionToolRun3.cxx:

Go to the source code of this file.

Macros

#define ENUMDEF(_N)
#define ENUMDEF(_N)
#define ENUMDEF(_N)

Functions

std::unique_ptr< TH1D > loadHist (const std::string &file)

Macro Definition Documentation

◆ ENUMDEF [1/3]

#define ENUMDEF ( _N)
Value:
case HI::IonDataType::_N: \
return #_N;

◆ ENUMDEF [2/3]

#define ENUMDEF ( _N)
Value:
case HI::PileupVariation::_N: \
return #_N;

◆ ENUMDEF [3/3]

#define ENUMDEF ( _N)
Value:
case HI::SelectionMask::_N: \
return #_N;

Function Documentation

◆ loadHist()

std::unique_ptr< TH1D > loadHist ( const std::string & file)

Definition at line 70 of file HIEventSelectionToolRun3.cxx.

70 {
71 const std::string path =
72 PathResolver::find_file(std::string("HIEventUtils/") + file, "DATAPATH");
73 std::ifstream i(path);
74 if (not i) {
75 throw std::runtime_error(path + " does nto exist");
76 }
77
78 nlohmann::json j;
79 i >> j;
80 i.close();
81
82 const size_t nbins = j.at("fNbins").get<size_t>();
83
84 auto h = std::make_unique<TH1D>(j.at("fName").get<std::string>().c_str(),
85 j.at("fTitle").get<std::string>().c_str(),
86 nbins, j.at("fXmin").get<double>(),
87 j.at("fXmax").get<double>());
88 const std::vector<double> bins = j.at("fArray").get<std::vector<double>>();
89 if (bins.size() != j.at("fNbins").get<size_t>() + 2) {
90 throw std::runtime_error(
91 "Histogram " + j.at("fName").get<std::string>() +
92 " has inconsistent number of bins and fNbins (should +2) value " +
93 std::to_string(bins.size()) + " and " + std::to_string(nbins));
94 }
95
96 for (size_t bin = 0; bin < nbins + 2; bin++) {
97 h->SetBinContent(bin, bins[bin]);
98 }
99 h->SetDirectory(0);
100 return h;
101}
static const std::vector< std::string > bins
Header file for AthHistogramAlgorithm.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
path
python interpreter configuration --------------------------------------—
Definition athena.py:126
TFile * file