CMS 3D CMS Logo

Functions
custom_muon_cff Namespace Reference

Functions

def AddPFTracks (proc)
 
def AddTriggerObjectBits (process)
 
def AddVariablesForMuon (proc)
 
def Custom_Muon_Task (process)
 
def IncreaseGenPrecesion (process)
 
def PrepMuonCustomNanoAOD (process)
 

Function Documentation

◆ AddPFTracks()

def custom_muon_cff.AddPFTracks (   proc)

Definition at line 30 of file custom_muon_cff.py.

References common_cff.Var().

Referenced by PrepMuonCustomNanoAOD().

30 def AddPFTracks(proc):
31  pfTracks = "pfTracks"
32  setattr(proc, pfTracks, cms.EDProducer("pfTracksProducer",
33  PFCands=cms.InputTag("packedPFCandidates"),
34  lostTracks=cms.InputTag("lostTracks"),
35  TrkHPurity = cms.bool(False),
36  trkSelection = cms.string("bestTrack.pt()>5 && abs(bestTrack.eta())<2.4 "),
37  )
38  )
39 
40  pfTracksTable = "pfTracksTable"
41  setattr(proc, pfTracksTable, cms.EDProducer("SimpleTrackFlatTableProducer",
42  src = cms.InputTag("pfTracks"),
43  cut = cms.string("pt > 15"), # filtered already above
44  name = cms.string("Track"),
45  doc = cms.string("General tracks with pt > 15 GeV"),
46  singleton = cms.bool(False), # the number of entries is variable
47  extension = cms.bool(False), # this is the main table for the muons
48  variables = cms.PSet(P3Vars,
49  dz = Var("dz",float,doc="dz (with sign) wrt first PV, in cm",precision=10),
50  dxy = Var("dxy",float,doc="dxy (with sign) wrt first PV, in cm",precision=10),
51  charge = Var("charge", int, doc="electric charge"),
52  normChiSq = Var("normalizedChi2", float, precision=14, doc="Chi^2/ndof"),
53  numberOfValidHits = Var('numberOfValidHits()', 'int', precision=-1, doc='Number of valid hits in track'),
54  numberOfLostHits = Var('numberOfLostHits()', 'int', precision=-1, doc='Number of lost hits in track'),
55  trackAlgo = Var('algo()', 'int', precision=-1, doc='Track algo enum, check DataFormats/TrackReco/interface/TrackBase.h for details.'),
56  trackOriginalAlgo = Var('originalAlgo()', 'int', precision=-1, doc='Track original algo enum'),
57  qualityMask = Var('qualityMask()', 'int', precision=-1, doc='Quality mask of the track.'),
58  extraIdx = Var('extra().key()', 'int', precision=-1, doc='Index of the TrackExtra in the original collection'),
59  vx = Var('vx', 'float', precision=-1, doc='Track X position'),
60  vy = Var('vy', 'float', precision=-1, doc='Track Y position'),
61  vz = Var('vz', 'float', precision=-1, doc='Track Z position'),
62  ),
63  )
64  )
65 
66  pfTracksTask = "pfTracksTask"
67  setattr(proc,pfTracksTask, cms.Task(
68  getattr(proc,pfTracks)
69  )
70  )
71 
72  pfTracksTableTask = "pfTracksTableTask"
73  setattr(proc,pfTracksTableTask, cms.Task(
74  getattr(proc,pfTracksTable)
75  )
76  )
77  proc.nanoTableTaskCommon.add(getattr(proc,pfTracksTask))
78  proc.nanoTableTaskCommon.add(getattr(proc,pfTracksTableTask))
79 
80  return proc
81 
82 
83 
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
def AddPFTracks(proc)

◆ AddTriggerObjectBits()

def custom_muon_cff.AddTriggerObjectBits (   process)

Definition at line 285 of file custom_muon_cff.py.

References triggerObjects_cff.mksel().

Referenced by PrepMuonCustomNanoAOD().

