Home | News | Documentation | Download

How to get the fitting plots using `FitSlicesY`

Dear experts,
I am using FitSlicesY to fit in each bin in a TH2D. And now I would like to get the fitting plots in each bin to check whether the fit is good. Does anyone know how to do it? This is a part of my code below!

Many thanks in advance!
Lingzhu

hdp_p[lab] = tf[lab].Get(
            "Track/TrackResChecker/Long/vertex/dpoverp_vs_p")
        hdp_p[lab].SetName("dpoverp_p_" + lab)
        hmom[lab] = hdp_p[lab].ProjectionX()
        hmom[lab].SetTitle("p histo. " + lab)
        hdp_p[lab].FitSlicesY(0,0,-1,0,"")

@linev could you please take a look if you will have time? Thank you in advance!

It really depends how many histogram bins you have.
If number of projections if below 100, you can divide canvas on so many subpads and draw you projections plots separately:

auto c1 = new TCanvas("c1","All projections", 1200, 800);
c1->Divide(10,10); // divide on 10x10 subpads
for (int n=0;n<100;n++) {
   c1->cd(n+1);
   hmom[n]->Draw("hist");
}

You also can use THStack to plot all histograms together on same pad.
Like in this example.

1 Like

Thanks!! This is very helpful!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.