PAT Exercise 06: High Level Analysis Tasks Exercise



  • This exercise should adress common tasks in physics analysis with emphasis on jets.
  • You should learn practical and commonly used features of PAT.
  • You will experience common programming problems when using PAT and learn how to solve them.
  • You should learn to make use of the modular FW structure.

ALERT! Note:

This web course is part of the PAT Tutorial, which takes regularly place at cern and in other places. When following the PAT Tutorial the answers of questions marked in RED should be filled into the exercise form that has been introduced at the beginning of the tutorial. Also the solutions to the Exercises should be filled into the form. The exercises are marked in three colours, indicating whether this exercise is basic (obligatory), continuative (recommended) or optional (free). The colour coding is summarized in the table below:

Color Code Explanation
red Basic exercise, which is obligatory for the PAT Tutorial.
yellow Continuative exercise, which is recommended for the PAT Tutorial to deepen what has been learned.
green Optional exercise, which shows interesting applications of what has been learned.

Basic exercises ( red ) are obliged and the solutions to the exercises should be filled into the exercise form during the PAT Tutorial.


This exercise is supposed to be guided and interactivly. Therefore the exercise is interupted by small lectures. Please setup your environment before the first lecture so everything will be compiled and ready to use after.

Setting up of the environment

We assume that you are logged in on lxplus and are in your work directory. If not you can follow the instruction given here. You can just copy and paste the following lines to be ready for the Wednesday tutorial.

ssh -Y
cd scratch0/
mkdir exercise06
cd exercise06
cmsrel CMSSW_7_4_1_patch4
cd CMSSW_7_4_1_patch4/src 
git cms-addpkg PhysicsTools/PatAlgos
git cms-merge-topic -u CMS-PAT-Tutorial:CMSSW_7_4_1_patTutorial
scram b -j 6
cd PhysicsTools/PatExamples

For this exercise, you need to produce in input file where the b-tagging information is stored in pat::Jets:

cmsRun ../PatAlgos/test/
You can see that it differs from the standard config by presence of following lines that use jetTools to modify default setting of PFBRECO sequence to store the b-tagging information:

from import *
                    jetSource = cms.InputTag('pfNoTauClonesPFBRECO'+postfix),
                    jetCorrections= ('AK4PFchs', ['L1FastJet','L2Relative', 'L3Absolute'], ''),
                    outputModules =  ['out'],
                    btagDiscriminators = ['combinedSecondaryVertexBJetTags','jetBProbabilityBJetTags','jetProbabilityBJetTags','trackCountingHighPurBJetTags','trackCountingHighEffBJetTags','simpleSecondaryVertexHighEffBJetTags','simpleSecondaryVertexHighPurBJetTags']

You have produced the inputfile for this exercise called patTuple_PATandPF2PAT.root. We are using particle flow objects that are discussed in more detail on Wednesday but you will not notice any difference. You can easily switch to conventional PAT except for exercise 3 where particle flow objects are necessary.


Exercise 1: Applying jet energy corrections within PAT

A commonly used feature of PAT jets are the application of jet energy corrections. You can find more details on the different energy corrections in CMS here. You can find more information about jets here and jet energy corrections factors here. Having a look at the doxygen of a pat jet you can see that there are possiblities to access jet energy corrections.

Task 1: Open the EDAnalyzer analyzerJEC with your favourite editor and try to understand the code.

emacs src/ &
You can see that this module analyzes the jet energy corrections by plotting the response function of the jets: pt_reco/pt_gen is plotted against eta for a jet energy correction level of you choice. The 2D histogram can be converted into a profiled histogram by a little python script (test/ afterwards. We are using generator matching by PAT that will be discussed in the tutorial on Thursday. Check the parameters which must be passed via the configuration file. When you have understood the code, have a look at the provided configuration file ( cfg file):
emacs test/ & 
Check the parameters that are set for this analyzer.

Task 2: Run the configuration file by

cmsRun  test/

As you can see there is an error frown . Uncomment 'hint1' of the MessageLogger in the configuration file, run again and try to solve the problem with the output you receive. If you get stuck, ask the tutor. You can find more information on the MessageLogger in SWGuideMessageLogger if you are interested.

Task 3: You solved the error? smile Have a look at the jet response after different correction levels by cloning various instances of the module. You can find an exemple how to do this in the comments. Do this analogue for the missing correction level. Afterwards you can use a little script to profile the 2D histograms:

python test/ -d jecAnalyzer
display profiledResponseFunction_jecAnalyzer_Response.png
This script reads in the TFileService output. The TFileService automatically creates a new directory for every module. The name of the directory corresponds to the python label of the module, in this case "jecAnalyzer".

Question Question 6 a):
Compare the JECSet label that you printed out in the analyzer with the member function availableJECSets() with the label that is set at the production of the selected pat jets within the config file What is the name of the parameter defining the JEC Set that is considered in the pat jets?

