ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
Namespaces | Macros | Functions | Variables
utilities.hpp File Reference
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <limits>
#include <mutex>
#include <set>
#include <numeric>
#include "TH1D.h"
#include "TRandom3.h"

Go to the source code of this file.

Namespaces

 Multithreading
 

Macros

#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)
 
#define DBG(x)   do{std::cerr << "In " << __FILE__ << " at line " << __LINE__ << " (in function " << __func__ << "): " << x << std::endl;}while(false)
 

Functions

std::set< std::string > Glob (const std::string &pattern)
 
std::string Basename (const std::string &filename)
 
bool Contains (const std::string &str, const std::string &pat)
 
bool StartsWith (const std::string &str, const std::string &pat)
 
void ReplaceAll (std::string &str, const std::string &orig, const std::string &rep)
 
std::string CopyReplaceAll (const std::string &str, const std::string &orig, const std::string &rep)
 
std::string execute (const std::string &cmd)
 
std::string CodeToPlainText (std::string code)
 
std::string CodeToLatex (std::string code)
 
std::string CodeToRootTex (std::string code)
 
template<typename T >
std::vector< std::size_t > SortPermutation (const std::vector< T > &vec)
 
template<typename T >
std::vector< T > ApplyPermutation (const std::vector< T > &vec, const std::vector< std::size_t > &perm)
 
std::vector< std::string > Tokenize (const std::string &input, const std::string &tokens=" ")
 
std::string MakeDir (std::string prefix)
 
void AdjustDensityForBinWidth (TH1D &h)
 
void Normalize (TH1D &h, double normalization, bool norm_per_avg_x)
 
void MergeOverflow (TH1D &h, bool merge_underflow, bool merge_overflow)
 
std::string FixedDigits (double x, int n_digits)
 
std::string FullTitle (const TH1 &h)
 
template<typename T >
void Append (T &collection, const typename T::value_type &value)
 
template<typename T >
std::string ToString (const T &x)
 
template<typename T >
std::string ToLongString (const T &x)
 
TString HoursMinSec (float fseconds)
 
TString AddCommas (double num)
 
TString RoundNumber (double num, int decimals, double denom=1.)
 
double Significance (double Nobs, double Nbkg, double Eup_bkg, double Edown_bkg=-1.)
 
double gsl_ran_gamma (const double a, const double b, TRandom3 &rand)
 
double intGaus (double mean, double sigma, double minX, double maxX)
 
float deltaR (float eta1, float phi1, float eta2, float phi2)
 
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)
 

Variables

std::mutex Multithreading::root_mutex
 

Macro Definition Documentation

#define DBG (   x)    do{std::cerr << "In " << __FILE__ << " at line " << __LINE__ << " (in function " << __func__ << "): " << x << std::endl;}while(false)
#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)

Function Documentation

TString AddCommas ( double  num)

Definition at line 351 of file utilities.cpp.

Referenced by PlotMaker::GetYields(), and ToLongString().

void AdjustDensityForBinWidth ( TH1D &  h)

Definition at line 273 of file utilities.cpp.

Referenced by ApplyPermutation(), and Hist1D::ScaleHistos().

template<typename T >
void Append ( T &  collection,
const typename T::value_type &  value 
)

Definition at line 69 of file utilities.hpp.

template<typename T >
std::vector<T> ApplyPermutation ( const std::vector< T > &  vec,
const std::vector< std::size_t > &  perm 
)
std::string Basename ( const std::string &  filename)

Definition at line 38 of file utilities.cpp.

Referenced by PlotMaker::GetYield().

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 CodeToLatex ( std::string  code)

Definition at line 242 of file utilities.cpp.

References CodeToRootTex(), and ReplaceAll().

Referenced by main(), and printTable().

std::string CodeToPlainText ( std::string  code)
std::string CodeToRootTex ( std::string  code)

Definition at line 116 of file utilities.cpp.

References ReplaceAll().

Referenced by CodeToLatex(), plotKappa(), plotRatio(), Table::PrintPie(), and Hist1D::Title().

bool Contains ( const std::string &  str,
const std::string &  pat 
)

Definition at line 44 of file utilities.cpp.

Referenced by anonymous_namespace{hist1d.cpp}::DrawAll(), main(), and Table::PrintPie().

std::string CopyReplaceAll ( const std::string &  str,
const std::string &  orig,
const std::string &  rep 
)

Referenced by main().

float deltaR ( float  eta1,
float  phi1,
float  eta2,
float  phi2 
)

Definition at line 420 of file utilities.cpp.

Referenced by Functions::NISRMatch(), nisrMatch(), and ToLongString().

std::string execute ( const std::string &  cmd)

Definition at line 65 of file utilities.cpp.

Referenced by SlideMaker::Close(), and main().

std::string FixedDigits ( double  x,
int  n_digits 
)

Definition at line 316 of file utilities.cpp.

Referenced by Hist1D::AddEntries(), and ApplyPermutation().

std::string FullTitle ( const TH1 &  h)

Definition at line 331 of file utilities.cpp.

Referenced by ApplyPermutation(), Expand(), and Clustering::Clusterizer::GetGraph().

std::set<std::string> Glob ( const std::string &  pattern)

Definition at line 27 of file utilities.cpp.

Referenced by Process::Process().

double gsl_ran_gamma ( const double  a,
const double  b,
TRandom3 &  rand 
)

Definition at line 386 of file utilities.cpp.

Referenced by calcKappa(), and ToLongString().

TString HoursMinSec ( float  fseconds)

Definition at line 337 of file utilities.cpp.

Referenced by PlotMaker::GetYields(), main(), and ToLongString().

double intGaus ( double  mean,
double  sigma,
double  minX,
double  maxX 
)

Definition at line 416 of file utilities.cpp.

Referenced by calcKappa(), and ToLongString().

std::string MakeDir ( std::string  prefix)

Definition at line 262 of file utilities.cpp.

Referenced by ApplyPermutation().

void MergeOverflow ( TH1D &  h,
bool  merge_underflow,
bool  merge_overflow 
)

Definition at line 300 of file utilities.cpp.

Referenced by ApplyPermutation().

void Normalize ( TH1D &  h,
double  normalization,
bool  norm_per_avg_x 
)

Definition at line 290 of file utilities.cpp.

Referenced by ApplyPermutation(), and Hist1D::NormalizeHistos().

void ReplaceAll ( std::string &  str,
const std::string &  orig,
const std::string &  rep 
)
TString RoundNumber ( double  num,
int  decimals,
double  denom = 1. 
)
double Significance ( double  Nobs,
double  Nbkg,
double  Eup_bkg,
double  Edown_bkg = -1. 
)

Definition at line 426 of file utilities.cpp.

Referenced by ToLongString(), and Zbi().

template<typename T >
std::vector<std::size_t> SortPermutation ( const std::vector< T > &  vec)

Definition at line 39 of file utilities.hpp.

Referenced by main().

bool StartsWith ( const std::string &  str,
const std::string &  pat 
)

Definition at line 48 of file utilities.cpp.

std::vector<std::string> Tokenize ( const std::string &  input,
const std::string &  tokens = " " 
)

Definition at line 248 of file utilities.cpp.

Referenced by ApplyPermutation().

template<typename T >
std::string ToLongString ( const T &  x)
template<typename T >
std::string ToString ( const T &  x)

Definition at line 74 of file utilities.hpp.

Referenced by Hist2D::GetBkgHist(), and Table::Print().