Logo ROOT  
Reference Guide
HistoToWorkspaceFactory.cxx
Go to the documentation of this file.
1 // @(#)root/roostats:$Id: cranmer $
2 // Author: Kyle Cranmer, Akira Shibata
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 ////////////////////////////////////////////////////////////////////////////////
12 
13 /** \class RooStats::HistFactory::HistoToWorkspaceFactory
14  * \ingroup HistFactory
15  */
16 
17 
18 #ifndef __CINT__
19 #include "RooGlobalFunc.h"
20 #endif
21 
22 // Roofit/Roostat include
23 #include "RooDataSet.h"
24 #include "RooRealVar.h"
25 #include "RooConstVar.h"
26 #include "RooAddition.h"
27 #include "RooProduct.h"
28 #include "RooProdPdf.h"
29 #include "RooAddPdf.h"
30 #include "RooGaussian.h"
31 #include "RooExponential.h"
32 #include "RooRandom.h"
33 #include "RooCategory.h"
34 #include "RooSimultaneous.h"
35 #include "RooMultiVarGaussian.h"
36 #include "RooNumIntConfig.h"
37 #include "RooMinuit.h"
38 #include "RooNLLVar.h"
39 #include "RooProfileLL.h"
40 #include "RooFitResult.h"
41 #include "RooDataHist.h"
42 #include "RooHistPdf.h"
43 #include "RooWorkspace.h"
44 #include "RooCustomizer.h"
45 #include "RooPlot.h"
46 #include "RooMsgService.h"
47 #include "RooStats/RooStatsUtils.h"
48 #include "RooStats/ModelConfig.h"
49 
50 #include "TFile.h"
51 #include "TCanvas.h"
52 #include "TH1.h"
53 #include "TLine.h"
54 #include "TTree.h"
55 #include "TStopwatch.h"
56 #include "TStyle.h"
57 #include "TVectorD.h"
58 #include "TMatrixDSym.h"
59 
60 // specific to this package
63 #include "Helper.h"
64 
65 #define VERBOSE
66 
67 #define alpha_Low "-5"
68 #define alpha_High "5"
69 #define NoHistConst_Low "0"
70 #define NoHistConst_High "2000"
71 
72 // use this order for safety on library loading
73 using namespace RooFit ;
74 using namespace RooStats ;
75 using namespace std ;
76 //using namespace RooMsgService ;
77 
79 
80 namespace RooStats{
81 namespace HistFactory{
82 
83  HistoToWorkspaceFactory::HistoToWorkspaceFactory() :
84  fNomLumi(0),
85  fLumiError(0),
86  fLowBin(0),
87  fHighBin(0),
88  fOut_f(0),
89  pFile(0)
90  {
91  }
92 
94  fclose(pFile);
95  }
96 
97  HistoToWorkspaceFactory::HistoToWorkspaceFactory(string filePrefix, string row, vector<string> syst, double nomL, double lumiE, int low, int high, TFile* f):
98  fFileNamePrefix(filePrefix),
99  fRowTitle(row),
100  fSystToFix(syst),
101  fNomLumi(nomL),
102  fLumiError(lumiE),
103  fLowBin(low),
104  fHighBin(high),
105  fOut_f(f) {
106 
107  // fResultsPrefixStr<<"results" << "_" << fNomLumi<< "_" << fLumiError<< "_" << fLowBin<< "_" << fHighBin;
108  fResultsPrefixStr<< "_" << fRowTitle;
109  while(fRowTitle.find("\\ ")!=string::npos){
110  int pos=fRowTitle.find("\\ ");
111  fRowTitle.replace(pos, 1, "");
112  }
113  pFile = fopen ((filePrefix+"_results.table").c_str(),"a");
114  //RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR) ;
115 
116  }
117 
119 
120  stringstream ss;
121  ss << prefix << "_" << fNomLumi<< "_" << fLumiError<< "_" << fLowBin<< "_" << fHighBin<< "_"<<fRowTitle;
122 
123  return ss.str();
124  }
125 
126  void HistoToWorkspaceFactory::ProcessExpectedHisto(TH1* hist,RooWorkspace* proto, string prefix, string productPrefix, string systTerm, double low, double high, int lowBin, int highBin){
127  if(hist)
128  cout << "processing hist " << hist->GetName() << endl;
129  else
130  cout << "hist is empty" << endl;
131  RooArgSet argset(prefix.c_str());
132  string highStr = "inf";
133  for(Int_t i=lowBin; i<highBin; ++i){
134  std::stringstream str;
135  std::stringstream range;
136  str<<"_"<<i;
137  if(hist)
138  range<<"["<<hist->GetBinContent(i+1) << "," << low << "," << highStr << "]";
139  else
140  range<<"["<< low << "," << high << "]";
141  cout << "for bin N"+str.str() << " var " << prefix+str.str()+" with range " << range.str() << endl;
142  RooRealVar* var = (RooRealVar*) proto->factory((prefix+str.str()+range.str()).c_str());
143 
144  // now create the product of the overall efficiency times the sigma(params) for this estimate
145  if(! (productPrefix.empty() || systTerm.empty()) )
146  proto->factory(("prod:"+productPrefix+str.str()+"("+prefix+str.str()+","+systTerm+")").c_str() );
147 
148  var->setConstant();
149  argset.add(* var );
150  }
151  proto->defineSet(prefix.c_str(),argset);
152  // proto->Print();
153  }
154 
155  void HistoToWorkspaceFactory::AddMultiVarGaussConstraint(RooWorkspace* proto, string prefix,int lowBin, int highBin, vector<string>& likelihoodTermNames){
156  // these are the nominal predictions: eg. the mean of some space of variations
157  // later fill these in a loop over histogram bins
158  TVectorD mean(highBin-lowBin);
159  cout << "a" << endl;
160  for(Int_t i=lowBin; i<highBin; ++i){
161  std::stringstream str;
162  str<<"_"<<i;
163  RooRealVar* temp = proto->var((prefix+str.str()).c_str());
164  mean(i) = temp->getVal();
165  }
166 
167  TMatrixDSym Cov(highBin-lowBin);
168  for(int i=lowBin; i<highBin; ++i){
169  for(int j=0; j<highBin-lowBin; ++j){
170  if(i==j)
171  Cov(i,j) = sqrt(mean(i));
172  else
173  Cov(i,j) = 0;
174  }
175  }
176  // can't make MultiVarGaussian with factory yet, do it by hand
177  RooArgList floating( *(proto->set(prefix.c_str() ) ) );
178  RooMultiVarGaussian constraint((prefix+"Constraint").c_str(),"",
179  floating, mean, Cov);
180 
181  proto->import(constraint);
182 
183  likelihoodTermNames.push_back(constraint.GetName());
184 
185  }
186 
187 
188  void HistoToWorkspaceFactory::LinInterpWithConstraint(RooWorkspace* proto, TH1* nominal, vector<TH1*> lowHist, vector<TH1*> highHist,
189  vector<string> sourceName, string prefix, string productPrefix, string systTerm,
190  int lowBin, int highBin, vector<string>& likelihoodTermNames){
191  // these are the nominal predictions: eg. the mean of some space of variations
192  // later fill these in a loop over histogram bins
193 
194  // make list of abstract parameters that interpolate in space of variations
195  RooArgList params( ("alpha_Hist") );
196  // range is set using defined macro (see top of the page)
197  string range=string("[")+alpha_Low+","+alpha_High+"]";
198  for(unsigned int j=0; j<lowHist.size(); ++j){
199  std::stringstream str;
200  str<<"_"<<j;
201 
202  RooRealVar* temp = (RooRealVar*) proto->var(("alpha_"+sourceName.at(j)).c_str());
203  if(!temp){
204  temp = (RooRealVar*) proto->factory(("alpha_"+sourceName.at(j)+range).c_str());
205 
206  // now add a constraint term for these parameters
207  string command=("Gaussian::alpha_"+sourceName.at(j)+"Constraint(alpha_"+sourceName.at(j)+",nom_"+sourceName.at(j)+"[0.,-10,10],1.)");
208  cout << command << endl;
209  likelihoodTermNames.push_back( proto->factory( command.c_str() )->GetName() );
210  proto->var(("nom_"+sourceName.at(j)).c_str())->setConstant();
211  const_cast<RooArgSet*>(proto->set("globalObservables"))->add(*proto->var(("nom_"+sourceName.at(j)).c_str()));
212 
213  }
214 
215  params.add(* temp );
216 
217  }
218 
219  // now make function that linearly interpolates expectation between variations
220  for(Int_t i=lowBin; i<highBin; ++i){
221  std::stringstream str;
222  str<<"_"<<i;
223 
224  // get low/high variations to interpolate between
225  vector<double> low, high;
226  for(unsigned int j=0; j<lowHist.size(); ++j){
227  low.push_back( lowHist.at(j)->GetBinContent(i+1) );
228  high.push_back( highHist.at(j)->GetBinContent(i+1) );
229  cout << "for "+prefix+" bin "+str.str()+" creating linear interp of nominal " << nominal->GetBinContent(i+1)
230  << " in parameter " << sourceName.at(j)
231  << " between " << low.back() << " - " << high.back()
232  << " about " << 100.*fabs(low.back() - high.back() )/nominal->GetBinContent(i+1) << " % error"
233  << endl;
234  }
235 
236  // this is sigma(params), a piece-wise linear interpolation
237  LinInterpVar interp( (prefix+str.str()).c_str(), "", params, nominal->GetBinContent(i+1), low, high);
238 
239  // cout << "check: " << interp.getVal() << endl;
240  proto->import(interp); // individual params have already been imported in first loop of this function
241 
242  // now create the product of the overall efficiency times the sigma(params) for this estimate
243  proto->factory(("prod:"+productPrefix+str.str()+"("+prefix+str.str()+","+systTerm+")").c_str() );
244 
245  }
246 
247  }
248 
249  string HistoToWorkspaceFactory::AddNormFactor(RooWorkspace * proto, string & channel, string & sigmaEpsilon, EstimateSummary & es, bool doRatio){
250  string overallNorm_times_sigmaEpsilon ;
251  string prodNames;
252  vector<EstimateSummary::NormFactor> norm=es.normFactor;
253  if(norm.size()){
254  for(vector<EstimateSummary::NormFactor>::iterator itr=norm.begin(); itr!=norm.end(); ++itr){
255  cout << "making normFactor: " << itr->name << endl;
256  // remove "doRatio" and name can be changed when ws gets imported to the combined model.
257  std::stringstream range;
258  range<<"["<<itr->val<<","<<itr->low<<","<<itr->high<<"]";
259  //RooRealVar* var = 0;
260 
261  string varname;
262  if(!prodNames.empty()) prodNames+=",";
263  if(doRatio) {
264  varname=itr->name+"_"+channel;
265  }
266  else {
267  varname=itr->name;
268  }
269  proto->factory((varname+range.str()).c_str());
270  if(itr->constant){
271  // proto->var(varname.c_str())->setConstant();
272  // cout <<"setting " << varname << " constant"<<endl;
273  cout <<"WARNING: Const attribute to <NormFactor> tag is deprecated, will ignore."<<
274  " Instead, add \n\t<ParamSetting Const=\"True\">"<<varname<<"</ParamSetting>\n"<<
275  " to your top-level XML's <Measurment> entry"<< endl;
276  }
277  prodNames+=varname;
278  }
279  overallNorm_times_sigmaEpsilon = es.name+"_"+channel+"_overallNorm_x_sigma_epsilon";
280  proto->factory(("prod::"+overallNorm_times_sigmaEpsilon+"("+prodNames+","+sigmaEpsilon+")").c_str());
281  }
282 
283  if(!overallNorm_times_sigmaEpsilon.empty())
284  return overallNorm_times_sigmaEpsilon;
285  else
286  return sigmaEpsilon;
287  }
288 
289 
290  void HistoToWorkspaceFactory::AddEfficiencyTerms(RooWorkspace* proto, string prefix, string interpName,
291  map<string,pair<double,double> > systMap,
292  vector<string>& likelihoodTermNames, vector<string>& totSystTermNames){
293  // add variables for all the relative overall uncertainties we expect
294 
295  // range is set using defined macro (see top of the page)
296  string range=string("[0,")+alpha_Low+","+alpha_High+"]";
297  //string range="[0,-1,1]";
298  totSystTermNames.push_back(prefix);
299  //bool first=true;
300  RooArgSet params(prefix.c_str());
301  vector<double> lowVec, highVec;
302  for(map<string,pair<double,double> >::iterator it=systMap.begin(); it!=systMap.end(); ++it){
303  // add efficiency term
304  RooRealVar* temp = (RooRealVar*) proto->var((prefix+ it->first).c_str());
305  if(!temp){
306  temp = (RooRealVar*) proto->factory((prefix+ it->first +range).c_str());
307 
308  string command=("Gaussian::"+prefix+it->first+"Constraint("+prefix+it->first+",nom_"+prefix+it->first+"[0.,-10,10],1.)");
309  cout << command << endl;
310  likelihoodTermNames.push_back( proto->factory( command.c_str() )->GetName() );
311  proto->var(("nom_"+prefix+it->first).c_str())->setConstant();
312  const_cast<RooArgSet*>(proto->set("globalObservables"))->add(*proto->var(("nom_"+prefix+it->first).c_str()));
313 
314  }
315  params.add(*temp);
316 
317  // add constraint in terms of bifrucated gauss with low/high as sigmas
318  std::stringstream lowhigh;
319  double low = it->second.first;
320  double high = it->second.second;
321  lowVec.push_back(low);
322  highVec.push_back(high);
323 
324  }
325  if(systMap.size()>0){
326  // this is epsilon(alpha_j), a piece-wise linear interpolation
327  LinInterpVar interp( (interpName).c_str(), "", params, 1., lowVec, highVec);
328  proto->import(interp); // params have already been imported in first loop of this function
329  } else{
330  // some strange behavior if params,lowVec,highVec are empty.
331  //cout << "WARNING: No OverallSyst terms" << endl;
332  RooConstVar interp( (interpName).c_str(), "", 1.);
333  proto->import(interp); // params have already been imported in first loop of this function
334  }
335 
336  }
337 
338 
339  void HistoToWorkspaceFactory::MakeTotalExpected(RooWorkspace* proto, string totName, string /**/, string /**/,
340  int lowBin, int highBin, vector<string>& syst_x_expectedPrefixNames,
341  vector<string>& normByNames){
342 
343  // for ith bin calculate totN_i = lumi * sum_j expected_j * syst_j
344 
345  for(Int_t i=lowBin; i<highBin; ++i){
346  std::stringstream str;
347  str<<"_"<<i;
348  string command="sum::"+totName+str.str()+"(";
349  //vector<string>::iterator it=syst_x_expectedPrefixNames.begin();
350  string prepend="";
351  for(unsigned int j=0; j<syst_x_expectedPrefixNames.size();++j){
352  command+=prepend+normByNames.at(j)+"*"+syst_x_expectedPrefixNames.at(j)+str.str();
353  prepend=",";
354  }
355  command+=")";
356  cout << "function to calculate total: " << command << endl;
357  proto->factory(command.c_str());
358  }
359  }
360 
361  void HistoToWorkspaceFactory::AddPoissonTerms(RooWorkspace* proto, string prefix, string obsPrefix, string expPrefix, int lowBin, int highBin,
362  vector<string>& likelihoodTermNames){
363  /////////////////////////////////
364  // Relate observables to expected for each bin
365  // later modify variable named expPrefix_i to be product of terms
366  RooArgSet Pois(prefix.c_str());
367  for(Int_t i=lowBin; i<highBin; ++i){
368  std::stringstream str;
369  str<<"_"<<i;
370  //string command("Poisson::"+prefix+str.str()+"("+obsPrefix+str.str()+","+expPrefix+str.str()+")");
371  string command("Poisson::"+prefix+str.str()+"("+obsPrefix+str.str()+","+expPrefix+str.str()+",1)");//for no rounding
372  RooAbsArg* temp = (proto->factory( command.c_str() ) );
373 
374  // output
375  cout << "Poisson Term " << command << endl;
376  ((RooAbsPdf*) temp)->setEvalErrorLoggingMode(RooAbsReal::PrintErrors);
377  //cout << temp << endl;
378 
379  likelihoodTermNames.push_back( temp->GetName() );
380  Pois.add(* temp );
381  }
382  proto->defineSet(prefix.c_str(),Pois); // add argset to workspace
383  }
384 
385  void HistoToWorkspaceFactory::SetObsToExpected(RooWorkspace* proto, string obsPrefix, string expPrefix, int lowBin, int highBin){
386  /////////////////////////////////
387  // set observed to expected
388  TTree* tree = new TTree();
389  Double_t* obsForTree = new Double_t[highBin-lowBin];
390  RooArgList obsList("obsList");
391 
392  for(Int_t i=lowBin; i<highBin; ++i){
393  std::stringstream str;
394  str<<"_"<<i;
395  RooRealVar* obs = (RooRealVar*) proto->var((obsPrefix+str.str()).c_str());
396  cout << "expected number of events called: " << expPrefix << endl;
397  RooAbsReal* exp = proto->function((expPrefix+str.str()).c_str());
398  if(obs && exp){
399 
400  //proto->Print();
401  obs->setVal( exp->getVal() );
402  cout << "setting obs"+str.str()+" to expected = " << exp->getVal() << " check: " << obs->getVal() << endl;
403 
404  // add entry to array and attach to tree
405  obsForTree[i] = exp->getVal();
406  tree->Branch((obsPrefix+str.str()).c_str(), obsForTree+i ,(obsPrefix+str.str()+"/D").c_str());
407  obsList.add(*obs);
408  }else{
409  cout << "problem retrieving obs or exp " << obsPrefix+str.str() << obs << " " << expPrefix+str.str() << exp << endl;
410  }
411  }
412  tree->Fill();
413  RooDataSet* data = new RooDataSet("expData","", tree, obsList); // one experiment
414 
415  proto->import(*data);
416  delete[] obsForTree;
417  obsForTree = nullptr;
418  }
419 
420  void HistoToWorkspaceFactory::Customize(RooWorkspace* proto, const char* pdfNameChar, map<string,string> renameMap) {
421  cout << "in customizations" << endl;
422  string pdfName(pdfNameChar);
423  map<string,string>::iterator it;
424  string edit="EDIT::customized("+pdfName+",";
425  string precede="";
426  for(it=renameMap.begin(); it!=renameMap.end(); ++it) {
427  cout << it->first + "=" + it->second << endl;
428  edit+=precede + it->first + "=" + it->second;
429  precede=",";
430  }
431  edit+=")";
432  cout << edit<< endl;
433  proto->factory( edit.c_str() );
434  }
435 
436  //////////////////////////////////////////////////////////////////////////////
437  /// cout << "in edit, gammamap.size = " << gammaSyst.size() << ", unimap.size = " << uniformSyst.size() << endl;
438 
439  void HistoToWorkspaceFactory::EditSyst(RooWorkspace* proto, const char* pdfNameChar, map<string,double> gammaSyst, map<string,double> uniformSyst,map<string,double> logNormSyst) {
440  string pdfName(pdfNameChar);
441 
442  ModelConfig * combined_config = (ModelConfig *) proto->obj("ModelConfig");
443  // const RooArgSet * constrainedParams=combined_config->GetNuisanceParameters();
444  // RooArgSet temp(*constrainedParams);
445  string edit="EDIT::newSimPdf("+pdfName+",";
446  string editList;
447  string lastPdf=pdfName;
448  string precede="";
449  unsigned int numReplacements = 0;
450  unsigned int nskipped = 0;
451  map<string,double>::iterator it;
452 
453  // add gamma terms and their constraints
454  for(it=gammaSyst.begin(); it!=gammaSyst.end(); ++it) {
455  //cout << "edit for " << it->first << "with rel uncert = " << it->second << endl;
456  if(! proto->var(("alpha_"+it->first).c_str())){
457  //cout << "systematic not there" << endl;
458  nskipped++;
459  continue;
460  }
461  numReplacements++;
462 
463  double relativeUncertainty = it->second;
464  double scale = 1/sqrt((1+1/pow(relativeUncertainty,2)));
465 
466  // this is the Gamma PDF and in a form that doesn't have roundoff problems like the Poisson does
467  proto->factory(Form("beta_%s[1,0,10]",it->first.c_str()));
468  proto->factory(Form("y_%s[%f]",it->first.c_str(),1./pow(relativeUncertainty,2))) ;
469  proto->factory(Form("theta_%s[%f]",it->first.c_str(),pow(relativeUncertainty,2))) ;
470  proto->factory(Form("Gamma::beta_%sConstraint(beta_%s,sum::k_%s(y_%s,one[1]),theta_%s,zero[0])",
471  it->first.c_str(),
472  it->first.c_str(),
473  it->first.c_str(),
474  it->first.c_str(),
475  it->first.c_str())) ;
476 
477  /*
478  // this has some problems because N in poisson is rounded to nearest integer
479  proto->factory(Form("Poisson::beta_%sConstraint(y_%s[%f],prod::taub_%s(taus_%s[%f],beta_%s[1,0,5]))",
480  it->first.c_str(),
481  it->first.c_str(),
482  1./pow(relativeUncertainty,2),
483  it->first.c_str(),
484  it->first.c_str(),
485  1./pow(relativeUncertainty,2),
486  it->first.c_str()
487  ) ) ;
488  */
489  // combined->factory(Form("expr::alphaOfBeta('(beta-1)/%f',beta)",scale));
490  // combined->factory(Form("expr::alphaOfBeta_%s('(beta_%s-1)/%f',beta_%s)",it->first.c_str(),it->first.c_str(),scale,it->first.c_str()));
491  proto->factory(Form("PolyVar::alphaOfBeta_%s(beta_%s,{%f,%f})",it->first.c_str(),it->first.c_str(),-1./scale,1./scale));
492 
493  // set beta const status to be same as alpha
494  if(proto->var(Form("alpha_%s",it->first.c_str()))->isConstant())
495  proto->var(Form("beta_%s",it->first.c_str()))->setConstant(true);
496  else
497  proto->var(Form("beta_%s",it->first.c_str()))->setConstant(false);
498  // set alpha const status to true
499  // proto->var(Form("alpha_%s",it->first.c_str()))->setConstant(true);
500 
501  // replace alphas with alphaOfBeta and replace constraints
502  //cout << "alpha_"+it->first+"Constraint=beta_" + it->first+ "Constraint" << endl;
503  editList+=precede + "alpha_"+it->first+"Constraint=beta_" + it->first+ "Constraint";
504  precede=",";
505  // cout << "alpha_"+it->first+"=alphaOfBeta_"+ it->first << endl;
506  editList+=precede + "alpha_"+it->first+"=alphaOfBeta_"+ it->first;
507 
508  /*
509  if( proto->pdf(("alpha_"+it->first+"Constraint").c_str()) && proto->var(("alpha_"+it->first).c_str()) )
510  cout << " checked they are there" << proto->pdf(("alpha_"+it->first+"Constraint").c_str()) << " " << proto->var(("alpha_"+it->first).c_str()) << endl;
511  else
512  cout << "NOT THERE" << endl;
513  */
514 
515  // EDIT seems to die if the list of edits is too long. So chunck them up.
516  if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
517  edit="EDIT::"+lastPdf+"_("+lastPdf+","+editList+")";
518  lastPdf+="_"; // append an underscore for the edit
519  editList=""; // reset edit list
520  precede="";
521  cout << "Going to issue this edit command\n" << edit<< endl;
522  proto->factory( edit.c_str() );
523  RooAbsPdf* newOne = proto->pdf(lastPdf.c_str());
524  if(!newOne)
525  cout << "\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
526 
527  }
528  }
529 
530  // add uniform terms and their constraints
531  for(it=uniformSyst.begin(); it!=uniformSyst.end(); ++it) {
532  cout << "edit for " << it->first << "with rel uncert = " << it->second << endl;
533  if(! proto->var(("alpha_"+it->first).c_str())){
534  cout << "systematic not there" << endl;
535  nskipped++;
536  continue;
537  }
538  numReplacements++;
539 
540  // this is the Uniform PDF
541  proto->factory(Form("beta_%s[1,0,10]",it->first.c_str()));
542  proto->factory(Form("Uniform::beta_%sConstraint(beta_%s)",it->first.c_str(),it->first.c_str()));
543  proto->factory(Form("PolyVar::alphaOfBeta_%s(beta_%s,{-1,1})",it->first.c_str(),it->first.c_str()));
544 
545  // set beta const status to be same as alpha
546  if(proto->var(Form("alpha_%s",it->first.c_str()))->isConstant())
547  proto->var(Form("beta_%s",it->first.c_str()))->setConstant(true);
548  else
549  proto->var(Form("beta_%s",it->first.c_str()))->setConstant(false);
550  // set alpha const status to true
551  // proto->var(Form("alpha_%s",it->first.c_str()))->setConstant(true);
552 
553  // replace alphas with alphaOfBeta and replace constraints
554  cout << "alpha_"+it->first+"Constraint=beta_" + it->first+ "Constraint" << endl;
555  editList+=precede + "alpha_"+it->first+"Constraint=beta_" + it->first+ "Constraint";
556  precede=",";
557  cout << "alpha_"+it->first+"=alphaOfBeta_"+ it->first << endl;
558  editList+=precede + "alpha_"+it->first+"=alphaOfBeta_"+ it->first;
559 
560  if( proto->pdf(("alpha_"+it->first+"Constraint").c_str()) && proto->var(("alpha_"+it->first).c_str()) )
561  cout << " checked they are there" << proto->pdf(("alpha_"+it->first+"Constraint").c_str()) << " " << proto->var(("alpha_"+it->first).c_str()) << endl;
562  else
563  cout << "NOT THERE" << endl;
564 
565  // EDIT seems to die if the list of edits is too long. So chunck them up.
566  if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
567  edit="EDIT::"+lastPdf+"_("+lastPdf+","+editList+")";
568  lastPdf+="_"; // append an underscore for the edit
569  editList=""; // reset edit list
570  precede="";
571  cout << edit<< endl;
572  proto->factory( edit.c_str() );
573  RooAbsPdf* newOne = proto->pdf(lastPdf.c_str());
574  if(!newOne)
575  cout << "\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
576 
577  }
578  }
579 
580  /////////////////////////////////////////
581  ////////////////////////////////////
582 
583 
584  // add lognormal terms and their constraints
585  for(it=logNormSyst.begin(); it!=logNormSyst.end(); ++it) {
586  cout << "edit for " << it->first << "with rel uncert = " << it->second << endl;
587  if(! proto->var(("alpha_"+it->first).c_str())){
588  cout << "systematic not there" << endl;
589  nskipped++;
590  continue;
591  }
592  numReplacements++;
593 
594  double relativeUncertainty = it->second;
595  double kappa = 1+relativeUncertainty;
596  // when transforming beta -> alpha, need alpha=1 to be +1sigma value.
597  // the P(beta>kappa*\hat(beta)) = 16%
598  // and \hat(beta) is 1, thus
599  double scale = relativeUncertainty;
600  //double scale = kappa;
601 
602  // this is the LogNormal
603  proto->factory(Form("beta_%s[1,0,10]",it->first.c_str()));
604  proto->factory(Form("kappa_%s[%f]",it->first.c_str(),kappa));
605  proto->factory(Form("Lognormal::beta_%sConstraint(beta_%s,one[1],kappa_%s)",
606  it->first.c_str(),
607  it->first.c_str(),
608  it->first.c_str())) ;
609  proto->factory(Form("PolyVar::alphaOfBeta_%s(beta_%s,{%f,%f})",it->first.c_str(),it->first.c_str(),-1./scale,1./scale));
610  // proto->factory(Form("PolyVar::alphaOfBeta_%s(beta_%s,{%f,%f})",it->first.c_str(),it->first.c_str(),-1.,1./scale));
611 
612  // set beta const status to be same as alpha
613  if(proto->var(Form("alpha_%s",it->first.c_str()))->isConstant())
614  proto->var(Form("beta_%s",it->first.c_str()))->setConstant(true);
615  else
616  proto->var(Form("beta_%s",it->first.c_str()))->setConstant(false);
617  // set alpha const status to true
618  // proto->var(Form("alpha_%s",it->first.c_str()))->setConstant(true);
619 
620  // replace alphas with alphaOfBeta and replace constraints
621  cout << "alpha_"+it->first+"Constraint=beta_" + it->first+ "Constraint" << endl;
622  editList+=precede + "alpha_"+it->first+"Constraint=beta_" + it->first+ "Constraint";
623  precede=",";
624  cout << "alpha_"+it->first+"=alphaOfBeta_"+ it->first << endl;
625  editList+=precede + "alpha_"+it->first+"=alphaOfBeta_"+ it->first;
626 
627  if( proto->pdf(("alpha_"+it->first+"Constraint").c_str()) && proto->var(("alpha_"+it->first).c_str()) )
628  cout << " checked they are there" << proto->pdf(("alpha_"+it->first+"Constraint").c_str()) << " " << proto->var(("alpha_"+it->first).c_str()) << endl;
629  else
630  cout << "NOT THERE" << endl;
631 
632  // EDIT seems to die if the list of edits is too long. So chunck them up.
633  if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
634  edit="EDIT::"+lastPdf+"_("+lastPdf+","+editList+")";
635  lastPdf+="_"; // append an underscore for the edit
636  editList=""; // reset edit list
637  precede="";
638  cout << edit<< endl;
639  proto->factory( edit.c_str() );
640  RooAbsPdf* newOne = proto->pdf(lastPdf.c_str());
641  if(!newOne)
642  cout << "\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
643 
644  }
645  }
646 
647  /////////////////////////////////////////
648  ////////////////////////////////////
649 
650  // commit last bunch of edits
651  edit="EDIT::newSimPdf("+lastPdf+","+editList+")";
652  cout << edit<< endl;
653  proto->factory( edit.c_str() );
654  // proto->writeToFile(("results/model_"+fRowTitle+"_edited.root").c_str());
655  RooAbsPdf* newOne = proto->pdf("newSimPdf");
656  if(newOne){
657  // newOne->graphVizTree(("results/"+pdfName+"_"+fRowTitle+"newSimPdf.dot").c_str());
658  combined_config->SetPdf(*newOne);
659  }
660  else{
661  cout << "\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
662  }
663  }
664 
666  // FILE * pFile;
667  pFile = fopen ((filename).c_str(),"w");
668 
669 
670  TIter iti = params->createIterator();
671  TIter itj = params->createIterator();
672  RooRealVar *myargi, *myargj;
673  fprintf(pFile," ") ;
674  while ((myargi = (RooRealVar *)iti.Next())) {
675  if(myargi->isConstant()) continue;
676  fprintf(pFile," & %s", myargi->GetName());
677  }
678  fprintf(pFile,"\\\\ \\hline \n" );
679  iti.Reset();
680  while ((myargi = (RooRealVar *)iti.Next())) {
681  if(myargi->isConstant()) continue;
682  fprintf(pFile,"%s", myargi->GetName());
683  itj.Reset();
684  while ((myargj = (RooRealVar *)itj.Next())) {
685  if(myargj->isConstant()) continue;
686  cout << myargi->GetName() << "," << myargj->GetName();
687  fprintf(pFile, " & %.2f", result->correlation(*myargi, *myargj));
688  }
689  cout << endl;
690  fprintf(pFile, " \\\\\n");
691  }
692  fclose(pFile);
693 
694  }
695 
696 
697  ///////////////////////////////////////////////
698  RooWorkspace* HistoToWorkspaceFactory::MakeSingleChannelModel(vector<EstimateSummary> summary, vector<string> systToFix, bool doRatio)
699  {
700 
701  if (summary.empty() ) {
702  Error("MakeSingleChannelModel","vector of EstimateSummry is empty - return a nullptr");
703  return 0;
704  }
705 
706  // to time the macro
707  TStopwatch t;
708  t.Start();
709  string channel=summary[0].channel;
710  cout << "\n\n-------------------\nStarting to process " << channel << " channel" << endl;
711 
712  //
713  // our main workspace that we are using to construct the model
714  //
715  RooWorkspace* proto = new RooWorkspace("proto","proto workspace");
716  ModelConfig * proto_config = new ModelConfig("ModelConfig", proto);
717  proto_config->SetWorkspace(*proto);
718 
719  RooArgSet likelihoodTerms("likelihoodTerms");
720  vector<string> likelihoodTermNames, totSystTermNames,syst_x_expectedPrefixNames, normalizationNames;
721 
722  string prefix, range;
723 
724  /////////////////////////////
725  // Make observables, set values to observed data if data is specified,
726  // otherwise use expected "Asimov" data
727  if (summary.at(0).name=="Data") {
728  ProcessExpectedHisto(summary.at(0).nominal,proto,"obsN","","",0,100000,fLowBin,fHighBin);
729  } else {
730  cout << "Will use expected (\"Asimov\") data set" << endl;
731  ProcessExpectedHisto(NULL,proto,"obsN","","",0,100000,fLowBin,fHighBin);
732  }
733 
734 
735 
736  /////////////////////////////
737  // shared parameters
738  // this is ratio of lumi to nominal lumi. We will include relative uncertainty in model
739  std::stringstream lumiStr;
740  // lumi range
741  lumiStr<<"["<<fNomLumi<<",0,"<<10.*fNomLumi<<"]";
742  proto->factory(("Lumi"+lumiStr.str()).c_str());
743  cout << "lumi str = " << lumiStr.str() << endl;
744 
745  std::stringstream lumiErrorStr;
746  // lumiErrorStr << "nominalLumi["<<fNomLumi << "]," << fLumiError ;
747  lumiErrorStr << "nominalLumi["<<fNomLumi << ",0,"<<fNomLumi+10*fLumiError<<"]," << fLumiError ;
748  proto->factory(("Gaussian::lumiConstraint(Lumi,"+lumiErrorStr.str()+")").c_str());
749  proto->var("nominalLumi")->setConstant();
750  proto->defineSet("globalObservables","nominalLumi");
751  likelihoodTermNames.push_back("lumiConstraint");
752  cout << "lumi Error str = " << lumiErrorStr.str() << endl;
753 
754  //proto->factory((string("SigXsecOverSM[1.,0.5,1..8]").c_str()));
755  ///////////////////////////////////
756  // loop through estimates, add expectation, floating bin predictions,
757  // and terms that constrain floating to expectation via uncertainties
758  vector<EstimateSummary>::iterator it = summary.begin();
759  for(; it!=summary.end(); ++it){
760  if(it->name=="Data") continue;
761 
762  string overallSystName = it->name+"_"+it->channel+"_epsilon";
763  string systSourcePrefix = "alpha_";
764  AddEfficiencyTerms(proto,systSourcePrefix, overallSystName,
765  it->overallSyst,
766  likelihoodTermNames, totSystTermNames);
767 
768  overallSystName=AddNormFactor(proto, channel, overallSystName, *it, doRatio);
769  // get histogram
770  TH1* nominal = it->nominal;
771  if(it->lowHists.size() == 0){
772  cout << it->name+"_"+it->channel+" has no variation histograms " <<endl;
773  string expPrefix=it->name+"_"+it->channel+"_expN";
774  string syst_x_expectedPrefix=it->name+"_"+it->channel+"_overallSyst_x_Exp";
775  ProcessExpectedHisto(nominal,proto,expPrefix,syst_x_expectedPrefix,overallSystName,atoi(NoHistConst_Low),atoi(NoHistConst_High),fLowBin,fHighBin);
776  syst_x_expectedPrefixNames.push_back(syst_x_expectedPrefix);
777  } else if(it->lowHists.size() != it->highHists.size()){
778  cout << "problem in "+it->name+"_"+it->channel
779  << " number of low & high variation histograms don't match" << endl;
780  return 0;
781  } else {
782  string constraintPrefix = it->name+"_"+it->channel+"_Hist_alpha"; // name of source for variation
783  string syst_x_expectedPrefix = it->name+"_"+it->channel+"_overallSyst_x_HistSyst";
784  LinInterpWithConstraint(proto, nominal, it->lowHists, it->highHists, it->systSourceForHist,
785  constraintPrefix, syst_x_expectedPrefix, overallSystName,
786  fLowBin, fHighBin, likelihoodTermNames);
787  syst_x_expectedPrefixNames.push_back(syst_x_expectedPrefix);
788  }
789 
790  // AddMultiVarGaussConstraint(proto, "exp"+it->first+"N", fLowBin, fHighBin, likelihoodTermNames);
791 
792  if(it->normName=="")
793  normalizationNames.push_back( "Lumi" );
794  else
795  normalizationNames.push_back( it->normName);
796  }
797  //proto->Print();
798 
799  ///////////////////////////////////
800  // for ith bin calculate totN_i = lumi * sum_j expected_j * syst_j
801  MakeTotalExpected(proto,channel+"_totN",channel+"_expN","Lumi",fLowBin,fHighBin,
802  syst_x_expectedPrefixNames, normalizationNames);
803 
804  /////////////////////////////////
805  // Relate observables to expected for each bin
806  AddPoissonTerms(proto, "Pois_"+channel, "obsN", channel+"_totN", fLowBin, fHighBin, likelihoodTermNames);
807 
808  /////////////////////////////////
809  // if no data histogram provided, make asimov data
810  if(summary.at(0).name!="Data"){
811  SetObsToExpected(proto, "obsN",channel+"_totN", fLowBin, fHighBin);
812  cout << " using asimov data" << endl;
813  } else{
814  SetObsToExpected(proto, "obsN","obsN", fLowBin, fHighBin);
815  cout << " using input data histogram" << endl;
816  }
817 
818  //////////////////////////////////////
819  // fix specified parameters
820  for(unsigned int i=0; i<systToFix.size(); ++i){
821  RooRealVar* temp = proto->var((systToFix.at(i)).c_str());
822  if(temp) temp->setConstant();
823  else cout << "could not find variable " << systToFix.at(i) << " could not set it to constant" << endl;
824  }
825 
826  //////////////////////////////////////
827  // final proto model
828  for(unsigned int i=0; i<likelihoodTermNames.size(); ++i){
829  // cout << likelihoodTermNames[i] << endl;
830  likelihoodTerms.add(* (proto->arg(likelihoodTermNames[i].c_str())) );
831  }
832  // likelihoodTerms.Print();
833 
834  proto->defineSet("likelihoodTerms",likelihoodTerms);
835  // proto->Print();
836 
837  cout <<"-----------------------------------------"<<endl;
838  cout <<"import model into workspace" << endl;
839  RooProdPdf* model = new RooProdPdf(("model_"+channel).c_str(),
840  "product of Poissons accross bins for a single channel",
841  likelihoodTerms);
842  proto->import(*model,RecycleConflictNodes());
843 
844  proto_config->SetPdf(*model);
845  proto_config->SetGlobalObservables(*proto->set("globalObservables"));
846 
847  proto->import(*proto_config,proto_config->GetName());
848  proto->importClassCode();
849  // proto->writeToFile(("results/model_"+channel+".root").c_str());
850 
851  return proto;
852  }
853 
854  RooWorkspace* HistoToWorkspaceFactory::MakeCombinedModel(vector<string> ch_names, vector<RooWorkspace*> chs)
855  {
856 
857  //
858  /// These things were used for debugging. Maybe useful in the future
859  //
860  // RooAbsReal::defaultIntegratorConfig()->setEpsAbs(1e-8) ;
861  // RooAbsReal::defaultIntegratorConfig()->setEpsRel(1e-8) ;
862  // RooMsgService::instance().setGlobalKillBelow(RooMsgService::WARNING);
863  // RooMsgService::instance().setGlobalKillBelow(RooMsgService::WARNING) ;
864  // cout << "MsgSvc: " << RooMsgService::instance().globalKillBelow() << " INFO "
865  // << RooMsgService::INFO << " WARNING " << RooMsgService::WARNING << endl;
866 
867  // RooArgSet* constrainedParams= new RooArgSet("constrainedParams");
868 
869  // check inputs (see JIRA-6890)
870  if (ch_names.empty() || chs.empty() ) {
871  Error("MakeCombinedModel","Input vectors are empty - return a nullptr");
872  return 0;
873  }
874  if (chs.size() < ch_names.size() ) {
875  Error("MakeCombinedModel","Input vector of workspace has an invalid size - return a nullptr");
876  return 0;
877  }
878 
879  map<string, RooAbsPdf*> pdfMap;
880  vector<RooAbsPdf*> models;
881  stringstream ss;
882 
883  RooArgSet globalObs;
884  for(unsigned int i = 0; i< ch_names.size(); ++i){
885  string channel_name=ch_names[i];
886 
887  if (ss.str().empty()) ss << channel_name ;
888  else ss << ',' << channel_name ;
889  RooWorkspace * ch=chs[i];
890 
891  RooAbsPdf* model = ch->pdf(("model_"+channel_name).c_str());
892  models.push_back(model);
893  globalObs.add(*ch->set("globalObservables"));
894 
895  // constrainedParams->add( * ch->set("constrainedParams") );
896  pdfMap[channel_name]=model;
897  }
898  //constrainedParams->Print();
899 
900  cout << "\n\n------------------\n Entering combination" << endl;
901  RooWorkspace* combined = new RooWorkspace("combined");
902 
903  RooCategory* channelCat = (RooCategory*) combined->factory(("channelCat["+ss.str()+"]").c_str());
904  RooSimultaneous * simPdf= new RooSimultaneous("simPdf","",pdfMap, *channelCat);
905  ModelConfig * combined_config = new ModelConfig("ModelConfig", combined);
906  combined_config->SetWorkspace(*combined);
907  // combined_config->SetNuisanceParameters(*constrainedParams);
908  combined->import(globalObs);
909  combined->defineSet("globalObservables",globalObs);
910  combined_config->SetGlobalObservables(*combined->set("globalObservables"));
911 
912  ////////////////////////////////////////////
913  // Make toy simultaneous dataset
914  cout <<"-----------------------------------------"<<endl;
915  cout << "create toy data for " << ss.str() << endl;
916 
917  const RooArgSet* obsN = chs[0]->set("obsN");
918 
919  RooDataSet * simData=new RooDataSet("simData","master dataset", *obsN,
920  Index(*channelCat), Import(ch_names[0].c_str(),*((RooDataSet*)chs[0]->data("expData"))));
921  for(unsigned int i = 1; i< ch_names.size(); ++i){
922  RooDataSet * simData_ch=new RooDataSet("simData","master dataset", *obsN,
923  Index(*channelCat), Import(ch_names[i].c_str(),*((RooDataSet*)chs[i]->data("expData"))));
924  simData->append(*simData_ch);
925  }
926  //for(int i=0; i<simData->numEntries(); ++i)
927  // simData->get(i)->Print("v");
928 
929  combined->import(*simData,RecycleConflictNodes());
930 
931  cout << "\n\n----------------\n Importing combined model" << endl;
932  combined->import(*simPdf,RecycleConflictNodes());
933  //combined->import(*simPdf, RenameVariable("SigXsecOverSM","SigXsecOverSM_comb"));
934  cout << "check pointer " << simPdf << endl;
935 
936  for(unsigned int i=0; i<fSystToFix.size(); ++i){
937  // make sure they are fixed
938  RooRealVar* temp = combined->var((fSystToFix.at(i)).c_str());
939  if(temp) {
940  temp->setConstant();
941  cout <<"setting " << fSystToFix.at(i) << " constant" << endl;
942  }
943  else cout << "could not find variable " << fSystToFix.at(i) << " could not set it to constant" << endl;
944  }
945 
946  ///
947  /// writing out the model in graphViz
948  ///
949  // RooAbsPdf* customized=combined->pdf("simPdf");
950  //combined_config->SetPdf(*customized);
951  combined_config->SetPdf(*simPdf);
952  // customized->graphVizTree(("results/"+fResultsPrefixStr.str()+"_simul.dot").c_str());
953  combined->import(*combined_config,combined_config->GetName());
954  combined->importClassCode();
955  // combined->writeToFile("results/model_combined.root");
956 
957  return combined;
958  }
959 
960  ///////////////////////////////////////////////
961  void HistoToWorkspaceFactory::FitModel(RooWorkspace * combined, string channel, string /*model_name*/, string data_name, bool /*doParamInspect*/)
962  {
963 
964  ModelConfig * combined_config = (ModelConfig *) combined->obj("ModelConfig");
965  RooDataSet * simData = (RooDataSet *) combined->obj(data_name.c_str());
966  // const RooArgSet * constrainedParams=combined_config->GetNuisanceParameters();
967  const RooArgSet * POIs=combined_config->GetParametersOfInterest();
968 
969  /*
970  RooRealVar* poi = (RooRealVar*) combined->var("SigXsecOverSM");
971  RooArgSet * params= new RooArgSet;
972  params->add(*poi);
973  combined_config->SetParameters(*params);
974 
975  RooAbsData* expData = combined->data("expData");
976  RooArgSet* temp = (RooArgSet*) combined->set("obsN")->Clone("temp");
977  temp->add(*poi);
978  RooAbsPdf* model=combined_config->GetPdf();
979  RooArgSet* constrainedParams = model->getParameters(temp);
980  combined->defineSet("constrainedParams", *constrainedParams);
981  */
982 
983  //RooAbsPdf* model=combined->pdf(model_name.c_str());
984  RooAbsPdf* model=combined_config->GetPdf();
985  // RooArgSet* allParams = model->getParameters(*simData);
986 
987  ///////////////////////////////////////
988  //Do combined fit
989  //RooMsgService::instance().setGlobalKillBelow(RooMsgService::INFO) ;
990  cout << "\n\n---------------" << endl;
991  cout << "---------------- Doing "<< channel << " Fit" << endl;
992  cout << "---------------\n\n" << endl;
993  // RooFitResult* result = model->fitTo(*simData, Minos(kTRUE), Save(kTRUE), PrintLevel(1));
994  model->fitTo(*simData, Minos(kTRUE), PrintLevel(1));
995  // PrintCovarianceMatrix(result, allParams, "results/"+FilePrefixStr(channel)+"_corrMatrix.table" );
996 
997  //
998  // assuming there is only on poi
999  //
1000  RooRealVar* poi = 0; // (RooRealVar*) POIs->first();
1001  // for results tables
1002  TIterator* params_itr=POIs->createIterator();
1003  TObject* params_obj=0;
1004  while((params_obj=params_itr->Next())){
1005  poi = (RooRealVar*) params_obj;
1006  cout << "printing results for " << poi->GetName() << " at " << poi->getVal()<< " high " << poi->getErrorLo() << " low " << poi->getErrorHi()<<endl;
1007  }
1008  fprintf(pFile, " %.4f / %.4f ", poi->getErrorLo(), poi->getErrorHi());
1009 
1010  RooAbsReal* nll = model->createNLL(*simData);
1011  RooAbsReal* profile = nll->createProfile(*poi);
1012  RooPlot* frame = poi->frame();
1013  FormatFrameForLikelihood(frame);
1014  TCanvas* c1 = new TCanvas( channel.c_str(), "",800,600);
1015  nll->plotOn(frame, ShiftToZero(), LineColor(kRed), LineStyle(kDashed));
1016  profile->plotOn(frame);
1017  frame->SetMinimum(0);
1018  frame->SetMaximum(2.);
1019  frame->Draw();
1020  // c1->SaveAs( ("results/"+FilePrefixStr(channel)+"_profileLR.eps").c_str() );
1021  c1->SaveAs( (fFileNamePrefix+"_"+channel+"_"+fRowTitle+"_profileLR.eps").c_str() );
1022 
1023  fOut_f->mkdir(channel.c_str())->mkdir("Summary")->cd();
1024 
1025  // an example of calculating profile for a nuisance parameter not poi
1026  /*
1027  RooRealVar* alpha_isrfsr = (RooRealVar*) combined->var("alpha_isrfsr");
1028  RooAbsReal* profile_isrfsr = nll->createProfile(*alpha_isrfsr);
1029  poi->setVal(0.55);
1030  poi->setConstant();
1031 
1032  RooPlot* frame_isrfsr = alpha_isrfsr->frame();
1033  profile_isrfsr->plotOn(frame_isrfsr, Precision(0.1));
1034  TCanvas c_isrfsr = new TCanvas( "combined", "",800,600);
1035  FormatFrameForLikelihood(frame_isrfsr, "alpha_{isrfsr}");
1036  frame_isrfsr->Draw();
1037  fOut_f->cd("Summary");
1038  c1->Write((FilePrefixStr(channel).str()+"_profileLR_alpha_isrfsr").c_str() );
1039  delete frame; delete c1;
1040  poi->setConstant(kFALSE);
1041  */
1042 
1043  RooCurve* curve=frame->getCurve();
1044  Int_t curve_N=curve->GetN();
1045  Double_t* curve_x=curve->GetX();
1046  delete frame; delete c1;
1047 
1048  //
1049  // Verbose output from MINUIT
1050  //
1051  /*
1052  RooMsgService::instance().setGlobalKillBelow(RooFit::DEBUG) ;
1053  profile->getVal();
1054  RooMinuit* minuit = ((RooProfileLL*) profile)->minuit();
1055  minuit->setPrintLevel(5) ; // Print MINUIT messages
1056  minuit->setVerbose(5) ; // Print RooMinuit messages with parameter
1057  // changes (corresponds to the Verbose() option of fitTo()
1058  */
1059 
1060  Double_t * x_arr = new Double_t[curve_N];
1061  Double_t * y_arr_nll = new Double_t[curve_N];
1062 // Double_t y_arr_prof_nll[curve_N];
1063 // Double_t y_arr_prof[curve_N];
1064 
1065  for(int i=0; i<curve_N; i++){
1066  double f=curve_x[i];
1067  poi->setVal(f);
1068  x_arr[i]=f;
1069  y_arr_nll[i]=nll->getVal();
1070  }
1071  TGraph * g = new TGraph(curve_N, x_arr, y_arr_nll);
1072  g->SetName((FilePrefixStr(channel)+"_nll").c_str());
1073  g->Write();
1074  delete g;
1075  delete [] x_arr;
1076  delete [] y_arr_nll;
1077 
1078  /** find out what's inside the workspace **/
1079  //combined->Print();
1080 
1081  }
1082 
1083 
1084 void HistoToWorkspaceFactory::FormatFrameForLikelihood(RooPlot* frame, string /*XTitle*/, string YTitle){
1085 
1088  gStyle->SetPadColor(0);
1089  gStyle->SetCanvasColor(255);
1090  gStyle->SetTitleFillColor(255);
1092  gStyle->SetStatColor(255);
1093 
1094  RooAbsRealLValue* var = frame->getPlotVar();
1095  double xmin = var->getMin();
1096  double xmax = var->getMax();
1097 
1098  frame->SetTitle("");
1099  // frame->GetXaxis()->SetTitle(XTitle.c_str());
1100  frame->GetXaxis()->SetTitle(var->GetTitle());
1101  frame->GetYaxis()->SetTitle(YTitle.c_str());
1102  frame->SetMaximum(2.);
1103  frame->SetMinimum(0.);
1104  TLine * line = new TLine(xmin,.5,xmax,.5);
1106  TLine * line90 = new TLine(xmin,2.71/2.,xmax,2.71/2.);
1107  line90->SetLineColor(kGreen);
1108  TLine * line95 = new TLine(xmin,3.84/2.,xmax,3.84/2.);
1109  line95->SetLineColor(kGreen);
1110  frame->addObject(line);
1111  frame->addObject(line90);
1112  frame->addObject(line95);
1113  }
1114 
1116  if(! file) return file;
1117  string path="";
1118  TDirectory* ptr=0;
1119  for(vector<string>::iterator itr=names.begin(); itr != names.end(); ++itr){
1120  if( ! path.empty() ) path+="/";
1121  path+=(*itr);
1122  ptr=file->GetDirectory(path.c_str());
1123  if( ! ptr ) ptr=file->mkdir((*itr).c_str());
1124  file=file->GetDirectory(path.c_str());
1125  }
1126  return ptr;
1127  }
1129  if(! file) return file;
1130  TDirectory* ptr=0;
1131  ptr=file->GetDirectory(name.c_str());
1132  if( ! ptr ) ptr=file->mkdir(name.c_str());
1133  return ptr;
1134  }
1135 
1136 }
1137 }
1138 
RooAbsRealLValue::frame
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
Definition: RooAbsRealLValue.cxx:199
RooMultiVarGaussian.h
TStyle::SetPadColor
void SetPadColor(Color_t color=19)
Definition: TStyle.h:338
RooStats::HistFactory::HistoToWorkspaceFactory::FitModel
void FitModel(RooWorkspace *, std::string, std::string, std::string, bool=false)
Definition: HistoToWorkspaceFactory.cxx:961
LinInterpVar.h
RooStats::HistFactory::HistoToWorkspaceFactory::HistoToWorkspaceFactory
HistoToWorkspaceFactory()
Definition: HistoToWorkspaceFactory.cxx:83
RooWorkspace.h
RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
RooRealVar::setVal
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:257
RooStats::HistFactory::HistoToWorkspaceFactory::fLumiError
double fLumiError
Definition: HistoToWorkspaceFactory.h:92
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooStats::HistFactory::HistoToWorkspaceFactory
Definition: HistoToWorkspaceFactory.h:36
TLine.h
RooMinuit.h
TDirectory::mkdir
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
Definition: TDirectory.cxx:1050
TVectorD.h
RooMsgService.h
RooStats::HistFactory::HistoToWorkspaceFactory::Customize
void Customize(RooWorkspace *proto, const char *pdfNameChar, std::map< std::string, std::string > renameMap)
Definition: HistoToWorkspaceFactory.cxx:420
f
#define f(i)
Definition: RSha256.hxx:104
TLine
A simple line.
Definition: TLine.h:22
RooNumIntConfig.h
RooAbsRealLValue::getMax
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Definition: RooAbsRealLValue.h:89
RooStats::HistFactory::EstimateSummary::name
std::string name
Definition: EstimateSummary.h:61
RooSimultaneous.h
kGreen
@ kGreen
Definition: Rtypes.h:66
RooFit::PrintLevel
RooCmdArg PrintLevel(Int_t code)
Definition: RooGlobalFunc.cxx:192
RooStats::HistFactory::HistoToWorkspaceFactory::AddNormFactor
std::string AddNormFactor(RooWorkspace *, std::string &, std::string &, EstimateSummary &, bool)
Definition: HistoToWorkspaceFactory.cxx:249
RooStats::HistFactory::HistoToWorkspaceFactory::ProcessExpectedHisto
void ProcessExpectedHisto(TH1 *hist, RooWorkspace *proto, std::string prefix, std::string productPrefix, std::string systTerm, double low, double high, int lowBin, int highBin)
Definition: HistoToWorkspaceFactory.cxx:126
RooStats::ModelConfig::SetWorkspace
virtual void SetWorkspace(RooWorkspace &ws)
Definition: ModelConfig.h:66
tree
Definition: tree.py:1
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
xmax
float xmax
Definition: THbookFile.cxx:95
TStopwatch.h
RooMultiVarGaussian
Multivariate Gaussian p.d.f.
Definition: RooMultiVarGaussian.h:31
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
TTree
A TTree represents a columnar dataset.
Definition: TTree.h:79
RooPlot::getCurve
RooCurve * getCurve(const char *name=0) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
Definition: RooPlot.cxx:907
RooGaussian.h
exp
double exp(double)
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooStats::HistFactory::HistoToWorkspaceFactory::fRowTitle
std::string fRowTitle
Definition: HistoToWorkspaceFactory.h:90
TStyle.h
RooFit::Minos
RooCmdArg Minos(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:197
RooFit::ShiftToZero
RooCmdArg ShiftToZero()
Definition: RooGlobalFunc.cxx:51
alpha_Low
#define alpha_Low
Definition: HistoToWorkspaceFactory.cxx:67
TStyle::SetStatColor
void SetStatColor(Color_t color=19)
Definition: TStyle.h:373
RooPlot::SetMaximum
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Definition: RooPlot.cxx:1081
NoHistConst_Low
#define NoHistConst_Low
Definition: HistoToWorkspaceFactory.cxx:69
TStyle::SetTitleFillColor
void SetTitleFillColor(Color_t color=1)
Definition: TStyle.h:387
RooAddPdf.h
RooDataSet::append
void append(RooDataSet &data)
Add all data points of given data set to this data set.
Definition: RooDataSet.cxx:1381
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
TIter::Reset
void Reset()
Definition: TCollection.h:252
TDirectory::cd
virtual Bool_t cd(const char *path=nullptr)
Change current directory to "this" directory.
Definition: TDirectory.cxx:504
TMatrixTSym< Double_t >
RooConstVar
RooConstVar represent a constant real-valued object.
Definition: RooConstVar.h:26
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TCanvas.h
TTree.h
TStyle::SetPadBorderMode
void SetPadBorderMode(Int_t mode=1)
Definition: TStyle.h:340
RooWorkspace::set
const RooArgSet * set(const char *name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
Definition: RooWorkspace.cxx:977
RooDataSet.h
RooStats::HistFactory::HistoToWorkspaceFactory::fNomLumi
double fNomLumi
Definition: HistoToWorkspaceFactory.h:92
RooFit::HistFactory
@ HistFactory
Definition: RooGlobalFunc.h:69
TFile.h
RooNLLVar.h
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
RooAbsRealLValue::getMin
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
Definition: RooAbsRealLValue.h:86
RooFitResult
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
RooWorkspace::factory
RooFactoryWSTool & factory()
Return instance to factory tool.
Definition: RooWorkspace.cxx:2166
RooStats::ModelConfig::SetPdf
virtual void SetPdf(const RooAbsPdf &pdf)
Set the Pdf, add to the the workspace if not already there.
Definition: ModelConfig.h:81
RooStats::HistFactory::HistoToWorkspaceFactory::EditSyst
void EditSyst(RooWorkspace *proto, const char *pdfNameChar, std::map< std::string, double > gammaSyst, std::map< std::string, double > uniformSyst, std::map< std::string, double > logNormSyst)
cout << "in edit, gammamap.size = " << gammaSyst.size() << ", unimap.size = " << uniformSyst....
Definition: HistoToWorkspaceFactory.cxx:439
TMatrixDSym.h
RooStats::HistFactory::LinInterpVar
RooAbsReal that does piecewise-linear interpolations.
Definition: LinInterpVar.h:25
RooStats::HistFactory::HistoToWorkspaceFactory::FilePrefixStr
std::string FilePrefixStr(std::string)
Definition: HistoToWorkspaceFactory.cxx:118
RooFit::RecycleConflictNodes
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:316
RooWorkspace::import
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
Definition: RooWorkspace.cxx:361
RooPlot::addObject
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
Definition: RooPlot.cxx:422
RooStats::HistFactory::HistoToWorkspaceFactory::fHighBin
int fHighBin
Definition: HistoToWorkspaceFactory.h:93
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
ROOT::Math::fabs
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Definition: UnaryOperators.h:131
TGraph::GetX
Double_t * GetX() const
Definition: TGraph.h:131
TH1::GetBinContent
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4993
RooCustomizer.h
RooStats::HistFactory::HistoToWorkspaceFactory::fResultsPrefixStr
std::stringstream fResultsPrefixStr
Definition: HistoToWorkspaceFactory.h:94
RooProdPdf.h
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
RooStats::HistFactory::EstimateSummary::normFactor
std::vector< NormFactor > normFactor
Definition: EstimateSummary.h:70
RooStats::HistFactory::HistoToWorkspaceFactory::MakeTotalExpected
void MakeTotalExpected(RooWorkspace *proto, std::string totName, std::string, std::string, int lowBin, int highBin, std::vector< std::string > &syst_x_expectedPrefixNames, std::vector< std::string > &normByNames)
Definition: HistoToWorkspaceFactory.cxx:339
RooRealVar::getErrorHi
Double_t getErrorHi() const
Definition: RooRealVar.h:70
xmin
float xmin
Definition: THbookFile.cxx:95
ModelConfig.h
RooFit
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: RooCFunction1Binding.h:29
RooStats::HistFactory::HistoToWorkspaceFactory::AddEfficiencyTerms
void AddEfficiencyTerms(RooWorkspace *proto, std::string prefix, std::string interpName, std::map< std::string, std::pair< double, double > > systMap, std::vector< std::string > &likelihoodTermNames, std::vector< std::string > &totSystTermNames)
Definition: HistoToWorkspaceFactory.cxx:290
RooRandom.h
RooDataHist.h
RooArgSet::add
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
Definition: RooArgSet.cxx:261
RooPlot.h
RooAbsCollection::createIterator
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
Definition: RooAbsCollection.h:119
RooStats::HistFactory::HistoToWorkspaceFactory::AddMultiVarGaussConstraint
void AddMultiVarGaussConstraint(RooWorkspace *proto, std::string prefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
Definition: HistoToWorkspaceFactory.cxx:155
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1263
RooWorkspace::obj
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
Definition: RooWorkspace.cxx:2106
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooStats::HistFactory::HistoToWorkspaceFactory::fSystToFix
std::vector< std::string > fSystToFix
Definition: HistoToWorkspaceFactory.h:91
RooWorkspace::pdf
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1277
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:437
RooAddition.h
RooCurve
A RooCurve is a one-dimensional graphical representation of a real-valued function.
Definition: RooCurve.h:32
RooCategory.h
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:58
sqrt
double sqrt(double)
RooStats::HistFactory::HistoToWorkspaceFactory::FormatFrameForLikelihood
void FormatFrameForLikelihood(RooPlot *frame, std::string XTitle=std::string("#sigma / #sigma_{SM}"), std::string YTitle=std::string("-log likelihood"))
Definition: HistoToWorkspaceFactory.cxx:1084
RooRealVar.h
RooFitResult::correlation
Double_t correlation(const RooAbsArg &par1, const RooAbsArg &par2) const
Return correlation between par1 and par2.
Definition: RooFitResult.h:118
kRed
@ kRed
Definition: Rtypes.h:66
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
line
TLine * line
Definition: entrylistblock_figure1.C:235
RooStats::HistFactory::HistoToWorkspaceFactory::PrintCovarianceMatrix
void PrintCovarianceMatrix(RooFitResult *result, RooArgSet *params, std::string filename)
Definition: HistoToWorkspaceFactory.cxx:665
RooStats::HistFactory::HistoToWorkspaceFactory::MakeCombinedModel
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< RooWorkspace * >)
Definition: HistoToWorkspaceFactory.cxx:854
RooProduct.h
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
RooStats::ModelConfig::GetPdf
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
Definition: ModelConfig.h:234
RooFitResult.h
TIterator::Next
virtual TObject * Next()=0
RooExponential.h
RooConstVar.h
RooStats::HistFactory::HistoToWorkspaceFactory::AddPoissonTerms
void AddPoissonTerms(RooWorkspace *proto, std::string prefix, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
Definition: HistoToWorkspaceFactory.cxx:361
RooAbsReal::plotOn
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
Definition: RooAbsReal.cxx:1729
RooGlobalFunc.h
RooAbsReal::createProfile
virtual RooAbsReal * createProfile(const RooArgSet &paramsOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function.
Definition: RooAbsReal.cxx:528
RooHistPdf.h
RooStats::HistFactory::HistoToWorkspaceFactory::Makedirs
TDirectory * Makedirs(TDirectory *file, std::vector< std::string > names)
Definition: HistoToWorkspaceFactory.cxx:1115
RooStats::ModelConfig::GetParametersOfInterest
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
Definition: ModelConfig.h:237
TIter::Next
TObject * Next()
Definition: TCollection.h:249
RooStatsUtils.h
alpha_High
#define alpha_High
Definition: HistoToWorkspaceFactory.cxx:68
TVectorT< Double_t >
proto
const char * proto
Definition: civetweb.c:16604
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooFit::LineColor
RooCmdArg LineColor(Color_t color)
Definition: RooGlobalFunc.cxx:57
TStyle::SetCanvasColor
void SetCanvasColor(Color_t color=19)
Definition: TStyle.h:327
Double_t
double Double_t
Definition: RtypesCore.h:59
TStyle::SetCanvasBorderMode
void SetCanvasBorderMode(Int_t mode=1)
Definition: TStyle.h:329
TGraph
A TGraph is an object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
RooPlot::SetTitle
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
Definition: RooPlot.cxx:1242
TCanvas
The Canvas class.
Definition: TCanvas.h:23
RooCategory
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:27
RooStats
Namespace for the RooStats classes.
Definition: Asimov.h:19
file
Definition: file.py:1
RooStats::HistFactory::HistoToWorkspaceFactory::pFile
FILE * pFile
Definition: HistoToWorkspaceFactory.h:96
TStopwatch
Stopwatch class.
Definition: TStopwatch.h:28
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
RooStats::HistFactory::HistoToWorkspaceFactory::MakeSingleChannelModel
RooWorkspace * MakeSingleChannelModel(std::vector< RooStats::HistFactory::EstimateSummary > summary, std::vector< std::string > systToFix, bool doRatio=false)
Definition: HistoToWorkspaceFactory.cxx:698
TH1
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
TGraph::GetN
Int_t GetN() const
Definition: TGraph.h:124
name
char name[80]
Definition: TGX11.cxx:110
RooAbsRealLValue::setConstant
void setConstant(Bool_t value=kTRUE)
Definition: RooAbsRealLValue.h:115
RooPlot::SetMinimum
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
Definition: RooPlot.cxx:1091
RooWorkspace::importClassCode
Bool_t importClassCode(const char *pat="*", Bool_t doReplace=kFALSE)
Inport code of all classes in the workspace that have a class name that matches pattern 'pat' and whi...
Definition: RooWorkspace.cxx:1134
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:45
kDashed
@ kDashed
Definition: TAttLine.h:48
Helper.h
RooWorkspace::var
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1295
TIter
Definition: TCollection.h:233
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
RooStats::HistFactory::HistoToWorkspaceFactory::~HistoToWorkspaceFactory
virtual ~HistoToWorkspaceFactory()
Definition: HistoToWorkspaceFactory.cxx:93
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
TStyle::SetFrameFillColor
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:355
RooStats::HistFactory::EstimateSummary
Definition: EstimateSummary.h:26
RooAbsPdf
Definition: RooAbsPdf.h:43
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
RooRealVar::getErrorLo
Double_t getErrorLo() const
Definition: RooRealVar.h:69
RooFit::LineStyle
RooCmdArg LineStyle(Style_t style)
Definition: RooGlobalFunc.cxx:58
RooFit::Index
RooCmdArg Index(RooCategory &icat)
Definition: RooGlobalFunc.cxx:98
RooSimultaneous
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Definition: RooSimultaneous.h:37
RooStats::HistFactory::HistoToWorkspaceFactory::Mkdir
TDirectory * Mkdir(TDirectory *file, std::string name)
Definition: HistoToWorkspaceFactory.cxx:1128
RooAbsReal::PrintErrors
@ PrintErrors
Definition: RooAbsReal.h:311
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
pow
double pow(double, double)
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooProdPdf
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:37
RooStats::ModelConfig
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition: ModelConfig.h:30
TH1.h
RooStats::ModelConfig::SetGlobalObservables
virtual void SetGlobalObservables(const RooArgSet &set)
Specify the global observables.
Definition: ModelConfig.h:172
NoHistConst_High
#define NoHistConst_High
Definition: HistoToWorkspaceFactory.cxx:70
RooAbsArg::isConstant
Bool_t isConstant() const
Check if the "Constant" attribute is set.
Definition: RooAbsArg.h:360
RooPlot::getPlotVar
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:139
RooStats::HistFactory::HistoToWorkspaceFactory::fLowBin
int fLowBin
Definition: HistoToWorkspaceFactory.h:93
RooProfileLL.h
RooStats::HistFactory::HistoToWorkspaceFactory::fOut_f
TFile * fOut_f
Definition: HistoToWorkspaceFactory.h:95
RooStats::HistFactory::HistoToWorkspaceFactory::LinInterpWithConstraint
void LinInterpWithConstraint(RooWorkspace *proto, TH1 *nominal, std::vector< TH1 * > lowHist, std::vector< TH1 * > highHist, std::vector< std::string > sourceName, std::string prefix, std::string productPrefix, std::string systTerm, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
Definition: HistoToWorkspaceFactory.cxx:188
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
HistoToWorkspaceFactory.h
RooPlot::GetXaxis
TAxis * GetXaxis() const
Definition: RooPlot.cxx:1261
TDirectoryFile::mkdir
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
Definition: TDirectoryFile.cxx:1207
int
RooStats::HistFactory::HistoToWorkspaceFactory::SetObsToExpected
void SetObsToExpected(RooWorkspace *proto, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin)
Definition: HistoToWorkspaceFactory.cxx:385
c1
return c1
Definition: legend1.C:41
RooStats::HistFactory::HistoToWorkspaceFactory::fFileNamePrefix
std::string fFileNamePrefix
Definition: HistoToWorkspaceFactory.h:89
RooFit::Import
RooCmdArg Import(const char *state, TH1 &histo)
Definition: RooGlobalFunc.cxx:99
g
#define g(i)
Definition: RSha256.hxx:105
RooWorkspace::defineSet
Bool_t defineSet(const char *name, const RooArgSet &aset, Bool_t importMissing=kFALSE)
Define a named RooArgSet with given constituents.
Definition: RooWorkspace.cxx:855