Logo ROOT  
Reference Guide
SamplingDistPlot.cxx
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Authors: Sven Kreiss June 2010
3 // Authors: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
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 /** \class RooStats::SamplingDistPlot
13  \ingroup Roostats
14 
15 This class provides simple and straightforward utilities to plot SamplingDistribution
16 objects.
17 */
18 
20 
22 
23 #include "RooRealVar.h"
24 #include "TStyle.h"
25 #include "TLine.h"
26 #include "TFile.h"
27 #include "TVirtualPad.h" // for gPad
28 
29 #include <algorithm>
30 #include <iostream>
31 
32 
33 #include "RooMsgService.h"
34 
35 #include <limits>
36 #define NaN std::numeric_limits<float>::quiet_NaN()
37 #include "TMath.h"
38 #define IsNaN(a) TMath::IsNaN(a)
39 
41 
42 using namespace RooStats;
43 using namespace std;
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// SamplingDistPlot default constructor with bin size
47 
49  fHist(0),
50  fLegend(NULL),
51  fItems(),
52  fOtherItems(),
53  fRooPlot(NULL),
54  fLogXaxis(kFALSE),
55  fLogYaxis(kFALSE),
56  fXMin(NaN), fXMax(NaN), fYMin(NaN), fYMax(NaN),
57  fApplyStyle(kTRUE),
58  fFillStyle(3004)
59 {
62  fBins = nbins;
63  fMarkerType = 20;
64  fColor = 1;
65 }
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 /// SamplingDistPlot constructor with bin size, min and max
69 
71  fHist(0),
72  fLegend(NULL),
73  fItems(),
74  fOtherItems(),
75  fRooPlot(NULL),
76  fLogXaxis(kFALSE),
77  fLogYaxis(kFALSE),
78  fXMin(NaN), fXMax(NaN), fYMin(NaN), fYMax(NaN),
79  fApplyStyle(kTRUE),
80  fFillStyle(3004)
81 {
84  fBins = nbins;
85  fMarkerType = 20;
86  fColor = 1;
87 
88  SetXRange( min, max );
89 }
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 /// destructors - delete objects contained in the list
93 
95 {
96  fItems.Delete();
98  if (fRooPlot) delete fRooPlot;
99  if (fIterator) delete fIterator;
100 }
101 
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// adds sampling distribution (and normalizes if "NORMALIZE" is given as an option)
105 
107  fSamplingDistr = samplingDist->GetSamplingDistribution();
108  if( fSamplingDistr.empty() ) {
109  coutW(Plotting) << "Empty sampling distribution given to plot. Skipping." << endl;
110  return 0.0;
111  }
112  SetSampleWeights(samplingDist);
113 
114  TString options(drawOptions);
115  options.ToUpper();
116 
118  // remove cases where xmin and xmax are +/- inf
119  for( unsigned int i=0; i < fSamplingDistr.size(); i++ ) {
120  if( fSamplingDistr[i] < xmin && fSamplingDistr[i] != -TMath::Infinity() ) {
121  xmin = fSamplingDistr[i];
122  }
123  if( fSamplingDistr[i] > xmax && fSamplingDistr[i] != TMath::Infinity() ) {
124  xmax = fSamplingDistr[i];
125  }
126  }
127  if( xmin >= xmax ) {
128  coutW(Plotting) << "Could not determine xmin and xmax of sampling distribution that was given to plot." << endl;
129  xmin = -1.0;
130  xmax = 1.0;
131  }
132 
133 
134  // add 1.5 bins left and right
135  assert(fBins > 1);
136  double binWidth = (xmax-xmin)/(fBins);
137  Double_t xlow = xmin - 1.5*binWidth;
138  Double_t xup = xmax + 1.5*binWidth;
139  if( !IsNaN(fXMin) ) xlow = fXMin;
140  if( !IsNaN(fXMax) ) xup = fXMax;
141 
142  fHist = new TH1F(samplingDist->GetName(), samplingDist->GetTitle(), fBins, xlow, xup);
143  fHist->SetDirectory(0); // make the object managed by this class
144 
145  if( fVarName.Length() == 0 ) fVarName = samplingDist->GetVarName();
147 
148 
149  std::vector<Double_t>::iterator valuesIt = fSamplingDistr.begin();
150  for (int w_idx = 0; valuesIt != fSamplingDistr.end(); ++valuesIt, ++w_idx) {
151  if (fIsWeighted) fHist->Fill(*valuesIt, fSampleWeights[w_idx]);
152  else fHist->Fill(*valuesIt);
153  }
154 
155  // NORMALIZATION
156  fHist->Sumw2();
157  double weightSum = 1.0;
158  if(options.Contains("NORMALIZE")) {
159  weightSum = fHist->Integral("width");
160  fHist->Scale(1./weightSum);
161 
162  options.ReplaceAll("NORMALIZE", "");
163  options.Strip();
164  }
165 
166 
167  //some basic aesthetics
171 
172  fMarkerType++;
173  fColor++;
174 
176 
177  addObject(fHist, options.Data());
178 
179  TString title = samplingDist->GetTitle();
180  if(fLegend && title.Length() > 0) fLegend->AddEntry(fHist, title, "L");
181 
182  return 1./weightSum;
183 }
184 
185 ////////////////////////////////////////////////////////////////////////////////
186 
188  if( samplingDist->GetSamplingDistribution().empty() ) {
189  coutW(Plotting) << "Empty sampling distribution given to plot. Skipping." << endl;
190  return 0.0;
191  }
192  Double_t scaleFactor = AddSamplingDistribution(samplingDist, drawOptions);
193 
194  TH1F *shaded = (TH1F*)fHist->Clone((string(samplingDist->GetName())+string("_shaded")).c_str());
195  shaded->SetDirectory(0);
196  shaded->SetFillStyle(fFillStyle++);
197  shaded->SetLineWidth(1);
198 
199  for (int i=0; i<shaded->GetNbinsX(); ++i) {
200  if (shaded->GetBinCenter(i) < minShaded || shaded->GetBinCenter(i) > maxShaded){
201  shaded->SetBinContent(i,0);
202  }
203  }
204 
205  TString options(drawOptions);
206  options.ToUpper();
207  if(options.Contains("NORMALIZE")) {
208  options.ReplaceAll("NORMALIZE", "");
209  options.Strip();
210  }
211  addObject(shaded, options.Data());
212 
213  return scaleFactor;
214 }
215 
216 ////////////////////////////////////////////////////////////////////////////////
217 
218 void SamplingDistPlot::AddLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char* title) {
219  TLine *line = new TLine(x1, y1, x2, y2);
220  line->SetLineWidth(3);
222 
223  if(fLegend && title) fLegend->AddEntry(line, title, "L");
224 
225  addOtherObject(line, ""); // no options
226 }
227 
228 ////////////////////////////////////////////////////////////////////////////////
229 /// add an histogram (it will be cloned);
230 
231 void SamplingDistPlot::AddTH1(TH1* h, Option_t *drawOptions) {
232  if(fLegend && h->GetTitle()) fLegend->AddEntry(h, h->GetTitle(), "L");
233  TH1 * hcopy = (TH1*) h->Clone();
234  hcopy->SetDirectory(0);
235  addObject(hcopy, drawOptions);
236 }
237 void SamplingDistPlot::AddTF1(TF1* f, const char* title, Option_t *drawOptions) {
238  if(fLegend && title) fLegend->AddEntry(f, title, "L");
239  addOtherObject(f->Clone(), drawOptions);
240 }
241 
242 ////////////////////////////////////////////////////////////////////////////////
243 ///Determine if the sampling distribution has weights and store them
244 
246 {
248 
249  if(samplingDist->GetSampleWeights().size() != 0){
250  fIsWeighted = kTRUE;
251  fSampleWeights = samplingDist->GetSampleWeights();
252  }
253 
254  return;
255 }
256 
257 ////////////////////////////////////////////////////////////////////////////////
258 /// Add a generic object to this plot. The specified options will be
259 /// used to Draw() this object later. The caller transfers ownership
260 /// of the object with this call, and the object will be deleted
261 /// when its containing plot object is destroyed.
262 
264 {
265 
266  if(0 == obj) {
267  std::cerr << fName << "::addObject: called with a null pointer" << std::endl;
268  return;
269  }
270 
271  fItems.Add(obj,drawOptions);
272 
273  return;
274 }
275 
276 ////////////////////////////////////////////////////////////////////////////////
277 /// Add a generic object to this plot. The specified options will be
278 /// used to Draw() this object later. The caller transfers ownership
279 /// of the object with this call, and the object will be deleted
280 /// when its containing plot object is destroyed.
281 
283 {
284  if(0 == obj) {
285  oocoutE(this,InputArguments) << fName << "::addOtherObject: called with a null pointer" << std::endl;
286  return;
287  }
288 
289  fOtherItems.Add(obj,drawOptions);
290 
291  return;
292 }
293 
294 ////////////////////////////////////////////////////////////////////////////////
295 /// Draw this plot and all of the elements it contains. The specified options
296 /// only apply to the drawing of our frame. The options specified in our add...()
297 /// methods will be used to draw each object we contain.
298 
299 void SamplingDistPlot::Draw(Option_t * /*options */) {
301 
302  Double_t theMin(0.), theMax(0.), theYMin(NaN), theYMax(0.);
303  GetAbsoluteInterval(theMin, theMax, theYMax);
304  if( !IsNaN(fXMin) ) theMin = fXMin;
305  if( !IsNaN(fXMax) ) theMax = fXMax;
306  if( !IsNaN(fYMin) ) theYMin = fYMin;
307  if( !IsNaN(fYMax) ) theYMax = fYMax;
308 
309  RooRealVar xaxis("xaxis", fVarName.Data(), theMin, theMax);
310 
311  //L.M. by drawing many times we create a memory leak ???
312  if (fRooPlot) delete fRooPlot;
313 
314  bool dirStatus = RooPlot::addDirectoryStatus();
315  // make the RooPlot managed by this class
317  fRooPlot = xaxis.frame();
319  if (!fRooPlot) {
320  oocoutE(this,InputArguments) << "invalid variable to plot" << std::endl;
321  return;
322  }
323  fRooPlot->SetTitle("");
324  if( !IsNaN(theYMax) ) {
325  //coutI(InputArguments) << "Setting maximum to " << theYMax << endl;
326  fRooPlot->SetMaximum(theYMax);
327  }
328  if( !IsNaN(theYMin) ) {
329  //coutI(InputArguments) << "Setting minimum to " << theYMin << endl;
330  fRooPlot->SetMinimum(theYMin);
331  }
332 
333  fIterator->Reset();
334  TH1F *obj = 0;
335  while ((obj = (TH1F*) fIterator->Next())) {
336  //obj->Draw(fIterator->GetOption());
337  // add cloned objects to avoid mem leaks
338  TH1 * cloneObj = (TH1*)obj->Clone();
339  if( !IsNaN(theYMax) ) {
340  //coutI(InputArguments) << "Setting maximum of TH1 to " << theYMax << endl;
341  cloneObj->SetMaximum(theYMax);
342  }
343  if( !IsNaN(theYMin) ) {
344  //coutI(InputArguments) << "Setting minimum of TH1 to " << theYMin << endl;
345  cloneObj->SetMinimum(theYMin);
346  }
347  cloneObj->SetDirectory(0); // transfer ownership of the object
348  fRooPlot->addTH1(cloneObj, fIterator->GetOption());
349  }
350 
351  TIterator *otherIt = fOtherItems.MakeIterator();
352  TObject *otherObj = NULL;
353  while ((otherObj = otherIt->Next())) {
354  TObject * cloneObj = otherObj->Clone();
355  fRooPlot->addObject(cloneObj, otherIt->GetOption());
356  }
357  delete otherIt;
358 
359 
361 
362  if(bool(gStyle->GetOptLogx()) != fLogXaxis) {
363  if(!fApplyStyle) coutW(Plotting) << "gStyle will be changed to adjust SetOptLogx(...)" << endl;
365  }
366  if(bool(gStyle->GetOptLogy()) != fLogYaxis) {
367  if(!fApplyStyle) coutW(Plotting) << "gStyle will be changed to adjust SetOptLogy(...)" << endl;
369  }
370  fRooPlot->Draw();
371 
372  // apply this since gStyle does not work for RooPlot
373  if (gPad) {
374  gPad->SetLogx(fLogXaxis);
375  gPad->SetLogy(fLogYaxis);
376  }
377 
378  return;
379 }
380 
381 ////////////////////////////////////////////////////////////////////////////////
382 
384  if(fApplyStyle) {
385  // use plain black on white colors
386  Int_t icol = 0;
387  gStyle->SetFrameBorderMode( icol );
388  gStyle->SetCanvasBorderMode( icol );
389  gStyle->SetPadBorderMode( icol );
390  gStyle->SetPadColor( icol );
391  gStyle->SetCanvasColor( icol );
392  gStyle->SetStatColor( icol );
394 
395  // set the paper & margin sizes
396  gStyle->SetPaperSize( 20, 26 );
397 
398  if(fLegend) {
399  fLegend->SetFillColor(0);
401  }
402  }
403 }
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 
407 void SamplingDistPlot::GetAbsoluteInterval(Double_t &theMin, Double_t &theMax, Double_t &theYMax) const
408 {
409  Double_t tmpmin = TMath::Infinity();
410  Double_t tmpmax = -TMath::Infinity();
411  Double_t tmpYmax = -TMath::Infinity();
412 
413  fIterator->Reset();
414  TH1F *obj = 0;
415  while((obj = (TH1F*)fIterator->Next())) {
416  if(obj->GetXaxis()->GetXmin() < tmpmin) tmpmin = obj->GetXaxis()->GetXmin();
417  if(obj->GetXaxis()->GetXmax() > tmpmax) tmpmax = obj->GetXaxis()->GetXmax();
418  if(obj->GetMaximum() > tmpYmax) tmpYmax = obj->GetMaximum() + 0.1*obj->GetMaximum();
419  }
420 
421  theMin = tmpmin;
422  theMax = tmpmax;
423  theYMax = tmpYmax;
424 
425  return;
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Sets line color for given sampling distribution and
430 /// fill color for the associated shaded TH1F.
431 
433  if (samplDist == 0) {
434  fHist->SetLineColor(color);
435 
436  fIterator->Reset();
437  TH1F *obj = 0;
438 
439  TString shadedName(fHist->GetName());
440  shadedName += "_shaded";
441 
442  while ((obj = (TH1F*) fIterator->Next())) {
443  if (!strcmp(obj->GetName(), shadedName.Data())) {
444  obj->SetLineColor(color);
445  obj->SetFillColor(color);
446  //break;
447  }
448  }
449  } else {
450  fIterator->Reset();
451  TH1F *obj = 0;
452 
453  TString shadedName(samplDist->GetName());
454  shadedName += "_shaded";
455 
456  while ((obj = (TH1F*) fIterator->Next())) {
457  if (!strcmp(obj->GetName(), samplDist->GetName())) {
458  obj->SetLineColor(color);
459  //break;
460  }
461  if (!strcmp(obj->GetName(), shadedName.Data())) {
462  obj->SetLineColor(color);
463  obj->SetFillColor(color);
464  //break;
465  }
466  }
467  }
468 
469  return;
470 }
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 
475 {
476  if(samplDist == 0){
477  fHist->SetLineWidth(lwidth);
478  }
479  else{
480  fIterator->Reset();
481  TH1F *obj = 0;
482  while((obj = (TH1F*)fIterator->Next())) {
483  if(!strcmp(obj->GetName(),samplDist->GetName())){
484  obj->SetLineWidth(lwidth);
485  break;
486  }
487  }
488  }
489 
490  return;
491 }
492 
493 ////////////////////////////////////////////////////////////////////////////////
494 
496 {
497  if(samplDist == 0){
499  }
500  else{
501  fIterator->Reset();
502  TH1F *obj = 0;
503  while((obj = (TH1F*)fIterator->Next())) {
504  if(!strcmp(obj->GetName(),samplDist->GetName())){
505  obj->SetLineStyle(style);
506  break;
507  }
508  }
509  }
510 
511  return;
512 }
513 
514 ////////////////////////////////////////////////////////////////////////////////
515 
517 {
518  if(samplDist == 0){
520  }
521  else{
522  fIterator->Reset();
523  TH1F *obj = 0;
524  while((obj = (TH1F*)fIterator->Next())) {
525  if(!strcmp(obj->GetName(),samplDist->GetName())){
526  obj->SetMarkerStyle(style);
527  break;
528  }
529  }
530  }
531 
532  return;
533 }
534 
535 ////////////////////////////////////////////////////////////////////////////////
536 
538 {
539  if(samplDist == 0){
540  fHist->SetMarkerColor(color);
541  }
542  else{
543  fIterator->Reset();
544  TH1F *obj = 0;
545  while((obj = (TH1F*)fIterator->Next())) {
546  if(!strcmp(obj->GetName(),samplDist->GetName())){
547  obj->SetMarkerColor(color);
548  break;
549  }
550  }
551  }
552 
553  return;
554 }
555 
556 ////////////////////////////////////////////////////////////////////////////////
557 
559 {
560  if(samplDist == 0){
562  }
563  else{
564  fIterator->Reset();
565  TH1F *obj = 0;
566  while((obj = (TH1F*)fIterator->Next())) {
567  if(!strcmp(obj->GetName(),samplDist->GetName())){
568  obj->SetMarkerSize(size);
569  break;
570  }
571  }
572  }
573 
574  return;
575 }
576 
577 ////////////////////////////////////////////////////////////////////////////////
578 
580 {
581  if(samplDist == NULL){
582  return fHist;
583  }else{
584  fIterator->Reset();
585  TH1F *obj = 0;
586  while((obj = (TH1F*)fIterator->Next())) {
587  if(!strcmp(obj->GetName(),samplDist->GetName())){
588  return obj;
589  }
590  }
591  }
592 
593  return NULL;
594 }
595 
596 ////////////////////////////////////////////////////////////////////////////////
597 
599 {
600  if(samplDist == 0){
601  fHist->Rebin(rebinFactor);
602  }
603  else{
604  fIterator->Reset();
605  TH1F *obj = 0;
606  while((obj = (TH1F*)fIterator->Next())) {
607  if(!strcmp(obj->GetName(),samplDist->GetName())){
608  obj->Rebin(rebinFactor);
609  break;
610  }
611  }
612  }
613 
614  return;
615 }
616 
617 ////////////////////////////////////////////////////////////////////////////////
618 /// TODO test
619 
620 void SamplingDistPlot::DumpToFile(const char* RootFileName, Option_t *option, const char *ftitle, Int_t compress) {
621  // All the objects are written to rootfile
622 
623  if(!fRooPlot) {
624  cout << "Plot was not drawn yet. Dump can only be saved after it was drawn with Draw()." << endl;
625  return;
626  }
627 
628  TFile ofile(RootFileName, option, ftitle, compress);
629  ofile.cd();
630  fRooPlot->Write();
631  ofile.Close();
632 }
RooStats::SamplingDistPlot::GetAbsoluteInterval
void GetAbsoluteInterval(Double_t &theMin, Double_t &theMax, Double_t &theYMax) const
Definition: SamplingDistPlot.cxx:407
TAttMarker::SetMarkerSize
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
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
TStyle::SetOptLogy
void SetOptLogy(Int_t logy=1)
Definition: TStyle.h:314
RooStats::SamplingDistPlot::SetMarkerColor
void SetMarkerColor(Color_t color, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:537
TPave::SetBorderSize
virtual void SetBorderSize(Int_t bordersize=4)
Definition: TPave.h:73
RooStats::SamplingDistPlot::fYMax
double fYMax
Definition: SamplingDistPlot.h:127
TStyle::SetPadColor
void SetPadColor(Color_t color=19)
Definition: TStyle.h:338
RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
Style_t
short Style_t
Definition: RtypesCore.h:89
TLine.h
TStyle::GetOptLogy
Int_t GetOptLogy() const
Definition: TStyle.h:239
TIterator::GetOption
virtual Option_t * GetOption() const
Definition: TIterator.h:40
RooMsgService.h
RooStats::SamplingDistPlot::fLegend
TLegend * fLegend
Definition: SamplingDistPlot.h:118
f
#define f(i)
Definition: RSha256.hxx:104
TLine
A simple line.
Definition: TLine.h:22
TAttFill::SetFillStyle
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
RooStats::SamplingDistPlot::fColor
Int_t fColor
Definition: SamplingDistPlot.h:111
Option_t
const char Option_t
Definition: RtypesCore.h:66
RooStats::SamplingDistPlot::AddSamplingDistributionShaded
Double_t AddSamplingDistributionShaded(const SamplingDistribution *samplingDist, Double_t minShaded, Double_t maxShaded, Option_t *drawOptions="NORMALIZE HIST")
Like AddSamplingDistribution, but also sets a shaded area in the minShaded and maxShaded boundaries.
Definition: SamplingDistPlot.cxx:187
RooStats::SamplingDistribution
This class simply holds a sampling distribution of some test statistic.
Definition: SamplingDistribution.h:28
TString::Strip
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1128
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:61
TH1::SetMinimum
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:399
TList::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:470
TString::Data
const char * Data() const
Definition: TString.h:369
RooStats::SamplingDistPlot::fSampleWeights
std::vector< Double_t > fSampleWeights
Definition: SamplingDistPlot.h:105
RooStats::SamplingDistPlot::AddTH1
void AddTH1(TH1 *h, Option_t *drawOptions="")
add a TH1
Definition: SamplingDistPlot.cxx:231
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
RooStats::SamplingDistribution::GetVarName
const TString GetVarName() const
Definition: SamplingDistribution.h:69
SamplingDistPlot.h
TStyle::SetFrameFillStyle
void SetFrameFillStyle(Style_t styl=0)
Definition: TStyle.h:357
xmax
float xmax
Definition: THbookFile.cxx:95
coutW
#define coutW(a)
Definition: RooMsgService.h:32
RooStats::SamplingDistPlot::SamplingDistPlot
SamplingDistPlot(Int_t nbins=100)
Constructors for SamplingDistribution.
Definition: SamplingDistPlot.cxx:48
TStyle.h
TStyle::SetStatColor
void SetStatColor(Color_t color=19)
Definition: TStyle.h:373
RooStats::SamplingDistPlot::addOtherObject
void addOtherObject(TObject *obj, Option_t *drawOptions=0)
Add a generic object to this plot.
Definition: SamplingDistPlot.cxx:282
TDirectoryFile::cd
Bool_t cd(const char *path=nullptr) override
Change current directory to "this" directory.
Definition: TDirectoryFile.cxx:340
TNamed::fName
TString fName
Definition: TNamed.h:32
RooPlot::SetMaximum
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Definition: RooPlot.cxx:1081
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
TH1::SetBinContent
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition: TH1.cxx:9055
RooStats::SamplingDistPlot
This class provides simple and straightforward utilities to plot SamplingDistribution objects.
Definition: SamplingDistPlot.h:32
RooStats::SamplingDistribution::GetSampleWeights
const std::vector< Double_t > & GetSampleWeights() const
Get the sampling weights.
Definition: SamplingDistribution.h:67
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TStyle::SetPaperSize
void SetPaperSize(EPaperSize size)
Set paper size for PostScript output.
Definition: TStyle.cxx:1654
RooStats::SamplingDistPlot::fYMin
double fYMin
Definition: SamplingDistPlot.h:127
RooStats::SamplingDistPlot::fIterator
TIterator * fIterator
other objects to be drawn like TLine etc.
Definition: SamplingDistPlot.h:122
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
oocoutE
#define oocoutE(o, a)
Definition: RooMsgService.h:48
TStyle::SetPadBorderMode
void SetPadBorderMode(Int_t mode=1)
Definition: TStyle.h:340
TString
Basic string class.
Definition: TString.h:136
TStyle::SetOptLogx
void SetOptLogx(Int_t logx=1)
Definition: TStyle.h:313
RooStats::SamplingDistPlot::SetLineColor
void SetLineColor(Color_t color, const SamplingDistribution *samplDist=0)
Sets line color for given sampling distribution and fill color for the associated shaded TH1F.
Definition: SamplingDistPlot.cxx:432
RooStats::SamplingDistPlot::fHist
TH1F * fHist
Definition: SamplingDistPlot.h:117
Color_t
short Color_t
Definition: RtypesCore.h:92
RooStats::SamplingDistPlot::GetTH1F
TH1F * GetTH1F(const SamplingDistribution *samplDist=NULL)
Returns the TH1F associated with the give SamplingDistribution.
Definition: SamplingDistPlot.cxx:579
TFile.h
RooStats::SamplingDistribution::GetSamplingDistribution
const std::vector< Double_t > & GetSamplingDistribution() const
Get test statistics values.
Definition: SamplingDistribution.h:65
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
RooStats::SamplingDistPlot::DumpToFile
void DumpToFile(const char *RootFileName, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
write to Root file
Definition: SamplingDistPlot.cxx:620
RooStats::SamplingDistPlot::RebinDistribution
void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:598
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TH1::Clone
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2740
TString::ToUpper
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1160
RooPlot::addObject
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
Definition: RooPlot.cxx:422
style
TCanvas * style()
Definition: style.C:1
TList::MakeIterator
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:722
RooStats::SamplingDistPlot::fIsWeighted
Bool_t fIsWeighted
Definition: SamplingDistPlot.h:107
RooStats::SamplingDistPlot::fXMax
double fXMax
Definition: SamplingDistPlot.h:127
kBlack
@ kBlack
Definition: Rtypes.h:65
RooStats::SamplingDistPlot::fMarkerType
Int_t fMarkerType
Definition: SamplingDistPlot.h:110
RooStats::SamplingDistPlot::fLogXaxis
Bool_t fLogXaxis
Definition: SamplingDistPlot.h:124
RooPlot::addDirectoryStatus
static Bool_t addDirectoryStatus()
Query whether new instances of RooPlot will add themselves to gDirectory.
Definition: RooPlot.cxx:78
TAxis::GetXmin
Double_t GetXmin() const
Definition: TAxis.h:133
RooStats::SamplingDistPlot::AddLine
void AddLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char *title=NULL)
add a line
Definition: SamplingDistPlot.cxx:218
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
RooStats::SamplingDistPlot::fFillStyle
Style_t fFillStyle
Definition: SamplingDistPlot.h:130
xmin
float xmin
Definition: THbookFile.cxx:95
TH1::Rebin
virtual TH1 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=0)
Rebin this histogram.
Definition: TH1.cxx:6222
h
#define h(i)
Definition: RSha256.hxx:106
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
RooStats::SamplingDistPlot::SetSampleWeights
void SetSampleWeights(const SamplingDistribution *samplingDist)
Determine if the sampling distribution has weights and store them.
Definition: SamplingDistPlot.cxx:245
TAttMarker::SetMarkerColor
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
Width_t
short Width_t
Definition: RtypesCore.h:91
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TH1::GetBinCenter
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
Definition: TH1.cxx:8974
RooStats::SamplingDistPlot::SetLineStyle
void SetLineStyle(Style_t style, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:495
RooFit::Plotting
@ Plotting
Definition: RooGlobalFunc.h:60
TH1::SetMaximum
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:398
TLegend::AddEntry
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
Definition: TLegend.cxx:330
TObject::Clone
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:146
RooStats::SamplingDistPlot::fLogYaxis
Bool_t fLogYaxis
Definition: SamplingDistPlot.h:125
TH1::Fill
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3350
RooStats::SamplingDistPlot::fBins
Int_t fBins
Definition: SamplingDistPlot.h:109
TVirtualPad.h
TStyle::SetFrameBorderMode
void SetFrameBorderMode(Int_t mode=1)
Definition: TStyle.h:361
TH1::SetDirectory
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
Definition: TH1.cxx:8770
TMath::Infinity
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
Definition: TMath.h:914
IsNaN
#define IsNaN(a)
Definition: SamplingDistPlot.cxx:38
RooRealVar.h
RooPlot::addTH1
void addTH1(TH1 *hist, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a TH1 histogram object to this plot.
Definition: RooPlot.cxx:441
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
TH1::SetStats
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8823
RooStats::SamplingDistPlot::~SamplingDistPlot
virtual ~SamplingDistPlot()
Destructor of SamplingDistribution.
Definition: SamplingDistPlot.cxx:94
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
TIterator::Next
virtual TObject * Next()=0
SamplingDistribution.h
TIterator::Reset
virtual void Reset()=0
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
RooStats::SamplingDistPlot::addObject
void addObject(TObject *obj, Option_t *drawOptions=0)
Add a generic object to this plot.
Definition: SamplingDistPlot.cxx:263
RooStats::SamplingDistPlot::fSamplingDistr
std::vector< Double_t > fSamplingDistr
Definition: SamplingDistPlot.h:104
RooStats::SamplingDistPlot::SetLineWidth
void SetLineWidth(Width_t lwidth, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:474
RooStats::SamplingDistPlot::ApplyDefaultStyle
void ApplyDefaultStyle(void)
Applies a predefined style if fApplyStyle is kTRUE (default).
Definition: SamplingDistPlot.cxx:383
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
RooStats::SamplingDistPlot::SetXRange
void SetXRange(double mi, double ma)
change x range
Definition: SamplingDistPlot.h:96
RooStats::SamplingDistPlot::Draw
void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: SamplingDistPlot.cxx:299
RooPlot::SetTitle
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
Definition: RooPlot.cxx:1251
RooStats::SamplingDistPlot::fRooPlot
RooPlot * fRooPlot
TODO remove class variable and instantiate locally as necessary.
Definition: SamplingDistPlot.h:123
RooStats::SamplingDistPlot::fXMin
double fXMin
Definition: SamplingDistPlot.h:127
RooStats::SamplingDistPlot::SetMarkerSize
void SetMarkerSize(Size_t size, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:558
RooStats
Namespace for the RooStats classes.
Definition: Asimov.h:19
TH1F
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
TAttFill::SetFillColor
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
RooStats::SamplingDistPlot::SetMarkerStyle
void SetMarkerStyle(Style_t style, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:516
TObject::Write
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:798
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TH1::Sumw2
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition: TH1.cxx:8853
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TFile::Close
void Close(Option_t *option="") override
Close a file.
Definition: TFile.cxx:880
TH1
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
TStyle::GetOptLogx
Int_t GetOptLogx() const
Definition: TStyle.h:238
NaN
#define NaN
Definition: SamplingDistPlot.cxx:36
RooPlot::SetMinimum
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
Definition: RooPlot.cxx:1091
RooStats::SamplingDistPlot::fOtherItems
RooList fOtherItems
holds TH1Fs only
Definition: SamplingDistPlot.h:121
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
gPad
#define gPad
Definition: TVirtualPad.h:287
RooPlot::setAddDirectoryStatus
static Bool_t setAddDirectoryStatus(Bool_t flag)
Configure whether new instances of RooPlot will add themselves to gDirectory.
Definition: RooPlot.cxx:79
TAttMarker::SetMarkerStyle
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TAxis::GetXmax
Double_t GetXmax() const
Definition: TAxis.h:134
TF1
1-Dim function class
Definition: TF1.h:213
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
TH1::GetXaxis
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:320
RooStats::SamplingDistPlot::fItems
RooList fItems
Definition: SamplingDistPlot.h:120
TAttLine::SetLineStyle
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
TH1::GetMaximum
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
Definition: TH1.cxx:8383
TH1::Integral
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
Definition: TH1.cxx:7827
RooStats::SamplingDistPlot::AddSamplingDistribution
Double_t AddSamplingDistribution(const SamplingDistribution *samplingDist, Option_t *drawOptions="NORMALIZE HIST")
adds the sampling distribution and returns the scale factor
Definition: SamplingDistPlot.cxx:106
TH1::Scale
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition: TH1.cxx:6564
RooStats::SamplingDistPlot::fApplyStyle
Bool_t fApplyStyle
Definition: SamplingDistPlot.h:129
RooStats::SamplingDistPlot::AddTF1
void AddTF1(TF1 *f, const char *title=NULL, Option_t *drawOptions="SAME")
add a TF1
Definition: SamplingDistPlot.cxx:237
TMath.h
TH1::GetNbinsX
virtual Int_t GetNbinsX() const
Definition: TH1.h:296
int
Size_t
float Size_t
Definition: RtypesCore.h:96
RooStats::SamplingDistPlot::fVarName
TString fVarName
Definition: SamplingDistPlot.h:113