# CMS Data Analysis School, Short Exercise MET

Instructions for short exercise MET at CMS Data Analysis School at Bari in January 2015

Facilitator: Tai Sakuma

Acknowledgement: In creating this exercise, the facilitator received valuable contributions and comments from Mariarosaria D'Alfonso, Matthieu Marionneau, Nathan Mirman, Giovanni Petrucciani, Philip Harris, Robert Schoefbeck, and other members of the MET group, developers of MiniAOD and CMSSW, facilitators and organizers of CMSDAS, and members of the Bristol CMS group

### Introduction

How can we measure particles that hardly ever interact with a detector material? For example, if particles don't interact with the electromagnetic or strong force, they don't ionize or excite atoms or collide with atomic nuclei, leaving no sign of their passage that we can collect in the CMS detector.

Such invisible particles are produced at LHC. While neutrinos are the only invisible particles in the Standard Model, the existence of other invisible particles and their productions at LHC are predicted by many models of physics beyond the Standard Model. For instance, in supersymmetric models, if R-parity is conserved, the cascade decay of supersymmetric partners ends with the LSPs (lightest supersymmetric particles), which are often invisible particles, i.e., neutralinos. As another example, if WIMPs (weakly interacting massive particles) are dark matter and are produced at LHC, they will be stable and won't interact with the CMS detector; they will be invisible particles. Therefore, if we can somehow measure invisible particles, it will enhance the precision of our measurements and the sensitivity of our searches in many physics analyses at CMS.

Missing transverse momentum (MET) is what we use to infer the presence of invisible particles or even to estimate their transverse momentum. MET is the imbalance in the transverse momentum of all visible particles. It is a physics object that is demanding to reconstruct. The accurate reconstruction of MET requires that we use only and all visible particles produced in the collision and that we measure their transverse momenta accurately. Furthermore, it will be more and more challenging as the number of pile-up interactions increases.

This short exercise is an introduction to MET in CMS. It covers the basics of MET reconstruction, MET corrections, MET significance in CMS, including how to access and use MET in CMSSW.

#### Lecture Slides

This short exercise includes an introductory lecture on missing transverse momentum (MET). The lecture slides can be found at the Indico contribution page at:

### Exercise 1: Check out CMSSW

##### Computing Environment

The instructions to set up the computing environment at Bari can be found at:

##### CMSSW Environment

You need to move to a directory in which you would like to practice this exercise.

mkdir -p ~/your/work/dir
cd ~/your/work/dir


Please replace ~/your/work/dir with a path to the directory of your choice.

This exercise uses CMSSW_7_2_3. Choose a relevant architecture for this version of CMSSW by setting the environmental variable SCRAM_ARCH:

export SCRAM_ARCH=slc6_amd64_gcc481


Then, you can check out CMSSW.

scramv1 project CMSSW CMSSW_7_2_3


Move down two directories and enter the CMSSW runtime environment:

cd CMSSW_7_2_3/src
cmsenv


##### MET Recipe

In order to work out this exercise, you need to check out several extra files from github repositories.

A git environment needs to be properly set up in order to be able to check out files from github repositories. The instructions to set up are linked from the pre-exercise SWGuideCMSDataAnalysisSchoolPreExerciseFirstSet

If you are using cmsdas0*.ba.infn.it, set the environmental variable CMSSW_GIT_REFERENCE:

export CMSSW_GIT_REFERENCE=/data/shared/git-cmssw-mirror


The above command is specific to cmsdas0*.ba.infn.it. This command is unnecessary at lxplus.cern.ch.

Then, check out the extra files with the following commands:

git-cms-merge-topic -u cms-met:72X-met-150118-01


The above command is specific to CMSSW_7_2_3. The commands for different versions of CMSSW are listed as MET recipes at

##### Build

Now, you can build with the scram command:

scram build -j 9


##### Exercise files

This exercise uses files in the branch cmsdas_2015_jan_bari at the github repo cms-met/WorkBookMet:

Clone this repo to your local directory.

git clone --branch cmsdas_2015_jan_bari git@github.com:cms-met/WorkBookMet


If the above command doesn't work, try instead

git clone --branch cmsdas_2015_jan_bari https://github.com/cms-met/WorkBookMet.git


### Exercise 2: Explore datasets

##### Sample MiniAOD files

This exercise uses two sample MiniAOD files and one sample RECO file stored at cmsdas0*.ba.infn.it.

106M	/data/shared/Short_Exercise_MET/QCD_Pt-15to30_MINIAODSIM_PHYS14_numEvent5000.root
173M	/data/shared/Short_Exercise_MET/TTJets_MINIAODSIM_PHYS14_numEvent5000.root
86M	/data/shared/Short_Exercise_MET/MET_Run2012C_RECO_run200491_numEvent12.root


