71int rf611_weightedfits(
int acceptancemodel=2) {
96 TH1D* haccepted =
new TH1D(
"haccepted",
"Generated events;cos(#theta);#events", 40, -1.0, 1.0);
97 TH1D* hweighted =
new TH1D(
"hweighted",
"Generated events;cos(#theta);#events", 40, -1.0, 1.0);
100 TH1D* hc0pull1 =
new TH1D(
"hc0pull1",
"Inverse weighted Hessian matrix [SumW2Error(false)];Pull (c_{0}^{fit}-c_{0}^{gen})/#sigma(c_{0});", 20, -5.0, 5.0);
101 TH1D* hc1pull1 =
new TH1D(
"hc1pull1",
"Inverse weighted Hessian matrix [SumW2Error(false)];Pull (c_{1}^{fit}-c_{1}^{gen})/#sigma(c_{1});", 20, -5.0, 5.0);
103 TH1D* hc0pull2 =
new TH1D(
"hc0pull2",
"Hessian matrix with squared weights [SumW2Error(true)];Pull (c_{0}^{fit}-c_{0}^{gen})/#sigma(c_{0});", 20, -5.0, 5.0);
104 TH1D* hc1pull2 =
new TH1D(
"hc1pull2",
"Hessian matrix with squared weights [SumW2Error(true)];Pull (c_{1}^{fit}-c_{1}^{gen})/#sigma(c_{1});", 20, -5.0, 5.0);
106 TH1D* hc0pull3 =
new TH1D(
"hc0pull3",
"Asymptotically correct approach [Asymptotic(true)];Pull (c_{0}^{fit}-c_{0}^{gen})/#sigma(c_{0});", 20, -5.0, 5.0);
107 TH1D* hc1pull3 =
new TH1D(
"hc1pull3",
"Asymptotically correct approach [Asymptotic(true)];Pull (c_{1}^{fit}-c_{1}^{gen})/#sigma(c_{1});", 20, -5.0, 5.0);
110 constexpr unsigned int ntoys = 500;
111 constexpr unsigned int nstats = 5000;
113 constexpr double c0gen = 0.0;
114 constexpr double c1gen = 0.0;
121 std::cout <<
"Running " << ntoys*3 <<
" toy fits ..." << std::endl;
125 for (
unsigned int i=0; i<ntoys; i++) {
129 RooRealVar costheta(
"costheta",
"costheta", -1.0, 1.0);
130 RooRealVar weight(
"weight",
"weight", 0.0, 1000.0);
133 RooRealVar c0(
"c0",
"0th-order coefficient", c0gen, -1.0, 1.0);
134 RooRealVar c1(
"c1",
"1st-order coefficient", c1gen, -1.0, 1.0);
144 for (
unsigned int j=0; j<nstats; j++) {
145 bool finished =
false;
148 costheta = 2.0*rnd->
Rndm()-1.0;
151 if (acceptancemodel == 1)
152 eff = 1.0 - 0.7 * costheta.getVal()*costheta.getVal();
154 eff = 0.3 + 0.7 * costheta.getVal()*costheta.getVal();
158 if (10.0*rnd->
Rndm() < eff*pol.getVal())
161 haccepted->
Fill(costheta.getVal());
162 hweighted->
Fill(costheta.getVal(), weight.getVal());
170 hc0pull1->
Fill((c0.getVal()-c0gen)/c0.getError());
171 hc1pull1->
Fill((
c1.getVal()-c1gen)/
c1.getError());
175 hc0pull2->
Fill((c0.getVal()-c0gen)/c0.getError());
176 hc1pull2->
Fill((
c1.getVal()-c1gen)/
c1.getError());
180 hc0pull3->
Fill((c0.getVal()-c0gen)/c0.getError());
181 hc1pull3->
Fill((
c1.getVal()-c1gen)/
c1.getError());
184 std::cout <<
"... done." << std::endl;
196 hweighted->
Draw(
"hist");
197 haccepted->
Draw(
"same hist");
199 leg->AddEntry(haccepted,
"Accepted");
200 leg->AddEntry(hweighted,
"Weighted");
210 hc0pull1->
Fit(
"gaus");
211 hc0pull1->
Draw(
"ep");
213 hc0pull2->
Fit(
"gaus");
214 hc0pull2->
Draw(
"ep");
216 hc0pull3->
Fit(
"gaus");
217 hc0pull3->
Draw(
"ep");
219 hc1pull1->
Fit(
"gaus");
220 hc1pull1->
Draw(
"ep");
222 hc1pull2->
Fit(
"gaus");
223 hc1pull2->
Draw(
"ep");
225 hc1pull3->
Fit(
"gaus");
226 hc1pull3->
Draw(
"ep");
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
R__EXTERN TStyle * gStyle
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooDataSet is a container class to hold unbinned data.
static RooMsgService & instance()
Return reference to singleton instance.
RooPolynomial implements a polynomial p.d.f of the form.
RooRealVar represents a variable that can be changed from the outside.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
void Update() override
Update canvas pad buffers.
1-D histogram with a double per channel (see TH1 documentation)}
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 Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SetMinimum(Double_t minimum=-1111)
This class displays a legend box (TPaveText) containing several legend entries.
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.
Double_t Rndm() override
Machine independent random number generator.
void SetSeed(ULong_t seed=0) override
Set the random generator sequence if seed is 0 (default value) a TUUID is generated and used to fill ...
void SetPadTopMargin(Float_t margin=0.1)
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
void SetPadBottomMargin(Float_t margin=0.1)
void SetPaintTextFormat(const char *format="g")
void SetEndErrorSize(Float_t np=2)
Set the size (in pixels) of the small lines drawn at the end of the error bars (TH1 or TGraphErrors).
void SetPadRightMargin(Float_t margin=0.1)
void SetTitleOffset(Float_t offset=1, Option_t *axis="X")
Specify a parameter offset to control the distance between the axis and the axis title.
void SetPadLeftMargin(Float_t margin=0.1)
void SetHistLineColor(Color_t color=1)
void SetTitleSize(Float_t size=0.02, Option_t *axis="X")
void SetHistLineWidth(Width_t width=1)
void SetLabelSize(Float_t size=0.04, Option_t *axis="X")
Set size of axis labels.
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg AsymptoticError(bool flag)
RooCmdArg Save(bool flag=true)
RooCmdArg SumW2Error(bool flag)
RooCmdArg BatchMode(std::string const &batchMode="cpu")
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...