Browse through the configuration file that creates the pat tuple, find the jet collection that you are using and the parameter that is set:
edmConfigBrowser ../PatAlgos/test/

Exercise 2: Using B-Tagging with PAT

In this exercise you will learn how to access b-tagging information in PAT. First open analyzerBTag with your favourite analyzer:

emacs src/ &
This analyzer is mainly to test some different b-tagging algorithms, as you can see it produces efficiency and mistagrate histograms as function of the b-tagging value.

Task 1: Investigate the created root (TFileServiceOutput.root) file. Why are there histograms in btagAnalyzer with zero entries? Switch on 'hint3' in the MessageLogger configuration to find it out and adapt the parameters in the configuration file accordingly.

Task 2: Now you know which b-tagging discriminators are available from within the pat jet. You can compare this with the pat::jet producer configuration:

python -i  ../PatAlgos/test/

Task 3: Try out the provided EDAnalyzer to investigate the performance of the different b tagging algorithms by cloning various instances of it.

Question Question 6 b):
What is the name of the parameter in the pat::jet producer that includes the various b-tagging algorithms?

You can find this out again by browsing through the configuration file that creates the pat tuple, find the jet collection that you are using and the parameter that is set:
edmConfigBrowser ../PatAlgos/test/

Exercise 3: Do Jet energy smearing and vary JEC with the help of PAT tools

Have a look at SWGuidePATTools and read through the description of "MET Systematics Tools". Under Exercise 3 in your configuration file you can see that the METUncertaintyTool is applied. Explore the METUncertaintyTool with the python interpreter and have a closer look which new modules are added to the process by uncommenting and commenting the tool and:
python -i  test/
As you can see a lot of collections are produced. You can comment the line back again and see how much new modules are added to the path by the command runMEtUncertainties. Can you find a collection again that is mentioned on the twiki here? As you can see the names of the output collections are sometimes slightly different.

Have a closer look at a module that you are interested in, e.g.:

Investigate the dependencies of this module: which input collections are needed, which collections need to be produced before hand? If you would try to investigate this with the ConfigEditor, which would be more comfortable, you would see that because of the unscheduled execution the newly modules appear in the browser as they have been automatically added to a scheduled path.

Task 1: Shift the energies of your selectedPatJetsPFlow by using the module process.shiftedPatJetsEnUpForCorrMEt in your configuration file.

Task 2: Do you see a difference in the response plots after scaling the jet energy? You maybe need to shift more extreme then by two sigma. Try higher values.

Use a new instance of your JECAnalyzer for this. You need to change the input collection and put the new instance into the path.

Question Question 6 c):
What is the location of the py implementation of the shiftedPatJetsEnUpForCorrMEt in cmssw?

Have a look at the implementation details linked on the twiki here and then guess where in the module is implemented/created.

Exercise 4: Writing User Data into Pat Objects e.g. Composite Pat Candidates

Have a look at SWGuidePATUserData. Please open with your favourite analyzer:
emacs plugins/ &
This producer gives you an example how to add user data to pat objects, in this case to a composite candidate.

Task 1: Require that the muons of the JPsi Candidates have a DR less than 100. This cut is just for demonstration issues.

The parameter cut takes a string where you can use any member function from the object itself (see doxygen pages). You can combine the requirements with boolean operators: &, ||.

Task 2: Require at least one good Jspi Candidate in the event by using the module PATCompositeCandidateSelector and PATCandViewCountFilter. How many events remain after this requirement? You can easily find this out by using the option 'wantSummary'.

Task 3: Plot the Delta R of the two muons building the Jpsi Candidate by using the module CandViewHistoAnalyzer. Try to add another plot with the pt of JPsi candidate.

The parameter histograms is a vector of Psets. So you can just add another PSet to the existing module with the parameter plotquantity adequately set.

ALERT! Note:

In case of problems don't hesitate to contact the SWGuidePAT#Support. Having successfully finished Exercise 6 you might want to proceed to the other exercises of the WorkBookPATTutorial to learn more about the PAT.

Review status

Reviewer/Editor and Date (copy from screen) Comments
RogerWolf - 17 March 2012 Added color coding. But this page need adaptations to the general Question and Exercise scheme.

Responsible: YvonneKuessel

Topic attachments
I Attachment History Action Size Date Who Comment
PDFpdf Lecture1.pdf r2 r1 manage 395.1 K 2012-12-04 - 14:59 YvonneKuessel  
PDFpdf Lecture2.pdf r2 r1 manage 822.5 K 2012-12-04 - 14:59 YvonneKuessel  
PDFpdf Lecture3.pdf r2 r1 manage 478.8 K 2012-12-04 - 15:00 YvonneKuessel  
Cascading Style Sheet filecss tutorial.css r1 manage 0.2 K 2011-11-18 - 09:38 RogerWolf  
Edit | Attach | Watch | Print version | History: r44 < r43 < r42 < r41 < r40 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r44 - 2015-06-25 - TaeJeongKim
    • 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-2021 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