Closed mvesteri closed 2 years ago
@mvesteri
I've plotted a fit for expo in C++, and spent some time fiddling with it to get the fit to show in the legend and the stat box. See example for Wp below.
I have uploaded my code as commits to Pull Request #26 (I wasn't aware that it was still open, I had intended to open new pull request, oops!)
Nice looking plot @lmcairns . I'm wondering if we return to trying different fit functions later, and now move on to trying to make a histogram template out of your exponential function, so that we can try and fit the muon data.
You can do the following:
hist.Fit("expo")
, which only works for a few simple functions, you should make a TF1
object.function = ROOT.TF1("my_expo","[0]*TMath::Exp(-[1]*x)")
hist.Fit("my_expo")
background_template = ROOT.TH1F(... you can fill in the rest...
for event in range(10000): background_template.Fill(function.GetRandom())
hist.SetBinContent(bin_number,function.Eval(hist.GetBinCenter(bin_number)
@mvesteri
I was just wondering what [0] and [1] represent in the line:
function = ROOT.TF1("my_expo","[0]*TMath::Exp(-[1]*x)")
How do I set these and what values should they take?
Hi @lmcairns, these represent the two parameters
of the function.
You can set the parameters like
# e.g. set them both to 1.
function.SetParameter(0,1.)
function.SetParameter(1,1.)
And then you can fit the function to a histogram like
my_histogram.Fit(function.GetName())
Note that the fitting is normally not happy if you don't set starting values for the parameters, though it may still work in simple cases like this (only two free parameters).
Hi @mvesteri, I have added this to my code producing the fit (for [0]=[1]=1.0) and background templates in the figures below.
What would be the next step? I assume I would have to edit the W isolated signal code to remove this background?
👍 @lmcairns . As a next step you could try to "fit" the W isolated data with a sum of the signal simulation plus this background template.
data_integral*fraction/histogram_integral
. Does that make sense? Hopefully that is a very quick exercise.
Then we can get you set up with the TFractionFitter
tool to automatically fit the fraction.
@mvesteri I feel like this might be a stupid question, but how do I determine the signal fraction variable? I'm unsure how to produce a numerical value for this from two histograms.
In this first exercise you have to guess/estimate it by eye initially. And then tweak the value until your signal+background sum better describes the data.
E.g. start by guessing that the isolated W sample is 50% signal and 50% background.
Then just use the Scale
and Add
functions of the ROOT histogram class to make your sum histogram.
I probably should have said that you should plot the muon pT distribution from the "isolated" data with some minimal isolation cut. E.g. require that the isolation is < 3 GeV. And start the plot from pT > 20 GeV. Otherwise the sample will be totally background dominated.
Ahh okay that makes sense. I had the rest, was just a bit unsure of the fraction.
Will add those cuts now!
One plot with cuts:
Ok, but that is a plot of the isolated muon data? (The legend suggests that it is a fit "model", i.e. some combination of data/simulation templates)
If, as I suspect, this is the isolated muon data then you can go ahead and try and model this with a sum of signal and background templates. You just have to find a signal fraction that roughly describes the data. No point doing this too carefully, since we can quickly move on to using a fitting/minimisation tool.
@lmcairns
The background is mostly from charged pions and kaons decaying to muonic final states. You could look up the branching fractions of these decays from the "PDG live" webpage.
What we need is a "shape" of this background that we could float in a fit of the W->munu candidate sample.
You see below that there are several paths in the data files. I suggest to look at the
W{m,p}SingleTrackNoBias/DecayTree
path which contains a selection of high pT tracks without any muon identification requirement. These will be mostly [charged] pions and kaons.Steps (just pick one charge to start with, e.g. Wp):