121 if(
f<parm[0]) itype=1;
122 else if(
f<parm[0]+parm[1]) itype=2;
133 ptgen=
pow(t*(
pow(parm[3],a1)-x0)+x0,1./a1);
135 if(iType) *iType=itype;
136 if(ptGen) *ptGen=ptgen;
140 TMath::Sqrt(parm[7]*parm[7]*ptgen+parm[8]*parm[8]*ptgen*ptgen);
145 triggerParm[2]/(1.+
TMath::Exp((triggerParm[0]-ptObs)/triggerParm[1]));
146 isTriggered= rnd->
Rndm()<triggerProb;
148 }
while((!triggerFlag) && (!isTriggered));
150 if(triggerFlag) *triggerFlag=isTriggered;
209 TH1D *histUnfoldInput=
210 new TH1D(
"unfolding input rec",
";ptrec",nDet,xminDet,xmaxDet);
211 TH2D *histUnfoldMatrix=
212 new TH2D(
"unfolding matrix",
";ptgen;ptrec",
213 nGen,xminGen,xmaxGen,nDet,xminDet,xmaxDet);
214 TH1D *histUnfoldBgr1=
215 new TH1D(
"unfolding bgr1 rec",
";ptrec",nDet,xminDet,xmaxDet);
216 TH1D *histUnfoldBgr2=
217 new TH1D(
"unfolding bgr2 rec",
";ptrec",nDet,xminDet,xmaxDet);
218 TH2D *histUnfoldMatrixSys=
219 new TH2D(
"unfolding matrix sys",
";ptgen;ptrec",
220 nGen,xminGen,xmaxGen,nDet,xminDet,xmaxDet);
224 new TH1D(
"bbb input rec",
";ptrec",nGen,xminGen,xmaxGen);
225 TH1D *histBbbSignalRec=
226 new TH1D(
"bbb signal rec",
";ptrec",nGen,xminGen,xmaxGen);
228 new TH1D(
"bbb bgr1 rec",
";ptrec",nGen,xminGen,xmaxGen);
230 new TH1D(
"bbb bgr2 rec",
";ptrec",nGen,xminGen,xmaxGen);
232 new TH1D(
"bbb bgrPt rec",
";ptrec",nGen,xminGen,xmaxGen);
233 TH1D *histBbbSignalGen=
234 new TH1D(
"bbb signal gen",
";ptgen",nGen,xminGen,xmaxGen);
235 TH1D *histBbbSignalRecSys=
236 new TH1D(
"bbb signal sys rec",
";ptrec",nGen,xminGen,xmaxGen);
237 TH1D *histBbbBgrPtSys=
238 new TH1D(
"bbb bgrPt sys rec",
";ptrec",nGen,xminGen,xmaxGen);
239 TH1D *histBbbSignalGenSys=
240 new TH1D(
"bbb signal sys gen",
";ptgen",nGen,xminGen,xmaxGen);
244 new TH1D(
"DATA truth gen",
";ptgen",nGen,xminGen,xmaxGen);
246 new TH1D(
"MC prediction rec",
";ptrec",nDet,xminDet,xmaxDet);
262 static Double_t triggerParm_DATA[]={8.0,
268 while(intLumi<lumiData) {
272 Double_t ptObs=GenerateEvent(parm_DATA,triggerParm_DATA,&intLumi,
273 &isTriggered,&ptGen,&iTypeGen);
276 histUnfoldInput->
Fill(ptObs);
279 histBbbInput->
Fill(ptObs);
282 if(iTypeGen==0) histDataTruth->
Fill(ptGen);
302 static Double_t triggerParm_MC[]={8.0,
308 Double_t lumiWeight = lumiData/lumiMC;
310 while(intLumi<lumiMC) {
314 Double_t ptObs=GenerateEvent(parm_MC,triggerParm_MC,&intLumi,&isTriggered,
316 if(!isTriggered) ptObs=0.0;
321 histUnfoldMatrix->
Fill(ptGen,ptObs,lumiWeight);
322 }
else if(iTypeGen==1) {
323 histUnfoldBgr1->
Fill(ptObs,lumiWeight);
324 }
else if(iTypeGen==2) {
325 histUnfoldBgr2->
Fill(ptObs,lumiWeight);
330 if((ptGen>=xminGen)&&(ptGen<xmaxGen)) {
331 histBbbSignalRec->
Fill(ptObs,lumiWeight);
333 histBbbBgrPt->
Fill(ptObs,lumiWeight);
335 histBbbSignalGen->
Fill(ptGen,lumiWeight);
336 }
else if(iTypeGen==1) {
337 histBbbBgr1->
Fill(ptObs,lumiWeight);
338 }
else if(iTypeGen==2) {
339 histBbbBgr2->
Fill(ptObs,lumiWeight);
343 histDetMC ->
Fill(ptObs,lumiWeight);
363 while(intLumi<lumiMC) {
367 Double_t ptObs=GenerateEvent(parm_MC_SYS,triggerParm_MC,&intLumi,
368 &isTriggered,&ptGen,&iTypeGen);
369 if(!isTriggered) ptObs=0.0;
373 histUnfoldMatrixSys->
Fill(ptGen,ptObs);
378 if((ptGen>=xminGen)&&(ptGen<xmaxGen)) {
379 histBbbSignalRecSys->
Fill(ptObs);
381 histBbbBgrPtSys->
Fill(ptObs);
383 histBbbSignalGenSys->
Fill(ptGen);
410 regMode,constraintMode,densityFlags);
413 unfold.SetInput(histUnfoldInput);
419 unfold.SubtractBackground(histUnfoldBgr1,
"background1",scale_bgr,dscale_bgr);
420 unfold.SubtractBackground(histUnfoldBgr2,
"background2",scale_bgr,dscale_bgr);
423 unfold.AddSysError(histUnfoldMatrixSys,
"signalshape_SYS",
433 Int_t iBest=unfold.ScanLcurve(nScan,0.,0.,&lCurve,&logTauX,&logTauY);
435 cout<<
"chi**2="<<unfold.GetChi2A()<<
"+"<<unfold.GetChi2L()
436 <<
" / "<<unfold.GetNdf()<<
"\n";
452 TH1 *histUnfoldOutput=unfold.GetOutput(
"PT(unfold,stat+bgrerr)");
455 TH2 *histEmatStat=unfold.GetEmatrixInput(
"unfolding stat error matrix");
459 TH2 *histEmatTotal=unfold.GetEmatrixTotal(
"unfolding total error matrix");
463 TH1 *histUnfoldStat=
new TH1D(
"PT(unfold,staterr)",
";Pt(gen)",
464 nGen,xminGen,xmaxGen);
465 TH1 *histUnfoldTotal=
new TH1D(
"PT(unfold,totalerr)",
";Pt(gen)",
466 nGen,xminGen,xmaxGen);
467 for(
Int_t i=0;i<nGen+2;i++) {
482 TH2D *histCorr=
new TH2D(
"Corr(total)",
";Pt(gen);Pt(gen)",
483 nGen,xminGen,xmaxGen,nGen,xminGen,xmaxGen);
484 for(
Int_t i=0;i<nGen+2;i++) {
487 if(ei<=0.0)
continue;
488 for(
Int_t j=0;j<nGen+2;j++) {
490 if(ej<=0.0)
continue;
496 TH1 *histDetNormBgr1=unfold.GetBackground(
"bgr1 normalized",
498 TH1 *histDetNormBgrTotal=unfold.GetBackground(
"bgr total normalized");
508 histUnfoldInput->
Draw(
"E");
513 histDetMC->
Draw(
"SAME HIST");
514 histDetNormBgr1->
Draw(
"SAME HIST");
515 histDetNormBgrTotal->
Draw(
"SAME HIST");
522 histUnfoldTotal->
Draw(
"E");
524 histUnfoldOutput->
Draw(
"SAME E1");
526 histUnfoldStat->
Draw(
"SAME E1");
527 histDataTruth->
Draw(
"SAME HIST");
529 histBbbSignalGen->
Draw(
"SAME HIST");
534 histUnfoldMatrix->
Draw(
"BOX");
540 bestLogTauLogChi2->
Draw(
"*");
546 bestLcurve->
Draw(
"*");
550 histCorr->
Draw(
"BOX");
552 output.
SaveAs(
"testUnfold3.ps");
557 std::cout<<
"bin truth result (stat) (bgr) (sys)\n";
558 std::cout<<
"===+=====+=========+========+========+=======\n";
559 for(
Int_t i=1;i<=nGen;i++) {
582 Double_t errData_stat_bbb = errData*fCorr;
584 Double_t errData_statbgr_bbb = errData_bgr*fCorr;
590 Double_t shift_sys= data_bgr*fCorr_sys - data_bbb;
594 TMath::Sqrt(errData_statbgr_bbb*errData_statbgr_bbb
595 +shift_sys*shift_sys);
606 (
"%3d %5.0f %8.1f +/-%5.1f +/-%5.1f +/-%5.1f (unfolding)",
608 errData_stat_unfold,
TMath::Sqrt(errData_statbgr_unfold*
609 errData_statbgr_unfold-
611 errData_stat_unfold),
613 errData_total_unfold-
614 errData_statbgr_unfold*
615 errData_statbgr_unfold))<<
"\n";
617 (
" %8.1f +/-%5.1f +/-%5.1f +/-%5.1f (bin-by-bin)",
618 data_bbb,errData_stat_bbb,
TMath::Sqrt(errData_statbgr_bbb*
625 errData_statbgr_bbb))
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
1-D histogram with a double per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
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)
static void SetDefaultSumw2(Bool_t sumw2=kTRUE)
When this static function is called with sumw2=kTRUE, all new histograms will automatically activate ...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
2-D histogram with a double per channel (see TH1 documentation)
Service class for 2-D histogram classes.
void SetBinContent(Int_t bin, Double_t content) override
Set bin content.
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Int_t Fill(Double_t) override
Invalid Fill method.
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.
void SaveAs(const char *filename="", Option_t *option="") const override
Save the pad content in a file.
Random number generator class based on M.
This is the base class for the ROOT Random number generators.
Double_t Rndm() override
Machine independent random number generator.
virtual Double_t BreitWigner(Double_t mean=0, Double_t gamma=1)
Return a number distributed following a BreitWigner function with mean and gamma.
Base class for spline implementation containing the Draw/Paint methods.
void Draw(Option_t *option="") override
Draw this function with its current attributes.
virtual void GetKnot(Int_t i, Double_t &x, Double_t &y) const =0
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
An algorithm to unfold distributions from detector to truth level.
EDensityMode
choice of regularisation scale factors to cinstruct the matrix L
@ kDensityModeBinWidth
scale factors from multidimensional bin width
@ kSysErrModeMatrix
matrix is an alternative to the default matrix, the errors are the difference to the original matrix
static const char * GetTUnfoldVersion(void)
return a string describing the TUnfold version
EConstraint
type of extra constraint
@ kEConstraintArea
enforce preservation of the area
ERegMode
choice of regularisation scheme
@ kRegModeCurvature
regularize the 2nd derivative of the output distribution
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.