Logo ROOT  
Reference Guide
RooStatsUtils.cxx
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer 28/07/2008
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "Rtypes.h"
13 
14 #if !defined(R__ALPHA) && !defined(R__SOLARIS) && !defined(R__ACC) && !defined(R__FBSD)
16 #endif
17 
18 #include "TTree.h"
19 #include "TBranch.h"
20 
21 #include "RooArgSet.h"
22 #include "RooWorkspace.h"
23 #include "RooAbsPdf.h"
24 #include "RooUniform.h"
25 #include "RooProdPdf.h"
26 #include "RooExtendPdf.h"
27 #include "RooSimultaneous.h"
28 #include "RooStats/ModelConfig.h"
29 #include "RooStats/RooStatsUtils.h"
30 
31 using namespace std;
32 
33 
34 namespace {
35  template<class listT, class stringT> void getParameterNames(const listT* l,std::vector<stringT>& names){
36  // extract the parameter names from a list
37  if(!l) return;
38  RooAbsArg* obj;
39  RooFIter itr(l->fwdIterator());
40  while((obj = itr.next())){
41  names.push_back(obj->GetName());
42  }
43  }
44  void getArgs(RooWorkspace* ws, const std::vector<TString> names, RooArgSet& args){
45  for(const auto& p:names){
46  RooRealVar* v = ws->var(p.Data());
47  if(v){
48  args.add(*v);
49  }
50  }
51  }
52  }
53 
54 namespace RooStats {
55 
57  static RooStatsConfig theConfig;
58  return theConfig;
59  }
60 
62  // Asimov significance
63  // formula [10] and [20] from https://www.pp.rhul.ac.uk/~cowan/stat/notes/medsigNote.pdf
64  // case we have a sigma_b
65  double sb2 = sigma_b*sigma_b;
66  // formula below has a large error when sigma_b becomes zero
67  // better to use the approximation for sigma_b=0 for very small values
68  double r = sb2/b;
69  if (r > 1.E-12) {
70  double bpsb2 = b + sb2;
71  double b2 = b*b;
72  double spb = s+b;
73  double za2 = 2.*( (spb)* std::log( ( spb)*(bpsb2)/(b2+ spb*sb2) ) -
74  (b2/sb2) * std::log(1. + ( sb2 * s)/(b * bpsb2) ) );
75  return sqrt(za2);
76 
77  }
78  // case when the background (b) is known
79  double za2 = 2.*( (s+b) * std::log(1. + s/b) -s );
80  return std::sqrt(za2);
81  }
82 
83  /// Use an offset in NLL calculations.
84  void UseNLLOffset(bool on) {
86  }
87 
88  /// Test of RooStats should by default offset NLL calculations.
89  bool IsNLLOffset() {
91  }
92 
93  void FactorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints) {
94  // utility function to factorize constraint terms from a pdf
95  // (from G. Petrucciani)
96  if (auto prod = dynamic_cast<RooProdPdf *>(&pdf)) {
97  RooArgList list(prod->pdfList());
98  for (int i = 0, n = list.getSize(); i < n; ++i) {
99  RooAbsPdf *pdfi = (RooAbsPdf *) list.at(i);
100  FactorizePdf(observables, *pdfi, obsTerms, constraints);
101  }
102  } else if (dynamic_cast<RooExtendPdf *>(&pdf)) {
103  // extract underlying pdf which is extended; first server is the pdf; second server is the number of events variable
104  auto iter = pdf.servers().begin();
105  assert(iter != pdf.servers().end());
106  assert(dynamic_cast<RooAbsPdf*>(*iter));
107  FactorizePdf(observables, static_cast<RooAbsPdf&>(**iter), obsTerms, constraints);
108  } else if (auto sim = dynamic_cast<RooSimultaneous *>(&pdf)) { //|| dynamic_cast<RooSimultaneousOpt>(&pdf)) {
109  assert(sim != 0);
110  RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().clone(sim->indexCat().GetName());
111  for (int ic = 0, nc = cat->numBins((const char *)0); ic < nc; ++ic) {
112  cat->setBin(ic);
113  RooAbsPdf* catPdf = sim->getPdf(cat->getCurrentLabel());
114  // it is possible that a pdf is not defined for every category
115  if (catPdf != 0) FactorizePdf(observables, *catPdf, obsTerms, constraints);
116  }
117  delete cat;
118  } else if (pdf.dependsOn(observables)) {
119  if (!obsTerms.contains(pdf)) obsTerms.add(pdf);
120  } else {
121  if (!constraints.contains(pdf)) constraints.add(pdf);
122  }
123  }
124 
125 
126  void FactorizePdf(RooStats::ModelConfig &model, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints) {
127  // utility function to factorize constraint terms from a pdf
128  // (from G. Petrucciani)
129  if (!model.GetObservables() ) {
130  oocoutE((TObject*)0,InputArguments) << "RooStatsUtils::FactorizePdf - invalid input model: missing observables" << endl;
131  return;
132  }
133  return FactorizePdf(*model.GetObservables(), pdf, obsTerms, constraints);
134  }
135 
136 
137  RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name) {
138  // make a nuisance pdf by factorizing out all constraint terms in a common pdf
139  RooArgList obsTerms, constraints;
140  FactorizePdf(observables, pdf, obsTerms, constraints);
141  if(constraints.getSize() == 0) {
142  oocoutW((TObject *)0, Eval) << "RooStatsUtils::MakeNuisancePdf - no constraints found on nuisance parameters in the input model" << endl;
143  return 0;
144  }
145  return new RooProdPdf(name,"", constraints);
146  }
147 
149  // make a nuisance pdf by factorizing out all constraint terms in a common pdf
150  if (!model.GetPdf() || !model.GetObservables() ) {
151  oocoutE((TObject*)0, InputArguments) << "RooStatsUtils::MakeNuisancePdf - invalid input model: missing pdf and/or observables" << endl;
152  return 0;
153  }
154  return MakeNuisancePdf(*model.GetPdf(), *model.GetObservables(), name);
155  }
156 
157  RooAbsPdf * StripConstraints(RooAbsPdf &pdf, const RooArgSet &observables) {
158 
159  if (auto prod = dynamic_cast<RooProdPdf *>(&pdf)) {
160 
161  RooArgList list(prod->pdfList()); RooArgList newList;
162 
163  for (int i = 0, n = list.getSize(); i < n; ++i) {
164  RooAbsPdf *pdfi = (RooAbsPdf *) list.at(i);
165  RooAbsPdf *newPdfi = StripConstraints(*pdfi, observables);
166  if(newPdfi != NULL) newList.add(*newPdfi);
167  }
168 
169  if(newList.getSize() == 0) return NULL; // only constraints in product
170  // return single component (no longer a product)
171  else if(newList.getSize() == 1) return dynamic_cast<RooAbsPdf *>(newList.at(0)->clone(TString::Format("%s_unconstrained",
172  newList.at(0)->GetName())));
173  else return new RooProdPdf(TString::Format("%s_unconstrained", prod->GetName()).Data(),
174  TString::Format("%s without constraints", prod->GetTitle()).Data(), newList);
175 
176  } else if (dynamic_cast<RooExtendPdf*>(&pdf)) {
177 
178  auto iter = pdf.servers().begin();
179  // extract underlying pdf which is extended; first server is the pdf; second server is the number of events variable
180  auto uPdf = dynamic_cast<RooAbsPdf *>(*(iter++));
181  auto extended_term = dynamic_cast<RooAbsReal *>(*(iter++));
182  assert(uPdf != nullptr);
183  assert(extended_term != nullptr);
184  assert(iter == pdf.servers().end());
185 
186  RooAbsPdf *newUPdf = StripConstraints(*uPdf, observables);
187  if(newUPdf == NULL) return NULL; // only constraints in underlying pdf
188  else return new RooExtendPdf(TString::Format("%s_unconstrained", pdf.GetName()).Data(),
189  TString::Format("%s without constraints", pdf.GetTitle()).Data(), *newUPdf, *extended_term);
190 
191  } else if (auto sim = dynamic_cast<RooSimultaneous *>(&pdf)) { //|| dynamic_cast<RooSimultaneousOpt *>(&pdf)) {
192 
193  assert(sim != nullptr);
194  RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone(); assert(cat != NULL);
195  RooArgList pdfList;
196 
197  for (int ic = 0, nc = cat->numBins((const char *)NULL); ic < nc; ++ic) {
198  cat->setBin(ic);
199  RooAbsPdf* catPdf = sim->getPdf(cat->getCurrentLabel());
200  RooAbsPdf* newPdf = NULL;
201  // it is possible that a pdf is not defined for every category
202  if (catPdf != NULL) newPdf = StripConstraints(*catPdf, observables);
203  if (newPdf == NULL) { delete cat; return NULL; } // all channels must have observables
204  pdfList.add(*newPdf);
205  }
206 
207  return new RooSimultaneous(TString::Format("%s_unconstrained", sim->GetName()).Data(),
208  TString::Format("%s without constraints", sim->GetTitle()).Data(), pdfList, *cat);
209 
210  } else if (pdf.dependsOn(observables)) {
211  return (RooAbsPdf *) pdf.clone(TString::Format("%s_unconstrained", pdf.GetName()).Data());
212  }
213 
214  return NULL; // just a constraint term
215  }
216 
217  RooAbsPdf * MakeUnconstrainedPdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name) {
218  // make a clone pdf without all constraint terms in a common pdf
219  RooAbsPdf * unconstrainedPdf = StripConstraints(pdf, observables);
220  if(!unconstrainedPdf) {
221  oocoutE((TObject *)NULL, InputArguments) << "RooStats::MakeUnconstrainedPdf - invalid observable list passed (observables not found in original pdf) or invalid pdf passed (without observables)" << endl;
222  return NULL;
223  }
224  if(name != NULL) unconstrainedPdf->SetName(name);
225  return unconstrainedPdf;
226  }
227 
229  // make a clone pdf without all constraint terms in a common pdf
230  if(!model.GetPdf() || !model.GetObservables()) {
231  oocoutE((TObject *)NULL, InputArguments) << "RooStatsUtils::MakeUnconstrainedPdf - invalid input model: missing pdf and/or observables" << endl;
232  return NULL;
233  }
234  return MakeUnconstrainedPdf(*model.GetPdf(), *model.GetObservables(), name);
235  }
236 
237  // Helper class for GetAsTTree
238  class BranchStore {
239  public:
240  std::map<TString, Double_t> fVarVals;
241  double fInval;
243 
244  BranchStore(const vector <TString> &params = vector <TString>(), double _inval = -999.) : fTree(0) {
245  fInval = _inval;
246  for(unsigned int i = 0;i<params.size();i++)
247  fVarVals[params[i]] = _inval;
248  }
249 
251  if (fTree) {
252  for(std::map<TString, Double_t>::iterator it = fVarVals.begin();it!=fVarVals.end();++it) {
253  TBranch *br = fTree->GetBranch( it->first );
254  if (br) br->ResetAddress();
255  }
256  }
257  }
258 
259  void AssignToTTree(TTree &myTree) {
260  fTree = &myTree;
261  for(std::map<TString, Double_t>::iterator it = fVarVals.begin();it!=fVarVals.end();++it) {
262  const TString& name = it->first;
263  myTree.Branch( name, &fVarVals[name], TString::Format("%s/D", name.Data()));
264  }
265  }
266  void ResetValues() {
267  for(std::map<TString, Double_t>::iterator it = fVarVals.begin();it!=fVarVals.end();++it) {
268  const TString& name = it->first;
269  fVarVals[name] = fInval;
270  }
271  }
272  };
273 
275  if (data.numEntries() == 0) {
276  return new BranchStore;
277  }
278  vector <TString> V;
279  const RooArgSet* aset = data.get(0);
280  RooAbsArg *arg(0);
281  TIterator *it = aset->createIterator();
282  for(;(arg = dynamic_cast<RooAbsArg*>(it->Next()));) {
283  RooRealVar *rvar = dynamic_cast<RooRealVar*>(arg);
284  if (rvar == NULL)
285  continue;
286  V.push_back(rvar->GetName());
287  if (rvar->hasAsymError()) {
288  V.push_back(TString::Format("%s_errlo", rvar->GetName()));
289  V.push_back(TString::Format("%s_errhi", rvar->GetName()));
290  }
291  else if (rvar->hasError()) {
292  V.push_back(TString::Format("%s_err", rvar->GetName()));
293  }
294  }
295  delete it;
296  return new BranchStore(V);
297  }
298 
299  void FillTree(TTree &myTree, const RooDataSet &data) {
300  BranchStore *bs = CreateBranchStore(data);
301  bs->AssignToTTree(myTree);
302 
303  for(int entry = 0;entry<data.numEntries();entry++) {
304  bs->ResetValues();
305  const RooArgSet* aset = data.get(entry);
306  RooAbsArg *arg(0);
307  RooLinkedListIter it = aset->iterator();
308  for(;(arg = dynamic_cast<RooAbsArg*>(it.Next()));) {
309  RooRealVar *rvar = dynamic_cast<RooRealVar*>(arg);
310  if (rvar == NULL)
311  continue;
312  bs->fVarVals[rvar->GetName()] = rvar->getValV();
313  if (rvar->hasAsymError()) {
314  bs->fVarVals[TString::Format("%s_errlo", rvar->GetName())] = rvar->getAsymErrorLo();
315  bs->fVarVals[TString::Format("%s_errhi", rvar->GetName())] = rvar->getAsymErrorHi();
316  }
317  else if (rvar->hasError()) {
318  bs->fVarVals[TString::Format("%s_err", rvar->GetName())] = rvar->getError();
319  }
320  }
321  myTree.Fill();
322  }
323 
324  delete bs;
325  }
326 
327  TTree * GetAsTTree(TString name, TString desc, const RooDataSet& data) {
328  TTree* myTree = new TTree(name, desc);
329  FillTree(*myTree, data);
330  return myTree;
331  }
332 
333 
334  // useful function to print in one line the content of a set with their values
335  void PrintListContent(const RooArgList & l, std::ostream & os ) {
336  bool first = true;
337  os << "( ";
338  for (int i = 0; i< l.getSize(); ++i) {
339  if (first) {
340  first=kFALSE ;
341  } else {
342  os << ", " ;
343  }
344  l[i].printName(os);
345  os << " = ";
346  l[i].printValue(os);
347  }
348  os << ")\n";
349  }
350 
351  // clone a workspace, copying all needed components and discarding all others
352  // start off with the old workspace
353  RooWorkspace* MakeCleanWorkspace(RooWorkspace *oldWS, const char *newName,
354  bool copySnapshots, const char *mcname,
355  const char *newmcname) {
356  auto objects = oldWS->allGenericObjects();
357  RooStats::ModelConfig *oldMC =
358  dynamic_cast<RooStats::ModelConfig *>(oldWS->obj(mcname));
359  auto data = oldWS->allData();
360  for (auto it : objects) {
361  if (!oldMC) {
362  oldMC = dynamic_cast<RooStats::ModelConfig *>(it);
363  }
364  }
365  if (!oldMC)
366  throw std::runtime_error("unable to retrieve ModelConfig");
367 
368  RooAbsPdf *origPdf = oldMC->GetPdf();
369 
370  // start off with the old modelconfig
371  std::vector<TString> poilist;
372  std::vector<TString> nplist;
373  std::vector<TString> obslist;
374  std::vector<TString> globobslist;
375  RooAbsPdf *pdf = NULL;
376  if (oldMC) {
377  pdf = oldMC->GetPdf();
378  ::getParameterNames(oldMC->GetParametersOfInterest(), poilist);
379  ::getParameterNames(oldMC->GetNuisanceParameters(), nplist);
380  ::getParameterNames(oldMC->GetObservables(), obslist);
381  ::getParameterNames(oldMC->GetGlobalObservables(), globobslist);
382  }
383  if (!pdf) {
384  if (origPdf)
385  pdf = origPdf;
386  }
387  if (!pdf) {
388  return NULL;
389  }
390 
391  // create them anew
392  RooWorkspace *newWS = new RooWorkspace(newName ? newName : oldWS->GetName());
393  newWS->autoImportClassCode(true);
394  RooStats::ModelConfig *newMC = new RooStats::ModelConfig(newmcname, newWS);
395 
396  // Copy snapshots
397  if (copySnapshots) {
398  RooFIter itr(oldWS->getSnapshots().fwdIterator());
399  RooArgSet *snap;
400  while ((snap = (RooArgSet *)itr.next())) {
401  RooArgSet *snapClone = (RooArgSet *)snap->snapshot();
402  snapClone->setName(snap->GetName());
403  newWS->getSnapshots().Add(snapClone);
404  }
405  }
406 
407  newWS->import(*pdf, RooFit::RecycleConflictNodes());
408  RooAbsPdf *newPdf = newWS->pdf(pdf->GetName());
409  newMC->SetPdf(*newPdf);
410 
411  for (auto d : data) {
412  newWS->import(*d);
413  }
414 
415  RooArgSet poiset;
416  ::getArgs(newWS, poilist, poiset);
417  RooArgSet npset;
418  ::getArgs(newWS, nplist, npset);
419  RooArgSet obsset;
420  ::getArgs(newWS, obslist, obsset);
421  RooArgSet globobsset;
422  ::getArgs(newWS, globobslist, globobsset);
423 
424  newMC->SetParametersOfInterest(poiset);
425  newMC->SetNuisanceParameters(npset);
426  newMC->SetObservables(obsset);
427  newMC->SetGlobalObservables(globobsset);
428  newWS->import(*newMC);
429 
430  return newWS;
431  }
432 
433 }
RooAbsArg::Clone
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:84
RooStats::AsimovSignificance
Double_t AsimovSignificance(Double_t s, Double_t b, Double_t sigma_b=0.0)
Compute the Asimov Median significance for a Poisson process with s = expected number of signal event...
Definition: RooStatsUtils.cxx:61
RooStats::BranchStore::AssignToTTree
void AssignToTTree(TTree &myTree)
Definition: RooStatsUtils.cxx:259
RooRealVar::getAsymErrorHi
Double_t getAsymErrorHi() const
Definition: RooRealVar.h:65
l
auto * l
Definition: textangle.C:4
TBranch::ResetAddress
virtual void ResetAddress()
Reset the address of the branch.
Definition: TBranch.cxx:2568
RooStats::ModelConfig::GetObservables
const RooArgSet * GetObservables() const
get RooArgSet for observables (return NULL if not existing)
Definition: ModelConfig.h:249
RooAbsCategoryLValue::setBin
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set category to i-th fit bin, which is the i-th registered state.
Definition: RooAbsCategoryLValue.cxx:177
n
const Int_t n
Definition: legend1.C:16
RooStats::BranchStore::fVarVals
std::map< TString, Double_t > fVarVals
Definition: RooStatsUtils.cxx:240
RooWorkspace.h
RooStats::BranchStore::ResetValues
void ResetValues()
Definition: RooStatsUtils.cxx:266
first
Definition: first.py:1
RooStats::IsNLLOffset
bool IsNLLOffset()
Test of RooStats should by default offset NLL calculations.
Definition: RooStatsUtils.cxx:89
RooExtendPdf.h
RooSimultaneous.h
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:61
RooArgSet.h
TString::Data
const char * Data() const
Definition: TString.h:369
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TBranch.h
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
RooAbsArg::SetName
void SetName(const char *name)
Set the name of the TNamed.
Definition: RooAbsArg.cxx:2325
log
double log(double)
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
NamespaceImp
#define NamespaceImp(name)
Definition: Rtypes.h:379
RooStats::BranchStore::BranchStore
BranchStore(const vector< TString > &params=vector< TString >(), double _inval=-999.)
Definition: RooStatsUtils.cxx:244
RooStats::ModelConfig::SetObservables
virtual void SetObservables(const RooArgSet &set)
Specify the observables.
Definition: ModelConfig.h:146
RooExtendPdf
RooExtendPdf is a wrapper around an existing PDF that adds a parameteric extended likelihood term to ...
Definition: RooExtendPdf.h:22
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooArgList::at
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:72
RooLinkedList::fwdIterator
RooFIter fwdIterator() const
Create a one-time-use forward iterator for this list.
Definition: RooLinkedList.cxx:750
RooStats::StripConstraints
RooAbsPdf * StripConstraints(RooAbsPdf &pdf, const RooArgSet &observables)
Definition: RooStatsUtils.cxx:157
TTree::Fill
virtual Int_t Fill()
Fill all branches.
Definition: TTree.cxx:4563
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2333
oocoutE
#define oocoutE(o, a)
Definition: RooMsgService.h:48
TTree.h
TString
Basic string class.
Definition: TString.h:136
RooAbsCollection::GetName
const char * GetName() const
Returns name of object.
Definition: RooAbsCollection.h:286
RooStats::BranchStore::~BranchStore
~BranchStore()
Definition: RooStatsUtils.cxx:250
RooAbsCategory::getCurrentLabel
virtual const char * getCurrentLabel() const
Return label string of current state.
Definition: RooAbsCategory.cxx:130
v
@ v
Definition: rootcling_impl.cxx:3664
b
#define b(i)
Definition: RSha256.hxx:100
RooLinkedListIter::Next
TObject * Next() override
Definition: RooLinkedListIter.h:229
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
RooWorkspace::autoImportClassCode
static void autoImportClassCode(Bool_t flag)
If flag is true, source code of classes not the the ROOT distribution is automatically imported if on...
Definition: RooWorkspace.cxx:141
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
RooDataSet::get
virtual const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
Definition: RooDataSet.cxx:1056
RooAbsCollection::iterator
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
Definition: RooAbsCollection.h:186
RooSTLRefCountList::end
Container_t::const_iterator end() const
End of contained objects.
Definition: RooSTLRefCountList.h:84
RooFit::RecycleConflictNodes
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:346
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
RooAbsCollection::setName
void setName(const char *name)
Definition: RooAbsCollection.h:282
RooSTLRefCountList::begin
Container_t::const_iterator begin() const
Iterator over contained objects.
Definition: RooSTLRefCountList.h:79
RooStats::GetAsTTree
TTree * GetAsTTree(TString name, TString desc, const RooDataSet &data)
Definition: RooStatsUtils.cxx:327
RooArgSet::snapshot
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:115
TBranch
A TTree is a list of TBranches.
Definition: TBranch.h:89
RooAbsArg::clone
virtual TObject * clone(const char *newname=0) const =0
TTree::GetBranch
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:5248
RooAbsCollection::contains
Bool_t contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
Definition: RooAbsCollection.h:143
RooAbsCategoryLValue::numBins
virtual Int_t numBins(const char *rangeName) const
Return the number of fit bins ( = number of types )
Definition: RooAbsCategoryLValue.cxx:203
RooLinkedListIter
A wrapper around TIterator derivatives.
Definition: RooLinkedListIter.h:204
ws
void ws()
Definition: ws.C:66
RooRealVar::getError
Double_t getError() const
Definition: RooRealVar.h:60
RooStats::RooStatsConfig::useLikelihoodOffset
bool useLikelihoodOffset
Definition: RooStatsUtils.h:42
RooProdPdf.h
RooRealVar::getAsymErrorLo
Double_t getAsymErrorLo() const
Definition: RooRealVar.h:64
ModelConfig.h
RooAbsPdf.h
RooStats::ModelConfig::SetNuisanceParameters
virtual void SetNuisanceParameters(const RooArgSet &set)
Specify the nuisance parameters (parameters that are not POI).
Definition: ModelConfig.h:119
TTree::Branch
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
Definition: TTree.h:349
RooWorkspace::allGenericObjects
std::list< TObject * > allGenericObjects() const
Return list of all generic objects in the workspace.
Definition: RooWorkspace.cxx:1550
RooFIter
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
Definition: RooLinkedListIter.h:40
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
RooStats::UseNLLOffset
void UseNLLOffset(bool on)
Use an offset in NLL calculations.
Definition: RooStatsUtils.cxx:84
RooAbsCollection::createIterator
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
Definition: RooAbsCollection.h:178
RooFIter::next
RooAbsArg * next()
Return next element or nullptr if at end.
Definition: RooLinkedListIter.h:49
RooStats::CreateBranchStore
BranchStore * CreateBranchStore(const RooDataSet &data)
Definition: RooStatsUtils.cxx:274
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
RooStats::PrintListContent
void PrintListContent(const RooArgList &l, std::ostream &os=std::cout)
Definition: RooStatsUtils.cxx:335
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:455
RooAbsData::numEntries
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Definition: RooAbsData.cxx:304
RooLinkedList::Add
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:64
sqrt
double sqrt(double)
RooWorkspace::getSnapshots
RooLinkedList getSnapshots()
Definition: RooWorkspace.h:97
RooStats::BranchStore
Definition: RooStatsUtils.cxx:238
oocoutW
#define oocoutW(o, a)
Definition: RooMsgService.h:47
RooStats::RooStatsConfig
Definition: RooStatsUtils.h:41
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
TIterator::Next
virtual TObject * Next()=0
RooAbsArg::servers
const RefCountList_t & servers() const
List of all servers of this object.
Definition: RooAbsArg.h:199
RooStats::MakeCleanWorkspace
RooWorkspace * MakeCleanWorkspace(RooWorkspace *oldWS, const char *newName, bool copySnapshots, const char *mcname, const char *newmcname)
Definition: RooStatsUtils.cxx:353
RooStats::ModelConfig::GetParametersOfInterest
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
Definition: ModelConfig.h:237
RooStatsUtils.h
RooRealVar::getValV
virtual Double_t getValV(const RooArgSet *nset=0) const
Return value of variable.
Definition: RooRealVar.cxx:217
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooStats::BranchStore::fInval
double fInval
Definition: RooStatsUtils.cxx:241
Double_t
double Double_t
Definition: RtypesCore.h:59
RooStats
Namespace for the RooStats classes.
Definition: Asimov.h:19
RooStats::ModelConfig::GetGlobalObservables
const RooArgSet * GetGlobalObservables() const
get RooArgSet for global observables (return NULL if not existing)
Definition: ModelConfig.h:255
RooRealVar::hasAsymError
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
Definition: RooRealVar.h:66
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
RooStats::FillTree
void FillTree(TTree &myTree, const RooDataSet &data)
Definition: RooStatsUtils.cxx:299
name
char name[80]
Definition: TGX11.cxx:110
RooAbsArg::dependsOn
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
Definition: RooAbsArg.cxx:799
d
#define d(i)
Definition: RSha256.hxx:102
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
RooStats::FactorizePdf
void FactorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints)
Definition: RooStatsUtils.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
RooStats::ModelConfig::SetParametersOfInterest
virtual void SetParametersOfInterest(const RooArgSet &set)
Specify parameters of interest.
Definition: ModelConfig.h:100
RooAbsPdf
Definition: RooAbsPdf.h:41
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
RooStats::GetGlobalRooStatsConfig
RooStatsConfig & GetGlobalRooStatsConfig()
Retrieve the config object which can be used to set flags for things like offsetting the likelihood o...
Definition: RooStatsUtils.cxx:56
RooStats::ModelConfig::GetNuisanceParameters
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
Definition: ModelConfig.h:240
RooSimultaneous
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Definition: RooSimultaneous.h:37
RooAbsCategoryLValue
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Definition: RooAbsCategoryLValue.h:25
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
RooFit::Eval
@ Eval
Definition: RooGlobalFunc.h:61
RooStats::MakeUnconstrainedPdf
RooAbsPdf * MakeUnconstrainedPdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name=NULL)
Definition: RooStatsUtils.cxx:217
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
RooStats::ModelConfig::SetGlobalObservables
virtual void SetGlobalObservables(const RooArgSet &set)
Specify the global observables.
Definition: ModelConfig.h:172
Rtypes.h
RooStats::BranchStore::fTree
TTree * fTree
Definition: RooStatsUtils.cxx:242
RooAbsCollection::getSize
Int_t getSize() const
Definition: RooAbsCollection.h:231
RooUniform.h
RooWorkspace::allData
std::list< RooAbsData * > allData() const
Return list of all dataset in the workspace.
Definition: RooWorkspace.cxx:1517
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
RooRealVar::hasError
Bool_t hasError(Bool_t allowZero=kTRUE) const
Definition: RooRealVar.h:61
RooStats::MakeNuisancePdf
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
Definition: RooStatsUtils.cxx:137