27 fitter( pset.getParameter<vector<
string> >(
"InputFileNames"),
28 pset.getParameter<
string>(
"InputDirectoryName"),
29 pset.getParameter<
string>(
"InputTreeName"),
30 pset.getParameter<
string>(
"OutputFileName"),
31 pset.existsAs<unsigned
int>(
"NumCPU")?pset.getParameter<unsigned
int>(
"NumCPU"):1,
32 pset.existsAs<
bool>(
"SaveWorkspace")?pset.getParameter<
bool>(
"SaveWorkspace"):
false,
33 pset.existsAs<
bool>(
"floatShapeParameters")?pset.getParameter<
bool>(
"floatShapeParameters"):
true,
34 pset.existsAs<vector<
string> >(
"fixVars")?pset.getParameter<vector<
string> >(
"fixVars"):vector<
string>()
36 split_mode( pset.existsAs<unsigned
int>(
"SplitMode")?pset.getParameter<unsigned
int>(
"SplitMode"):0 )
41 if (pset.
existsAs<
bool>(
"binnedFit")) {
44 }
else if (pset.
existsAs<uint32_t>(
"binsForMassPlots")) {
48 if (pset.
existsAs<
bool>(
"saveDistributionsPlot")) {
56 for (vector<string>::const_iterator
name = variableNames.begin();
name != variableNames.end();
name++) {
59 if(var.size()>=4 && !(istringstream(var[1])>>lo).
fail() && !(istringstream(var[2])>>hi).
fail()){
62 LogError(
"TagProbeFitTreeAnalyzer")<<
"Could not create variable: "<<*name<<
63 ". Example: pt = cms.vstring(\"Probe pT\", \"1.0\", \"100.0\", \"GeV/c\") ";
69 for (vector<string>::const_iterator
name = categoryNames.begin();
name != categoryNames.end();
name++) {
74 LogError(
"TagProbeFitTreeAnalyzer")<<
"Could not create category: "<<*name<<
75 ". Example: mcTrue = cms.vstring(\"MC True\", \"dummy[true=1,false=0]\") ";
82 for (vector<string>::const_iterator
name = exprNames.begin();
name != exprNames.end();
name++) {
85 vector<string>
args(expr.begin()+2,expr.end());
88 LogError(
"TagProbeFitTreeAnalyzer")<<
"Could not create expr: "<<*name<<
89 ". Example: qop = cms.vstring(\"qOverP\", \"charge/p\", \"charge\", \"p\") ";
98 for (vector<string>::const_iterator
name = cutNames.begin();
name != cutNames.end();
name++) {
103 LogError(
"TagProbeFitTreeAnalyzer")<<
"Could not create cut: "<<*name<<
104 ". Example: matched = cms.vstring(\"Matched\", \"deltaR\", \"0.5\") ";
112 for (vector<string>::const_iterator
name = pdfNames.begin();
name != pdfNames.end();
name++) {
113 vector<string> pdf = pdfs.
getParameter<vector<string> >(*name);
120 for (vector<string>::const_iterator
name = efficiencyNames.begin();
name != efficiencyNames.end();
name++) {
130 vector<string> effCatState = pset.
getParameter<vector<string> >(
"EfficiencyCategoryAndState");
131 if(effCatState.empty() || (effCatState.size() % 2 == 1)){
132 cout<<
"EfficiencyCategoryAndState must be a even-sized list of category names and states of that category (cat1, state1, cat2, state2, ...)."<<endl;
136 vector<string> unbinnedVariables;
137 if(pset.
existsAs<vector<string> >(
"UnbinnedVariables")){
138 unbinnedVariables = pset.
getParameter<vector<string> >(
"UnbinnedVariables");
142 map<string, vector<double> >binnedVariables;
144 for (vector<string>::const_iterator
var = variableNames.begin();
var != variableNames.end();
var++) {
145 vector<double>
binning = binVars.getParameter<vector<double> >(*var);
148 map<string, vector<string> >mappedCategories;
149 vector<string> categoryNames = binVars.getParameterNamesForType<vector<string> >();
150 for (vector<string>::const_iterator
var = categoryNames.begin();
var != categoryNames.end();
var++) {
151 vector<string>
map = binVars.getParameter<vector<string> >(*var);
152 mappedCategories[*
var] =
map;
155 vector<string> binToPDFmap;
156 if(pset.
existsAs<vector<string> >(
"BinToPDFmap")){
157 binToPDFmap = pset.
getParameter<vector<string> >(
"BinToPDFmap");
159 if((!binToPDFmap.empty()) && (binToPDFmap.size()%2 == 0)){
160 cout<<
"BinToPDFmap must have odd size, first string is the default, followed by binRegExp - PDFname pairs!"<<endl;
164 vector<string> effCats, effStates;
165 for (
size_t i = 0,
n = effCatState.size()/2;
i <
n; ++
i) {
166 effCats.push_back(effCatState[2*
i]);
167 effStates.push_back(effCatState[2*i+1]);
void setSaveDistributionsPlot(bool saveDistributionsPlot_)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
void addPdf(std::string pdfName, std::vector< std::string > &pdfCommands)
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
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 "...
def setup(process, global_tag, zero_tesla=False)
void calculateEfficiency(string name, const edm::ParameterSet &pset)
bool addThresholdCategory(std::string categoryName, std::string title, std::string varName, double cutValue)
adds a new category based on a cut
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
void setQuiet(bool quiet_=true)
suppress most of the output from RooFit and Minuit
#define DEFINE_FWK_MODULE(type)
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
TagProbeFitTreeAnalyzer(const edm::ParameterSet &pset)
void endRun(const edm::Run &run, const edm::EventSetup &setup) override
void setBinnedFit(bool binned, int bins=0)
set if to do a binned fit
~TagProbeFitTreeAnalyzer() override
void setSplitMode(unsigned int nevents)
void setBinsForMassPlots(int bins)
set number of bins to use when making the plots; 0 = automatic
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