285 def AddTriggerObjectBits(process):
286  process.triggerObjectTable.selections.Muon_POG = cms.PSet(
287  id = cms.int32(1313),
288  sel = cms.string("type(83) && pt > 5 && (coll('hltIterL3MuonCandidates') || (pt > 45 && coll('hltHighPtTkMuonCands')) || (pt > 95 && coll('hltOldL3MuonCandidates')))"),
289  l1seed = cms.string("type(-81)"), l1deltaR = cms.double(0.5),
290  l2seed = cms.string("type(83) && coll('hltL2MuonCandidates')"), l2deltaR = cms.double(0.3),
291  skipObjectsNotPassingQualityBits = cms.bool(True),
292  qualityBits = cms.VPSet(
293  mksel("filter('hltTripleMuonL2PreFiltered0')","hltTripleMuonL2PreFiltered0"), #0
294  mksel("filter('hltTripleMuL3PreFiltered222')","hltTripleMuL3PreFiltered222"), #1
295  mksel("filter('hltJpsiMuonL3Filtered3p5')","hltJpsiMuonL3Filtered3p5"), #2
296  mksel("filter('hltVertexmumuFilterJpsiMuon3p5')","hltVertexmumuFilterJpsiMuon3p5"), #3
297  mksel("filter('hltL2fL1sDoubleMu0er15OSIorDoubleMu0er14OSIorDoubleMu4OSIorDoubleMu4p5OSL1Filtered0')","hltL2fL1sDoubleMu0er15OSIorDoubleMu0er14OSIorDoubleMu4OSIorDoubleMu4p5OSL1Filtered0"), #4
298  mksel("filter('hltDoubleMu4JpsiDisplacedL3Filtered')","hltDoubleMu4JpsiDisplacedL3Filtered"), #5
299  mksel("filter('hltDisplacedmumuFilterDoubleMu4Jpsi')","hltDisplacedmumuFilterDoubleMu4Jpsi"), #6
300  mksel("filter('hltJpsiTkVertexFilter')","hltJpsiTkVertexFilter"), #7
301  mksel("filter('hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered')","hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered"), #8
302  mksel("filter('hltL3fL1DoubleMu155fPreFiltered8')","hltL3fL1DoubleMu155fPreFiltered8"), #9
303  mksel("filter('hltL3fL1DoubleMu155fFiltered17')","hltL3fL1DoubleMu155fFiltered17"), #10
304  mksel("filter('hltDiMuon178RelTrkIsoFiltered0p4')","hltDiMuon178RelTrkIsoFiltered0p4"), #11
305  mksel("filter('hltDiMuon178RelTrkIsoFiltered0p4DzFiltered0p2')","hltDiMuon178RelTrkIsoFiltered0p4DzFiltered0p2"), #12
306  mksel("filter('hltDiMuon178RelTrkIsoVVLFiltered')","hltDiMuon178RelTrkIsoVVLFiltered"), #13
307  mksel("filter('hltDiMuon178RelTrkIsoVVLFilteredDzFiltered0p2')","hltDiMuon178RelTrkIsoVVLFilteredDzFiltered0p2"), #14
308  mksel("filter('hltDiMuon178Mass3p8Filtered')","hltDiMuon178Mass3p8Filtered"), #15
309  mksel("filter('hltL3fL1sMu22Or25L1f0L2f10QL3Filtered50Q')","hltL3fL1sMu22Or25L1f0L2f10QL3Filtered50Q"), #16
310  mksel("filter('hltL2fOldL1sMu22or25L1f0L2Filtered10Q')","hltL2fOldL1sMu22or25L1f0L2Filtered10Q"), #17
311  mksel("filter('hltL3fL1sMu22Or25L1f0L2f10QL3Filtered100Q')","hltL3fL1sMu22Or25L1f0L2f10QL3Filtered100Q"), #18
312  mksel("filter('hltL3fL1sMu25f0TkFiltered100Q')","hltL3fL1sMu25f0TkFiltered100Q"), #19
313  mksel("filter('hltL3fL1sMu15DQlqL1f0L2f10L3Filtered17')","hltL3fL1sMu15DQlqL1f0L2f10L3Filtered17"), #20
314  mksel("filter('hltL3fL1sMu1lqL1f0L2f10L3Filtered17TkIsoFiltered0p4')","hltL3fL1sMu1lqL1f0L2f10L3Filtered17TkIsoFiltered0p4"), #21
315  mksel("filter('hltL3fL1sMu1lqL1f0L2f10L3Filtered17TkIsoVVLFiltered')","hltL3fL1sMu1lqL1f0L2f10L3Filtered17TkIsoVVLFiltered"), #22
316  mksel("filter('hltL3fL1sMu5L1f0L2f5L3Filtered8')","hltL3fL1sMu5L1f0L2f5L3Filtered8"), #23
317  mksel("filter('hltL3fL1sMu5L1f0L2f5L3Filtered8TkIsoFiltered0p4')","hltL3fL1sMu5L1f0L2f5L3Filtered8TkIsoFiltered0p4"), #24
318  mksel("filter('hltL3fL1sMu5L1f0L2f5L3Filtered8TkIsoVVLFiltered')","hltL3fL1sMu5L1f0L2f5L3Filtered8TkIsoVVLFiltered"), #25
319  mksel("filter('hltL3fL1sMu15DQlqL1f0L2f10L3Filtered12')","hltL3fL1sMu15DQlqL1f0L2f10L3Filtered12"), #26
320  mksel("filter('hltL3fL1sMu15DQlqL1f0L2f10L3Filtered15')","hltL3fL1sMu15DQlqL1f0L2f10L3Filtered15"), #27
321  mksel("filter('hltL3fL1sMu15DQlqL1f0L2f10L3Filtered19')","hltL3fL1sMu15DQlqL1f0L2f10L3Filtered19"), #28
322  mksel("filter('hltL3fL1sMu15DQlqL1f0L2f10L3Filtered19')","hltL3fL1sMu15DQlqL1f0L2f10L3Filtered19") #29
323  )
324  )
325 
326  process.triggerObjectTable.selections.Muon_POG_v2 = cms.PSet(
327  id = cms.int32(131313),
328  sel = cms.string("type(83) && pt > 5 && (coll('hltIterL3MuonCandidates') || (pt > 45 && coll('hltHighPtTkMuonCands')) || (pt > 95 && coll('hltOldL3MuonCandidates')))"),
329  l1seed = cms.string("type(-81)"), l1deltaR = cms.double(0.5),
330  l2seed = cms.string("type(83) && coll('hltL2MuonCandidates')"), l2deltaR = cms.double(0.3),
331  skipObjectsNotPassingQualityBits = cms.bool(True),
332  qualityBits = cms.VPSet(
333  mksel("filter('hltL3fL1sSingleMuOpenCandidateL1f0L2f3QL3Filtered50Q')","hltL3fL1sSingleMuOpenCandidateL1f0L2f3QL3Filtered50Q"), #0
334  mksel("filter('hltTrk200MuonEndcapFilter')","hltTrk200MuonEndcapFilter") #1
335  )
336  )
337 
338  return process
339 
def mksel(selection, doc=None, bit=None)
def AddTriggerObjectBits(process)

