PAT Examples: QCD Analysis



  • QCD analysis of inclusive jet distribution, as preferred by the High pT QCD group, is presented as an example.
  • The object that play an important role in this analysis are
    • PAT::Jet

How to get the code

  • Login to lxplus
  • cd to your CMSSW base folder ($CMSSW_BASE/src) * This tutorial was tested and commissioned for CMSSW_3_8_2 [Special instruction: "setenv SCRAM_ARCH slc5_ia32_gcc434" is required to get this version of cmssw. ]
  • At the command prompt
    • >cmsenv
    • >cvs co UserCode/QCDPATExample/
    • >scramv1 b
  • This example predominantly uses the PAT default sequence and requires no additional code to be checked out.

How to run the code on Data:

  • To run the code
    • To make PAT tuples from RECO from real data:
      • >cd UserCode/QCDPATExample/test
      • >cmsRun
      • This example produces a set of PAT objects to be analyzed offline, from a preselected, centrally located file containing actual CMS data from 2010. The configuration file can be used with any analysis in CMSSW_3_8_2 by moving the file to the test directory of your software package (or by simply running it here as shown in this example).
    • To produce plots:
      • >cmsRun
    • This configuration file runs off of the output of the previous step. It produces a short series of histograms in a file labelled "PATTutorial.root" that you may wish to use as a starting point for producing more rigorous analysis plots.

How to run the code on Monte Carlo

  • To compile the code
    • $CMSSW_BASE/src/UserCode/QCDAnalysisExample
    • scram b
  • To run the code
    • To make PAT tuples from RECO from Monte Carlo:
      • >cd UserCode/QCDPATExample/test
      • >cmsRun
      • This example produces a set of PAT objects to be analyzed offline, from a small sample of Monte Carlo QCD Jets from the Release Validation of CMSSW_3_8_2.
    • To produce plots:
      • >cmsRun
    • This configuration file runs off of the output of the previous step. It produces a short series of histograms in a file labelled "PATTutorialMC.root"

Find out more about the details

  • PAT object production using the is mainly using the PAT defaults. Let's take a look at the configuration file itself, specifically the version that runs on Data:

   from CMS.PhysicsTools.PatAlgos.patTemplate_cfg import *

   from import *
   removeMCMatching(process, ['All'])

  • We begin by importing a basic template for running the PAT default sequence, adding an additional statement that removes all matching to MC-generated objects. Obviously the last of these lines should be removed if you are running on MC.


   from import *
   addPfMET(process, 'PF')

  • In this example, we will be performing our analysis on jets reconstructed using the Anti-kT algorithm and the Particle Flow (PF) scheme. Particle Flow uses its own brand of MET, separate from that in the default PAT sequence. These lines add that brand into our PAT Ntuple.

   from import *
   addJetCollection(process, cms.InputTag('ak5PFJets'), 'AK5', 'PF',
     doJTA            = False,
     doBTagging       = False,
     jetCorrLabel     = ('AK5', 'PF'),
     doType1MET       = False,
     genJetCollection = cms.InputTag("ak5GenJets"),
     doJetID          = False,

  • Here we choose the jet algorithm we are going to use with the addJetCollection command from the jetTools PAT toolkit. The arguments are as follows:
    • Jet Algorithm: In this case, Anti-kT of size .5.
    • Jet Type: Here, Particle Flow. For both jet type and algorithm, see the above jet Tools documentation for lists of the most commonly used and accepted entries for these arguments.
    • doJTA, doBTagging: Run the jet-track associator, and perform B-Tagging respectively. Set to true by default.
    • jetCorrLabel: Choose the type of jet response corrections you wish to use (generally, this should correspond to the algorithm and type you specified in the first two arguments)
    • doType1MET: Triggers whether to use this particular MET correction for the jet collection. Non-Calojets do not use this correction, so for this example it is set to False.
    • genJetCollection: Select the collection of MC jets you wish to perform matching against. Unless you are looking at MC, this will not be relevant.
    • doJetID: Add JetID variables to the jet collection. Set to false here as Particle Flow Jets have the variables used as Jet ID build into the Jet object itself.
    • jetIDlabel: Select the type of jet ID variables you would like to use. Should, again, correspond to the algorithm selected above. Not used here as Jet ID is turned off.

   process.filterJets = cms.EDFilter("CandViewSelector",
      cut = cms.string  ('pt > 10.0'),
      src = cms.InputTag("ak5CMS.CaloJets"),

   process.countJets = cms.EDFilter("PATCandViewCountFilter",
     minNumber = cms.uint32  (4),
     maxNumber = cms.uint32  (999999),
     src       = cms.InputTag("filterJets"),

Here we do some basic jet screening as a form of event selection, filtering only on events containing a certain number of jets satisfying basic kinematic requirements.

   process.scrapingVeto = cms.EDFilter("FilterOutScraping",
     applyfilter = cms.untracked.bool  (True),
     debugOn     = cms.untracked.bool  (False),
     numtrack    = cms.untracked.uint32(10),
     thresh      = cms.untracked.double(0.25)
   process.primaryVertexFilter = cms.EDFilter("GoodVertexFilter",
     vertexCollection = cms.InputTag('offlinePrimaryVertices'), 
     minimumNDOF      = cms.uint32  (4),
     maxAbsZ          = cms.double  (24.0),
     maxd0            = cms.double  (2.0),

*These are further event selection cuts on beam scraping and vertex reconstruction, based on the general recommendations for QCD analyses at large by the tracking group, etc. The remainder of the file is the basic establishemnt of input/output files and selection of data objects to maintain in your PATtuple, which should be covered elsewhere in the tutorial.

Looking at the Executable

  • Now we'll take a look at the compiled code that runs over the PATtuple produced in the previous step, to produce some basic histograms. This code can be found by heading to: *>cd $CMSSW_BASE/src/UserCode/QCDPATExample/src/

   using namespace pat;
   edm::Handle<edm::View<pat::Jet> > jets;

  • Here we acquire our PAT Jet collection. The label of this particular collection is "selectedPatJetsAK5PF", corresponding to the addJetCollection command from the previous steps of the tutorial, in which we instructed PAT to save jets from the AK5 algorithm and PF scheme. You can change the input to this step of the tutorial by editing the corresponding line in the file

   int iJetMult=0;

   float fEtaMin=-2.4;
   float fEtaMax=2.4;
   float fPtMin=10.0;

   int NConst_min = 2;
   int NCharged_min = 1;
   float Charged_hadron_frac_min = 0.;
   float Charged_em_frac_max = 1.;
   float Neutral_hadron_frac_max = 0.9;
   float Neutral_em_frac_max = 0.9;


  • Next we set some jet ID variables to cut on. In this case, we are restricting ourselves to the inner edge of the forward region (abs(eta) < 2.4), applying the same pT cut we applied in the PAT filter, and additionally setting the approved noise thresholds for Particle Flow jets.

   for(edm::View<pat::Jet>::const_iterator i_jet=jets->begin(); i_jet!=jets->end(); ++i_jet){

        if((abs(i_jet->getPFConstituents().size()) > NConst_min) &&
      (i_jet->chargedMultiplicity() > NCharged_min) &&
      (i_jet->chargedHadronEnergyFraction() > Charged_hadron_frac_min) &&
      (i_jet->chargedEmEnergyFraction() < Charged_em_frac_max) &&
      (i_jet->neutralHadronEnergyFraction() < Neutral_hadron_frac_max) &&
      (i_jet->neutralEmEnergyFraction() < Neutral_em_frac_max)){

  • Here we actually apply the cuts by accessing the corresponding cuts by looping over and accessing the individual PAT jet information. The remainder is simply filling histograms. If you follow these steps exactly with no modifications to input files, you should have plots similar to those shown below.

How to get more information

Review status

Reviewer/Editor and Date (copy from screen) Comments
VasundharaChetluru - 01 Jun 2009 Created the page from the template

Responsible: VasundharaChetluru
Last reviewed by: most recent reviewer and date

  • Jet Eta:

  • Jet p_T:
Topic attachments
I Attachment History Action Size Date Who Comment
GIFgif JetEta.gif r1 manage 8.1 K 2010-09-23 - 15:12 KeithJRose Jet Eta
GIFgif JetPt.gif r1 manage 7.3 K 2010-09-23 - 15:13 KeithJRose Jet p_T
Edit | Attach | Watch | Print version | History: r14 < r13 < r12 < r11 < r10 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r14 - 2012-06-20 - unknown
    • 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