b-tagging tutorial

Btagging example

Let's create a working are based on CMSSW 1.1.1, add the latest b tagging software packages, and run the TrackCounting and SoftLepton algorithms on some b and c jets:
scramv1 project -n Tutorial20061116 CMSSW CMSSW_1_1_1
cd Tutorial20061116/src/
project CMSSW
cvs co -r Tutorial20061116 DataFormats/BTauReco
cvs co -r Tutorial20061116 RecoBTau
cvs co -r Tutorial20061116 RecoBTag
scramv1 b -r
eval `scramv1 runtime -sh`
cd ..

Two sample config files are test_b.cfg and test_c.cfg.

mkdir analysis
cd analysis
wget https://twiki.cern.ch/twiki/pub/CMS/BTagTutorialFnal/test_b.cfg
cmsRun test_b.cfg
wget https://twiki.cern.ch/twiki/pub/CMS/BTagTutorialFnal/test_c.cfg
cmsRun test_c.cfg

We can look at the output with ROOT and fwLite:

TFile* file = new TFile("test_b.root");
new TBrowser;

Events->SetAlias("tkCountBase", "recoJetTags_trackCountingJetTags__bTag.obj");
Events->SetAlias("tkCountExt",  "recoTrackCountingTagInfos_trackCountingJetTags__bTag.obj");
Events->SetAlias("leptonBase",  "recoJetTags_softLeptonJetTags_softLepton_bTag.obj");
Events->SetAlias("leptonExt",   "recoSoftLeptonTagInfos_softLeptonJetTags__bTag.obj");

c1 = new TCanvas();
Events->Draw("tkCountBase.discriminator()", "tkCountBase.jet().pt() > 20");
Events->Draw("tkCountExt.discriminator(3,1)", "tkCountBase.jet().pt() > 20");
Events->Draw("tkCountExt.discriminator(3,0)", "tkCountBase.jet().pt() > 20");

c2 = new TCanvas();
Events->Draw("leptonExt.discriminator()", "(leptonExt.jet().pt() > 20) && (leptonExt.leptons() > 0)");
Events->Draw("leptonExt.properties(0).sip3d", "(leptonExt.jet().pt() > 20) && (leptonExt.leptons() > 0)");
Events->Draw("leptonExt.properties(0).ptRel", "(leptonExt.jet().pt() > 20) && (leptonExt.leptons() > 0)");


For this tutorial, check out the head of RecoBTag/Analysis and RecoBTag/MCTools, and compile the two packages.

The full explanation of the Analysis package is given in this page.


  replace bTagTrackCountingAnalysis.rootfile = "plots_b.root"
  • Run on your sample of c jets, calling the ouptut file plots_c.root
  • You now have two root files. Merge the files obtained using the root executable hadd (you should have this in your path, in $ROOTSYS/bin):
 hadd plots_add.root    plots_b.root    plots_c.root

  • Run the cfg file nicePlots.cfg to produce the final performance plots and produce a root file (test_final.root) and eps and ps files of the merged plots (= cmsRun nicePlots.cfg=). Notice in nicePlots.cfg the replace statements, to replace the parameters of the default configuration. In case you have used different eta and pt bins, put in the correct bins through two other replace statements. For example:
  replace bTagTrackCountingAnalysis.etaRanges = { 0.0,  2.4 }
  replace bTagTrackCountingAnalysis.ptRanges = { 30.0, 400.0 }

Look at the plots produced, either in the root file, the ps or the eps file.

MC tools

An example of the usage of the Jet flavour identification tools is given in the EDAnalyzer RecoBTag/MCTools/test/BtagMCTest.cc. It is explained in the SWGuideBTagMCTools page. A sample configuration file to run it is provided in the same directory (test.cfg).

-- Andrea Bocci, Thomas Speer - 15 Nov 2006

Topic attachments
I Attachment History ActionSorted ascending Size Date Who Comment
Unknown file formatcfg nicePlots.cfg r2 r1 manage 0.6 K 2006-11-16 - 15:10 AndreaBocci draw final plots
Unknown file formatcfg plot_b.cfg r2 r1 manage 0.5 K 2006-11-16 - 15:01 AndreaBocci plot b jets stuff
Unknown file formatcfg plot_c.cfg r2 r1 manage 0.5 K 2006-11-16 - 15:01 AndreaBocci plot c jets stuff
Unknown file formatcfg test_b.cfg r1 manage 2.5 K 2006-11-16 - 10:29 AndreaBocci sample .cfg file running b tag algorithms on RelVal 1.1.1 b jets
Unknown file formatcfg test_c.cfg r1 manage 2.8 K 2006-11-16 - 10:30 AndreaBocci sample .cfg file running b tag algorithms on RelVal 1.1.1 c jets

This topic: CMSPublic > BTag > SWGuideBTagTutorialFnal
Topic revision: r8 - 2007-02-28 - JennyWilliams
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback