Difference: SWGuidePATTriggerMatchExercise (61 vs. 62)

Revision 622014-07-03 - TaeJeongKim

Line: 1 to 1
 
META TOPICPARENT name="WorkBookPATTutorial"

PAT Exercise 11: How to produce PAT trigger matches and use them in analysis

Line: 67 to 67
 
<!--/twistyPlugin twikiMakeVisibleInline-->
Changed:
<
<
%SYNTAX{ syntax="python"}%### ====
>
>
%SYNTAX{ syntax="python"}% ### ====
 ### Skeleton ### ====
Line: 76 to 77
 ## --- from PatAlgos.patTemplate_cfg import *
Added:
>
>
## switch to uncheduled mode process.options.allowUnscheduled = cms.untracked.bool(True) #process.Tracer = cms.Service("Tracer")

process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff") process.load("PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff")

 ## --- ## Modifications ## --- # general
Changed:
<
<
from PatAlgos.tools.cmsswVersionTools import pickRelValInputFiles process.source.fileNames = pickRelValInputFiles( cmsswVersion = 'CMSSW_5_3_6' , relVal = 'RelValProdTTbar' , globalTag = 'START53_V14' , dataTier = 'AODSIM' , maxVersions = 2 , numberOfFiles = -1 ) process.maxEvents.input = -1 # reduce number of events for testing.
>
>
# input files. Let's use Z to mumu sample process.source.fileNames = ["/store/relval/CMSSW_7_1_0/RelValZMM_13/GEN-SIM-RECO/POSTLS171_V15-v1/00000/6650F961-99FB-E311-BA90-0025905A48BC.root"] process.maxEvents.input = 1000 # reduce number of events for testing.
 process.options.wantSummary = False # to suppress the long output at the end of the job # specific process.selectedPatMuons.cut = 'isGlobalMuon && pt > 20. && abs(eta) < 2.1 && globalTrack.normalizedChi2 < 10. && track.hitPattern.trackerLayersWithMeasurement > 5 && globalTrack.hitPattern.numberOfValidMuonHits > 0 && abs(dB) < 0.2 && innerTrack.hitPattern.numberOfValidPixelHits > 0 && numberOfMatchedStations > 1 && (trackIso+caloIso)/pt<0.2'
Changed:
<
<
>
>
## no need to define the path in the unscheduled mode. comment out below lines
 ## --- ## Define the path ## ---
Changed:
<
<
process.p = cms.Path( process.patDefaultSequence )%ENDSYNTAX%
>
>
## ## process.p = cms.Path( ## process.patDefaultSequence ## )%ENDSYNTAX%
  ALERT! As you see we use the patDefaultSequence from the patTemplate_cfg file. For the selectedPatMuons we apply a "tight muon ID" selection additionally to the kinematic cuts:
  • The muon should be both a global muon.
Line: 120 to 123
  # matching in DeltaR, sorting by best DeltaR "PATTriggerMatcherDRLessByR" # matcher input collections
Changed:
<
<
, src = cms.InputTag( 'cleanPatMuons' )
>
>
, src = cms.InputTag( 'selectedPatMuons' )
 , matched = cms.InputTag( 'patTrigger' ) # selections of trigger objects , matchedCuts = cms.string( 'type( "TriggerMuon" ) && path( "HLT_IsoMu24_eta2p1_v*" )' )
Line: 133 to 136
 , resolveByMatchQuality = cms.bool( True ) )%ENDSYNTAX%
Changed:
<
<
The offline reconstructed objects we want to match the trigger objects to are the cleanPatMuon candidates at this point in the configuration. The trigger objects are stored in the patTrigger object, that will be created beforehand in the patTriggerSequence. Note that the patTrigger objects keep not much more than the information of a reco::LeafCandidate and the object ID, that indicates whether it is a muon, electron or anything else at trigger level. You can find all possible trigger object type definitions here. In our example we are obviously interested in objects of type TriggerMuon and especially in those that are part of the HLT_IsoMu24_eta2p1 trigger path.

Now we want to switch to use the selectedPatMuons instead of the cleaned ones. You can achieve this by applying the tool removeCleaning. Have a look to SWGuidePATTools to learn more about the many tools that PAT provides to facilitate the configuration of customised PAT tuples.

>
>
The offline reconstructed objects we want to match the trigger objects to are the selectedPatMuon candidates at this point in the configuration. The trigger objects are stored in the patTrigger object, that will be created beforehand in the patTriggerSequence. Note that the patTrigger objects keep not much more than the information of a reco::LeafCandidate and the object ID, that indicates whether it is a muon, electron or anything else at trigger level. You can find all possible trigger object type definitions here. In our example we are obviously interested in objects of type TriggerMuon and especially in those that are part of the HLT_IsoMu24_eta2p1 trigger path.
  %TWISTY{mode="div" showlink="Show " hidelink="Hide " firststart="hide" showimgright="/twiki/pub/TWiki/TWikiDocGraphics/toggleopen-small.gif"
Line: 146 to 147
 from PatAlgos.tools.coreTools import removeCleaning removeCleaning( process ) # to save a bit of disk space
Changed:
<
<
process.out.outputCommands += [ 'drop recoBaseTagInfosOwned_*_*_*' , 'drop CaloTowers_*_*_*' , 'drop recoGenJets_*_*_*'
>
>
process.out.outputCommands += [ 'drop *_*_*_*' ,'keep *_patTrigger*_*_*' ,'keep *_selectedPatMuons*_*_*'
  ]%ENDSYNTAX%
<!--/twistyPlugin-->

Now we switch on our trigger matching module muonTriggerMatchHLTMuons. This switch includes the complete trigger information automatically, if not done already.

Deleted:
<
<
Since the cleaning has been removed from the patDefaultSequence, we also have to remove it from thze matching by invoking the removeCleaningFromTriggerMatching tool.
  %SYNTAX{ syntax="python"}%## -- ## Switch on PAT trigger
Line: 162 to 162
 switchOnTrigger( process ) # This is optional and can be omitted. switchOnTriggerMatching( process, triggerMatchers = [ 'muonTriggerMatchHLTMuons' ] ) # Switch to selected PAT objects in the trigger matching
Changed:
<
<
removeCleaningFromTriggerMatching( process )%ENDSYNTAX%
>
>
%ENDSYNTAX%
  To learn more about the patTrigger workflow we inspect it a bit further with the python interpreter:
 
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