◆ AddVariablesForMuon()

def custom_muon_cff.AddVariablesForMuon (   proc)

Definition at line 84 of file custom_muon_cff.py.

References PVValHelper.add(), and common_cff.Var().

Referenced by PrepMuonCustomNanoAOD().

84 def AddVariablesForMuon(proc):
85 
86  muonWithVariables = "muonWithVariables"
87  setattr(proc, muonWithVariables, cms.EDProducer("MuonSpecialVariables",
88  muonSrc=cms.InputTag("slimmedMuons"),
89  vertexSrc=cms.InputTag("offlineSlimmedPrimaryVertices"),
90  trkSrc=cms.InputTag("pfTracks"),
91  )
92  )
93  getattr(proc,"muonTask").add(getattr(proc,muonWithVariables))
94 
95  proc.slimmedMuonsUpdated.src = cms.InputTag("muonWithVariables")
96  #proc.muonMVATTH.src = cms.InputTag("muonWithVariables")
97  #proc.muonMVALowPt.src = cms.InputTag("muonWithVariables")
98  #proc.muonTable.src = cms.InputTag("muonWithVariables")
99  #proc.muonMCTable.src = cms.InputTag("muonWithVariables")
100  #proc.muonsMCMatchForTable.src = cms.InputTag("muonWithVariables")
101 
102 
103  #SandAlone Variables
104  proc.muonTable.variables.standalonePt = Var("? standAloneMuon().isNonnull() ? standAloneMuon().pt() : -1", float, doc = "pt of the standalone muon", precision=14)
105  proc.muonTable.variables.standaloneEta = Var("? standAloneMuon().isNonnull() ? standAloneMuon().eta() : -99", float, doc = "eta of the standalone muon", precision=14)
106  proc.muonTable.variables.standalonePhi = Var("? standAloneMuon().isNonnull() ? standAloneMuon().phi() : -99", float, doc = "phi of the standalone muon", precision=14)
107  proc.muonTable.variables.standaloneCharge = Var("? standAloneMuon().isNonnull() ? standAloneMuon().charge() : -99", float, doc = "phi of the standalone muon", precision=14)
108 
109  # Inner Track Algo variables
110  proc.muonTable.variables.innerTrackAlgo = Var('? innerTrack().isNonnull() ? innerTrack().algo() : -99', 'int', precision=-1, doc='Track algo enum, check DataFormats/TrackReco/interface/TrackBase.h for details.')
111  proc.muonTable.variables.innerTrackOriginalAlgo = Var('? innerTrack().isNonnull() ? innerTrack().originalAlgo() : -99', 'int', precision=-1, doc='Track original algo enum')
112 
113  #Spark Tool Iso 03 variables
114  proc.muonTable.variables.pfAbsIso03_neu = Var("pfIsolationR03().sumNeutralHadronEt",float,doc="PF absolute isolation dR=0.3, neutral component")
115  proc.muonTable.variables.pfAbsIso03_pho = Var("pfIsolationR03().sumPhotonEt",float,doc="PF absolute isolation dR=0.3, photon component")
116  proc.muonTable.variables.pfAbsIso03_sumPU = Var("pfIsolationR03().sumPUPt",float,doc="PF absolute isolation dR=0.3, pu component (no deltaBeta corrections)")
117  proc.muonTable.variables.absTrkIso03 = Var("userFloat('absTrkiso03')",float,doc="Realtive Tracker Iso with cone size 0.3")
118 
119  # Spark Tool Iso 04 variables
120  proc.muonTable.variables.pfAbsIso04_chg = Var("pfIsolationR04().sumChargedHadronPt",float,doc="PF absolute isolation dR=0.4, charged component")
121  proc.muonTable.variables.pfAbsIso04_neu = Var("pfIsolationR04().sumNeutralHadronEt",float,doc="PF absolute isolation dR=0.4, neutral component")
122  proc.muonTable.variables.pfAbsIso04_pho = Var("pfIsolationR04().sumPhotonEt",float,doc="PF absolute isolation dR=0.4, photon component")
123  proc.muonTable.variables.pfAbsIso04_sumPU = Var("pfIsolationR04().sumPUPt",float,doc="PF absolute isolation dR=0.4, pu component (no deltaBeta corrections)")
124  proc.muonTable.variables.absTrkIso04 = Var("userFloat('absTrkiso04')",float,doc="Realtive Tracker Iso with cone size 0.4")
125 
126  #Mini PF Isolation
127  proc.muonTable.variables.miniPFAbsIso_chg = Var("userFloat('miniIsoChg')",float,doc="mini PF absolute isolation, charged component")
128  proc.muonTable.variables.miniPFAbsIso_all = Var("userFloat('miniIsoAll')",float,doc="mini PF absolute isolation, total (with scaled rho*EA PU corrections)")
129  proc.muonTable.variables.miniPFAbsIso_neu = Var("miniPFIsolation().neutralHadronIso()",float,doc="mini PF absolute isolation, neutral component")
130  proc.muonTable.variables.miniPFAbsIso_pho = Var("miniPFIsolation().photonIso()", float, doc="mini PF absolute isolation, photon component")
131 
132  # Absolute Isolations for variables already present in Standard NanoAOD as Relative Isolation
133  proc.muonTable.variables.tkAbsIso = Var("isolationR03().sumPt",float,doc="Tracker-based absolute isolation dR=0.3 for highPt, trkIso",precision=6)
134  proc.muonTable.variables.pfAbsIso03_chg = Var("pfIsolationR03().sumChargedHadronPt",float,doc="PF absolute isolation dR=0.3, charged component")
135  proc.muonTable.variables.pfAbsIso03_all = Var("(pfIsolationR03().sumChargedHadronPt + max(pfIsolationR03().sumNeutralHadronEt + pfIsolationR03().sumPhotonEt - pfIsolationR03().sumPUPt/2,0.0))",float,doc="PF absolute isolation dR=0.3, total (deltaBeta corrections)")
136  proc.muonTable.variables.pfAbsIso04_all = Var("(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))",float,doc="PF absolute isolation dR=0.4, total (deltaBeta corrections)")
137  proc.muonTable.variables.jetAbsIso = Var("?userCand('jetForLepJetVar').isNonnull()?(1./userFloat('ptRatio'))-1.:(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))",float,doc="Absolute isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)",precision=8)
138 
139  # Muon Quality Variables
140  proc.muonTable.variables.expectedMatchedStations = Var("expectedNnumberOfMatchedStations()",int,doc="Expected Number of Matched stations")
141  proc.muonTable.variables.RPCLayers = Var("numberOfMatchedRPCLayers()",int,doc="Number of RPC Layers")
142  proc.muonTable.variables.stationMask = Var("stationMask()","uint8",doc="Number of masked station")
143  proc.muonTable.variables.nShowers = Var("numberOfShowers()",int,doc="Number of Showers")
144 
145 
146 
147  # Hits related variables
148  proc.muonTable.variables.pixelLayers = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().hitPattern().pixelLayersWithMeasurement() : -99", float,doc="Number of Pixel Layers") # No of tracker layers are already saved in the standard NanoAODs
149  proc.muonTable.variables.pixelHits = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().hitPattern().numberOfValidPixelHits() : -99", float, doc="Numbr of valid pixel hits")
150  proc.muonTable.variables.muonStations = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().hitPattern().muonStationsWithValidHits() : -99", float, doc="No of valid hits in muon stations")
151  proc.muonTable.variables.DTHits = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().hitPattern().numberOfValidMuonDTHits() : -99", float, doc="No of valid hits in DT")
152  proc.muonTable.variables.CSCHits = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().hitPattern().numberOfValidMuonCSCHits() : -99", float, doc="No of valid hits in CSC")
153  proc.muonTable.variables.RPCHits = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().hitPattern().numberOfValidMuonRPCHits() : -99", float, doc="No of valid hits in RPC")
154 
155 
156 
157  # Chi2 related to different tracks
158  proc.muonTable.variables.trkChi2 = Var("? globalTrack().isNonnull() ? globalTrack().normalizedChi2() : ? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().normalizedChi2() : -99",float,doc="Normalized Chi Square from either globalTrack or innerTrack ")
159  proc.muonTable.variables.trkChi2_outerTrack = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().normalizedChi2() : -99",float,doc="Normalized Chi Square from outerTrack ")
160  proc.muonTable.variables.trkChi2_innerTrack = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().normalizedChi2() : -99",float,doc="Normalized Chi Square from outerTrack ")
161 
162 
163  #Inner Track related variables
164  proc.muonTable.variables.innerTrack_ptErr = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().ptError()/innerTrack().pt() : -99", float, doc="InnerTrack Pt Error")
165  proc.muonTable.variables.innerTrack_pt = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().pt(): -99", float, doc="InnerTrack Pt")
166  proc.muonTable.variables.innerTrack_eta = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().eta(): -99", float, doc="InnerrTrack Eta")
167  proc.muonTable.variables.innerTrack_phi = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().phi(): -99", float, doc="InnerTrack Phi")
168  proc.muonTable.variables.innerTrack_charge = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().charge(): -99", float, doc="InnerTrack charge")
169  proc.muonTable.variables.innerTrack_MuonHits = Var("? innerTrack().isNonnull() ? innerTrack().hitPattern().numberOfValidMuonHits() : -99", float, doc = "Number of valid Muon Hits from InnerTrack")
170  proc.muonTable.variables.innerTrack_validFraction = Var("? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().validFraction() : -99", float, doc="Inner Track Valid Fraction")
171 
174 
175  #Dxy Dz variables as of Spark tool
176  proc.muonTable.variables.innerTrackDxy = Var("? userInt('isGoodVertex') ? userFloat('innerTrackDxy') : -99.9",float,doc = "dxy from Primary Vertex calculated with Inner Track")
177  proc.muonTable.variables.innerTrackDz = Var("? userInt('isGoodVertex') ? userFloat('innerTrackDz') : -99.9",float,doc= "dz from Primary Vertex calculated with Inner Track")
178 
179 
180  # Outer Track related variables
181  proc.muonTable.variables.outerTrack_ptErr = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().ptError()/outerTrack().pt() : -99", float, doc="OuterTrack Pt Error")
182  proc.muonTable.variables.outerTrack_pt = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().pt(): -99", float, doc="OuterTrack Pt")
183  proc.muonTable.variables.outerTrack_eta = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().eta(): -99", float, doc="OuterTrack Eta")
184  proc.muonTable.variables.outerTrack_phi = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().phi(): -99", float, doc="OuterTrack Phi")
185  proc.muonTable.variables.outerTrack_charge = Var("? outerTrack().isNonnull() && outerTrack().isAvailable() ? outerTrack().charge(): -99", float, doc="OuterTrack charge")
186  proc.muonTable.variables.outerTrack_MuonHits = Var("? outerTrack().isNonnull() ? outerTrack().hitPattern().numberOfValidMuonHits() : -99", float, doc = "Number of valid Muon Hits from OuterTrack")
187 
189 
190  #Global track realted variables
191  proc.muonTable.variables.muonHits = Var("? globalTrack().isNonnull() ? globalTrack().hitPattern().numberOfValidMuonHits() : ? innerTrack().isNonnull() && innerTrack().isAvailable() ? innerTrack().hitPattern().numberOfValidMuonHits() :-99",float,doc="Number of valid Muon Hits from either globalTrack or innerTrack")
192  proc.muonTable.variables.globalTrack_ptErr = Var("? globalTrack().isNonnull() ? globalTrack().ptError()/globalTrack().pt() : -99", float, doc="GlobalTrack Pt Error")
193  proc.muonTable.variables.globalTrack_pt = Var("? globalTrack().isNonnull() ? globalTrack().pt(): -99", float, doc="GlobalTrack Pt")
194  proc.muonTable.variables.globalTrack_eta = Var("? globalTrack().isNonnull() ? globalTrack().eta(): -99", float, doc="GlobalTrack Eta")
195  proc.muonTable.variables.globalTrack_phi = Var("? globalTrack().isNonnull() ? globalTrack().phi(): -99", float, doc="GlobalTrack Phi")
196  proc.muonTable.variables.globalTrack_charge = Var("? globalTrack().isNonnull() ? globalTrack().charge(): -99", float, doc="GlobalTrack charge")
197 
198  #muonBestTrack related varaibles
199 
200  proc.muonTable.variables.best_pt = Var("? muonBestTrack().isNonnull() && muonBestTrack().isAvailable() ? muonBestTrack().pt(): -99", float, doc="MuonBestTrack Pt")
201  proc.muonTable.variables.best_pterr = Var("? muonBestTrack().isNonnull() && muonBestTrack().isAvailable() ? muonBestTrack().ptError() : -99", float, doc = "pTerr from MuonBestTrack")
202  proc.muonTable.variables.best_eta = Var("? muonBestTrack().isNonnull() && muonBestTrack().isAvailable() ? muonBestTrack().eta(): -99", float, doc="MuonBestrack Eta")
203  proc.muonTable.variables.best_phi = Var("? muonBestTrack().isNonnull() && muonBestTrack().isAvailable() ? muonBestTrack().phi(): -99", float, doc="MuonBestTrack Phi")
204  proc.muonTable.variables.best_charge = Var("? muonBestTrack().isNonnull() && muonBestTrack().isAvailable() ? muonBestTrack().charge(): -99", float, doc="MuonBestTrack charge")
205 
206  # TuneP related variables
207  proc.muonTable.variables.tuneP_pt = Var("? tunePMuonBestTrack().isNonnull() && tunePMuonBestTrack().isAvailable() ? tunePMuonBestTrack().pt() : -99", float, doc = "pT from tunePMuonBestTrack")
208  # tuneP_ptErr is now moved to standard NanoAODs
209  proc.muonTable.variables.tuneP_eta = Var("? tunePMuonBestTrack().isNonnull() && tunePMuonBestTrack().isAvailable() ? tunePMuonBestTrack().eta(): -99", float, doc="tunePMuonBestTrack Eta")
210  proc.muonTable.variables.tuneP_phi = Var("? tunePMuonBestTrack().isNonnull() && tunePMuonBestTrack().isAvailable() ? tunePMuonBestTrack().phi(): -99", float, doc="tunePMuonBestTrack Phi")
211  proc.muonTable.variables.tuneP_charge = Var("? tunePMuonBestTrack().isNonnull() && tunePMuonBestTrack().isAvailable() ? tunePMuonBestTrack().charge(): -99", float, doc="tunePMuonBestTrack() charge")
212  proc.muonTable.variables.tuneP_muonHits = Var("? tunePMuonBestTrack().isNonnull() && tunePMuonBestTrack().isAvailable() ? tunePMuonBestTrack().hitPattern().numberOfValidMuonHits() : -99", int, doc="No of valid muon hists from tunePMuonBestTrack")
213 
214  # tpfms Track
215  proc.muonTable.variables.tpfms_pt = Var("? tpfmsTrack().isNonnull() && tpfmsTrack().isAvailable() ? tpfmsTrack().pt() : -99", float, doc = "pT from tpfmsTrack")
216  proc.muonTable.variables.tpfms_pterr = Var("? tpfmsTrack().isNonnull() && tpfmsTrack().isAvailable() ? tpfmsTrack().ptError() : -99", float, doc = "pTerr from tpfmsTrack")
217  proc.muonTable.variables.tpfms_eta = Var("? tpfmsTrack().isNonnull() && tpfmsTrack().isAvailable() ? tpfmsTrack().eta(): -99", float, doc="tpfmsTrack Eta")
218  proc.muonTable.variables.tpfms_phi = Var("? tpfmsTrack().isNonnull() && tpfmsTrack().isAvailable() ? tpfmsTrack().phi(): -99", float, doc="tpfmsTrack Phi")
219  proc.muonTable.variables.tpfms_charge = Var("? tpfmsTrack().isNonnull() && tpfmsTrack().isAvailable() ? tpfmsTrack().charge(): -99", float, doc="tpfmsTrack charge")
220  proc.muonTable.variables.tpfms_muonHits = Var("? tpfmsTrack().isNonnull() && tpfmsTrack().isAvailable() ? tpfmsTrack().hitPattern().numberOfValidMuonHits() : -99", int, doc="No of valid muon hists from tpfmsTrack")
221 
222 
223  #picky Track
224  proc.muonTable.variables.picky_pt = Var("? pickyTrack().isNonnull() && pickyTrack().isAvailable() ? pickyTrack().pt() : -99", float, doc = "pT from pickyTrack")
225  proc.muonTable.variables.picky_pterr = Var("? pickyTrack().isNonnull() && pickyTrack().isAvailable() ? pickyTrack().ptError() : -99", float, doc = "pTerr from pickyTrack")
226  proc.muonTable.variables.picky_eta = Var("? pickyTrack().isNonnull() && pickyTrack().isAvailable() ? pickyTrack().eta(): -99", float, doc="pickyTrack Eta")
227  proc.muonTable.variables.picky_phi = Var("? pickyTrack().isNonnull() && pickyTrack().isAvailable() ? pickyTrack().phi(): -99", float, doc="pickyTrack Phi")
228  proc.muonTable.variables.picky_charge = Var("? pickyTrack().isNonnull() && pickyTrack().isAvailable() ? pickyTrack().charge(): -99", float, doc="pickyTrack charge")
229  proc.muonTable.variables.picky_muonHits = Var("? pickyTrack().isNonnull() && pickyTrack().isAvailable() ? pickyTrack().hitPattern().numberOfValidMuonHits() : -99", int, doc="No of valid muon hists from pickyTrack")
230 
231  #dyt Track
232  proc.muonTable.variables.dyt_pt = Var("? dytTrack().isNonnull() && dytTrack().isAvailable() ? dytTrack().pt() : -99", float, doc = "pT from dytTrack")
233  proc.muonTable.variables.dyt_pterr = Var("? dytTrack().isNonnull() && dytTrack().isAvailable() ? dytTrack().ptError() : -99", float, doc = "pTerr from dytTrack")
234  proc.muonTable.variables.dyt_eta = Var("? dytTrack().isNonnull() && dytTrack().isAvailable() ? dytTrack().eta(): -99", float, doc="dytTrack Eta")
235  proc.muonTable.variables.dyt_phi = Var("? dytTrack().isNonnull() && dytTrack().isAvailable() ? dytTrack().phi(): -99", float, doc="dytTrack Phi")
236  proc.muonTable.variables.dyt_charge = Var("? dytTrack().isNonnull() && dytTrack().isAvailable() ? dytTrack().charge(): -99", float, doc="dytTrack charge")
237  proc.muonTable.variables.dyt_muonHits = Var("? dytTrack().isNonnull() && dytTrack().isAvailable() ? dytTrack().hitPattern().numberOfValidMuonHits() : -99", int, doc="No of valid muon hists from dytTrack")
238 
239  #CombinedQuality Variables
240  proc.muonTable.variables.positionChi2 = Var("combinedQuality().chi2LocalPosition", float, doc="chi2 Local Position")
241  proc.muonTable.variables.momentumChi2 = Var("combinedQuality().chi2LocalMomentum", float, doc="chi2 Local Momentum")
242  proc.muonTable.variables.trkKink = Var("combinedQuality().trkKink", float, doc="Track Kink")
243  proc.muonTable.variables.glbKink = Var("combinedQuality().glbKink", float, doc="Glb Kink")
244  proc.muonTable.variables.glbTrackProbability = Var("combinedQuality().glbTrackProbability", float, doc="Glb Track Probability")
245  proc.muonTable.variables.trkRelChi2 = Var("combinedQuality().trkRelChi2",float,doc="Track Rel Chi2")
246 
247  #timAtIpInOutErr
248  proc.muonTable.variables.timAtIpInOutErr = Var("time().timeAtIpInOutErr",float,doc="timAtIpInOutErr")
249 
250  #isArbitratedTracker
251  proc.muonTable.variables.isArbitratedTracker = Var("userInt('isArbitratedTracker')", bool, doc = "s Arbitrated Tracker")
252 
253  #ExtraidX
254  proc.muonTable.variables.standaloneExtraIdx = Var('? standAloneMuon().isNonnull() ? standAloneMuon().extra().key() : -99', 'int', precision=-1, doc='Index of the StandAloneTrack TrackExtra in the original collection')
255  proc.muonTable.variables.innerTrackExtraIdx = Var('? innerTrack().isNonnull() ? innerTrack().extra().key() : -99', 'int', precision=-1, doc='Index of the innerTrack TrackExtra in the original collection')
256 
257  #Jet Related Variables
258  # lazyEval=True: userCand() returns the base type `reco::CandidatePtr`, needs to be dynamically casted to pat::Jet to call the userFloat() / bDiscriminator() methods
259  proc.muonTable.variables.jetPtRatio = Var("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt)", float, doc="ptRatio using the LepAware JEC approach, for muon MVA", lazyEval=True)
260  proc.muonTable.variables.jetDF = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probbb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:problepb'),0.0):0.0",float,doc="b-tagging discriminator of the jet matched to the lepton, for muon MVA", lazyEval=True)
261  proc.muonTable.variables.jetCSVv2 = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfCombinedSecondaryVertexV2BJetTags'),0.0):0.0",float,doc="CSVv2 b-tagging discriminator of the jet matched to the lepton, for muon MVA", lazyEval=True)
262 
263  #nSegments
264  proc.muonTable.variables.nsegments = Var("userInt('nsegments')", int, doc = "nsegments as of Spark-tool")
265 
266  #Sim Variables
267  proc.muonTable.variables.simType = Var("? simType() ? simType() : -99",int,doc="simType")
268  proc.muonTable.variables.simExtType = Var("? simExtType() ? simExtType() : -99",int,doc="simExtType")
269  proc.muonTable.variables.simFlavour = Var("? simFlavour() ? simFlavour() : -99",int,doc="simFlavour")
270  proc.muonTable.variables.simHeaviestMotherFlavour = Var(" ? simHeaviestMotherFlavour() ? simHeaviestMotherFlavour() : -99",int,doc="simHeaviestMotherFlavour")
271  proc.muonTable.variables.simPdgId = Var("? simPdgId() ? simPdgId() : -99",int,doc="simPdgId")
272  proc.muonTable.variables.simMotherPdgId = Var("? simMotherPdgId() ? simMotherPdgId() : -99",int,doc="simMotherPdgId")
273  proc.muonTable.variables.simBX = Var("? simBX() ? simBX() : -99",int,doc="simBX")
274  proc.muonTable.variables.simProdRho = Var("? simProdRho() ? simProdRho(): -99",float,doc="simProdRho")
275  proc.muonTable.variables.simProdZ = Var("? simProdZ() ? simProdZ(): -99",float,doc="simProdZ")
276  proc.muonTable.variables.simPt = Var("? simPt() ? simPt(): -99",float,doc="simPt")
277  proc.muonTable.variables.simEta = Var("? simEta() ? simEta(): -99",float,doc="simEta")
278  proc.muonTable.variables.simPhi = Var("? simPhi() ? simPhi(): -99",float,doc='simPhi')
279 
280  #ID Variables
281  proc.muonTable.variables.isRPC = Var("isRPCMuon",bool,doc="muon is RPC muon")
282 
283  return proc
284 
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
def AddVariablesForMuon(proc)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ Custom_Muon_Task()

def custom_muon_cff.Custom_Muon_Task (   process)

Definition at line 8 of file custom_muon_cff.py.

Referenced by PrepMuonCustomNanoAOD().

8 def Custom_Muon_Task(process):
9  process.nanoTableTaskCommon.remove(process.electronTablesTask)
10  process.nanoTableTaskCommon.remove(process.lowPtElectronTablesTask)
11  process.nanoTableTaskCommon.remove(process.photonTablesTask)
12  process.nanoTableTaskCommon.remove(process.metTablesTask)
13  process.nanoTableTaskCommon.remove(process.tauTablesTask)
14  process.nanoTableTaskCommon.remove(process.boostedTauTablesTask)
15  process.nanoTableTaskCommon.remove(process.jetPuppiTablesTask)
16  process.nanoTableTaskCommon.remove(process.jetAK8TablesTask)
17 
18  process.nanoTableTaskFS.remove(process.electronMCTask)
19  process.nanoTableTaskFS.remove(process.lowPtElectronMCTask)
20  process.nanoTableTaskFS.remove(process.photonMCTask)
21  process.nanoTableTaskFS.remove(process.jetMCTask)
22  process.nanoTableTaskFS.remove(process.tauMCTask)
23  process.nanoTableTaskFS.remove(process.boostedTauMCTask)
24  process.nanoTableTaskFS.remove(process.metMCTable)
25  process.nanoTableTaskFS.remove(process.ttbarCatMCProducersTask)
26  process.nanoTableTaskFS.remove(process.ttbarCategoryTableTask)
27 
28  return process
29 
def Custom_Muon_Task(process)

