1 #ifndef CombineTools_Utilities_h
2 #define CombineTools_Utilities_h
9 #include "boost/algorithm/string.hpp"
10 #include "boost/lexical_cast.hpp"
11 #include "boost/regex.hpp"
12 #include "boost/filesystem.hpp"
14 #include "RooFitResult.h"
15 #include "RooArgSet.h"
21 namespace ch {
class CombineHarvester; }
24 RooArgSet
ParametersByName(RooAbsReal
const* pdf, RooArgSet
const* dat_vars);
38 std::string
const& pattern =
"$ANALYSIS_$CHANNEL_$BINID_$ERA");
42 template<
class T,
class U>
44 if (first.bin() == second.bin() &&
45 first.process() == second.process() &&
46 first.signal() == second.signal() &&
47 first.analysis() == second.analysis() &&
48 first.era() == second.era() &&
49 first.channel() == second.channel() &&
50 first.bin_id() == second.bin_id() &&
51 first.mass() == second.mass()) {
58 template<
class T,
class U>
60 first->set_bin(second->bin());
61 first->set_process(second->process());
62 first->set_signal(second->signal());
63 first->set_analysis(second->analysis());
64 first->set_era(second->era());
65 first->set_channel(second->channel());
66 first->set_bin_id(second->bin_id());
67 first->set_mass(second->mass());
68 first->set_all_attributes(second->all_attributes());
76 TGraph
TGraphFromTable(std::string filename, std::string
const& x_column,
77 std::string
const& y_column);
83 std::vector<T>
Join(std::vector<std::vector<T>>
const& in) {
85 for (
auto const& x : in) size += x.size();
86 std::vector<T> res(size);
88 for (
auto const& x : in) {
89 for (
auto const& y : x) {
97 std::vector<std::string>
JoinStr(
98 std::vector<std::vector<std::string>>
const& in);
101 std::vector<T>
Set2Vec(std::set<T>
const& in) {
102 return std::vector<T>(in.begin(), in.end());
105 RooDataHist
TH1F2Data(TH1F
const& hist, RooRealVar
const& x,
106 std::string
const& name);
114 std::vector<unsigned> vec);
116 std::vector<std::string>
ParseFileLines(std::string
const& file_name);
119 bool is_float(std::string
const& str);
144 std::string
const& fmt =
"%.0f");
164 std::vector<std::string>
ValsFromRange(std::string
const& input,
165 std::string
const& fmt =
"%.0f");
176 namespace tupleprint {
179 template <
class Tuple, std::
size_t N>
181 static void print(
const Tuple &t, std::stringstream & str) {
183 str <<
", " << std::get<N - 1>(t);
187 template <
class Tuple>
189 static void print(
const Tuple & t, std::stringstream & str) {
190 str << std::get<0>(t);
196 template <
class Tuple>
198 static void print(
const Tuple & , std::stringstream & ) { }
213 template <
class... Args>
215 std::stringstream str;
240 boost::filesystem::path
make_relative(boost::filesystem::path p_from,
241 boost::filesystem::path p_to);
void SetProperties(T *first, U const *second)
RooDataHist TH1F2Data(TH1F const &hist, RooRealVar const &x, std::string const &name)
void SetStandardBinName(ch::Object *obj, std::string pattern)
std::vector< std::string > ParseFileLines(std::string const &file_name)
TH1F RestoreBinning(TH1F const &src, TH1F const &ref)
TH1F RebinHist(TH1F const &hist)
boost::filesystem::path make_relative(boost::filesystem::path p_from, boost::filesystem::path p_to)
Determine the relative path from one file to another.
std::vector< ch::Parameter > ExtractFitParameters(RooFitResult const &res)
std::vector< T > Set2Vec(std::set< T > const &in)
std::vector< T > Join(std::vector< std::vector< T >> const &in)
bool HasNegativeBins(TH1 const *h)
std::string Tuple2String(const std::tuple< Args... > &t)
Format any std::tuple as a string.
TGraph TGraphFromTable(std::string filename, std::string const &x_column, std::string const &y_column)
std::vector< std::vector< unsigned > > GenerateCombinations(std::vector< unsigned > vec)
void SetStandardBinNames(CombineHarvester &cb, std::string const &pattern="$ANALYSIS_$CHANNEL_$BINID_$ERA")
std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of mass values using ranges and intervals specified in a string.
std::vector< ch::Parameter > ExtractSampledFitParameters(RooFitResult const &res)
bool MatchingProcess(T const &first, U const &second)
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
bool is_float(std::string const &str)
void ZeroNegativeBins(TH1 *h)
RooArgSet ParametersByName(RooAbsReal const *pdf, RooArgSet const *dat_vars)
void SetFromBinName(ch::Object *input, std::string parse_rules)
static void print(const Tuple &, std::stringstream &)
static void print(const Tuple &t, std::stringstream &str)
static void print(const Tuple &t, std::stringstream &str)