Logo ROOT   6.14/05
Reference Guide
SamplingDistPlot.h
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 #ifndef ROOSTATS_SamplingDistPlot
13 #define ROOSTATS_SamplingDistPlot
14 
15 #include "RooList.h"
16 #include "RooPrintable.h"
17 #include "TNamed.h"
18 #include "TIterator.h"
19 #include "TH1F.h"
20 #include "TF1.h"
21 #include "TLegend.h"
22 
24 
25 #include "RooPlot.h"
26 
27 
28 namespace RooStats {
29 
30  class SamplingDistPlot : public TNamed, public RooPrintable {
31 
32  public:
33  /// Constructors for SamplingDistribution
34  SamplingDistPlot(Int_t nbins = 100);
35  SamplingDistPlot(Int_t nbins, Double_t min, Double_t max);
36 // SamplingDistPlot(const char* name, const char* title, Int_t nbins, Double_t xmin, Double_t xmax);
37 
38  /// Destructor of SamplingDistribution
39  virtual ~SamplingDistPlot();
40 
41  /// adds the sampling distribution and returns the scale factor
42  Double_t AddSamplingDistribution(const SamplingDistribution *samplingDist, Option_t *drawOptions="NORMALIZE HIST");
43  /// Like AddSamplingDistribution, but also sets a shaded area in the
44  /// minShaded and maxShaded boundaries.
45  Double_t AddSamplingDistributionShaded(const SamplingDistribution *samplingDist, Double_t minShaded, Double_t maxShaded, Option_t *drawOptions="NORMALIZE HIST");
46 
47  /// add a line
48  void AddLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char* title = NULL);
49  /// add a TH1
50  void AddTH1(TH1* h, Option_t *drawOptions="");
51  /// add a TF1
52  void AddTF1(TF1* f, const char* title = NULL, Option_t *drawOptions="SAME");
53  /// set legend
54  void SetLegend(TLegend* l){ fLegend = l; }
55 
56  void Draw(Option_t *options=0);
57 
58  /// Applies a predefined style if fApplyStyle is kTRUE (default).
59  void ApplyDefaultStyle(void);
60 
61  void SetLineColor(Color_t color, const SamplingDistribution *samplDist = 0);
62  void SetLineWidth(Width_t lwidth, const SamplingDistribution *samplDist = 0);
63  void SetLineStyle(Style_t style, const SamplingDistribution *samplDist = 0);
64 
65  void SetMarkerColor(Color_t color, const SamplingDistribution *samplDist = 0);
66  void SetMarkerStyle(Style_t style, const SamplingDistribution *samplDist = 0);
67  void SetMarkerSize(Size_t size, const SamplingDistribution *samplDist = 0);
68 
69  void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *samplDist = 0);
70 
71  void SetAxisTitle(char *varName) { fVarName = TString(varName); }
72 
73  /// If you do not want SamplingDistPlot to interfere with your style settings, call this
74  /// function with "false" before Draw().
76 
77  /// Returns the TH1F associated with the give SamplingDistribution.
78  /// Intended use: Access to member functions of TH1F like GetMean(),
79  /// GetRMS() etc.
80  /// The return objects is managed by SamplingDistPlot
81  TH1F* GetTH1F(const SamplingDistribution *samplDist = NULL);
82  TH1 * GetHistogram(const SamplingDistribution *samplDist = NULL) { return GetTH1F(samplDist); }
83 
84  /// return plotter class used to draw the sampling distribution histograms
85  /// object is managed by SamplingDistPlot
86  RooPlot * GetPlot() { return fRooPlot; }
87 
88  /// changes plot to log scale on x axis
89  void SetLogXaxis(Bool_t lx) { fLogXaxis = lx; }
90  /// changes plot to log scale on y axis
91  void SetLogYaxis(Bool_t ly) { fLogYaxis = ly; }
92 
93  /// change x range
94  void SetXRange( double mi, double ma ) { fXMin = mi; fXMax = ma; }
95  /// change y range
96  void SetYRange( double mi, double ma ) { fYMin = mi; fYMax = ma; }
97 
98  /// write to Root file
99  void DumpToFile(const char* RootFileName, Option_t *option="", const char *ftitle="", Int_t compress=1);
100 
101  private:
102  std::vector<Double_t> fSamplingDistr;
103  std::vector<Double_t> fSampleWeights;
104 
106 
110 
112 
113  protected:
114 
117 
118  RooList fItems; /// holds TH1Fs only
119  RooList fOtherItems; /// other objects to be drawn like TLine etc.
120  TIterator* fIterator; /// TODO remove class variable and instantiate locally as necessary
124 
125  double fXMin, fXMax, fYMin, fYMax;
126 
129 
130  void SetSampleWeights(const SamplingDistribution *samplingDist);
131 
132  void addObject(TObject *obj, Option_t *drawOptions=0); // for TH1Fs only
133  void addOtherObject(TObject *obj, Option_t *drawOptions=0);
134  void GetAbsoluteInterval(Double_t &theMin, Double_t &theMax, Double_t &theYMax) const;
135 
136  ClassDef(SamplingDistPlot,1) /// Class containing the results of the HybridCalculator
137  };
138 }
139 
140 #endif
RooPlot * fRooPlot
TODO remove class variable and instantiate locally as necessary.
void SetLogXaxis(Bool_t lx)
changes plot to log scale on x axis
This class displays a legend box (TPaveText) containing several legend entries.
Definition: TLegend.h:23
void ApplyDefaultStyle(void)
Applies a predefined style if fApplyStyle is kTRUE (default).
short Style_t
Definition: RtypesCore.h:76
RooPlot * GetPlot()
return plotter class used to draw the sampling distribution histograms object is managed by SamplingD...
void SetLineColor(Color_t color, const SamplingDistribution *samplDist=0)
Sets line color for given sampling distribution and fill color for the associated shaded TH1F...
float Size_t
Definition: RtypesCore.h:83
const char Option_t
Definition: RtypesCore.h:62
Double_t AddSamplingDistribution(const SamplingDistribution *samplingDist, Option_t *drawOptions="NORMALIZE HIST")
adds the sampling distribution and returns the scale factor
Basic string class.
Definition: TString.h:131
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:567
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetLogYaxis(Bool_t ly)
changes plot to log scale on y axis
void SetSampleWeights(const SamplingDistribution *samplingDist)
Determine if the sampling distribution has weights and store them.
void GetAbsoluteInterval(Double_t &theMin, Double_t &theMax, Double_t &theYMax) const
Iterator abstract base class.
Definition: TIterator.h:30
static const double x2[5]
#define ClassDef(name, id)
Definition: Rtypes.h:320
RooPlotable is a &#39;mix-in&#39; base class that define the standard RooFit plotting and printing methods...
Definition: RooPrintable.h:25
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void addObject(TObject *obj, Option_t *drawOptions=0)
Add a generic object to this plot.
void SetLineWidth(Width_t lwidth, const SamplingDistribution *samplDist=0)
void SetXRange(double mi, double ma)
change x range
void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
void AddTH1(TH1 *h, Option_t *drawOptions="")
add a TH1
void SetMarkerSize(Size_t size, const SamplingDistribution *samplDist=0)
short Color_t
Definition: RtypesCore.h:79
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...
RooList fOtherItems
holds TH1Fs only
void DumpToFile(const char *RootFileName, Option_t *option="", const char *ftitle="", Int_t compress=1)
write to Root file
void SetMarkerStyle(Style_t style, const SamplingDistribution *samplDist=0)
void SetLegend(TLegend *l)
set legend
TIterator * fIterator
other objects to be drawn like TLine etc.
void SetAxisTitle(char *varName)
A RooList is a TList with extra support for working with options that are associated with each node...
Definition: RooList.h:21
TH1 * GetHistogram(const SamplingDistribution *samplDist=NULL)
void SetYRange(double mi, double ma)
change y range
This class simply holds a sampling distribution of some test statistic.
void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *samplDist=0)
#define h(i)
Definition: RSha256.hxx:106
short Width_t
Definition: RtypesCore.h:78
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Definition: RooPlot.h:41
Namespace for the RooStats classes.
Definition: Asimov.h:20
void AddTF1(TF1 *f, const char *title=NULL, Option_t *drawOptions="SAME")
add a TF1
static const double x1[5]
TH1F * GetTH1F(const SamplingDistribution *samplDist=NULL)
Returns the TH1F associated with the give SamplingDistribution.
double Double_t
Definition: RtypesCore.h:55
TCanvas * style()
Definition: style.C:1
The TH1 histogram class.
Definition: TH1.h:56
static constexpr double s
void AddLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char *title=NULL)
add a line
void SetMarkerColor(Color_t color, const SamplingDistribution *samplDist=0)
std::vector< Double_t > fSampleWeights
This class provides simple and straightforward utilities to plot SamplingDistribution objects...
Mother of all ROOT objects.
Definition: TObject.h:37
void SetLineStyle(Style_t style, const SamplingDistribution *samplDist=0)
auto * l
Definition: textangle.C:4
1-Dim function class
Definition: TF1.h:211
void addOtherObject(TObject *obj, Option_t *drawOptions=0)
Add a generic object to this plot.
void SetApplyStyle(Bool_t s)
If you do not want SamplingDistPlot to interfere with your style settings, call this function with "f...
virtual ~SamplingDistPlot()
Destructor of SamplingDistribution.
SamplingDistPlot(Int_t nbins=100)
Constructors for SamplingDistribution.
std::vector< Double_t > fSamplingDistr