RooFit (Things that I used)

Table of Contents


couple of small scripts that I used

  1. Compare the two workspaces: https://gist.github.com/ram1123/88233943beb031b63265417b9b93c6ce
  2. Read workspace: https://gist.github.com/ram1123/847d079cef00e503e884ed65aa9a8c58
  3. Get integral of RooRealVar: https://gist.github.com/ram1123/f6fce437307cce7b3fba2b25a3c9cc02
  4. Read histo from ROOT file and fit using RooFit: https://gist.github.com/ram1123/42e5e95952f13abbe5d5e3adc65d7315

Some nice references

  1. RooStatsWorkbook (gitbook): https://roostatsworkbook.readthedocs.io/en/latest/introduction.html 2.

Calculate Chi2/ndf

Method 1 : (Using RooFit function chiSquare)

Double_t chiSquare(int nFitParam=0) ;
Double_t chiSquare(const char* pdfname, const char* histname, int nFitParam=0) const ;
  • RooPlot::chiSquare() gives us the chi2/dof.

  • We can also provide the number of floating parameters if the curve is the result of the fit.

  • If we have multiple curve or dataset then the chi2 is calculated from the last added dataset and curve. Or we can add explicitly the names of the curve and histogram in the RooPlot we would like to compare.

  • Plot and histogram names are automatically chosen (do e.g. RooPlot::print()), but you can also choose them yourself by adding a Name(“blah”) argument to each plotOn call.

Reference:

  1. https://root-forum.cern.ch/t/how-to-obtain-fit-goodness-in-roofit/8199/2?u=ramkrishna

Method 2: (Using TH1 method Chi2Test)

Reference: link

Double_t TH1::Chi2Test  (   const TH1 *     h2,
Option_t *  option = "UU",
Double_t *  res = 0
)       const
  • calculate chi2/ndf like this:
      chi2ndf  = hData->Chi2Test(hPdf,"CHI2/NDFUW");

Reference: link

plotting components of composite p.d.f.s

Reference: https://root.cern.ch/root/html/tutorials/roofit/rf205_compplot.C.html




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • ROOT CheatSheet
  • Condor Jobs
  • GitLab workflow for CMS-AN
  • awk command
  • Vi-Editor
  • Git CheatSheet
  • XDAQ Basics
  • Grep command
  • Mac Settings
  • EOS uses
  • C++ CheatSheet