Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
alefisico committed Dec 19, 2023
1 parent 7c543a0 commit 2ecc9f2
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 98 deletions.
117 changes: 20 additions & 97 deletions _episodes/01-jets101.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ exercises: 0
questions:
- "What is a jet?"
- "Are there different types of jets? What is a recluster algorithm?"
- "What is the basic jet quality criteria?"
objectives:
- "Learn about jets, their properties, types and reclustering algorithms."
- "Learn about the difference between gen, calo, pfjet."
- "Learn about about the basic jet quality criteria."
keypoints:
- "Jet is a physical object which represents hadronic showers that interact with our detectors. A jet is usually associated with the physical representation of quark and gluons, but they can be more than that depending of their origin and the algorithm used to define them."
- "A jet is defined by its reclustering algorithm and their constituents. In current experiments, jets are reclusted using the anti-kt algorithm. Depending on their constituents, in CMS, we called jets reclustered from genparticles as GenJets, from calorimeter clusters as CaloJets, and from particle flow candidates as PFJets."
- "The so-called jetID is the basic jet quality criteria to remove fake jets."
---

Full set of intro slides: Slides 1-24 (FIXME)
Expand Down Expand Up @@ -147,7 +144,7 @@ You can also read these excellent overviews of jet substructure techniques:
## Jet types and algorithms in CMS
The standard jet algorithms are all implemented in the CMS reconstruction software, [CMSSW](github.com/cms-sw/cmssw). However, a few algorithms with specific parameters (namely AK4, AK8, and CA15) have become standard tools in CMS; these jet types are extensively studied by the JetMET POG, and are highly recommended. These algorithms are included in the centrally produced CMS samples, at the AOD, miniAOD, and nanoAOD data tiers (note that miniAOD and nanoAOD are most commonly used for analysis, while AOD is much less common these days, and is not widely available on the grid). Other algorithms can be implemented and tested using the **JetToolbox** (discussed later in the tutorial).
The standard jet algorithms are all implemented in the CMS reconstruction software, [CMSSW](github.com/cms-sw/cmssw). However, a few algorithms with specific parameters (namely AK4, AK8, and CA15) have become standard tools in CMS; these jet types are extensively studied by the JetMET POG, and are highly recommended. These algorithms are included in the centrally produced CMS samples, at the AOD, miniAOD, and nanoAOD data tiers (note that miniAOD and nanoAOD are most commonly used for analysis, while AOD is much less common these days, and is not widely available on the grid). Other algorithms can be implemented and tested using the **JetToolbox** (more in the [following link](https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetToolbox)).
In this part of the tutorial, you will learn how to access the jet collection included in the CMS datasets, do some comparisons of the different jet types, and how to create your own collections.
Expand All @@ -170,113 +167,39 @@ There are three main jet collections stored in the MiniAOD format, as described
* Access to softdrop subjets
* Access to the associated AK8 CHS jet four momentum, including softdrop and pruned mass, and n-subjettiness.
> ## Examples of how to access jet collections in miniAOD samples
> ## Examples of how to access jet collections in miniAOD samples
> Below are two examples of how to access jet collections from these samples. This exercise does not intend for you to modify code in order to access these collections, but rather for you to look at the code and get an idea about how you could access this information if needed.
>
> ### In C++
> Please take a look at the file `$CMSSW_BASE/src/Analysis/JMEDAS/src/jmedas_miniAODAnalyzer.C` with your favourite code viewer.
> You can run this code by using the python config file `$CMSSW_BASE/src/Analysis/JMEDAS/scripts/jmedas_miniAODtest.py` from your terminal. This script will only print out some information about the jets in that sample. Again, the most important part of this exercise is to get familiar with how to access jet collections from miniAOD. Take a good look at the prints this script produces to your terminal.
> Please take a look at the file [`jmedas_miniAODAnalyzer.C`](https://github.com/cms-jet/JMEDAS/blob/DASJan2023/src/jmedas_miniAODAnalyzer.C) with your favourite code viewer.
> You can run this code by using the python config file [`jmedas_miniAODtest.py`](https://github.com/cms-jet/JMEDAS/blob/DASJan2023/scripts/jmedas_miniAODtest.py) from your terminal once you have set a CMSSW environment and download this JMEDAS package. This script will only print out some information about the jets in that sample. Again, the most important part of this exercise is to get familiar with how to access jet collections from miniAOD. Take a good look at the prints this script produces to your terminal.
> ~~~
> cmsRun $CMSSW_BASE/src/Analysis/JMEDAS/scripts/jmedas_miniAODtest.py
> ~~~
> {: .language-bash}
>
> ### In Python
>
> Now take a look at the file [`jmedas_miniAODtest_purePython.py`](https://github.com/cms-jet/JMEDAS/blob/DASJan2023/scripts/jmedas_miniAODtest_purePython.py).
> This code can be run with simple python in your terminal. Similar as in the case for C++, the output of this job is some information about jets. The most important part of the exercise is to get familiar with how to access jet collections using python from miniAOD.
> ~~~
> python $CMSSW_BASE/src/Analysis/JMEDAS/scripts/jmedas_miniAODtest_purePython.py
> ~~~
> {: .language-bash}
>
{: .solution}
### NanoAOD
In nanoAOD, only AK4 CHS jets ( _Jet_ ) and AK8 PUPPI jets ( _FatJet_ ) are stored in Run 2. For Run 3, AK4 and AK8 jets are PUPPI jets. The jets in nanoAOD are similar to those in miniAOD, but not identical (for example, the $p_{\mathrm{T}}$ cuts might be different). A full set of variables for each jet collection can be found in this [website](https://cms-nanoaod-integration.web.cern.ch/autoDoc/NanoAODv9/2018UL/doc_TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8_RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1.html).
NanoAOD is a "flat tree" format, meaning that you can access the information directly with simple ROOT, or even simple python tools (like numpy or pandas). This format is the recommended format for analyses in CMS, unless one needs to access other variables not stored in nanoAOD. _This tutorial will only use nanoAOD files._
> ## Note
> There are several advanced tools on the market which allow you to do sophisticated analysis using nanoAOD format, including [RDataFrame](https://root.cern/doc/master/classROOT_1_1RDataFrame.html), [NanoAOD-tools](https://github.com/cms-nanoAOD/nanoAOD-tools), or [Coffea](https://github.com/CoffeaTeam/coffea). We excourage you to look at them and use the one you like the most. However, we are going to use coffea for this tutorial.
{: .callout}
## Jet ID
In order to avoid using fake jets, which can originate from a hot calorimeter cell or electronic read-out box, we need to require some basic quality criteria for jets. These criteria are collectively called "jet ID". Details on the jet ID for PFJets can be found in the following twiki:
[https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetID](https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetID)
The JetMET POG recommends a single jet ID for most physics analysess in CMS, which corresponds to what used to be called the tight Jet ID. Some important observations from the above twiki:
- Jet ID is defined for uncorrected jets only. Never apply jet ID on corrected jets. This means that in your analysis you should apply jet ID first, and then apply JECs on those jets that pass jet ID.
- Jet ID is fully efficient (>99%) for real, high-$p_{\mathrm{T}}$ jets used in most physics analysis. Its background rejection power is similarly high.
> ## Open a notebook
>
> For this part open the notebook called `Jet_Types_and_Algorithms.ipynb` and run the Exercise 3.
{: .checklist}
In nanoAOD is trivial to apply jetID. They are stored as Flags, where `events.Jet.jetId>=2` corresponds to *tightID* and `events.Jet.jetId>=6` corresponds to *tightLepVetoID*.
If you want to know how this flags are stored in nanoAOD, the next block shows the implementation in
C++ from a miniAOD file:
> ## Implementation in c++
> There are several ways to apply jet ID. In our above exercises, we have run the cuts "on-the-fly" in our python FWLite macro (the first option here). Others are listed for your convenience.
>
> The following examples use somewhat out of date numbers. See the above link to the JetID twiki for the current numbers.
>
> To apply the cuts on pat::Jet (like in miniAOD) in python then you can do :
>
> ~~~
> # Apply jet ID to uncorrected jet
> nhf = jet.neutralHadronEnergy() / uncorrJet.E()
> nef = jet.neutralEmEnergy() / uncorrJet.E()
> chf = jet.chargedHadronEnergy() / uncorrJet.E()
> cef = jet.chargedEmEnergy() / uncorrJet.E()
> nconstituents = jet.numberOfDaughters()
> nch = jet.chargedMultiplicity()
> goodJet = \
> nhf < 0.99 and \
> nef < 0.99 and \
> chf > 0.00 and \
> cef < 0.99 and \
> nconstituents > 1 and \
> nch > 0
> ~~~
> {: .code}
>
> To apply the cuts on pat::Jet (like in miniAOD) in C++ then you can do:
>
> ~~~
> // Apply jet ID to uncorrected jet
> double nhf = jet.neutralHadronEnergy() / uncorrJet.E();
> double nef = jet.neutralEmEnergy() / uncorrJet.E();
> double chf = jet.chargedHadronEnergy() / uncorrJet.E();
> double cef = jet.chargedEmEnergy() / uncorrJet.E();
> int nconstituents = jet.numberOfDaughters();
> int nch = jet.chargedMultiplicity();
> bool goodJet =
> nhf < 0.99 &&
> nef < 0.99 &&
> chf > 0.00 &&
> cef < 0.99 &&
> nconstituents > 1 &&
> nch > 0;
> ~~~
> {: .code}
>
> To create selected jets in cmsRun:
> ~~~
> from PhysicsTools.SelectorUtils.pfJetIDSelector_cfi import pfJetIDSelector
> process.tightPatJetsPFlow = cms.EDFilter("PFJetIDSelectionFunctorFilter",
> filterParams = pfJetIDSelector.clone(quality=cms.string("TIGHT")),
> src = cms.InputTag("slimmedJets")
> )
> ~~~
> {: .code}
>
> It is also possible to use the `PFJetIDSelectionFunctor` C++ selector (actually, either in C++ or python), but this was primarily developed in the days before PF when applying CaloJet ID was not possible very easily. Nevertheless, the functionality of more complicated selection still exists for PFJets, but is almost never used other than the few lines above. If you would still like to use that C++ class, it is documented as an example here.
{: .solution}
> ## Discussion 1.4
>
> What do the jets with jetId represent? Were you expecting more or less jets with jetId==0?
{: .discussion}
{% include links.md %}
90 changes: 89 additions & 1 deletion _episodes/02-Pileup.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
title: "Pileup"
title: "Pileup and jetID"
teaching: 0
exercises: 0
questions:
- "What is pileup and how does it afffect to jets?"
- "What is the basic jet quality criteria?"
objectives:
- "Learn about the pileup mitigation techniques used at CMS."
- "Learn about about the basic jet quality criteria."
keypoints:
- "First key point. Brief Answer to questions. (FIXME)"
- "The so-called jetID is the basic jet quality criteria to remove fake jets."
---

Full set of intro slides: Slides 30-44 (FIXME)
Expand Down Expand Up @@ -74,5 +77,90 @@ There are 12 interactions before and 3 after.
(FIXME)
## Jet ID
In order to avoid using fake jets, which can originate from a hot calorimeter cell or electronic read-out box, we need to require some basic quality criteria for jets. These criteria are collectively called "jet ID". Details on the jet ID for PFJets can be found in the following twiki:
[https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetID](https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetID)
The JetMET POG recommends a single jet ID for most physics analysess in CMS, which corresponds to what used to be called the tight Jet ID. Some important observations from the above twiki:
- Jet ID is defined for uncorrected jets only. Never apply jet ID on corrected jets. This means that in your analysis you should apply jet ID first, and then apply JECs on those jets that pass jet ID.
- Jet ID is fully efficient (>99%) for real, high-$p_{\mathrm{T}}$ jets used in most physics analysis. Its background rejection power is similarly high.
> ## Open a notebook
>
> For this part open the notebook called `Jet_Types_and_Algorithms.ipynb` and run the Exercise 3.
{: .checklist}
In nanoAOD is trivial to apply jetID. They are stored as Flags, where `events.Jet.jetId>=2` corresponds to *tightID* and `events.Jet.jetId>=6` corresponds to *tightLepVetoID*.
If you want to know how this flags are stored in nanoAOD, the next block shows the implementation in
C++ from a miniAOD file:
> ## Implementation in c++
> There are several ways to apply jet ID. In our above exercises, we have run the cuts "on-the-fly" in our python FWLite macro (the first option here). Others are listed for your convenience.
>
> The following examples use somewhat out of date numbers. See the above link to the JetID twiki for the current numbers.
>
> To apply the cuts on pat::Jet (like in miniAOD) in python then you can do :
>
> ~~~
> # Apply jet ID to uncorrected jet
> nhf = jet.neutralHadronEnergy() / uncorrJet.E()
> nef = jet.neutralEmEnergy() / uncorrJet.E()
> chf = jet.chargedHadronEnergy() / uncorrJet.E()
> cef = jet.chargedEmEnergy() / uncorrJet.E()
> nconstituents = jet.numberOfDaughters()
> nch = jet.chargedMultiplicity()
> goodJet = \
> nhf < 0.99 and \
> nef < 0.99 and \
> chf > 0.00 and \
> cef < 0.99 and \
> nconstituents > 1 and \
> nch > 0
> ~~~
> {: .code}
>
> To apply the cuts on pat::Jet (like in miniAOD) in C++ then you can do:
>
> ~~~
> // Apply jet ID to uncorrected jet
> double nhf = jet.neutralHadronEnergy() / uncorrJet.E();
> double nef = jet.neutralEmEnergy() / uncorrJet.E();
> double chf = jet.chargedHadronEnergy() / uncorrJet.E();
> double cef = jet.chargedEmEnergy() / uncorrJet.E();
> int nconstituents = jet.numberOfDaughters();
> int nch = jet.chargedMultiplicity();
> bool goodJet =
> nhf < 0.99 &&
> nef < 0.99 &&
> chf > 0.00 &&
> cef < 0.99 &&
> nconstituents > 1 &&
> nch > 0;
> ~~~
> {: .code}
>
> To create selected jets in cmsRun:
> ~~~
> from PhysicsTools.SelectorUtils.pfJetIDSelector_cfi import pfJetIDSelector
> process.tightPatJetsPFlow = cms.EDFilter("PFJetIDSelectionFunctorFilter",
> filterParams = pfJetIDSelector.clone(quality=cms.string("TIGHT")),
> src = cms.InputTag("slimmedJets")
> )
> ~~~
> {: .code}
>
> It is also possible to use the `PFJetIDSelectionFunctor` C++ selector (actually, either in C++ or python), but this was primarily developed in the days before PF when applying CaloJet ID was not possible very easily. Nevertheless, the functionality of more complicated selection still exists for PFJets, but is almost never used other than the few lines above. If you would still like to use that C++ class, it is documented as an example here.
{: .solution}
> ## Discussion 1.4
>
> What do the jets with jetId represent? Were you expecting more or less jets with jetId==0?
{: .discussion}
{% include links.md %}

0 comments on commit 2ecc9f2

Please sign in to comment.