PF2PAT + PAT Tutorial

Complete: 4

This is just a tutorial, please refer to SWGuidePF2PAT for the full documentation.

Tip, idea NEW: PF2PAT with 3_6_X

TIP For the impatient user

Installation

TIP Follow the most recent recipe.

CMSSW_3_7_0_patch2

* Login on a SLC5 machine e.g.:

ssh lxplus5.cern.ch
  • Setup CMSSW, and add the PF2PAT and PAT packages:
cmsrel CMSSW_3_7_0_patch2
cd CMSSW_3_7_0_patch2/src
cmsenv
addpkg PhysicsTools/PFCandProducer
addpkg PhysicsTools/PatAlgos
scram b -j 4 

CMSSW_3_6_1_patch2

  • Login on a SLC5 machine e.g.:
ssh lxplus5.cern.ch
  • Setup CMSSW, and add the PF2PAT and PAT packages:
cmsrel CMSSW_3_6_1_patch2
cd CMSSW_3_6_1_patch2/src
cmsenv
cvs co -r V04-06-01 PhysicsTools/PFCandProducer
cvs co -r PF2PATonData_CMSSW_3_6_1_patch2 PhysicsTools/PatAlgos
scram b -j 4 

Older recipes

PF2PATOlderRecipes

Creation of the PAT objects (PF2PAT+PAT)

Basic

Run PF2PAT followed by PAT on your input file

Warning, important Please make sure that the global tag in the cfg is correct before running it. All global tags are described on this page.

To run PF2PAT followed by PAT:

cd PhysicsTools/PatAlgos/test
cmsRun  patTuple_PF2PAT_cfg.py

You get an output file named patTuple_PF2PAT.root, which contains the PAT objects.

Advanced PF2PAT

This page is just a simple tutorial. Please refer to SWGuidePF2PAT for the full documentation.

Understanding PF2PAT

You must have completed this tutorial section.

We're now going to run only PF2PAT in verbose mode, to see how the top projection is working (Using CMSSW_3_1_4 or more recent code)

Edit your cfg file and edit the following lines:

process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) )
process.pfNoJetPFlow.verbose = True
For information, the configuration of the pfNoJetPFlow module can be found here Then, run it, and have a look at the resulting printout (in this special case the output of the module which removes jets from the list of PFCandidates is printed). A commented printout can be found on WorkBookPF2PATPrintOut

The PFCandidates printed with an "X" are the ones which are masked. The other PFCandidates remain unmasked and will end up in the collection of PFCandidates created by the top projection.

PATTuple Event Content

To check the collections present in your PATTuple:
   edmFileUtil -P -f file:patTuple_PF2PAT.root
Resulting printout:
file:patTuple_PF2PAT.root
patTuple_PF2PAT.root ( 1 events, 1002367 bytes )
Branch 0 of Events tree: EventAuxiliary Total size = 746
Branch 1 of Events tree: patElectrons_selectedPatElectrons__PAT. Total size = 111214
Branch 2 of Events tree: patElectrons_selectedPatElectronsPFlow__PAT. Total size = 114024
Branch 3 of Events tree: patJets_selectedPatJets__PAT. Total size = 63252
Branch 4 of Events tree: patJets_selectedPatJetsPFlow__PAT. Total size = 65022
Branch 5 of Events tree: patMETs_patMETs__PAT. Total size = 30848
Branch 6 of Events tree: patMETs_patMETsPFlow__PAT. Total size = 31758
Branch 7 of Events tree: patMuons_selectedPatMuons__PAT. Total size = 111512
Branch 8 of Events tree: patMuons_selectedPatMuonsPFlow__PAT. Total size = 114562
Branch 9 of Events tree: patPFParticles_selectedPatPFParticles__PAT. Total size = 81478
Branch 10 of Events tree: patPhotons_selectedPatPhotons__PAT. Total size = 62639
Branch 11 of Events tree: patTaus_selectedPatTaus__PAT. Total size = 104595
Branch 12 of Events tree: patTaus_selectedPatTausPFlow__PAT. Total size = 107345
Both the standard PAT and the PF2PAT+PAT products are kept in the event. The PF2PAT+PAT products are marked with the postfix "PFlow".

It is possible to add new collections to your PATTuple by manipulating the EventContent of the output file. For example, to add the intermediate PF2PAT collections, edit the following line in your cfg file:

addPF2PATProducts = True
and run again. More information: SWGuideSelectingBranchesForOutput.

Running PF2PAT and PAT in separate processes

to be written

Analysis of the PAT objects (PF2PAT+PAT)

The PAT objects can be analysed in the standard way, following the PAT instructions. Here, we are only going to use ROOT together with FWLite, to get a couple of plots.