These files are also stored in /afs/cern.ch/cms/Tutorials/TWIKI_DATA/MET.

We will primarily use the 1st and 2nd files in this exercise. We will use the 3rd file only at the last part of this exercise.

The 1st file contains 5000 MC simulated events from /QCD_Pt-15to30_Tune4C_13TeV_pythia8/Phys14DR-PU20bx25_trkalmb_castor_PHYS14_25_V1-v1/MINIAODSIM (DAS).

The 2nd file contains 5000 MC simulated events from /TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola/Phys14DR-PU20bx25_PHYS14_25_V1-v1/MINIAODSIM (DAS).

The 3rd file contains 12 events in the run 200491 in Run2012C, which were certified (json), and which were stored in /MET/Run2012C-22Jan2013-v1/RECO (DAS).

These are the commands used to create the 1st and 2nd files:
cmsrel CMSSW_7_2_3_patch1
cd CMSSW_7_2_3_patch1/src
cmsenv
edmCopyPickMerge \
outputFile=TTJets_MINIAODSIM_PHYS14 \
maxEvents=5000
edmCopyPickMerge \
inputFiles=/store/mc/Phys14DR/QCD_Pt-15to30_Tune4C_13TeV_pythia8/MINIAODSIM/PU20bx25_trkalmb_castor_PHYS14_25_V1-v1/00000/729D935A-0675-E411-AB4D-002590A83190.root \
outputFile=QCD_Pt-15to30_MINIAODSIM_PHYS14 \
maxEvents=5000


These are the commands used to create the 3rd file:

cmsrel CMSSW_5_3_23_patch1
cd CMSSW_5_3_23_patch1/src
cmsenv
curl -k https://cmsweb.cern.ch/das/cli > das_client.py
chmod a+x das_client.py
./das_client.py --query='file dataset=/MET/Run2012C-22Jan2013-v1/RECO run=200491' --limit=0 | sed 's#^$$.*$$$#\1,#' | tr -d "\n" | sed 's/,$//' > inputFiles_RECO.txt
edmCopyPickMerge \
inputFiles=cat inputFiles_RECO.txt \
eventsToProcess=200491:414:546863289,200491:96:64746350,200491:376:496003201,200491:282:362700364,200491:180:205080346,200491:183:211163363,200491:183:210482899,200491:185:213100974,200491:187:217419122,200491:329:429671465,200491:220:268247998,200491:395:520922689 \
outputFile=MET_Run2012C_RECO_run200491.root
mv MET_Run2012C_RECO_run200491.root MET_Run2012C_RECO_run200491_numEvent12.root


##### Exercises

The 1st and 2nd files are MC samples in MiniAOD from PHYS14.

• What is MiniAOD?
• What is PHYS14?
• What processes (interactions) were generated in each file?
• What generators were used?
• What PDFs (parton density functions) were used?
• How were fragmentation and hadronization simulated?
• How was the detector response simulated?
• What versions of CMSSW were used in generating events?
• What versions of CMSSW were used in reconstructing events?
• How do you locate the data?
• Are the data currently stored in Bari?

The 3rd file contains data in RECO collected in the run 200491.

• What is RECO?
• What version of CMSSW was used in reconstructing events?
• Are the data currently stored in Bari?

• Find answers to the following questions about the run by using CMS web services: CADI, iCMS, TWiki, DAS, WBM, DocDB, LXR, HLT Config Browser.
• When were the data collected?
• What was the HLT key used in the run?
• Which version of HLT_MET120_* was used? (What was '*' in the HLT path in this run?)
• What were the pre-scale columns for this HLT path?
• Which pre-scale column was actually used?
• Which PD is the data triggered by this HLT path stored?
• Can you find the answers to above questions by the command line?

Find the name of MET objects in MiniAOD with edmDumpEventContent.

edmDumpEventContent /data/shared/Short_Exercise_MET/TTJets_MINIAODSIM_PHYS14_numEvent5000.root


This will print the contents of the file.

Type                                  Module                      Label             Process
----------------------------------------------------------------------------------------------
⋮
vector<pat::MET>                      "slimmedMETs"               ""                "PAT"
⋮


The ellipses (⋮) indicate that several output lines are omitted. The slimmedMETs is the only MET product in the MiniAOD file . The slimmedMETs contains values for several MET objects.

We will use the python script:

This script uses FWLite.Python, introduced at WorkBookFWLitePython.

We will use this script to access slimmedMETs in the PHYS14 MiniAOD sample file introduced above:

Execute the script:

./WorkBookMet/printMet_MiniAOD.py --inputPath=/data/shared/Short_Exercise_MET/TTJets_MINIAODSIM_PHYS14_numEvent5000.root


The script will print event contents as follows:

   run       lumi     event   nPU  nVtx                    object     met.pt     met.px     met.py    met.phi
1     823846  82384507    23    17            "Type-I PFMET"     21.132      9.787     18.729     62.411
1     823846  82384507    23    17    "Type-I Smeared PFMET"     23.336     10.288     20.945     63.840
1     823846  82384507    23    17               "Raw PFMET"     20.966     10.952     17.879     58.511
1     823846  82384507    23    17                  "GenMET"     14.992      8.388     12.426     55.981
1     823846  82384512    21    17            "Type-I PFMET"     61.145     11.658     60.024     79.009
1     823846  82384512    21    17    "Type-I Smeared PFMET"     60.901     12.100     59.687     78.540
1     823846  82384512    21    17               "Raw PFMET"     64.810     17.647     62.361     74.199
1     823846  82384512    21    17                  "GenMET"     28.124     21.386     18.265     40.498
1     823846  82384514    15    13            "Type-I PFMET"     51.616     17.072     48.711     70.686
1     823846  82384514    15    13    "Type-I Smeared PFMET"     49.844     16.896     46.893     70.186
1     823846  82384514    15    13               "Raw PFMET"     52.383     21.542     47.748     65.717
1     823846  82384514    15    13                  "GenMET"    118.588    -13.843    117.777     96.704
⋮


• run, lumi, event are the run number, the luminosity section, and the event id.
• nPU is the number of the in-time pile-up interactions mixed in the event (MC only).
• nVtx is the number of the reconstructed vertices in the event.
• object specifies the MET object
• met.pt is the magnitude of MET. MET is, in principle, a vector on the px-py plane. However, we often casually call its magnitude MET as well.
• met.px, met.py are the x and y components of MET respectively.
• met.phi is the azimuth of MET.

##### Exercises

The above script printed four types of MET objects: Type-I PFMET, Type-I Smeared PFMET, Raw PFMET, GenMET.

• How each of these MET objects is defined?
• What other MET objects have been used or developed in CMS?

Copy WorkBookMet/printMet_MiniAOD.py as WorkBookMet/histMet_MiniAOD.py

cp WorkBookMet/printMet_MiniAOD.py WorkBookMet/histMet_MiniAOD.py

Then modify WorkBookMet/histMet_MiniAOD.py to make histograms of met.px, met.py, and met.pt of "Type-I PFMET" and "GenMET".

• Why are they distributed in the way they are?
• What are possible distribution functions?
• Do met.px, met.py have Gaussian with the mean zero and the same variance? If so, what will be the distribution for met.pt?

The following code snippets might help to create the histograms.

To create a file in python

outFile = ROOT.TFile('filename.root', 'RECREATE')


To create a histogram in python

hist = ROOT.TH1D("hist_name", "hist_title", 80, -40, 40)


To fill a histogram

hist.Fill(value)


To save the histogram in the file and close the file

outFile.Write()
outFile.Close()


### Exercise 4: Construct extra MET objects from MiniAOD

We will run cmsRun with the configuration file

on MiniAOD files and produce extra MET objects, i.e., MVA PF MET and the MET significance.

This configuration requires the branch cms-met:72X-met-150118-01, which we checked out in Exercise 1.

cmsRun ./WorkBookMet/extraMet_cfg.py inputFiles=file:/data/shared/Short_Exercise_MET/QCD_Pt-15to30_MINIAODSIM_PHYS14_numEvent5000.root outputFile=extMet_QCD.root
cmsRun ./WorkBookMet/extraMet_cfg.py inputFiles=file:/data/shared/Short_Exercise_MET/TTJets_MINIAODSIM_PHYS14_numEvent5000.root outputFile=extMet_TTJets.root


These commands will produce two files.

extMet_QCD.root
extMet_TTJets.root


The contents of the files can be checked with edmDumpEventContent.

edmDumpEventContent extMet_TTJets.root


This will print:

Type                           Module                      Label             Process
----------------------------------------------------------------------------------------
edm::TriggerResults            "TriggerResults"            ""                "PAT"
vector<pat::MET>               "slimmedMETs"               ""                "PAT"
vector<reco::Vertex>           "offlineSlimmedPrimaryVertices"   ""                "PAT"
double                         "METSignificance"           "CovarianceMatrix00"   "EXTMET"
double                         "METSignificance"           "CovarianceMatrix01"   "EXTMET"
double                         "METSignificance"           "CovarianceMatrix10"   "EXTMET"
double                         "METSignificance"           "CovarianceMatrix11"   "EXTMET"
double                         "METSignificance"           "METSignificance"   "EXTMET"
vector<reco::PFMET>            "pfMVAMEt"                  ""                "EXTMET"


