File indexing completed on 2025-12-16 10:29:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOSTATS_SamplingDistPlot
0013 #define ROOSTATS_SamplingDistPlot
0014
0015 #include "Compression.h"
0016 #include "RooPrintable.h"
0017 #include "TNamed.h"
0018 #include "TH1F.h"
0019 #include "TF1.h"
0020 #include "TLegend.h"
0021 #include "TList.h"
0022
0023 #include <limits>
0024 #include <vector>
0025
0026 #include "RooStats/SamplingDistribution.h"
0027
0028 #include "RooPlot.h"
0029
0030
0031 namespace RooStats {
0032
0033 class SamplingDistPlot : public TNamed, public RooPrintable {
0034
0035 public:
0036
0037 SamplingDistPlot(Int_t nbins = 100);
0038 SamplingDistPlot(Int_t nbins, double min, double max);
0039
0040
0041 ~SamplingDistPlot() override;
0042
0043
0044 double AddSamplingDistribution(const SamplingDistribution *samplingDist, Option_t *drawOptions="NORMALIZE HIST");
0045
0046
0047 double AddSamplingDistributionShaded(const SamplingDistribution *samplingDist, double minShaded, double maxShaded, Option_t *drawOptions="NORMALIZE HIST");
0048
0049
0050 void AddLine(double x1, double y1, double x2, double y2, const char* title = nullptr);
0051
0052 void AddTH1(TH1* h, Option_t *drawOptions="");
0053
0054 void AddTF1(TF1* f, const char* title = nullptr, Option_t *drawOptions="SAME");
0055
0056 void SetLegend(TLegend* l){ fLegend = l; }
0057
0058 void Draw(Option_t *options=nullptr) override;
0059
0060
0061 void ApplyDefaultStyle(void);
0062
0063 void SetLineColor(Color_t color, const SamplingDistribution *sampleDist = nullptr);
0064 void SetLineWidth(Width_t lwidth, const SamplingDistribution *sampleDist = nullptr);
0065 void SetLineStyle(Style_t style, const SamplingDistribution *sampleDist = nullptr);
0066
0067 void SetMarkerColor(Color_t color, const SamplingDistribution *sampleDist = nullptr);
0068 void SetMarkerStyle(Style_t style, const SamplingDistribution *sampleDist = nullptr);
0069 void SetMarkerSize(Size_t size, const SamplingDistribution *sampleDist = nullptr);
0070
0071 void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *sampleDist = nullptr);
0072
0073 void SetAxisTitle(char *varName) { fVarName = TString(varName); }
0074
0075
0076
0077 void SetApplyStyle(bool s) { fApplyStyle = s; }
0078
0079
0080
0081
0082
0083 TH1F* GetTH1F(const SamplingDistribution *sampleDist = nullptr);
0084 TH1 * GetHistogram(const SamplingDistribution *sampleDist = nullptr) { return GetTH1F(sampleDist); }
0085
0086
0087
0088 RooPlot * GetPlot() { return fRooPlot; }
0089
0090
0091 void SetLogXaxis(bool lx) { fLogXaxis = lx; }
0092
0093 void SetLogYaxis(bool ly) { fLogYaxis = ly; }
0094
0095
0096 void SetXRange( double mi, double ma ) { fXMin = mi; fXMax = ma; }
0097
0098 void SetYRange( double mi, double ma ) { fYMin = mi; fYMax = ma; }
0099
0100
0101 void DumpToFile(const char* RootFileName, Option_t *option="", const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
0102
0103 private:
0104 std::vector<double> fSamplingDistr;
0105 std::vector<double> fSampleWeights;
0106
0107 bool fIsWeighted = false;
0108
0109 Int_t fBins;
0110 Int_t fMarkerType = 20;
0111 Int_t fColor = 1;
0112
0113 TString fVarName;
0114
0115 protected:
0116
0117 TH1F* fHist = nullptr;
0118 TLegend *fLegend = nullptr;
0119
0120 TList fItems;
0121 TList fOtherItems;
0122 RooPlot* fRooPlot = nullptr;
0123 bool fLogXaxis = false;
0124 bool fLogYaxis = false;
0125
0126 double fXMin = std::numeric_limits<float>::quiet_NaN();
0127 double fXMax = std::numeric_limits<float>::quiet_NaN();
0128 double fYMin = std::numeric_limits<float>::quiet_NaN();
0129 double fYMax = std::numeric_limits<float>::quiet_NaN();
0130
0131 bool fApplyStyle = true;
0132 Style_t fFillStyle = 3004;
0133
0134 void SetSampleWeights(const SamplingDistribution *samplingDist);
0135
0136 void addObject(TObject *obj, Option_t *drawOptions=nullptr);
0137 void addOtherObject(TObject *obj, Option_t *drawOptions=nullptr);
0138 void GetAbsoluteInterval(double &theMin, double &theMax, double &theYMax) const;
0139
0140 ClassDefOverride(SamplingDistPlot,2)
0141 };
0142 }
0143
0144 #endif