FWLite initialization and TTree aliases

Start root and initialize the system:

root 
.L $CMSSW_BASE/src/CMS.PhysicsTools/PFCandProducer/test/Macros/rootlogon.C
loadFWLite()

The line

.L $CMSSW_BASE/src/CMS.PhysicsTools/PFCandProducer/test/Macros/rootlogon.C
Loads the definition of a set of useful functions that we are going to use in the later steps. In particular, the function loadFWLite(), defined in rootlogon.C, initializes FWLite. You can replace your rootlogon.C by this file, so that everytime you start root, the functions defined in rootlogon.C are available.

Open your root file:

TFile f("patTuple_PF2PAT.root")

Init the TTree aliases for the various reconstruction steps. These aliases are shortcuts for long names in the Events TTree. Please have a look in the rootlogon.C, which is self explanatory for a list of these aliases.

initAOD("HLT")
initPF2PAT("PAT")
initPAT("PAT")

Jets

  • Resolution on pT for your PAT jets:
   Events.Draw("patJets.obj.pt() - patJets.obj.genJet().pt()>>h(150,-200,100)")

you should get something like this

pat_jetptResolution.png

MET

Please try to plot the MET phi residual:

  Events.Draw("patMet.obj.phi()-patMet.obj.genMET().phi()")

Leptons

Energy resolution

  • Energy resolution of the electrons:
Events.Draw("patElectrons.obj.pt() - patElectrons.obj.genLepton().pt()","patElectrons.obj.genLepton().pdgId()!=0")

Electron identification

  • Electron fake rate (distribution of electrons not matched to a PAT lepton, according to the PAT matcher - which you should check!)
Events.Draw("patElectrons.obj.pt()")
Events.SetLineColor(4)
Events.Draw("patElectrons.obj.pt()","patElectrons.obj.genLepton().pdgId()==0","same")
  • Electron PF MVA
Events.Draw("patElectrons.obj.pfCandidateRef().get().mva_e_pi()","patElectrons.obj.genLepton().pdgId()!=0")

Lepton isolation

  • Electron isolation
Events.Draw("patElectrons.obj.isoDeposit(4).depositWithin(0.5)","patElectrons.obj.genLepton().pdgId()!=0")
The 4 in isoDeposit is the isolationKey as defined in this file

Taus

Don't hesitate to contribute to this section smile

Vertices

This tutorial section is based on the PF2PAT collections. First add them to your PATTuple EventContent

PFCandidates are associated to a vertex, see SWGuidePF2PAT#ParticlePileUp for more information.

  • z distribution of all vertices:
   Events.Draw("vertices.obj.z()>>vertz");

vertices_zVertex.png

  • z candidate - z vertex, for all charged PFCandidates. The first vertex in the collection of vertices is the primary vertex.
   Events.Draw("pfcandin.obj.vertex().z() - vertices.obj[0].z()>>dzin","pfcandin.obj.charge()!=0");

vertices_deltaz_allChargedHadrons.png

  • z candidate - z vertex, for non pile-up PFCandidates:
   Events.Draw("pfcandout.obj.vertex().z() - vertices.obj[0].z()>>dzout","pfcandout.obj.charge()!=0");

vertices_deltaz_nonPUChargedHadrons.png

  • z candidate - z vertex, for pile-up PFCandidates. Note that all pile-up PFCandidates are charged.
   Events.Draw("pileup.obj.vertex().z() - vertices.obj[0].z()>>dzpu");

vertices_deltaz_PUChargedHadrons.png

More plots

TIP WorkBookPATDataFormats : PAT objects : Information available, and how to access it.

PF2PAT+PAT on real data


-- ColinBernet - 15 Oct 2008
Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng pat_jetptResolution.png r1 manage 11.7 K 2008-10-17 - 11:44 ColinBernet  
PNGpng vertices_deltaz_PUChargedHadrons.png r1 manage 9.7 K 2008-10-20 - 17:51 ColinBernet  
PNGpng vertices_deltaz_allChargedHadrons.png r1 manage 8.6 K 2008-10-20 - 17:50 ColinBernet  
PNGpng vertices_deltaz_nonPUChargedHadrons.png r1 manage 9.6 K 2008-10-20 - 17:51 ColinBernet  
PNGpng vertices_zVertex.png r1 manage 7.7 K 2008-10-20 - 17:51 ColinBernet  
Edit | Attach | Watch | Print version | History: r60 < r59 < r58 < r57 < r56 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r60 - 2010-11-08 - ColinBernet


No permission to view CMS.PFlowLeftBar

ESSENTIALS

ADVANCED TOPICS


 
    • 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