#include <TagProbeFitter.h>
Public Member Functions | |
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 parsed by factory() More... | |
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 More... | |
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. More... | |
void | addPdf (std::string pdfName, std::vector< std::string > &pdfCommands) |
bool | addThresholdCategory (std::string categoryName, std::string title, std::string varName, double cutValue) |
adds a new category based on a cut More... | |
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 More... | |
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 "dirName", uses the previously defined PDF with name "pdfName" More... | |
std::string | calculateEfficiency (std::string dirName, const std::vector< std::string > &efficiencyCategories, const 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) |
void | setBinnedFit (bool binned, int bins=0) |
set if to do a binned fit More... | |
void | setBinsForMassPlots (int bins) |
set number of bins to use when making the plots; 0 = automatic More... | |
void | setQuiet (bool quiet_=true) |
suppress most of the output from RooFit and Minuit More... | |
void | setSaveDistributionsPlot (bool saveDistributionsPlot_) |
void | setSplitMode (unsigned int nevents) |
void | setWeightVar (const std::string &weight) |
set a variable to be used as weight for a dataset. empty string means no weights. More... | |
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 specify wether to save the workspace with data for each bin More... | |
~TagProbeFitter () | |
destructor closes the files More... | |
Protected Member Functions | |
void | createPdf (RooWorkspace *w, std::vector< std::string > &pdfCommands) |
creates the simultaneous PDF in the workspace according to the "pdfCommands" More... | |
void | doCntEfficiency (RooWorkspace *w, RooRealVar &efficiency) |
calculate the efficiecny by counting in the dataset found in the workspace More... | |
void | doFitEfficiency (RooWorkspace *w, std::string pdfName, RooRealVar &efficiency) |
calculate the efficiecny with a simulataneous maximum likelihood fit in the dataset found in the workspace with PDF pdfName More... | |
void | doSBSEfficiency (RooWorkspace *w, RooRealVar &efficiency) |
calculate the efficiecny with side band substraction in the dataset found in the workspace More... | |
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 More... | |
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 More... | |
void | saveDistributionsPlot (RooWorkspace *w) |
saves the distributions canvas More... | |
void | saveEfficiencyPlots (RooDataSet &eff, const TString &effName, RooArgSet &binnedVariables, RooArgSet &mappedCategories) |
saves the efficiency plots More... | |
void | saveFitPlot (RooWorkspace *w) |
saves the fit canvas More... | |
void | setInitialValues (RooWorkspace *w) |
sets initial values of the PDF parameters based on the data available in the workspace More... | |
void | varFixer (RooWorkspace *w, bool fix) |
fix or release variables selected by user More... | |
void | varRestorer (RooWorkspace *w) |
restore variables's values for fit starting point More... | |
void | varSaver (RooWorkspace *w) |
store values in the vector More... | |
Protected Attributes | |
int | binnedFit |
do binned fit; 0 = automatic, 1 = yes, -1 = no. d More... | |
bool | doSaveDistributionsPlot |
save distribution plots More... | |
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 More... | |
std::vector< std::string > | fixVars |
list of variables fo fix (see below) More... | |
std::vector< double > | fixVarValues |
bool | floatShapeParameters |
TChain * | inputTree |
pointer to the input TTree Chain of data More... | |
int | massBins |
number of bins to use in mass shape plots; 0 = automatic More... | |
int | numCPU |
number of CPUs to use for the fit More... | |
TDirectory * | outputDirectory |
pointer to the TDirectory in the output file that is the root directory for this fitter More... | |
TFile * | outputFile |
pointer to the output file More... | |
RooWorkspace | parameterParser |
a RooWorkspace object to parse input parameters with ".factory()" More... | |
std::map< std::string, std::vector< std::string > > | pdfs |
the map of pdf names to the vector of commands to build the pdf More... | |
bool | quiet |
suppress most printout More... | |
bool | saveWorkspace |
the default option wether to save the workspace for each bin More... | |
unsigned int | split_mode |
std::vector< std::pair< std::pair< std::string, std::string >, std::pair< std::string, double > > > | thresholdCategories |
RooArgSet | variables |
the set of variables describing the data in the input TTree More... | |
std::string | weightVar |
weight variable (or empy string for no weights) More... | |
Definition at line 11 of file TagProbeFitter.h.
TagProbeFitter::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 specify wether to save the workspace with data for each bin
Definition at line 52 of file TagProbeFitter.cc.
References gather_cfg::cout, MillePedeFileConverter_cfg::e, mps_fire::i, and download_sqlite_cfg::outputFile.
TagProbeFitter::~TagProbeFitter | ( | ) |
destructor closes the files
Definition at line 86 of file TagProbeFitter.cc.
References download_sqlite_cfg::outputFile.
bool TagProbeFitter::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 parsed by factory()
Definition at line 113 of file TagProbeFitter.cc.
References EnergyCorrector::c, and objects.autophobj::variables.
Referenced by TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
bool TagProbeFitter::addExpression | ( | std::string | expressionName, |
std::string | title, | ||
std::string | expression, | ||
const std::vector< std::string > & | arguments | ||
) |
adds a new category based on a cut
Definition at line 124 of file TagProbeFitter.cc.
Referenced by TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
void TagProbeFitter::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.
void TagProbeFitter::addPdf | ( | std::string | pdfName, |
std::vector< std::string > & | pdfCommands | ||
) |
add a new PDF to the list of available PDFs; "pdfCommands" are parsed by factory(). the user needs to define efficiency[0.9,0,1] for the initial value, "signal" PDF, "backgroundPass" PDF and "backgroundFail" PDF
Definition at line 136 of file TagProbeFitter.cc.
References dataset::name.
Referenced by TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
bool TagProbeFitter::addThresholdCategory | ( | std::string | categoryName, |
std::string | title, | ||
std::string | varName, | ||
double | cutValue | ||
) |
adds a new category based on a cut
Definition at line 130 of file TagProbeFitter.cc.
Referenced by TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
bool TagProbeFitter::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
Definition at line 106 of file TagProbeFitter.cc.
References groupFilesInBlocks::temp, and objects.autophobj::variables.
Referenced by TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
|
inline |
calculate the efficiency for a particular binning of the data; it saves everything in the directory "dirName", uses the previously defined PDF with name "pdfName"
Definition at line 39 of file TagProbeFitter.h.
References TrackerOfflineValidation_Dqm_cff::dirName, genParticles_cff::map, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by TagProbeFitTreeAnalyzer::calculateEfficiency(), and setWeightVar().
std::string TagProbeFitter::calculateEfficiency | ( | std::string | dirName, |
const std::vector< std::string > & | efficiencyCategories, | ||
const 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 | ||
) |
|
protected |
creates the simultaneous PDF in the workspace according to the "pdfCommands"
Definition at line 644 of file TagProbeFitter.cc.
References mps_check::command, mps_fire::i, and AlCaHLTBitMon_QueryRunRegistry::string.
|
protected |
calculate the efficiecny by counting in the dataset found in the workspace
Definition at line 937 of file TagProbeFitter.cc.
References alpha, MillePedeFileConverter_cfg::e, and cmsPerfPublish::fail().
|
protected |
calculate the efficiecny with a simulataneous maximum likelihood fit in the dataset found in the workspace with PDF pdfName
—> if "floatShapeParameters==false" && "fixVars is NOT empty" : Perform a global fit to the whole sample, save the fitted values of the user specified parameters, and fix them for bin-by-bin fit.
Definition at line 484 of file TagProbeFitter.cc.
References MessageLogger_cfi::cerr, data, MillePedeFileConverter_cfg::e, and TagProbeFitTreeAnalyzer_cfi::NumCPU.
|
protected |
calculate the efficiecny with side band substraction in the dataset found in the workspace
Definition at line 934 of file TagProbeFitter.cc.
|
protected |
makes the 1D plot
Definition at line 880 of file TagProbeFitter.cc.
References svgfig::canvas(), mps_splice::entry, mps_fire::i, gen::n, and AlCaHLTBitMon_ParallelJobs::p.
|
protected |
makes the 2D plot
Definition at line 908 of file TagProbeFitter.cc.
References svgfig::canvas(), MillePedeFileConverter_cfg::e, mps_splice::entry, h, and mps_fire::i.
|
protected |
saves the distributions canvas
Definition at line 785 of file TagProbeFitter.cc.
References svgfig::canvas(), mps_fire::i, globaldigis_analyze_cfi::Name, and findQualityFiles::v.
|
protected |
saves the efficiency plots
Definition at line 830 of file TagProbeFitter.cc.
References protons_cff::t.
|
protected |
saves the fit canvas
Definition at line 722 of file TagProbeFitter.cc.
References svgfig::canvas(), mps_fire::i, ResonanceBuilder::mass, globaldigis_analyze_cfi::Name, and findQualityFiles::v.
|
inline |
set if to do a binned fit
Definition at line 48 of file TagProbeFitter.h.
References binnedFit, create_public_pileup_plots::bins, massBins, and setBinsForMassPlots().
Referenced by TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
void TagProbeFitter::setBinsForMassPlots | ( | int | bins | ) |
set number of bins to use when making the plots; 0 = automatic
Definition at line 140 of file TagProbeFitter.cc.
References create_public_pileup_plots::bins.
Referenced by setBinnedFit(), and TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
|
protected |
sets initial values of the PDF parameters based on the data available in the workspace
Definition at line 685 of file TagProbeFitter.cc.
void TagProbeFitter::setQuiet | ( | bool | quiet_ = true | ) |
suppress most of the output from RooFit and Minuit
Definition at line 93 of file TagProbeFitter.cc.
References dqm::qstatus::ERROR, instance, and dqm::qstatus::WARNING.
Referenced by setSaveDistributionsPlot(), and TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
|
inline |
Definition at line 54 of file TagProbeFitter.h.
References doSaveDistributionsPlot, setQuiet(), setSplitMode(), setWeightVar(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
void TagProbeFitter::setSplitMode | ( | unsigned int | nevents | ) |
split mode - use it for very large input files (slower that non-split mode, which is the default) 0 - import input TTree as a whole (non-split mode) non-zero value - use split reading mode and read specified number of events for each iteration
Definition at line 102 of file TagProbeFitter.cc.
Referenced by setSaveDistributionsPlot(), and TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
void TagProbeFitter::setWeightVar | ( | const std::string & | weight | ) |
set a variable to be used as weight for a dataset. empty string means no weights.
Definition at line 144 of file TagProbeFitter.cc.
References writedatasetfile::args, RecoTauDiscriminantConfiguration::binning, calculateEfficiency(), eostools::cat(), myMessageLogger_cff::categories, hippyaddtobaddatafiles::cd(), MessageLogger_cfi::cerr, cuy::col, gather_cfg::cout, data, TrackerOfflineValidation_Dqm_cff::dirName, PostProcessor_cff::efficiency, ev, jets_cff::expr, mps_fire::i, genParticles_cff::map, SiStripPI::mean, MultiGaussianStateTransform::multiState(), dataset::name, haddnano::obj, protons_cff::t, tmp, findQualityFiles::v, JetChargeProducer_cfi::var, objects.autophobj::variables, and w.
Referenced by setSaveDistributionsPlot(), and TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer().
|
protected |
fix or release variables selected by user
Definition at line 953 of file TagProbeFitter.cc.
References gather_cfg::cout.
|
protected |
restore variables's values for fit starting point
Definition at line 976 of file TagProbeFitter.cc.
References gather_cfg::cout, and mps_fire::i.
|
protected |
store values in the vector
Definition at line 964 of file TagProbeFitter.cc.
References gather_cfg::cout.
|
protected |
do binned fit; 0 = automatic, 1 = yes, -1 = no. d
Definition at line 87 of file TagProbeFitter.h.
Referenced by setBinnedFit().
|
protected |
save distribution plots
Definition at line 81 of file TagProbeFitter.h.
Referenced by setSaveDistributionsPlot().
|
protected |
expressions computed almost on the fly
Definition at line 103 of file TagProbeFitter.h.
|
protected |
list of variables fo fix (see below)
Definition at line 110 of file TagProbeFitter.h.
|
protected |
Definition at line 111 of file TagProbeFitter.h.
|
protected |
release some variables before the fit in each bin if set to "false" will fit all dataset to get values of specified variables and then fit all bins having them fixed if set to "true" (default) will not fit all dataset, just each bin with fixed and then released variables
Definition at line 116 of file TagProbeFitter.h.
|
protected |
pointer to the input TTree Chain of data
Definition at line 69 of file TagProbeFitter.h.
|
protected |
number of bins to use in mass shape plots; 0 = automatic
Definition at line 90 of file TagProbeFitter.h.
Referenced by setBinnedFit().
|
protected |
number of CPUs to use for the fit
Definition at line 78 of file TagProbeFitter.h.
|
protected |
pointer to the TDirectory in the output file that is the root directory for this fitter
Definition at line 75 of file TagProbeFitter.h.
|
protected |
pointer to the output file
Definition at line 72 of file TagProbeFitter.h.
|
protected |
a RooWorkspace object to parse input parameters with ".factory()"
Definition at line 119 of file TagProbeFitter.h.
|
protected |
the map of pdf names to the vector of commands to build the pdf
Definition at line 93 of file TagProbeFitter.h.
|
protected |
suppress most printout
Definition at line 122 of file TagProbeFitter.h.
|
protected |
the default option wether to save the workspace for each bin
Definition at line 84 of file TagProbeFitter.h.
|
protected |
split mode - use it for very large input files (slower that non-split mode, which is the default) 0 - import input TTree as a whole (non-split mode) non-zero value - use split reading mode and read specified number of events for each iteration
Definition at line 127 of file TagProbeFitter.h.
|
protected |
Definition at line 107 of file TagProbeFitter.h.
|
protected |
the set of variables describing the data in the input TTree
Definition at line 96 of file TagProbeFitter.h.
|
protected |
weight variable (or empy string for no weights)
Definition at line 99 of file TagProbeFitter.h.