How to determine the True Flavour of a Jet in CMSSW 2.X and beyond

Since CMSSW_2_X_Y the old way (see 1.6 chapter) of finding the flavour of a jet is deprecated, and we use GenParticles, which are available in any data tier up to (including) AODSIM.

To access the information, you have before to add in the cmsRun Path the sequence process.myPartons * process.AK5Flavour which can be defined via

process.load("CMS.PhysicsTools.JetMCAlgos.CaloJetsMCFlavour_cfi")  

Here is how to operate:

  • take a CMSSW version (let's say CMSSW_3_3_5)
  • prepare a cmsRun sequence which includes
process.load("CMS.PhysicsTools.JetMCAlgos.CaloJetsMCFlavour_cfi")  
and runs before your analyzer
process.myPartons * process.AK5Flavour

In the .cc code of the analyzer includes lines like

  edm::Handle<reco::JetFlavourMatchingCollection> jetMC;
  iEvent.getByLabel(jetMCSrc, jetMC);
to load the product. jetMCsrc is the collection you want to analyze, depending on the jet type. Default should be 'AK5byValAlgo'.

This product is a mapping between Reco::Jets and an int which is the flavour (please note it can be positive and negative, so to select b quark ask for std::abs(flavour)==5. Then, inside the loop in which you analyze jets, you can ask for the flavour. The easiest way is to produce event by event a searchable map, with lines like

typedef std::map<edm::RefToBase<reco::Jet>, unsigned int, JetRefCompare> FlavourMap;
FlavourMap flavours;
  for (reco::JetFlavourMatchingCollection::const_iterator iter = jetMC->begin();
       iter != jetMC->end(); iter++) {
    unsigned int fl = std::abs(iter->second.getFlavour());
    flavours.insert(FlavourMap::value_type(iter->first, fl));
  }

Then, when you have a RefToBase<reco::Jet> (for example from a view), you can ask for the flavour:

unsigned int myFlavour=0;
RefToBase<reco::Jet> aJet; // fill it from the collection you want to probe!
if (flavours.find (aJet) == flavours.end()) {
    std::cout <<" Cannot access flavour for this jet - not in the Map"<<std::endl;
} else {
   myFlavour = flavours[aJet];
}

Please note the value of myFlavour can be zero if there was not a positive identification of the jet flavour (for example, no partons inside the matching cone).

In summary the following things need to be changed in order to get the jet flavour.

  • Make changes in your MyEDAnalyzer.cc and it should look like this MyEDAnalyzer.cc

  • Make changes in the BuildFile and it should look like this CMS.BuildFile

Then do scram b and run it by doing cmsRun myedanalyzer_cfg.py

You should see something like this (click on Show result below):

Begin processing the 1st record. Run 1, Event 8753440, LumiSection 5674 at 18-May-2010 10:31:54 CEST
 Jet 0 has b tag discriminator = -100 and jet Pt = 1.51255
 Jet 1 has b tag discriminator = -100 and jet Pt = 1.12788
 Jet 2 has b tag discriminator = -100 and jet Pt = 1.00847
 Jet 0 has flavour = 21
 Jet 1 has flavour = 0
 Jet 2 has flavour = 0
Begin processing the 2nd record. Run 1, Event 8753441, LumiSection 5674 at 18-May-2010 10:31:54 CEST
 Jet 0 has b tag discriminator = -100 and jet Pt = 3.76868
 Jet 1 has b tag discriminator = -100 and jet Pt = 3.47249
 Jet 2 has b tag discriminator = -100 and jet Pt = 3.33955
 Jet 3 has b tag discriminator = -100 and jet Pt = 2.79301
 Jet 4 has b tag discriminator = -100 and jet Pt = 1.48905
 Jet 5 has b tag discriminator = -100 and jet Pt = 1.48498
 Jet 6 has b tag discriminator = -100 and jet Pt = 1.21182
 Jet 7 has b tag discriminator = -100 and jet Pt = 1.19971
 Jet 8 has b tag discriminator = -100 and jet Pt = 1.16671
 Jet 9 has b tag discriminator = -100 and jet Pt = 1.12592
 Jet 10 has b tag discriminator = -100 and jet Pt = 1.03013
 Jet 0 has flavour = 2
 Jet 1 has flavour = 21
 Jet 2 has flavour = 21
 Jet 3 has flavour = 0
 Jet 4 has flavour = 0
 Jet 5 has flavour = 0
 Jet 6 has flavour = 0
 Jet 7 has flavour = 0
 Jet 8 has flavour = 0
 Jet 9 has flavour = 0
 Jet 10 has flavour = 0
Begin processing the 3rd record. Run 1, Event 8753442, LumiSection 5674 at 18-May-2010 10:31:54 CEST
 Jet 0 has b tag discriminator = -2.35632 and jet Pt = 2.80738
 Jet 1 has b tag discriminator = -100 and jet Pt = 2.4376
 Jet 2 has b tag discriminator = -100 and jet Pt = 2.3545
 Jet 3 has b tag discriminator = -100 and jet Pt = 2.02223
 Jet 4 has b tag discriminator = -100 and jet Pt = 1.65683
 Jet 5 has b tag discriminator = -100 and jet Pt = 1.6328
 Jet 6 has b tag discriminator = -100 and jet Pt = 1.61783
 Jet 7 has b tag discriminator = -100 and jet Pt = 1.57096
 Jet 8 has b tag discriminator = -100 and jet Pt = 1.56623
 Jet 9 has b tag discriminator = -100 and jet Pt = 1.38087
 Jet 10 has b tag discriminator = -100 and jet Pt = 1.33699
 Jet 11 has b tag discriminator = -100 and jet Pt = 1.27284
 Jet 12 has b tag discriminator = -100 and jet Pt = 1.09305
 Jet 0 has flavour = 0
 Jet 1 has flavour = 0
 Jet 2 has flavour = 0
 Jet 3 has flavour = 21
 Jet 4 has flavour = 21
 Jet 5 has flavour = 0
 Jet 6 has flavour = 21
 Jet 7 has flavour = 0
 Jet 8 has flavour = 21
 Jet 9 has flavour = 21
 Jet 10 has flavour = 0
 Jet 11 has flavour = 0
 Jet 12 has flavour = 0

-- TommasoBoccali - 11-Dec-2009

-- JyothsnaK - 18-May-2010

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2010-05-18 - JyothsnaK
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback