24 using namespace RooFit;
26 void rf704_amplitudefit()
32 RooRealVar t(
"t",
"time", -1., 15.);
33 RooRealVar cosa(
"cosa",
"cos(alpha)", -1., 1.);
36 RooRealVar tau(
"tau",
"#tau", 1.5);
37 RooRealVar deltaGamma(
"deltaGamma",
"deltaGamma", 0.3);
38 RooTruthModel truthModel(
"tm",
"tm", t);
39 RooFormulaVar coshGBasis(
"coshGBasis",
"exp(-@0/ @1)*cosh(@0*@2/2)", RooArgList(t, tau, deltaGamma));
40 RooFormulaVar sinhGBasis(
"sinhGBasis",
"exp(-@0/ @1)*sinh(@0*@2/2)", RooArgList(t, tau, deltaGamma));
41 RooAbsReal *coshGConv = truthModel.convolution(&coshGBasis, &t);
42 RooAbsReal *sinhGConv = truthModel.convolution(&sinhGBasis, &t);
45 RooPolyVar poly1(
"poly1",
"poly1", cosa, RooArgList(RooConst(0.5), RooConst(0.2), RooConst(0.2)), 0);
46 RooPolyVar poly2(
"poly2",
"poly2", cosa, RooArgList(RooConst(1), RooConst(-0.2), RooConst(3)), 0);
49 RooProduct ampl1(
"ampl1",
"amplitude 1", RooArgSet(poly1, *coshGConv));
50 RooProduct ampl2(
"ampl2",
"amplitude 2", RooArgSet(poly2, *sinhGConv));
56 RooRealVar f1(
"f1",
"f1", 1, 0, 2);
57 RooRealVar f2(
"f2",
"f2", 0.5, 0, 2);
60 RooRealSumPdf pdf(
"pdf",
"pdf", RooArgList(ampl1, ampl2), RooArgList(f1, f2));
63 RooDataSet *data = pdf.generate(RooArgSet(t, cosa), 10000);
72 TH1 *hh_cos = ampl1.createHistogram(
"hh_cos", t, Binning(50), YVar(cosa, Binning(50)));
73 TH1 *hh_sin = ampl2.createHistogram(
"hh_sin", t, Binning(50), YVar(cosa, Binning(50)));
74 hh_cos->SetLineColor(kBlue);
75 hh_sin->SetLineColor(kRed);
79 RooPlot *frame1 = t.frame();
82 pdf.plotOn(frame1, Components(ampl1), LineStyle(kDashed));
83 pdf.plotOn(frame1, Components(ampl2), LineStyle(kDashed), LineColor(kRed));
87 RooPlot *frame2 = cosa.frame();
90 pdf.plotOn(frame2, Components(ampl1), LineStyle(kDashed));
91 pdf.plotOn(frame2, Components(ampl2), LineStyle(kDashed), LineColor(kRed));
93 TCanvas *c =
new TCanvas(
"rf704_amplitudefit",
"rf704_amplitudefit", 800, 800);
96 gPad->SetLeftMargin(0.15);
97 frame1->GetYaxis()->SetTitleOffset(1.4);
100 gPad->SetLeftMargin(0.15);
101 frame2->GetYaxis()->SetTitleOffset(1.4);
104 gPad->SetLeftMargin(0.20);
105 hh_cos->GetZaxis()->SetTitleOffset(2.3);
106 hh_cos->Draw(
"surf");
108 gPad->SetLeftMargin(0.20);
109 hh_sin->GetZaxis()->SetTitleOffset(2.3);
110 hh_sin->Draw(
"surf");