My question in short: How to draw a normalized histogram of a specific RooDataSet instance without any adjustment by my hand after drawing it.
I want to compare the shape of a physical quantity from two different datasets.
If I use TTree instance, I can make such comparison plot with the following commands.
Let’s say “tree1” and “tree2” as the name of trees and “mass” as physical quantity for the comparison
This works for me so far (some problems are there though… such like problems of range for y-axis and so on…).
But in this time, I migrated to RooFit and in this framework, a class like TTree is RooDataSet I think.
One can draw a histogram of “mass” distribution in RooDataSet by using RooRealVar and plotOn() method in RooDataSet. However, I cannot find the way to do a similar thing stated above in RooFit, drawing histogram which is normalized by its integral (to have unit area)
I tried Rescale option of plotOn() method, but it does not adjust the y-axis at all, so I should get my plot from a RooPlot instance and call some functions to adjust it by my hand every time.
So, my question is very simple: Is there an elegant way to draw a normalized histogram from a RooDataSet instance only by using plotOn() and its option?
It seems there are no people who are interested in this topic. So I have written some utility function for my purpose. Here I want to share my function.
This is working for me so far (there might be some bugs in here, I am not sure…).
However, I didn’t stop to find more elegeant way to draw a normalized plot to a RooPlot instance from RooAbsData one. If I could get some answer from experts, I would be very appreciated.
Apologies for the late reply. First of all, when you want to draw normalised data points in order that the integral is 1, you need to divide the content by the bin width. For histograms you should use h1->Scale(1./h1->Integral(), "width").
In Roofit when plotting RooAbsData you just need to call rescale and do for example: