#ifndef DStatUtilities_h #define DStatUtilities_h #include #include #include #include #include #include "TObject.h" #include "TClass.h" #include "TFile.h" #include "TF1.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TObjArray.h" #include "TDirectory.h" #include "TKey.h" #include "TMap.h" using namespace std; class DStatUtilities : public TObject { //Pairs: value, uncertainty public: //CONTROL VARIABLES static double dMinNumTrialsForAcceptance; //POINT: BINOMIAL static double Calc_BinomialSuccessUncertainty(double locNumSuccesses, double locNumTrials); static pair Calc_BinomialRate(double locNumSuccesses, double locNumTrials); //e.g. efficiency, acceptance //POINTS: SUM static pair Calc_Sum(pair locTerm1, pair locTerm2, double locFactor1 = 1.0, double locFactor2 = 1.0); static pair Calc_Sum(const vector >& locTerms); //POINTS: PRODUCT static pair Calc_Product(pair locTerm1, pair locTerm2, double locFactor = 1.0); static pair Calc_Product(pair locTerm, double locFactor = 1.0); static pair Calc_Product(const vector >& locTerms, double locFactor = 1.0); //POINTS: RATIO static pair Calc_Ratio(pair locNumerator, pair locDenominator, double locFactor = 1.0); static pair Calc_Ratio(pair locDenominator, double locFactor = 1.0); static pair Calc_Ratio(pair locNumeratorTerm, const vector >& locDenominatorTerms, double locFactor = 1.0); static pair Calc_Ratio(const vector >& locNumeratorTerms, pair locDenominatorTerm, double locFactor = 1.0); static pair Calc_Ratio(const vector >& locNumeratorTerms, const vector >& locDenominatorTerms, double locFactor = 1.0); //POINT COMPARISON: UNWEIGHTED static double Calc_Average(const vector& locData); static double Calc_SampleSigma(const vector& locData); static double Calc_SampleSigma(double locAverage, const vector& locData); //POINT COMPARISON: WEIGHTED static pair Calc_WeightedAverage(const vector >& locData); static double Calc_WeightedSampleSigma(const vector >& locData); static double Calc_WeightedSampleSigma(double locWeightedAverage, const vector >& locData); static pair Calc_SystematicUncertainty(pair locTerm1, pair locTerm2); //HISTOGRAMS //Works for 1D, 2D, and 3D static TH1* Calc_Acceptance(TH1* locSuccessesHist, TH1* locTrialsHist, pair locStringReplacement = pair("", "")); static TH1* Calc_Acceptance_SeparateTotals(TH1* locSuccessesHist, TH1* locFailuresHist, pair locStringReplacement = pair("", "")); static TH1* Calc_Ratio(TH1* locNumeratorHist, TH1* locDenominatorHist, pair locStringReplacement = pair("", "")); static TH1* Compare(TH1* locCheckHist, TH1* locCompareToHist, pair locStringReplacement = pair("", "")); using TObject::Compare; //this is necessary because the above declaration hides the base class function static TPair* Calc_SystematicUncertainty(TH1* locResultHist, TH1* locAlternativeHist); //GROUP OF HISTOGRAMS //Works for 1D, 2D, and 3D static TH1* Calc_TotalSystematicUncertainty(TObjArray* locUncertaintyHists); static TH1* Calc_WeightedSampleSigmaFraction(TObjArray* locHistArray); static TH1* Calc_WeightedAverage(TObjArray* locHistArray); //THESE BELONG SOMEWHERE ELSE static TH1* CloneAndReset_Hist(TH1* locReferenceHist, string locNameSuffix, bool locCreateDoubleFlag = false, pair locStringReplacement = pair("", "")); static void Replace_TitleSubString(TH1* locHist, pair locStringReplacement); //Recognized actions: "Calc_Acceptance," "Calc_Ratio," "Compare," "Calc_SystematicUncertainty" //In the future, try: http://stackoverflow.com/questions/4013391/is-it-possible-to-have-a-function-name-as-a-template-parameter-in-c static TObjArray* Perform_Action(const TObjArray* locHistArray1, const TObjArray* locHistArray2, string locAction, pair locStringReplacement = pair("", "")); static void Perform_Action(TDirectory* locDir1, TDirectory* locDir2, TDirectory* locOutputDir, string locAction, pair locStringReplacement = pair("", "")); ClassDef(DStatUtilities, 1) }; #endif