I use function “createHistogram” creat a histogram from a RooAbsPdf, but the number of bins is not consistent. 7 bins was assigned, but when I got the diagram it only drawn 5 bins. Would you please me tell me how to control the number of bins.
RooRealVar *mass_tt= w->var(“mass_tt”);
TH1F* aterm_ytt_hist=(TH1F*) atem_ytt_pdf->createHistogram(“rapidity_tt”,7);
I tried largen the second argument, for example, set it as 50 or 100, then I obtain 7bins as expected.
In Root reference guide it says: TH1 * createHistogram (const char *varNameList, Int_t xbins=0, Int_t ybins=0, Int_t zbins=0).
I found the second argument is not the number of bins, it seems it is the number of events used to create the histogram.
You could try the
Binning argument that is documented here:
I also had a look at the code, but it looks correct. Could you post an example that we can run?
I found the problem. the command “createHistogram(“rapidity_tt”,7);” create a histogram with even bin width, but my PDF(the original histogram) is not even bin width. The edge of my bins is :
How can I create a histogram with not even width using createHistogram?
In the documentation I linked you should find an argument that’s also called
Binning, but it should take the number of bins and an array with bin boundaries.
What you can do is either use
IntrinsicBinning() or you can create a new RooBinning, and pass it like this:
createHistogram(... Binning(RooBinning(pass your arguments here));
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.