57void TestBinomial(
int nloop = 100,
int nevts = 100,
bool plot =
false,
bool debug =
false,
int seed = 111)
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);
243 if (status != 0)
break;
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]);
272 "Efficiency fit biases",10,10,1000,800);
277 h0 =
dynamic_cast<TH1D*
>(hbiasNorm[0]);
279 h1 =
dynamic_cast<TH1D*
>(hbiasNorm[1]);
283 "plateau parameter",
"ndc");
291 h0 =
dynamic_cast<TH1D*
>(hbiasThreshold[0]);
293 h1 =
dynamic_cast<TH1D*
>(hbiasThreshold[1]);
297 "threshold parameter",
"ndc");
305 h0 =
dynamic_cast<TH1D*
>(hbiasWidth[0]);
307 h1 =
dynamic_cast<TH1D*
>(hbiasWidth[1]);
310 TLegend* l3 =
new TLegend(0.1, 0.75, 0.5, 0.9,
"width parameter",
"ndc");
318 hChisquared->
Draw(
"HIST");
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TStyle * gStyle
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 SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Binomial fitter for the division of two histograms.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
virtual void SetParError(Int_t ipar, Double_t error)
Set error for parameter number ipar.
virtual TH1 * GetHistogram() const
Return a pointer to the histogram used to visualise the function Note that this histogram is managed ...
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
virtual Double_t GetProb() const
Return the fit probability.
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
IntegralOneDim or analytical integral.
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set lower and upper limits for parameter ipar.
virtual TF1 * DrawCopy(Option_t *option="") const
Draw a copy of this function with its current attributes.
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.
A TGraphErrors is a TGraph with error bars.
Double_t * GetEY() const override
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(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
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.
This class displays a legend box (TPaveText) containing several legend entries.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
void Draw(Option_t *option="") override
Draw this legend with its current attributes.
const char * GetName() const override
Returns name of object.
void Add(TObject *obj) override
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
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.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
static void SetDefaultFitter(const char *name="")
static: set name of default fitter
fit(model, train_loader, val_loader, num_epochs, batch_size, optimizer, criterion, save_best, scheduler)
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
fill the data vector from a TH1.