1 #ifndef TagProbeFitter_h 2 #define TagProbeFitter_h 6 #include "TGraphAsymmErrors.h" 7 #include "RooWorkspace.h" 8 #include "RooFitResult.h" 9 #include "RooDataSet.h" 40 std::vector<std::string> efficiencyCategories(1,efficiencyCategory);
41 std::vector<std::string> efficiencyStates(1,efficiencyState);
42 return calculateEfficiency(dirName, efficiencyCategories, efficiencyStates, unbinnedVariables, binnedReals, binnedCategories, binToPDFmap);
93 std::map<std::string, std::vector<std::string> >
pdfs;
103 std::vector<std::pair<std::pair<std::string,std::string>, std::pair<std::string, std::vector<std::string> > > >
expressionVars;
107 std::vector<std::pair<std::pair<std::string,std::string>, std::pair<std::string, double> > >
thresholdCategories;
130 void varFixer(RooWorkspace*
w,
bool fix);
146 void createPdf(RooWorkspace*
w, std::vector<std::string>& pdfCommands);
158 void saveEfficiencyPlots(RooDataSet& eff,
const TString& effName, RooArgSet& binnedVariables, RooArgSet& mappedCategories);
161 void makeEfficiencyPlot1D(RooDataSet& eff, RooRealVar&
v,
const TString& plotName,
const TString& plotTitle,
const TString& effName,
const char *catName =
nullptr,
int catIndex = -1);
164 void makeEfficiencyPlot2D(RooDataSet& eff, RooRealVar& v1, RooRealVar& v2,
const TString& plotName,
const TString& plotTitle,
const TString& effName,
const char *catName =
nullptr,
int catIndex = -1);
168 #endif //TagProbeFitter_h bool floatShapeParameters
void setSaveDistributionsPlot(bool saveDistributionsPlot_)
void doCntEfficiency(RooWorkspace *w, RooRealVar &efficiency)
calculate the efficiecny by counting in the dataset found in the workspace
std::vector< std::pair< std::pair< std::string, std::string >, std::pair< std::string, std::vector< std::string > > > > expressionVars
expressions computed almost on the fly
void makeEfficiencyPlot1D(RooDataSet &eff, RooRealVar &v, const TString &plotName, const TString &plotTitle, const TString &effName, const char *catName=nullptr, int catIndex=-1)
makes the 1D plot
void addPdf(std::string pdfName, std::vector< std::string > &pdfCommands)
void setWeightVar(const std::string &weight)
set a variable to be used as weight for a dataset. empty string means no weights. ...
std::string calculateEfficiency(std::string dirName, std::string efficiencyCategory, std::string efficiencyState, std::vector< std::string > &unbinnedVariables, std::map< std::string, std::vector< double > > &binnedReals, std::map< std::string, std::vector< std::string > > &binnedCategories, std::vector< std::string > &binToPDFmap)
calculate the efficiency for a particular binning of the data; it saves everything in the directory "...
void makeEfficiencyPlot2D(RooDataSet &eff, RooRealVar &v1, RooRealVar &v2, const TString &plotName, const TString &plotTitle, const TString &effName, const char *catName=nullptr, int catIndex=-1)
makes the 2D plot
bool addThresholdCategory(std::string categoryName, std::string title, std::string varName, double cutValue)
adds a new category based on a cut
std::string weightVar
weight variable (or empy string for no weights)
std::vector< std::string > fixVars
list of variables fo fix (see below)
TChain * inputTree
pointer to the input TTree Chain of data
void setQuiet(bool quiet_=true)
suppress most of the output from RooFit and Minuit
TagProbeFitter(const std::vector< std::string > &inputFileNames, std::string inputDirectoryName, std::string inputTreeName, std::string outputFileName, int numCPU=1, bool saveWorkspace_=false, bool floatShapeParameters=true, const std::vector< std::string > &fixVars_=std::vector< std::string >())
construct the fitter with the inputFileName, inputDirectoryName, inputTreeName, outputFileName and sp...
bool addExpression(std::string expressionName, std::string title, std::string expression, const std::vector< std::string > &arguments)
adds a new category based on a cut
void saveEfficiencyPlots(RooDataSet &eff, const TString &effName, RooArgSet &binnedVariables, RooArgSet &mappedCategories)
saves the efficiency plots
std::map< std::string, std::vector< std::string > > pdfs
the map of pdf names to the vector of commands to build the pdf
void varSaver(RooWorkspace *w)
store values in the vector
void setBinnedFit(bool binned, int bins=0)
set if to do a binned fit
void varRestorer(RooWorkspace *w)
restore variables's values for fit starting point
void saveFitPlot(RooWorkspace *w)
saves the fit canvas
~TagProbeFitter()
destructor closes the files
bool saveWorkspace
the default option wether to save the workspace for each bin
bool doSaveDistributionsPlot
save distribution plots
RooWorkspace parameterParser
a RooWorkspace object to parse input parameters with ".factory()"
void setInitialValues(RooWorkspace *w)
sets initial values of the PDF parameters based on the data available in the workspace ...
int numCPU
number of CPUs to use for the fit
int massBins
number of bins to use in mass shape plots; 0 = automatic
void saveDistributionsPlot(RooWorkspace *w)
saves the distributions canvas
bool quiet
suppress most printout
std::vector< std::pair< std::pair< std::string, std::string >, std::pair< std::string, double > > > thresholdCategories
int binnedFit
do binned fit; 0 = automatic, 1 = yes, -1 = no. d
void varFixer(RooWorkspace *w, bool fix)
fix or release variables selected by user
std::vector< double > fixVarValues
void setSplitMode(unsigned int nevents)
TString units(TString variable, Char_t axis)
TFile * outputFile
pointer to the output file
void setBinsForMassPlots(int bins)
set number of bins to use when making the plots; 0 = automatic
void doSBSEfficiency(RooWorkspace *w, RooRealVar &efficiency)
calculate the efficiecny with side band substraction in the dataset found in the workspace ...
void createPdf(RooWorkspace *w, std::vector< std::string > &pdfCommands)
creates the simultaneous PDF in the workspace according to the "pdfCommands"
void doFitEfficiency(RooWorkspace *w, std::string pdfName, RooRealVar &efficiency)
calculate the efficiecny with a simulataneous maximum likelihood fit in the dataset found in the work...
TDirectory * outputDirectory
pointer to the TDirectory in the output file that is the root directory for this fitter ...
RooArgSet variables
the set of variables describing the data in the input TTree
bool addCategory(std::string categoryName, std::string title, std::string expression)
adds a new category variable to the set of variables describing the data in the tree; "expression" is...
bool addVariable(std::string variableName, std::string title, double low, double hi, std::string units)
adds a new real variable to the set of variables describing the data in the tree
void addFixedVariavles(const std::vector< std::string > &)
set a list of variables to fix during first fit iteration. If the list is empty, do one iteration...