17 #define ERROR(x) do{throw std::runtime_error(std::string("Error in file ")+__FILE__+" at line "+std::to_string(__LINE__)+" (in "+__func__+"): "+x);}while(false) 18 #define DBG(x) do{std::cerr << "In " << __FILE__ << " at line " << __LINE__ << " (in function " << __func__ << "): " << x << std::endl;}while(false) 24 std::set<std::string>
Glob(
const std::string &pattern);
27 bool Contains(
const std::string &str,
const std::string &pat);
28 bool StartsWith(
const std::string &str,
const std::string &pat);
29 void ReplaceAll(std::string &str,
const std::string &orig,
const std::string &rep);
30 std::string
CopyReplaceAll(
const std::string &str,
const std::string &orig,
const std::string &rep);
40 std::vector<std::size_t> p(vec.size());
41 std::iota(p.begin(), p.end(), 0);
42 std::sort(p.begin(), p.end(),
43 [&](std::size_t i, std::size_t j){
return vec[i] < vec[j]; });
47 std::vector<T>
ApplyPermutation(
const std::vector<T>& vec,
const std::vector<std::size_t>& perm){
48 if(vec.size() != perm.size())
ERROR(
"Bad permutation: vector and perm have to have the same size");
49 std::vector<T> vsorted(vec.size());
50 for(std::size_t ind=0; ind<vec.size(); ind++) vsorted[ind] = vec[perm[ind]];
54 std::vector<std::string>
Tokenize(
const std::string& input,
55 const std::string& tokens=
" ");
57 std::string
MakeDir(std::string prefix);
60 void Normalize(TH1D &h,
double normalization,
bool norm_per_avg_x);
62 void MergeOverflow(TH1D &h,
bool merge_underflow,
bool merge_overflow);
69 void Append(T &collection,
const typename T::value_type &value){
70 collection.insert(collection.end(), value);
75 std::ostringstream oss;
76 oss << std::setprecision(std::numeric_limits<double>::digits10) << x << std::flush;
82 std::ostringstream oss;
83 oss << std::setprecision(std::numeric_limits<double>::max_digits10) << x << std::flush;
89 TString
RoundNumber(
double num,
int decimals,
double denom=1.);
91 double Significance(
double Nobs,
double Nbkg,
double Eup_bkg,
double Edown_bkg=-1.);
92 double gsl_ran_gamma (
const double a,
const double b, TRandom3 &rand);
93 double intGaus(
double mean,
double sigma,
double minX,
double maxX);
94 float deltaR(
float eta1,
float phi1,
float eta2,
float phi2);
98 double calcKappa(std::vector<std::vector<float> > &entries, std::vector<std::vector<float> > &weights,
99 std::vector<float> &powers,
float &mSigma,
float &pSigma,
bool do_data=
false,
100 bool verbose=
false,
double syst=-1.,
bool do_plot=
false,
int nrep=100000);
void Append(T &collection, const typename T::value_type &value)
bool StartsWith(const std::string &str, const std::string &pat)
TString HoursMinSec(float fseconds)
void Normalize(TH1D &h, double normalization, bool norm_per_avg_x)
double Significance(double Nobs, double Nbkg, double Eup_bkg, double Edown_bkg=-1.)
std::string CodeToPlainText(std::string code)
std::string FullTitle(const TH1 &h)
double gsl_ran_gamma(const double a, const double b, TRandom3 &rand)
void ReplaceAll(std::string &str, const std::string &orig, const std::string &rep)
bool Contains(const std::string &str, const std::string &pat)
TString AddCommas(double num)
double intGaus(double mean, double sigma, double minX, double maxX)
std::string execute(const std::string &cmd)
std::vector< T > ApplyPermutation(const std::vector< T > &vec, const std::vector< std::size_t > &perm)
double calcKappa(std::vector< std::vector< float > > &entries, std::vector< std::vector< float > > &weights, std::vector< float > &powers, float &mSigma, float &pSigma, bool do_data=false, bool verbose=false, double syst=-1., bool do_plot=false, int nrep=100000)
std::string ToLongString(const T &x)
std::string CodeToRootTex(std::string code)
std::string CodeToLatex(std::string code)
std::string Basename(const std::string &filename)
TString RoundNumber(double num, int decimals, double denom=1.)
float deltaR(float eta1, float phi1, float eta2, float phi2)
void MergeOverflow(TH1D &h, bool merge_underflow, bool merge_overflow)
void AdjustDensityForBinWidth(TH1D &h)
std::set< std::string > Glob(const std::string &pattern)
std::vector< std::size_t > SortPermutation(const std::vector< T > &vec)
std::string FixedDigits(double x, int n_digits)
std::string MakeDir(std::string prefix)
std::string ToString(const T &x)
std::string CopyReplaceAll(const std::string &str, const std::string &orig, const std::string &rep)
std::vector< std::string > Tokenize(const std::string &input, const std::string &tokens=" ")