The following section will walk you through scheduling the muon analysis sequence, applying selection cuts, and writing them to the output ntuple. It follows the electron procedure closely, so many of the steps will not be spelled out explicitly.
Begin by scheduling the muon analysis sequence. Do this by adding
the following lines to makeSequence()
in MyAnalysisAlgorithms.py
after the GRL and pileup sequences:
# Include and set up the muon analysis sequence:
from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence
workingpoint = 'Medium.NonIso'
muonSequence = makeMuonAnalysisSequence( dataType, workingpoint, postfix = 'medium',
shallowViewOutput = False )
muonSequence.configure( inputName = 'Muons',
outputName = 'AnaMuons_%SYS%' )
# Add the muon analysis sequence to the job:
algSeq += muonSequence
This schedules the implementation of muon identification and isolation requirements, momentum corrections, and the calculation of muon scale factors and systematic uncertainties.
Now let’s apply some basic selection criteria for our muons. We want to only select muons with pT > 25 GeV without a requirement on η.
Define the following variables in MyAnalysisAlgorithms.py
:
muonMinPt = 25e3 # Minimum pt in MeV
muonMaxEta = None
Put the following lines in makeSequence()
after the electron selection
algorithm:
# Include and set up muon selection algorithm:
selAlgMu = createAlgorithm( 'CP::AsgSelectionAlg', 'UserMuonSelectionAlg' )
addPrivateTool( selAlgMu, 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
if muonMinPt is not None :
selAlgMu.selectionTool.minPt = muonMinPt
if muonMaxEta is not None :
selAlgMu.selectionTool.maxEta = muonMaxEta
selAlgMu.selectionDecoration = 'selectPtEta,as_char'
selAlgMu.particles = 'AnaMuons_%SYS%'
# Add the muon selection algorithm to the job:
algSeq += selAlgMu
Follow the steps for adding electrons to the output,
making the necessary modifications for muons. Note that you will
need to add xAODMuon
to CMakeLists.txt
and add
#include <xAODMuon/MuonContainer.h>
to MyxAODAnalysis.cxx
.
Rerun your code to ensure it is correctly implemented. When you are satisfied that it is working properly, commit and push your code changes.
If you find that the muon pT spectrum looks like every event is in the first bin except for a very small number of events at very high pT (far larger than a few hundred GeV), this is likely due to muons with incorrectly measured pT. You can ignore these when drawing the distribution with a draw command like:
analysis->Draw("mu_pt","mu_pt<300e3");
The second string is a selection string that constrains the information that is drawn. You can find more details about this approach in the ROOT documentation. Note that draw command selections are useful for quick checks like this, but are inefficient and very difficult to get right for complex analysis selections.
Try different muon working points and see how much of an effect it has on your output.