r-preston / MPhysProject2021

Initial code for 2021 MPhys project
0 stars 0 forks source link

Modelling the QCD background in the W data sample #28

Closed mvesteri closed 2 years ago

mvesteri commented 3 years ago

@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):

hist = ROOT.TH1F('hist','Track transverse momentum',100,15.,60.)
tree.Draw('mu_PT*1.e-3>>hist')
hist.Fit('expo') # fit with an exponential function.
c = ROOT.TCanvas()
hist.Draw()
c.Print('plot.png')
./run root -l /storage/epp2/phshgg/DVTuples__v23b/5TeV_2017_32_Down_EW.root 
root [0] 
Attaching file /storage/epp2/phshgg/DVTuples__v23b/5TeV_2017_32_Down_EW.root as _file0...
(TFile *) 0x371c140
root [1] gDirectory->ls()
TFile**     /storage/epp2/phshgg/DVTuples__v23b/5TeV_2017_32_Down_EW.root   
 TFile*     /storage/epp2/phshgg/DVTuples__v23b/5TeV_2017_32_Down_EW.root   
  KEY: TDirectoryFile   WpIso;1 WpIso
  KEY: TDirectoryFile   WmIso;1 WmIso
  KEY: TDirectoryFile   WpNoIso;1   WpNoIso
  KEY: TDirectoryFile   WmNoIso;1   WmNoIso
  KEY: TDirectoryFile   WmSingleTrackNoBias;1   WmSingleTrackNoBias
  KEY: TDirectoryFile   WpNoMuID;1  WpNoMuID
  KEY: TDirectoryFile   WpSingleTrackNoBias;1   WpSingleTrackNoBias
  KEY: TDirectoryFile   WmNoMuID;1  WmNoMuID
  KEY: TDirectoryFile   ZMuID;1 ZMuID
  KEY: TDirectoryFile   Z;1 Z
  KEY: TDirectoryFile   ZTrkEff;1   ZTrkEff
  KEY: TDirectoryFile   GetIntegratedLuminosity;1   GetIntegratedLuminosity
lmcairns commented 3 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. W_back_plot_expo

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!)

mvesteri commented 3 years ago

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:

lmcairns commented 3 years ago

@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?

mvesteri commented 3 years ago

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).

lmcairns commented 3 years ago

Hi @mvesteri, I have added this to my code producing the fit (for [0]=[1]=1.0) and background templates in the figures below. W_expo_back_plot W_background_template

What would be the next step? I assume I would have to edit the W isolated signal code to remove this background?

mvesteri commented 3 years ago

👍 @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.

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.

lmcairns commented 3 years ago

@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.

mvesteri commented 3 years ago

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.

mvesteri commented 3 years ago

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.

lmcairns commented 3 years ago

Ahh okay that makes sense. I had the rest, was just a bit unsure of the fraction.

Will add those cuts now!

lmcairns commented 3 years ago

One plot with cuts: W_fit_model

mvesteri commented 3 years ago

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.