SamplingDistPlot.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: SamplingDistPlot.h 37333 2010-12-06 14:26:57Z moneta $
00002 // Authors: Sven Kreiss    June 2010
00003 // Authors: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
00004 /*************************************************************************
00005  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOSTATS_SamplingDistPlot
00013 #define ROOSTATS_SamplingDistPlot
00014 
00015 #include "RooList.h"
00016 #include "RooPrintable.h"
00017 #include "TNamed.h"
00018 #include "TIterator.h"
00019 #include "TH1F.h"
00020 #include "TLegend.h"
00021 
00022 #ifndef ROOSTATS_SamplingDistribution
00023 #include "RooStats/SamplingDistribution.h"
00024 #endif
00025 
00026 #ifndef ROO_PLOT
00027 #include "RooPlot.h"
00028 #endif
00029 
00030 
00031 namespace RooStats {
00032 
00033  class SamplingDistPlot : public TNamed, public RooPrintable {
00034 
00035    public:
00036     // Constructors for SamplingDistribution
00037     SamplingDistPlot(Int_t nbins = 100);
00038 //    SamplingDistPlot(const char* name, const char* title, Int_t nbins, Double_t xmin, Double_t xmax);
00039 
00040     // Destructor of SamplingDistribution
00041     virtual ~SamplingDistPlot() {}
00042 
00043     // adds the sampling distribution and returns the scale factor
00044     Double_t AddSamplingDistribution(const SamplingDistribution *samplingDist, Option_t *drawOptions="NORMALIZE HIST");
00045     // Like AddSamplingDistribution, but also sets a shaded area in the
00046     // minShaded and maxShaded boundaries.
00047     Double_t AddSamplingDistributionShaded(const SamplingDistribution *samplingDist, Double_t minShaded, Double_t maxShaded, Option_t *drawOptions="NORMALIZE HIST");
00048 
00049     // add a line
00050     void AddLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char* title = NULL);
00051 
00052     void Draw(Option_t *options=0);
00053 
00054     // Applies a predefined style if fApplyStyle is kTRUE (default).
00055     void ApplyDefaultStyle(void);
00056 
00057     void SetLineColor(Color_t color, const SamplingDistribution *samplDist = 0);
00058     void SetLineWidth(Width_t lwidth, const SamplingDistribution *samplDist = 0);
00059     void SetLineStyle(Style_t style, const SamplingDistribution *samplDist = 0);
00060 
00061     void SetMarkerColor(Color_t color, const SamplingDistribution *samplDist = 0);
00062     void SetMarkerStyle(Style_t style, const SamplingDistribution *samplDist = 0);
00063     void SetMarkerSize(Size_t size, const SamplingDistribution *samplDist = 0);
00064 
00065     void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *samplDist = 0);
00066 
00067     void SetAxisTitle(char *varName) { fVarName = TString(varName); }
00068 
00069     // If you do not want SamplingDistPlot to interfere with your style settings, call this
00070     // function with "false" before Draw().
00071     void SetApplyStyle(Bool_t s) { fApplyStyle = s; }
00072 
00073     // Returns the TH1F associated with the give SamplingDistribution.
00074     // Intended use: Access to member functions of TH1F like GetMean(),
00075     // GetRMS() etc.
00076     TH1F* GetTH1F(const SamplingDistribution *samplDist);
00077 
00078     // changes plot to log scale on x axis
00079     void SetLogXaxis(Bool_t lx) { fLogXaxis = lx; }
00080     // changes plot to log scale on y axis
00081     void SetLogYaxis(Bool_t ly) { fLogYaxis = ly; }
00082 
00083     // write to Root file
00084     void DumpToFile(const char* RootFileName, Option_t *option="", const char *ftitle="", Int_t compress=1);
00085 
00086   private:
00087     std::vector<Double_t> fSamplingDistr;
00088     std::vector<Double_t> fSampleWeights;
00089 
00090     Bool_t fIsWeighted;
00091 
00092     Int_t fBins;
00093     Int_t fMarkerType;
00094     Int_t fColor;
00095 
00096     TString fVarName;
00097 
00098   protected:
00099 
00100     TH1F* fHist;
00101     TLegend *fLegend;
00102 
00103     RooList fItems; // holds TH1Fs only
00104     RooList fOtherItems; // other objects to be drawn like TLine etc.
00105     TIterator* fIterator; // TODO remove class variable and instantiate locally as necessary
00106     RooPlot* fRooPlot;
00107     Bool_t fLogXaxis;
00108     Bool_t fLogYaxis;
00109 
00110     Bool_t fApplyStyle;
00111     Style_t fFillStyle;
00112 
00113     void SetSampleWeights(const SamplingDistribution *samplingDist);
00114 
00115     void addObject(TObject *obj, Option_t *drawOptions=0); // for TH1Fs only
00116     void addOtherObject(TObject *obj, Option_t *drawOptions=0);
00117     void GetAbsoluteInterval(Float_t &theMin, Float_t &theMax, Float_t &theYMax) const;
00118 
00119     ClassDef(SamplingDistPlot,1)  // Class containing the results of the HybridCalculator
00120   };
00121 }
00122 
00123 #endif

Generated on Tue Jul 5 14:26:26 2011 for ROOT_528-00b_version by  doxygen 1.5.1