Logo ROOT  
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 "Compression.h"
16 #include "RooList.h"
17 #include "RooPrintable.h"
18 #include "TNamed.h"
19 #include "TIterator.h"
20 #include "TH1F.h"
21 #include "TF1.h"
22 #include "TLegend.h"
23 #include <vector>
24 
26 
27 #include "RooPlot.h"
28 
29 
30 namespace RooStats {
31 
32  class SamplingDistPlot : public TNamed, public RooPrintable {
33 
34  public:
35  /// Constructors for SamplingDistribution
36  SamplingDistPlot(Int_t nbins = 100);
37  SamplingDistPlot(Int_t nbins, Double_t min, Double_t max);
38 // SamplingDistPlot(const char* name, const char* title, Int_t nbins, Double_t xmin, Double_t xmax);
39 
40  /// Destructor of SamplingDistribution
41  virtual ~SamplingDistPlot();
42 
43  /// adds the sampling distribution and returns the scale factor
44  Double_t AddSamplingDistribution(const SamplingDistribution *samplingDist, Option_t *drawOptions="NORMALIZE HIST");
45  /// Like AddSamplingDistribution, but also sets a shaded area in the
46  /// minShaded and maxShaded boundaries.
47  Double_t AddSamplingDistributionShaded(const SamplingDistribution *samplingDist, Double_t minShaded, Double_t maxShaded, Option_t *drawOptions="NORMALIZE HIST");
48 
49  /// add a line
50  void AddLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char* title = NULL);
51  /// add a TH1
52  void AddTH1(TH1* h, Option_t *drawOptions="");
53  /// add a TF1
54  void AddTF1(TF1* f, const char* title = NULL, Option_t *drawOptions="SAME");
55  /// set legend
56  void SetLegend(TLegend* l){ fLegend = l; }
57 
58  void Draw(Option_t *options=0);
59 
60  /// Applies a predefined style if fApplyStyle is kTRUE (default).
61  void ApplyDefaultStyle(void);
62 
63  void SetLineColor(Color_t color, const SamplingDistribution *samplDist = 0);
64  void SetLineWidth(Width_t lwidth, const SamplingDistribution *samplDist = 0);
65  void SetLineStyle(Style_t style, const SamplingDistribution *samplDist = 0);
66 
67  void SetMarkerColor(Color_t color, const SamplingDistribution *samplDist = 0);
68  void SetMarkerStyle(Style_t style, const SamplingDistribution *samplDist = 0);
69  void SetMarkerSize(Size_t size, const SamplingDistribution *samplDist = 0);
70 
71  void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *samplDist = 0);
72 
73  void SetAxisTitle(char *varName) { fVarName = TString(varName); }
74 
75  /// If you do not want SamplingDistPlot to interfere with your style settings, call this
76  /// function with "false" before Draw().
77  void SetApplyStyle(Bool_t s) { fApplyStyle = s; }
78 
79  /// Returns the TH1F associated with the give SamplingDistribution.
80  /// Intended use: Access to member functions of TH1F like GetMean(),
81  /// GetRMS() etc.
82  /// The return objects is managed by SamplingDistPlot
83  TH1F* GetTH1F(const SamplingDistribution *samplDist = NULL);
84  TH1 * GetHistogram(const SamplingDistribution *samplDist = NULL) { return GetTH1F(samplDist); }
85 
86  /// return plotter class used to draw the sampling distribution histograms
87  /// object is managed by SamplingDistPlot
88  RooPlot * GetPlot() { return fRooPlot; }
89 
90  /// changes plot to log scale on x axis
91  void SetLogXaxis(Bool_t lx) { fLogXaxis = lx; }
92  /// changes plot to log scale on y axis
93  void SetLogYaxis(Bool_t ly) { fLogYaxis = ly; }
94 
95  /// change x range
96  void SetXRange( double mi, double ma ) { fXMin = mi; fXMax = ma; }
97  /// change y range
98  void SetYRange( double mi, double ma ) { fYMin = mi; fYMax = ma; }
99 
100  /// write to Root file
101  void DumpToFile(const char* RootFileName, Option_t *option="", const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
102 
103  private:
104  std::vector<Double_t> fSamplingDistr;
105  std::vector<Double_t> fSampleWeights;
106 
108 
109  Int_t fBins;
111  Int_t fColor;
112 
114 
115  protected:
116 
118  TLegend *fLegend;
119 
120  RooList fItems; /// holds TH1Fs only
121  RooList fOtherItems; /// other objects to be drawn like TLine etc.
122  TIterator* fIterator; /// TODO remove class variable and instantiate locally as necessary
126 
127  double fXMin, fXMax, fYMin, fYMax;
128 
131 
132  void SetSampleWeights(const SamplingDistribution *samplingDist);
133 
134  void addObject(TObject *obj, Option_t *drawOptions=0); // for TH1Fs only
135  void addOtherObject(TObject *obj, Option_t *drawOptions=0);
136  void GetAbsoluteInterval(Double_t &theMin, Double_t &theMax, Double_t &theYMax) const;
137 
138  ClassDef(SamplingDistPlot,1) /// Class containing the results of the HybridCalculator
139  };
140 }
141 
142 #endif
RooStats::SamplingDistPlot::GetAbsoluteInterval
void GetAbsoluteInterval(Double_t &theMin, Double_t &theMax, Double_t &theYMax) const
Definition: SamplingDistPlot.cxx:405
l
auto * l
Definition: textangle.C:4
RooStats::SamplingDistPlot::SetMarkerColor
void SetMarkerColor(Color_t color, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:535
Compression.h
RooStats::SamplingDistPlot::fYMax
double fYMax
Definition: SamplingDistPlot.h:139
TH1F.h
Style_t
short Style_t
Definition: RtypesCore.h:80
RooStats::SamplingDistPlot::fLegend
TLegend * fLegend
Definition: SamplingDistPlot.h:130
f
#define f(i)
Definition: RSha256.hxx:122
RooStats::SamplingDistPlot::fColor
Int_t fColor
Definition: SamplingDistPlot.h:123
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:185
RooStats::SamplingDistribution
Definition: SamplingDistribution.h:39
ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault
@ kUseCompiledDefault
Use the compile-time default setting.
Definition: Compression.h:74
RooStats::SamplingDistPlot::fSampleWeights
std::vector< Double_t > fSampleWeights
Definition: SamplingDistPlot.h:117
RooStats::SamplingDistPlot::AddTH1
void AddTH1(TH1 *h, Option_t *drawOptions="")
add a TH1
Definition: SamplingDistPlot.cxx:229
RooStats::SamplingDistPlot::SetApplyStyle
void SetApplyStyle(Bool_t s)
If you do not want SamplingDistPlot to interfere with your style settings, call this function with "f...
Definition: SamplingDistPlot.h:89
TNamed.h
TLegend.h
RooStats::SamplingDistPlot::SamplingDistPlot
SamplingDistPlot(Int_t nbins=100)
Constructors for SamplingDistribution.
Definition: SamplingDistPlot.cxx:48
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
RooPrintable.h
RooStats::SamplingDistPlot::addOtherObject
void addOtherObject(TObject *obj, Option_t *drawOptions=0)
Add a generic object to this plot.
Definition: SamplingDistPlot.cxx:280
RooStats::SamplingDistPlot
Definition: SamplingDistPlot.h:38
RooStats::SamplingDistPlot::SetLegend
void SetLegend(TLegend *l)
set legend
Definition: SamplingDistPlot.h:68
RooStats::SamplingDistPlot::fYMin
double fYMin
Definition: SamplingDistPlot.h:139
RooStats::SamplingDistPlot::SetYRange
void SetYRange(double mi, double ma)
change y range
Definition: SamplingDistPlot.h:110
RooStats::SamplingDistPlot::fIterator
TIterator * fIterator
other objects to be drawn like TLine etc.
Definition: SamplingDistPlot.h:134
TString
Definition: TString.h:136
RooPrintable
Definition: RooPrintable.h:25
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:430
RooStats::SamplingDistPlot::fHist
TH1F * fHist
Definition: SamplingDistPlot.h:129
Color_t
short Color_t
Definition: RtypesCore.h:83
RooStats::SamplingDistPlot::GetTH1F
TH1F * GetTH1F(const SamplingDistribution *samplDist=NULL)
Returns the TH1F associated with the give SamplingDistribution.
Definition: SamplingDistPlot.cxx:577
bool
TIterator
Definition: TIterator.h:30
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:618
RooStats::SamplingDistPlot::RebinDistribution
void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:596
RooStats::SamplingDistPlot::GetHistogram
TH1 * GetHistogram(const SamplingDistribution *samplDist=NULL)
Definition: SamplingDistPlot.h:96
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
style
TCanvas * style()
Definition: style.C:1
RooStats::SamplingDistPlot::fIsWeighted
Bool_t fIsWeighted
Definition: SamplingDistPlot.h:119
RooList.h
RooStats::SamplingDistPlot::fXMax
double fXMax
Definition: SamplingDistPlot.h:139
RooStats::SamplingDistPlot::fMarkerType
Int_t fMarkerType
Definition: SamplingDistPlot.h:122
RooStats::SamplingDistPlot::fLogXaxis
Bool_t fLogXaxis
Definition: SamplingDistPlot.h:136
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
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:216
RooStats::SamplingDistPlot::fFillStyle
Style_t fFillStyle
Definition: SamplingDistPlot.h:142
h
#define h(i)
Definition: RSha256.hxx:124
RooStats::SamplingDistPlot::SetSampleWeights
void SetSampleWeights(const SamplingDistribution *samplingDist)
Determine if the sampling distribution has weights and store them.
Definition: SamplingDistPlot.cxx:243
TIterator.h
TNamed
Definition: TNamed.h:29
Width_t
short Width_t
Definition: RtypesCore.h:82
RooStats::SamplingDistPlot::SetLineStyle
void SetLineStyle(Style_t style, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:493
RooPlot.h
RooStats::SamplingDistPlot::fLogYaxis
Bool_t fLogYaxis
Definition: SamplingDistPlot.h:137
RooStats::SamplingDistPlot::fBins
Int_t fBins
Definition: SamplingDistPlot.h:121
RooPlot
Definition: RooPlot.h:44
RooStats::SamplingDistPlot::~SamplingDistPlot
virtual ~SamplingDistPlot()
Destructor of SamplingDistribution.
Definition: SamplingDistPlot.cxx:94
SamplingDistribution.h
RooStats::SamplingDistPlot::addObject
void addObject(TObject *obj, Option_t *drawOptions=0)
Add a generic object to this plot.
Definition: SamplingDistPlot.cxx:261
RooStats::SamplingDistPlot::fSamplingDistr
std::vector< Double_t > fSamplingDistr
Definition: SamplingDistPlot.h:116
RooStats::SamplingDistPlot::GetPlot
RooPlot * GetPlot()
return plotter class used to draw the sampling distribution histograms object is managed by SamplingD...
Definition: SamplingDistPlot.h:100
RooStats::SamplingDistPlot::SetLogXaxis
void SetLogXaxis(Bool_t lx)
changes plot to log scale on x axis
Definition: SamplingDistPlot.h:103
RooStats::SamplingDistPlot::SetLineWidth
void SetLineWidth(Width_t lwidth, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:472
RooStats::SamplingDistPlot::ApplyDefaultStyle
void ApplyDefaultStyle(void)
Applies a predefined style if fApplyStyle is kTRUE (default).
Definition: SamplingDistPlot.cxx:381
Double_t
double Double_t
Definition: RtypesCore.h:59
TF1.h
RooStats::SamplingDistPlot::SetXRange
void SetXRange(double mi, double ma)
change x range
Definition: SamplingDistPlot.h:108
RooStats::SamplingDistPlot::Draw
void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: SamplingDistPlot.cxx:297
RooStats::SamplingDistPlot::fRooPlot
RooPlot * fRooPlot
TODO remove class variable and instantiate locally as necessary.
Definition: SamplingDistPlot.h:135
RooStats::SamplingDistPlot::fXMin
double fXMin
Definition: SamplingDistPlot.h:139
RooStats::SamplingDistPlot::SetMarkerSize
void SetMarkerSize(Size_t size, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:556
RooStats
Definition: Asimov.h:19
TH1F
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:572
RooStats::SamplingDistPlot::SetMarkerStyle
void SetMarkerStyle(Style_t style, const SamplingDistribution *samplDist=0)
Definition: SamplingDistPlot.cxx:514
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
Definition: TH1.h:57
RooStats::SamplingDistPlot::SetAxisTitle
void SetAxisTitle(char *varName)
Definition: SamplingDistPlot.h:85
RooStats::SamplingDistPlot::fOtherItems
RooList fOtherItems
holds TH1Fs only
Definition: SamplingDistPlot.h:133
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
TLegend
Definition: TLegend.h:23
TF1
1-Dim function class
Definition: TF1.h:212
RooStats::SamplingDistPlot::fItems
RooList fItems
Definition: SamplingDistPlot.h:132
RooList
Definition: RooList.h:21
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:104
RooStats::SamplingDistPlot::fApplyStyle
Bool_t fApplyStyle
Definition: SamplingDistPlot.h:141
RooStats::SamplingDistPlot::AddTF1
void AddTF1(TF1 *f, const char *title=NULL, Option_t *drawOptions="SAME")
add a TF1
Definition: SamplingDistPlot.cxx:235
int
Size_t
float Size_t
Definition: RtypesCore.h:87
RooStats::SamplingDistPlot::fVarName
TString fVarName
Definition: SamplingDistPlot.h:125
RooStats::SamplingDistPlot::SetLogYaxis
void SetLogYaxis(Bool_t ly)
changes plot to log scale on y axis
Definition: SamplingDistPlot.h:105