◆ IncreaseGenPrecesion()

def custom_muon_cff.IncreaseGenPrecesion (   process)

Definition at line 340 of file custom_muon_cff.py.

References common_cff.Var().

Referenced by PrepMuonCustomNanoAOD().

340 def IncreaseGenPrecesion(process):
341 
342  process.genParticleTable.variables.pt = Var("pt", float, precision=16)
343  process.genParticleTable.variables.eta = Var("eta", float,precision=16)
344  process.genParticleTable.variables.phi = Var("phi", float,precision=16)
345 
346  return process
347 
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
def IncreaseGenPrecesion(process)

◆ PrepMuonCustomNanoAOD()

def custom_muon_cff.PrepMuonCustomNanoAOD (   process)

Definition at line 348 of file custom_muon_cff.py.

References AddPFTracks(), AddTriggerObjectBits(), AddVariablesForMuon(), Custom_Muon_Task(), and IncreaseGenPrecesion().

348 def PrepMuonCustomNanoAOD(process):
349 
350  process = Custom_Muon_Task(process)
351  process = AddPFTracks(process)
352  process = AddVariablesForMuon(process)
353  process = AddTriggerObjectBits(process)
354  process = IncreaseGenPrecesion(process)
355 
356 
357  return process
358 
def Custom_Muon_Task(process)
def AddVariablesForMuon(proc)
def IncreaseGenPrecesion(process)
def PrepMuonCustomNanoAOD(process)
def AddPFTracks(proc)
def AddTriggerObjectBits(process)