##### Exercises

Edit WorkBookMet/printMet_MiniAOD.py and uncomment several lines to print MVA PF MET.

./WorkBookMet/printMet_MiniAOD.py --inputPath=extMet_TTJets.root


### Exercise 5: Look at MET in pile-up

##### Exercises

In the Exercises in Exercise 3, we created WorkBookMet/histMet_MiniAOD.py and made histograms of met.px, met.py, and met.pt. Here we study how these distributions change with the number of the pile-up interactions.

• Modify WorkBookMet/histMet_MiniAOD.py further and make the same histograms of met.px, met.py, and met.pt for each of the four different ranges of the number of the reconstructed vertices, [1, 15], [16, 17], [18, 20], and [21, ∞], for each of the two files, extMet_QCD.root, extMet_TTJets.root.

### Exercise 6: Look at MET significance

The script WorkBookMet/printMetSig.py will print the MET significance.

./WorkBookMet/printMetSig.py --inputPath=extMet_TTJets.root


This will print:

   run       lumi     event   nPU  nVtx          S    pfMetT1     genMet
1     823846  82384507    23    17      1.462     21.132     14.992
1     823846  82384512    21    17      9.539     61.145     28.124
1     823846  82384514    15    13      4.182     51.616    118.588
1     823846  82384517    19    13     41.777    148.652    152.350
1     823846  82384520    21    13     12.626     65.936      0.000
1     823846  82384521    20    17     13.799     69.760     69.746
1     823846  82384535    19    12     27.189     97.511    109.380
1     823846  82384555    22    17      0.826     20.565      0.957
1     823846  82384561    12    12      7.810     47.977     46.415
1     823846  82384563    19    19      0.510     17.077      0.000
⋮


##### Exercises

• Plot histograms of the MET significance for each of the two files: extMet_QCD.root, extMet_TTJets.root

• Plot histograms of CHI22(S), where S is the MET significance and CHI22(x) is the cumulative distribution function of the chi-square distribution with 2 degrees of freedom.
• When S has the chi-square distribution with 2 degrees of freedom, CHI22(S) is the probability integral transformation. How is CHI22(S) distributed?

The result of each MET filter is stored in MiniAOD. Here, we will see an example of how to access to those results.

This script shows how many events passed each filter. You can run it as follows.

./WorkBookMet/printMetFilters_MiniAOD.py --inputPath=/data/shared/Short_Exercise_MET/TTJets_MINIAODSIM_PHYS14_numEvent5000.root


It will print the following table:

                                  filter     n
Flag_CSCTightHaloFilter  4921
Flag_HBHENoiseFilter  3019
Flag_METFilters  2415
Flag_ecalLaserCorrFilter  4994
Flag_goodVertices  5000
Flag_hcalLaserEventFilter  5000
Flag_trackingFailureFilter  5000
Flag_trkPOGFilters  3967
Flag_trkPOG_logErrorTooManyClusters  5000
Flag_trkPOG_manystripclus53X  3967
Flag_trkPOG_toomanystripclus53X  4420


Note: The MET filters used in the MiniAOD files used in this exercise are not optimal. They were optimized for Run-1 data. When the MET filters are optimized, they will reject no or a very few MC events.

### Exercise 8: Scan high MET events with Fireworks

We will look at high MET events with the event display Fireworks.

PHYS14 samples are all MC events, in which the causes of false MET have not been explicitly simulated. To look at false MET events, we will use the data collected in Run-1.

In order to look at Run-1 data, we will need to use a different version of CMSSW. We will use CMSSW_5_3_24, the most recent version of CMSSW_5_3.

Open new shell and go to your work dir that you created at the beginning of this exercise.

cd ~/your/work/dir


We will need to use a different architecture.

export SCRAM_ARCH=slc6_amd64_gcc472


Checkout CMSSW_5_3_24 and enter the environment.

scramv1 project CMSSW CMSSW_5_3_24
cd CMSSW_5_3_24/src
cmsenv


Check out the exercise files.

git clone --branch cmsdas_2015_jan_bari git@github.com:cms-met/WorkBookMet


Start Fireworks:

cmsShow -c WorkBookMet/met_scan_42X.fwc /data/shared/Short_Exercise_MET/MET_Run2012C_RECO_run200491_numEvent12.root


-- TaiSakuma - 2014-12-01

Topic attachments
I Attachment History Action Size Date Who Comment
png met_schematic_800.png r1 manage 31.4 K 2014-12-02 - 20:48 TaiSakuma
Topic revision: r25 - 2015-01-22 - TaiSakuma

Create a LeftBar

 Cern Search TWiki Search Google Search CMSPublic All webs
Copyright &© 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