CMS 3D CMS Logo

triggerObjects_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
3 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016
4 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff import run2_nanoAOD_94XMiniAODv1
5 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2
6 from PhysicsTools.NanoAOD.common_cff import ExtVar
7 import copy
8 
9 unpackedPatTrigger = cms.EDProducer("PATTriggerObjectStandAloneUnpacker",
10  patTriggerObjectsStandAlone = cms.InputTag('slimmedPatTrigger'),
11  triggerResults = cms.InputTag('TriggerResults::HLT'),
12  unpackFilterLabels = cms.bool(True)
13 )
14 # ERA-dependent configuration
15 run2_miniAOD_80XLegacy.toModify(
16  unpackedPatTrigger,
17  patTriggerObjectsStandAlone = "selectedPatTrigger",
18  unpackFilterLabels = False
19 )
20 
21 triggerObjectTable = cms.EDProducer("TriggerObjectTableProducer",
22  name= cms.string("TrigObj"),
23  src = cms.InputTag("unpackedPatTrigger"),
24  l1EG = cms.InputTag("caloStage2Digis","EGamma"),
25  l1Sum = cms.InputTag("caloStage2Digis","EtSum"),
26  l1Jet = cms.InputTag("caloStage2Digis","Jet"),
27  l1Muon = cms.InputTag("gmtStage2Digis","Muon"),
28  l1Tau = cms.InputTag("caloStage2Digis","Tau"),
29  selections = cms.VPSet(
30  cms.PSet(
31  name = cms.string("Electron (PixelMatched e/gamma)"), # this selects also photons for the moment!
32  id = cms.int32(11),
33  sel = cms.string("type(92) && pt > 7 && coll('hltEgammaCandidates') && filter('*PixelMatchFilter')"),
34  l1seed = cms.string("type(-98)"), l1deltaR = cms.double(0.3),
35  #l2seed = cms.string("type(92) && coll('')"), l2deltaR = cms.double(0.5),
36  qualityBits = cms.string(
37  "filter('*CaloIdLTrackIdLIsoVL*TrackIso*Filter') + " \
38  "2*filter('hltEle*WPTight*TrackIsoFilter*') + " \
39  "4*filter('hltEle*WPLoose*TrackIsoFilter') + " \
40  "8*filter('*OverlapFilterIsoEle*PFTau*') + " \
41  "16*filter('hltEle*Ele*CaloIdLTrackIdLIsoVL*Filter') + " \
42  "32*filter('hltMu*TrkIsoVVL*Ele*CaloIdLTrackIdLIsoVL*Filter*') + " \
43  "64*filter('*OverlapFilterIsoEle*PFTau*') + " \
44  "128*filter('hltEle*Ele*Ele*CaloIdLTrackIdLDphiLeg*Filter') + " \
45  "256*max(filter('hltL3fL1Mu*DoubleEG*Filtered*'),filter('hltMu*DiEle*CaloIdLTrackIdLElectronleg*Filter')) + " \
46  "512*max(filter('hltL3fL1DoubleMu*EG*Filter*'),filter('hltDiMu*Ele*CaloIdLTrackIdLElectronleg*Filter')) + " \
47  "1024*min(filter('hltEle32L1DoubleEGWPTightGsfTrackIsoFilter'),filter('hltEGL1SingleEGOrFilter'))"),
48  qualityBitsDoc = cms.string("1 = CaloIdL_TrackIdL_IsoVL, 2 = 1e (WPTight), 4 = 1e (WPLoose), 8 = OverlapFilter PFTau, 16 = 2e, 32 = 1e-1mu, 64 = 1e-1tau, 128 = 3e, 256 = 2e-1mu, 512 = 1e-2mu, 1024 = 1e (32_L1DoubleEG_AND_L1SingleEGOr)"),
49  ),
50  cms.PSet(
51  name = cms.string("Photon (PixelMatch-vetoed e/gamma)"),
52  id = cms.int32(22),
53  sel = cms.string("type(92) && pt > 20 && coll('hltEgammaCandidates') && !filter('*PixelMatchFilter')"),
54  l1seed = cms.string("type(-98)"), l1deltaR = cms.double(0.3),
55  #l2seed = cms.string("type(92) && coll('')"), l2deltaR = cms.double(0.5),
56  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
57  ),
58  cms.PSet(
59  name = cms.string("Muon"),
60  id = cms.int32(13),
61  sel = cms.string("type(83) && pt > 5 && coll('hltIterL3MuonCandidates')"),
62  l1seed = cms.string("type(-81)"), l1deltaR = cms.double(0.5),
63  l2seed = cms.string("type(83) && coll('hltL2MuonCandidates')"), l2deltaR = cms.double(0.3),
64  qualityBits = cms.string(
65  "filter('*RelTrkIsoVVLFiltered0p4') + " \
66  "2*filter('hltL3crIso*Filtered0p07') + " \
67  "4*filter('*OverlapFilterIsoMu*PFTau*') + " \
68  "8*max(filter('hltL3crIsoL1*SingleMu*Filtered0p07'),filter('hltL3crIsoL1sMu*Filtered0p07')) + " \
69  "16*filter('hltDiMuon*Filtered*') + " \
70  "32*filter('hltMu*TrkIsoVVL*Ele*CaloIdLTrackIdLIsoVL*Filter*') + " \
71  "64*filter('hltOverlapFilterIsoMu*PFTau*') + " \
72  "128*filter('hltL3fL1TripleMu*') + " \
73  "256*max(filter('hltL3fL1DoubleMu*EG*Filtered*'),filter('hltDiMu*Ele*CaloIdLTrackIdLElectronleg*Filter')) + " \
74  "512*max(filter('hltL3fL1Mu*DoubleEG*Filtered*'),filter('hltMu*DiEle*CaloIdLTrackIdLElectronleg*Filter'))"),
75  qualityBitsDoc = cms.string("1 = TrkIsoVVL, 2 = Iso, 4 = OverlapFilter PFTau, 8 = 1mu, 16 = 2mu, 32 = 1mu-1e, 64 = 1mu-1tau, 128 = 3mu, 256 = 2mu-1e, 512 =1mu-2e"),
76  ),
77  cms.PSet(
78  name = cms.string("Tau"),
79  id = cms.int32(15),
80  sel = cms.string("type(84) && pt > 5 && coll('*Tau*') && ( filter('*LooseChargedIso*') || filter('*MediumChargedIso*') || filter('*TightChargedIso*') || filter('*TightOOSCPhotons*') || filter('hltL2TauIsoFilter') || filter('*OverlapFilterIsoMu*') || filter('*OverlapFilterIsoEle*') || filter('*L1HLTMatched*') || filter('*Dz02*') )"), #All trigger objects from a Tau collection + passing at least one filter
81  l1seed = cms.string("type(-100)"), l1deltaR = cms.double(0.3),
82  l2seed = cms.string("type(84) && coll('hltL2TauJetsL1IsoTauSeeded')"), l2deltaR = cms.double(0.3),
83  qualityBits = cms.string(
84  "filter('*LooseChargedIso*') + " \
85  "2*filter('*MediumChargedIso*') + " \
86  "4*filter('*TightChargedIso*') + " \
87  "8*filter('*TightOOSCPhotons*') + " \
88  "16*filter('*Hps*') + " \
89  "32*filter('hltSelectedPFTau*MediumChargedIsolationL1HLTMatched*') + " \
90  "64*filter('hltDoublePFTau*TrackPt1*ChargedIsolation*Dz02Reg') + " \
91  "128*filter('hltOverlapFilterIsoEle*PFTau*') + " \
92  "256*filter('hltOverlapFilterIsoMu*PFTau*') + " \
93  "512*filter('hltDoublePFTau*TrackPt1*ChargedIsolation*')"),
94  qualityBitsDoc = cms.string("1 = LooseChargedIso, 2 = MediumChargedIso, 4 = TightChargedIso, 8 = TightID OOSC photons, 16 = HPS, 32 = single-tau + tau+MET, 64 = di-tau, 128 = e-tau, 256 = mu-tau, 512 = VBF+di-tau"),
95  ),
96  cms.PSet(
97  name = cms.string("Jet"),
98  id = cms.int32(1),
99  sel = cms.string("type(85) && pt > 30 && (coll('hltAK4PFJetsCorrected') || coll('hltMatchedVBF*PFJets*PFTau*OverlapRemoval'))"),
100  l1seed = cms.string("type(-99)"), l1deltaR = cms.double(0.3),
101  l2seed = cms.string("type(85) && coll('hltAK4CaloJetsCorrectedIDPassed')"), l2deltaR = cms.double(0.3),
102  qualityBits = cms.string("filter('*CrossCleaned*LooseChargedIsoPFTau*')"), qualityBitsDoc = cms.string("1 = VBF cross-cleaned from loose iso PFTau"),
103  ),
104  cms.PSet(
105  name = cms.string("FatJet"),
106  id = cms.int32(6),
107  sel = cms.string("type(85) && pt > 120 && coll('hltAK8PFJetsCorrected')"),
108  l1seed = cms.string("type(-99)"), l1deltaR = cms.double(0.3),
109  l2seed = cms.string("type(85) && coll('hltAK8CaloJetsCorrectedIDPassed')"), l2deltaR = cms.double(0.3),
110  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
111  ),
112  cms.PSet(
113  name = cms.string("MET"),
114  id = cms.int32(2),
115  sel = cms.string("type(87) && pt > 30 && coll('hltPFMETProducer')"),
116  l1seed = cms.string("type(-87) && coll('L1ETM')"), l1deltaR = cms.double(9999),
117  l1seed_2 = cms.string("type(-87) && coll('L1ETMHF')"), l1deltaR_2 = cms.double(9999),
118  l2seed = cms.string("type( 87) && coll('hltMetClean')"), l2deltaR = cms.double(9999),
119  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
120  ),
121  cms.PSet(
122  name = cms.string("HT"),
123  id = cms.int32(3),
124  sel = cms.string("type(89) && pt > 100 && coll('hltPFHTJet30')"),
125  l1seed = cms.string("type(-89) && coll('L1HTT')"), l1deltaR = cms.double(9999),
126  l1seed_2 = cms.string("type(-89) && coll('L1HTTHF')"), l1deltaR_2 = cms.double(9999),
127  #l2seed = cms.string("type(89) && coll('hltHtMhtJet30')"), l2deltaR = cms.double(9999),
128  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
129  ),
130  cms.PSet(
131  name = cms.string("MHT"),
132  id = cms.int32(4),
133  sel = cms.string("type(90) && pt > 30 && coll('hltPFMHTTightID')"),
134  l1seed = cms.string("type(-90) && coll('L1HTM')"), l1deltaR = cms.double(9999),
135  l1seed_2 = cms.string("type(-90) && coll('L1HTMHF')"), l1deltaR_2 = cms.double(9999),
136  #l2seed = cms.string("type(90) && coll('hltHtMhtJet30')"), l2deltaR = cms.double(9999),
137  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
138  ),
139 
140  ),
141 )
142 
143 # ERA-dependent configuration
144 # Tune filter and collection names to 2016 HLT menus
145 # FIXME: check non-lepton objects and cross check leptons
146 selections80X = copy.deepcopy(triggerObjectTable.selections)
147 for sel in selections80X:
148  if sel.name=='Muon':
149  sel.sel = cms.string("type(83) && pt > 5 && (coll('hlt*L3MuonCandidates') || coll('hlt*TkMuonCands') || coll('hlt*TrkMuonCands'))")
150  sel.qualityBits = cms.string("filter('*RelTrkIso*Filtered0p4') + 2*filter('hltL3cr*IsoFiltered0p09') + 4*filter('*OverlapFilter*IsoMu*PFTau*') + 8*filter('hltL3f*IsoFiltered0p09')")
151  sel.qualityBitsDoc = cms.string("1 = TrkIsoVVL, 2 = Iso, 4 = OverlapFilter PFTau, 8 = IsoTkMu")
152  elif sel.name=='Tau':
153  sel.sel = cms.string("type(84) && pt > 5 && coll('*Tau*') && ( filter('*LooseIso*') || filter('*MediumIso*') || filter('*MediumComb*Iso*') || filter('hltL2TauIsoFilter') || filter('*OverlapFilter*IsoMu*') || filter('*OverlapFilter*IsoEle*') || filter('*L1HLTMatched*') || filter('*Dz02*') )")
154  sel.qualityBits = cms.string("(filter('*LooseIso*')-filter('*VLooseIso*'))+2*filter('*Medium*Iso*')+4*filter('*VLooseIso*')+8*0+16*filter('hltL2TauIsoFilter')+32*filter('*OverlapFilter*IsoMu*')+64*filter('*OverlapFilter*IsoEle*')+128*filter('*L1HLTMatched*')+256*filter('*Dz02*')")
155  sel.qualityBitsDoc = cms.string("1 = LooseIso, 2 = Medium(Comb)Iso, 4 = VLooseIso, 8 = None, 16 = L2p5 pixel iso, 32 = OverlapFilter IsoMu, 64 = OverlapFilter IsoEle, 128 = L1-HLT matched, 256 = Dz")
156  elif sel.name=='Electron (PixelMatched e/gamma)':
157  #sel.sel = cms.string("type(92) && pt > 7 && coll('hltEgammaCandidates') && filter('*PixelMatchFilter')")
158  sel.qualityBits = cms.string("filter('*CaloIdLTrackIdLIsoVL*TrackIso*Filter') + 2*filter('hltEle*WPTight*TrackIsoFilter*') + 4*filter('hltEle*WPLoose*TrackIsoFilter') + 8*filter('*OverlapFilter*IsoEle*PFTau*')")
159  #sel.qualityBitsDoc = cms.string("1 = CaloIdL_TrackIdL_IsoVL, 2 = WPLoose, 4 = WPTight, 8 = OverlapFilter PFTau")
160 
161 (run2_miniAOD_80XLegacy | run2_nanoAOD_94X2016).toModify(
162  triggerObjectTable,
163  selections = selections80X
164 )
165 
166 from PhysicsTools.PatUtils.L1ECALPrefiringWeightProducer_cff import prefiringweight
167 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
168  modifier.toModify(prefiringweight, DataEra = cms.string("2016BtoH"))
169 
170 l1PreFiringEventWeightTable = cms.EDProducer("GlobalVariablesTableProducer",
171  variables = cms.PSet(
172  L1PreFiringWeight_Nom = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProb"), "double", doc = "L1 pre-firing event correction weight (1-probability)", precision=8),
173  L1PreFiringWeight_Up = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbUp"), "double", doc = "L1 pre-firing event correction weight (1-probability), up var.", precision=8),
174  L1PreFiringWeight_Dn = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbDown"), "double", doc = "L1 pre-firing event correction weight (1-probability), down var.", precision=8),
175  )
176 )
177 
178 triggerObjectTables = cms.Sequence( unpackedPatTrigger + triggerObjectTable )
179 
180 _triggerObjectTables_withL1PreFiring = triggerObjectTables.copy()
181 _triggerObjectTables_withL1PreFiring.replace(triggerObjectTable, prefiringweight + l1PreFiringEventWeightTable + triggerObjectTable)
182 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
183  modifier.toReplaceWith(triggerObjectTables, _triggerObjectTables_withL1PreFiring)
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:31