1 #ifndef ROOT_TEfficiency
2 #define ROOT_TEfficiency
22 class TGraphAsymmErrors;
27 class TEfficiency:
public TNamed,
public TAttLine,
public TAttFill,
public TAttMarker
48 std::vector<std::pair<Double_t, Double_t> > fBeta_bin_params;
50 Double_t (*fBoundary)(Double_t,Double_t,Double_t,Bool_t);
52 TDirectory* fDirectory;
54 TGraphAsymmErrors* fPaintGraph;
56 TH1* fPassedHistogram;
57 EStatOption fStatisticOption;
62 kIsBayesian = BIT(14),
63 kPosteriorMode = BIT(15),
64 kShortestInterval = BIT(16),
65 kUseBinPrior = BIT(17),
69 void Build(
const char* name,
const char* title);
70 void FillGraph(TGraphAsymmErrors * graph, Option_t * opt)
const;
71 void FillHistogram(TH2 * h2)
const;
75 TEfficiency(
const TH1& passed,
const TH1& total);
76 TEfficiency(
const char* name,
const char* title,Int_t nbins,
77 const Double_t* xbins);
78 TEfficiency(
const char* name,
const char* title,Int_t nbins,Double_t xlow,
80 TEfficiency(
const char* name,
const char* title,Int_t nbinsx,
81 Double_t xlow,Double_t xup,Int_t nbinsy,Double_t ylow,
83 TEfficiency(
const char* name,
const char* title,Int_t nbinsx,
84 const Double_t* xbins,Int_t nbinsy,
const Double_t* ybins);
85 TEfficiency(
const char* name,
const char* title,Int_t nbinsx,
86 Double_t xlow,Double_t xup,Int_t nbinsy,Double_t ylow,
87 Double_t yup,Int_t nbinsz,Double_t zlow,Double_t zup);
88 TEfficiency(
const char* name,
const char* title,Int_t nbinsx,
89 const Double_t* xbins,Int_t nbinsy,
const Double_t* ybins,
90 Int_t nbinsz,
const Double_t* zbins);
91 TEfficiency(
const TEfficiency& heff);
94 void Add(
const TEfficiency& rEff) {*
this += rEff;}
95 void Browse(TBrowser*){Draw();}
96 TGraphAsymmErrors* CreateGraph(Option_t * opt =
"")
const;
97 TH2* CreateHistogram(Option_t * opt =
"")
const;
98 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
99 void Draw(Option_t* opt =
"");
100 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
101 void Fill(Bool_t bPassed,Double_t x,Double_t y=0,Double_t z=0);
102 void FillWeighted(Bool_t bPassed,Double_t weight,Double_t x,Double_t y=0,Double_t z=0);
103 Int_t FindFixBin(Double_t x,Double_t y=0,Double_t z=0)
const;
104 TFitResultPtr Fit(TF1* f1,Option_t* opt=
"");
106 Double_t GetBetaAlpha(Int_t bin = -1)
const {
return (fBeta_bin_params.size() > (UInt_t)bin) ? fBeta_bin_params[bin].first : fBeta_alpha;}
107 Double_t GetBetaBeta(Int_t bin = -1)
const {
return (fBeta_bin_params.size() > (UInt_t)bin) ? fBeta_bin_params[bin].second : fBeta_beta;}
108 Double_t GetConfidenceLevel()
const {
return fConfLevel;}
109 TH1* GetCopyPassedHisto()
const;
110 TH1* GetCopyTotalHisto()
const;
111 Int_t GetDimension()
const;
112 TDirectory* GetDirectory()
const {
return fDirectory;}
113 Double_t GetEfficiency(Int_t bin)
const;
114 Double_t GetEfficiencyErrorLow(Int_t bin)
const;
115 Double_t GetEfficiencyErrorUp(Int_t bin)
const;
116 Int_t GetGlobalBin(Int_t binx,Int_t biny=0,Int_t binz=0)
const;
117 TGraphAsymmErrors* GetPaintedGraph()
const {
return fPaintGraph; }
118 TH2* GetPaintedHistogram()
const {
return fPaintHisto; }
119 TList* GetListOfFunctions();
120 const TH1* GetPassedHistogram()
const {
return fPassedHistogram;}
121 EStatOption GetStatisticOption()
const {
return fStatisticOption;}
122 const TH1* GetTotalHistogram()
const {
return fTotalHistogram;}
123 Double_t GetWeight()
const {
return fWeight;}
124 Long64_t Merge(TCollection* list);
125 TEfficiency& operator+=(
const TEfficiency& rhs);
126 TEfficiency& operator=(
const TEfficiency& rhs);
127 void Paint(Option_t* opt);
128 void SavePrimitive(std::ostream& out,Option_t* opt=
"");
129 void SetBetaAlpha(Double_t alpha);
130 void SetBetaBeta(Double_t beta);
131 void SetBetaBinParameters(Int_t bin, Double_t alpha, Double_t beta);
132 void SetConfidenceLevel(Double_t level);
133 void SetDirectory(TDirectory* dir);
134 void SetName(
const char* name);
135 Bool_t SetPassedEvents(Int_t bin,Int_t events);
136 Bool_t SetPassedHistogram(
const TH1& rPassed,Option_t* opt);
137 void SetPosteriorMode(Bool_t on =
true) { SetBit(kPosteriorMode,on); SetShortestInterval(on); }
138 void SetPosteriorAverage(Bool_t on =
true) { SetBit(kPosteriorMode,!on); }
139 void SetShortestInterval(Bool_t on =
true) { SetBit(kShortestInterval,on); }
140 void SetCentralInterval(Bool_t on =
true) { SetBit(kShortestInterval,!on); }
141 void SetStatisticOption(EStatOption option);
142 Bool_t SetBins(Int_t nx, Double_t xmin, Double_t xmax);
143 Bool_t SetBins(Int_t nx,
const Double_t *xBins);
144 Bool_t SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax);
145 Bool_t SetBins(Int_t nx,
const Double_t *xBins, Int_t ny,
const Double_t *yBins);
146 Bool_t SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax,
147 Int_t nz, Double_t zmin, Double_t zmax);
148 Bool_t SetBins(Int_t nx,
const Double_t *xBins, Int_t ny,
const Double_t * yBins, Int_t nz,
149 const Double_t *zBins);
151 void SetTitle(
const char* title);
152 Bool_t SetTotalEvents(Int_t bin,Int_t events);
153 Bool_t SetTotalHistogram(
const TH1& rTotal,Option_t* opt);
154 void SetUseWeightedEvents(Bool_t on = kTRUE);
155 void SetWeight(Double_t weight);
156 Bool_t UsesBayesianStat()
const {
return TestBit(kIsBayesian);}
157 Bool_t UsesPosteriorMode()
const {
return TestBit(kPosteriorMode) && TestBit(kIsBayesian);}
158 Bool_t UsesShortestInterval()
const {
return TestBit(kShortestInterval) && TestBit(kIsBayesian);}
159 Bool_t UsesPosteriorAverage()
const {
return !UsesPosteriorMode();}
160 Bool_t UsesCentralInterval()
const {
return !UsesShortestInterval();}
161 Bool_t UsesWeights()
const {
return TestBit(kUseWeights);}
163 static Bool_t CheckBinning(
const TH1& pass,
const TH1& total);
164 static Bool_t CheckConsistency(
const TH1& pass,
const TH1& total,Option_t* opt=
"");
165 static Bool_t CheckEntries(
const TH1& pass,
const TH1& total,Option_t* opt=
"");
166 static Bool_t CheckWeights(
const TH1& pass,
const TH1& total);
167 static Double_t Combine(Double_t& up,Double_t& low,Int_t n,
const Int_t* pass,
const Int_t* total,
168 Double_t alpha,Double_t beta,Double_t level=0.683,
169 const Double_t* w=0,Option_t* opt=
"");
170 static TGraphAsymmErrors* Combine(TCollection* pList,Option_t* opt=
"",Int_t n=0,
const Double_t* w=0);
173 static Double_t AgrestiCoull(Double_t total,Double_t passed,Double_t level,Bool_t bUpper);
174 static Double_t ClopperPearson(Double_t total,Double_t passed,Double_t level,Bool_t bUpper);
175 static Double_t Normal(Double_t total,Double_t passed,Double_t level,Bool_t bUpper);
176 static Double_t Wilson(Double_t total,Double_t passed,Double_t level,Bool_t bUpper);
177 static Double_t FeldmanCousins(Double_t total,Double_t passed,Double_t level,Bool_t bUpper);
178 static Bool_t FeldmanCousinsInterval(Double_t total,Double_t passed,Double_t level,Double_t & lower, Double_t & upper);
179 static Double_t MidPInterval(Double_t total,Double_t passed,Double_t level,Bool_t bUpper);
181 static Double_t Bayesian(Double_t total,Double_t passed,Double_t level,Double_t alpha,Double_t beta,Bool_t bUpper, Bool_t bShortest =
false);
183 static Double_t BetaCentralInterval(Double_t level,Double_t alpha,Double_t beta,Bool_t bUpper);
184 static Bool_t BetaShortestInterval(Double_t level,Double_t alpha,Double_t beta,Double_t & lower, Double_t & upper);
185 static Double_t BetaMean(Double_t alpha,Double_t beta);
186 static Double_t BetaMode(Double_t alpha,Double_t beta);
188 ClassDef(TEfficiency,2)
191 const TEfficiency operator+(
const TEfficiency& lhs,
const TEfficiency& rhs);