52void TestBinomial(
int nloop = 100,
int nevts = 100,
bool plot =
false,
bool debug =
false,
int seed = 111)
59 hbiasNorm.
Add(
new TH1D(
"h0Norm",
"Bias Histogram fit",100,-5,5));
60 hbiasNorm.
Add(
new TH1D(
"h1Norm",
"Bias Binomial fit",100,-5,5));
62 hbiasThreshold.
Add(
new TH1D(
"h0Threshold",
"Bias Histogram fit",100,-5,5));
63 hbiasThreshold.
Add(
new TH1D(
"h1Threshold",
"Bias Binomial fit",100,-5,5));
65 hbiasWidth.
Add(
new TH1D(
"h0Width",
"Bias Histogram fit",100,-5,5));
66 hbiasWidth.
Add(
new TH1D(
"h1Width",
"Bias Binomial fit",100,-5,5));
67 TH1D* hChisquared =
new TH1D(
"hChisquared",
68 "#chi^{2} probability (Baker-Cousins)", 200, 0.0, 1.0);
84 TH1D* hM2D =
new TH1D(
"hM2D",
"x^(-2) denominator distribution",
86 TH1D* hM2N =
new TH1D(
"hM2N",
"x^(-2) numerator distribution",
88 TH1D* hM2E =
new TH1D(
"hM2E",
"x^(-2) efficiency",
91 TF1* fM2D =
new TF1(
"fM2D",
"(1-[0]/(1+exp(([1]-x)/[2])))/(x*x)",
93 TF1* fM2N =
new TF1(
"fM2N",
"[0]/(1+exp(([1]-x)/[2]))/(x*x)",
95 TF1* fM2Fit =
new TF1(
"fM2Fit",
"[0]/(1+exp(([1]-x)/[2]))",
116 Double_t fracN = integralN/(integralN+integralD);
117 Int_t nevtsN = rb.Binomial(nevts, fracN);
118 Int_t nevtsD = nevts - nevtsN;
120 std::cout << nevtsN <<
" " << nevtsD << std::endl;
125 for (
int iloop = 0; iloop < nloop; ++iloop) {
136 hM2E->
Divide(hM2N, hM2D, 1, 1,
"b");
160 Form(
"plots for experiment %d", iloop),
169 for (
int fit = 0;
fit < 2; ++
fit) {
179 if (debug) optFit +=
TString(
"SV");
186 if (debug) res->
Print();
206 if (debug) optFit +=
TString(
"V");
210 std::cerr <<
"Error performing binomial efficiency fit, result = "
211 << status << std::endl;
219 bool confint = (status == 0);
238 if (status != 0)
break;
257 h->
Fill((fnorm-normalization)/enorm);
258 h =
dynamic_cast<TH1D*
>(hbiasThreshold[
fit]);
259 h->
Fill((fthreshold-threshold)/ethreshold);
260 h =
dynamic_cast<TH1D*
>(hbiasWidth[
fit]);
267 "Efficiency fit biases",10,10,1000,800);
272 h0 =
dynamic_cast<TH1D*
>(hbiasNorm[0]);
274 h1 =
dynamic_cast<TH1D*
>(hbiasNorm[1]);
278 "plateau parameter",
"ndc");
286 h0 =
dynamic_cast<TH1D*
>(hbiasThreshold[0]);
288 h1 =
dynamic_cast<TH1D*
>(hbiasThreshold[1]);
292 "threshold parameter",
"ndc");
300 h0 =
dynamic_cast<TH1D*
>(hbiasWidth[0]);
302 h1 =
dynamic_cast<TH1D*
>(hbiasWidth[1]);
305 TLegend* l3 =
new TLegend(0.1, 0.75, 0.5, 0.9,
"width parameter",
"ndc");
313 hChisquared->
Draw(
"HIST");
include TDocParser_001 C image html pict1_TDocParser_001 png width
char * Form(const char *fmt,...)
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 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...
virtual void Print(Option_t *option="") const
Print result of the fit, by default chi2, parameter values and errors.
A TGraphErrors is a TGraph with error bars.
1-D histogram with a double per channel (see TH1 documentation)}
virtual void Reset(Option_t *option="")
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.
Double_t GetRMS(Int_t axis=1) const
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
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.
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
virtual const char * GetName() const
Returns name of object.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad...
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=0)
fill the data vector from a TH1.