57void TestBinomial(
int nloop = 100,
int nevts = 100,
bool plot =
false,
bool debug =
false,
int seed = 111)
59 gStyle->SetMarkerStyle(20);
64 hbiasNorm.
Add(
new TH1D(
"h0Norm",
"Bias Histogram fit",100,-5,5));
65 hbiasNorm.
Add(
new TH1D(
"h1Norm",
"Bias Binomial fit",100,-5,5));
67 hbiasThreshold.
Add(
new TH1D(
"h0Threshold",
"Bias Histogram fit",100,-5,5));
68 hbiasThreshold.
Add(
new TH1D(
"h1Threshold",
"Bias Binomial fit",100,-5,5));
70 hbiasWidth.
Add(
new TH1D(
"h0Width",
"Bias Histogram fit",100,-5,5));
71 hbiasWidth.
Add(
new TH1D(
"h1Width",
"Bias Binomial fit",100,-5,5));
72 TH1D* hChisquared =
new TH1D(
"hChisquared",
73 "#chi^{2} probability (Baker-Cousins)", 200, 0.0, 1.0);
89 TH1D* hM2D =
new TH1D(
"hM2D",
"x^(-2) denominator distribution",
91 TH1D* hM2N =
new TH1D(
"hM2N",
"x^(-2) numerator distribution",
93 TH1D* hM2E =
new TH1D(
"hM2E",
"x^(-2) efficiency",
96 TF1* fM2D =
new TF1(
"fM2D",
"(1-[0]/(1+exp(([1]-x)/[2])))/(x*x)",
98 TF1* fM2N =
new TF1(
"fM2N",
"[0]/(1+exp(([1]-x)/[2]))/(x*x)",
100 TF1* fM2Fit =
new TF1(
"fM2Fit",
"[0]/(1+exp(([1]-x)/[2]))",
102 TF1* fM2Fit2 =
nullptr;
109 double normalization = 0.80;
110 double threshold = 25.0;
121 double fracN = integralN/(integralN+integralD);
122 int nevtsN = rb.Binomial(nevts, fracN);
123 int nevtsD = nevts - nevtsN;
125 std::cout << nevtsN <<
" " << nevtsD << std::endl;
130 for (
int iloop = 0; iloop < nloop; ++iloop) {
141 hM2E->
Divide(hM2N, hM2D, 1, 1,
"b");
165 Form(
"plots for experiment %d", iloop),
174 for (
int fit = 0; fit < 2; ++fit) {
184 if (debug) optFit +=
TString(
"SV");
191 if (debug) res->
Print();
211 if (debug) optFit +=
TString(
"V");
215 std::cerr <<
"Error performing binomial efficiency fit, result = "
216 << status << std::endl;
224 bool confint = (status == 0);
233 gr.SetFillStyle(3005);
234 gr.DrawClone(
"4 same");
243 if (status != 0)
break;
261 TH1D*
h =
dynamic_cast<TH1D*
>(hbiasNorm[fit]);
262 h->Fill((fnorm-normalization)/enorm);
263 h =
dynamic_cast<TH1D*
>(hbiasThreshold[fit]);
264 h->Fill((fthreshold-threshold)/ethreshold);
265 h =
dynamic_cast<TH1D*
>(hbiasWidth[fit]);
266 h->Fill((fwidth-width)/ewidth);
272 "Efficiency fit biases",10,10,1000,800);
277 h0 =
dynamic_cast<TH1D*
>(hbiasNorm[0]);
279 h1 =
dynamic_cast<TH1D*
>(hbiasNorm[1]);
281 h1->Draw(
"HIST SAMES");
283 "plateau parameter",
"ndc");
287 %4.2f",
h1->GetMean(),
h1->GetRMS()),
"l");
291 h0 =
dynamic_cast<TH1D*
>(hbiasThreshold[0]);
293 h1 =
dynamic_cast<TH1D*
>(hbiasThreshold[1]);
295 h1->Draw(
"HIST SAMES");
297 "threshold parameter",
"ndc");
301 %4.2f",
h1->GetMean(),
h1->GetRMS()),
"l");
305 h0 =
dynamic_cast<TH1D*
>(hbiasWidth[0]);
307 h1 =
dynamic_cast<TH1D*
>(hbiasWidth[1]);
309 h1->Draw(
"HIST SAMES");
310 TLegend* l3 =
new TLegend(0.1, 0.75, 0.5, 0.9,
"width parameter",
"ndc");
314 %4.2f",
h1->GetMean(),
h1->GetRMS()),
"l");
318 hChisquared->
Draw(
"HIST");
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
void GetConfidenceIntervals(unsigned int n, unsigned int stride1, unsigned int stride2, const double *x, double *ci, double cl=0.95, bool norm=false) const
get confidence intervals for an array of n points x.
static void SetDefaultIntegrator(const char *name)
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Binomial fitter for the division of two histograms.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
virtual Double_t GetProb() const
virtual void SetParError(Int_t ipar, Double_t error)
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
virtual Double_t GetParError(Int_t ipar) const
virtual TH1 * GetHistogram() const
virtual TF1 * DrawCopy(Option_t *option="") const
virtual void SetParameter(Int_t param, Double_t value)
virtual Double_t GetParameter(Int_t ipar) const
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
void Print(Option_t *option="") const override
Print result of the fit, by default chi2, parameter values and errors.
1-D histogram with a double per channel (see TH1 documentation)
void Reset(Option_t *option="") override
Reset.
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2),...
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
Double_t GetRMS(Int_t axis=1) const
This function returns the Standard Deviation (Sigma) of the distribution not the Root Mean Square (RM...
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
virtual Bool_t Divide(TF1 *f1, Double_t c1=1)
Performs the operation: this = this/(c1*f1) if errors are defined (see TH1::Sumw2),...
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
void Draw(Option_t *option="") override
Draw this box with its current attributes.
const char * GetName() const override
Returns name of object.
void Add(TObject *obj) override
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
Random number generator class based on M.
static void SetDefaultFitter(const char *name="")
static: set name of default fitter
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
fill the data vector from a TH1.