1 #ifndef TagProbeFitter_h
2 #define TagProbeFitter_h
6 #include "TGraphAsymmErrors.h"
7 #include "RooWorkspace.h"
8 #include "RooFitResult.h"
9 #include "RooDataSet.h"
14 TagProbeFitter(std::vector<std::string> inputFileNames, std::string inputDirectoryName, std::string inputTreeName, std::string
outputFileName,
int numCPU = 1,
bool saveWorkspace_ =
false,
bool floatShapeParameters =
true, std::vector<std::string> fixVars_ = std::vector<std::string>() );
20 bool addVariable(std::string variableName, std::string
title,
double low,
double hi, std::string
units);
23 bool addCategory(std::string categoryName, std::string title, std::string expression);
26 bool addExpression(std::string expressionName, std::string title, std::string expression, std::vector<std::string> arguments);
29 bool addThresholdCategory(std::string categoryName, std::string title, std::string varName,
double cutValue);
33 void addPdf(std::string pdfName, std::vector<std::string>& pdfCommands);
39 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) {
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);
45 std::string
calculateEfficiency(std::string
dirName, std::vector<std::string> efficiencyCategories, std::vector<std::string> efficiencyStates, 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);
82 std::map<std::string, std::vector<std::string> >
pdfs;
92 std::vector<std::pair<std::pair<std::string,std::string>, std::pair<std::string, std::vector<std::string> > > >
expressionVars;
96 std::vector<std::pair<std::pair<std::string,std::string>, std::pair<std::string, double> > >
thresholdCategories;
114 void varFixer(RooWorkspace*
w,
bool fix);
130 void createPdf(RooWorkspace*
w, std::vector<std::string>& pdfCommands);
142 void saveEfficiencyPlots(RooDataSet&
eff, TString effName, RooArgSet& binnedVariables, RooArgSet& mappedCategories);
148 void makeEfficiencyPlot2D(RooDataSet&
eff, RooRealVar& v1, RooRealVar& v2, TString plotName, TString plotTitle, TString effName);
152 #endif //TagProbeFitter_h
bool floatShapeParameters
void doCntEfficiency(RooWorkspace *w, RooRealVar &efficiency)
calculate the efficiecny by counting in the dataset found in the workspace
bool addExpression(std::string expressionName, std::string title, std::string expression, std::vector< std::string > arguments)
adds a new category based on a cut
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, TString plotName, TString plotTitle, TString effName)
makes the 1D plot
void addPdf(std::string pdfName, std::vector< std::string > &pdfCommands)
TagProbeFitter(std::vector< std::string > inputFileNames, std::string inputDirectoryName, std::string inputTreeName, std::string outputFileName, int numCPU=1, bool saveWorkspace_=false, bool floatShapeParameters=true, std::vector< std::string > fixVars_=std::vector< std::string >())
construct the fitter with the inputFileName, inputDirectoryName, inputTreeName, outputFileName and sp...
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 "...
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)
void addFixedVariavles(std::vector< string >)
set a list of variables to fix during first fit iteration. If the list is empty, do one iteration...
TChain * inputTree
pointer to the input TTree Chain of data
void setQuiet(bool quiet_=true)
suppress most of the output from RooFit and Minuit
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
void saveEfficiencyPlots(RooDataSet &eff, TString effName, RooArgSet &binnedVariables, RooArgSet &mappedCategories)
saves the efficiency 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 makeEfficiencyPlot2D(RooDataSet &eff, RooRealVar &v1, RooRealVar &v2, TString plotName, TString plotTitle, TString effName)
makes the 2D plot
void varFixer(RooWorkspace *w, bool fix)
fix or release variables selected by user
std::vector< double > fixVarValues
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