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  skipObjectsNotPassingQualityBits = cms.bool(True),
37  qualityBits = cms.string(
38  "filter('*CaloIdLTrackIdLIsoVL*TrackIso*Filter') + " \
39  "2*filter('hltEle*WPTight*TrackIsoFilter*') + " \
40  "4*filter('hltEle*WPLoose*TrackIsoFilter') + " \
41  "8*filter('*OverlapFilter*IsoEle*PFTau*') + " \
42  "16*filter('hltEle*Ele*CaloIdLTrackIdLIsoVL*Filter') + " \
43  "32*filter('hltMu*TrkIsoVVL*Ele*CaloIdLTrackIdLIsoVL*Filter*') + " \
44  "64*filter('hltOverlapFilterIsoEle*PFTau*') + " \
45  "128*filter('hltEle*Ele*Ele*CaloIdLTrackIdLDphiLeg*Filter') + " \
46  "256*max(filter('hltL3fL1Mu*DoubleEG*Filtered*'),filter('hltMu*DiEle*CaloIdLTrackIdLElectronleg*Filter')) + " \
47  "512*max(filter('hltL3fL1DoubleMu*EG*Filter*'),filter('hltDiMu*Ele*CaloIdLTrackIdLElectronleg*Filter')) + " \
48  "1024*min(filter('hltEle32L1DoubleEGWPTightGsfTrackIsoFilter'),filter('hltEGL1SingleEGOrFilter')) + " \
49  "2048*filter('hltEle*CaloIdVTGsfTrkIdTGsfDphiFilter') + " \
50  "4096*path('HLT_Ele*PFJet*') + " \
51  "8192*max(filter('hltEG175HEFilter'),filter('hltEG200HEFilter'))"),
52  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), 2048 = 1e (CaloIdVT_GsfTrkIdT), 4096 = 1e (PFJet), 8192 = 1e (Photon175_OR_Photon200)"),
53  ),
54  cms.PSet(
55  name = cms.string("Photon (PixelMatch-vetoed e/gamma)"),
56  id = cms.int32(22),
57  sel = cms.string("type(92) && pt > 20 && coll('hltEgammaCandidates') && !filter('*PixelMatchFilter')"),
58  l1seed = cms.string("type(-98)"), l1deltaR = cms.double(0.3),
59  #l2seed = cms.string("type(92) && coll('')"), l2deltaR = cms.double(0.5),
60  skipObjectsNotPassingQualityBits = cms.bool(True),
61  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
62  ),
63  cms.PSet(
64  name = cms.string("Muon"),
65  id = cms.int32(13),
66  sel = cms.string("type(83) && pt > 5 && (coll('hltIterL3MuonCandidates') || (pt > 45 && coll('hltHighPtTkMuonCands')) || (pt > 95 && coll('hltOldL3MuonCandidates')))"),
67  l1seed = cms.string("type(-81)"), l1deltaR = cms.double(0.5),
68  l2seed = cms.string("type(83) && coll('hltL2MuonCandidates')"), l2deltaR = cms.double(0.3),
69  skipObjectsNotPassingQualityBits = cms.bool(True),
70  qualityBits = cms.string(
71  "filter('*RelTrkIsoVVLFiltered0p4') + " \
72  "2*filter('hltL3crIso*Filtered0p07') + " \
73  "4*filter('*OverlapFilterIsoMu*PFTau*') + " \
74  "8*max(filter('hltL3crIsoL1*SingleMu*Filtered0p07'),filter('hltL3crIsoL1sMu*Filtered0p07')) + " \
75  "16*filter('hltDiMuon*Filtered*') + " \
76  "32*filter('hltMu*TrkIsoVVL*Ele*CaloIdLTrackIdLIsoVL*Filter*') + " \
77  "64*filter('hltOverlapFilterIsoMu*PFTau*') + " \
78  "128*filter('hltL3fL1TripleMu*') + " \
79  "256*max(filter('hltL3fL1DoubleMu*EG*Filtered*'),filter('hltDiMu*Ele*CaloIdLTrackIdLElectronleg*Filter')) + " \
80  "512*max(filter('hltL3fL1Mu*DoubleEG*Filtered*'),filter('hltMu*DiEle*CaloIdLTrackIdLElectronleg*Filter')) + " \
81  "1024*max(filter('hltL3fL1sMu*L3Filtered50*'),filter('hltL3fL1sMu*TkFiltered50*')) + " \
82  "2048*max(filter('hltL3fL1sMu*L3Filtered100*'),filter('hltL3fL1sMu*TkFiltered100*'))"),
83  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, 1024 = 1mu (Mu50), 2048 = 1mu (Mu100)"),
84  ),
85  cms.PSet(
86  name = cms.string("Tau"),
87  id = cms.int32(15),
88  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
89  l1seed = cms.string("type(-100)"), l1deltaR = cms.double(0.3),
90  l2seed = cms.string("type(84) && coll('hltL2TauJetsL1IsoTauSeeded')"), l2deltaR = cms.double(0.3),
91  skipObjectsNotPassingQualityBits = cms.bool(True),
92  qualityBits = cms.string(
93  "filter('*LooseChargedIso*') + " \
94  "2*filter('*MediumChargedIso*') + " \
95  "4*filter('*TightChargedIso*') + " \
96  "8*filter('*TightOOSCPhotons*') + " \
97  "16*filter('*Hps*') + " \
98  "32*filter('hltSelectedPFTau*MediumChargedIsolationL1HLTMatched*') + " \
99  "64*filter('hltDoublePFTau*TrackPt1*ChargedIsolation*Dz02Reg') + " \
100  "128*filter('hltOverlapFilterIsoEle*PFTau*') + " \
101  "256*filter('hltOverlapFilterIsoMu*PFTau*') + " \
102  "512*filter('hltDoublePFTau*TrackPt1*ChargedIsolation*')"),
103  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"),
104  ),
105  cms.PSet(
106  name = cms.string("Jet"),
107  id = cms.int32(1),
108  sel = cms.string("( type(0) || type(85) || type(86) || type(-99) )"),
109  l1seed = cms.string("type(-99)"), l1deltaR = cms.double(0.3),
110  l2seed = cms.string("type(85) || type(86) || type(-99)"), l2deltaR = cms.double(0.3),
111  skipObjectsNotPassingQualityBits = cms.bool(True),
112  qualityBits = cms.string(
113  "1 * filter('*CrossCleaned*LooseChargedIsoPFTau*') + " \
114  "2 * filter('hltBTagCaloCSVp087Triple') + " \
115  "4 * filter('hltDoubleCentralJet90') + " \
116  "8 * filter('hltDoublePFCentralJetLooseID90') + " \
117  "16 * filter('hltL1sTripleJetVBFIorHTTIorDoubleJetCIorSingleJet') + " \
118  "32 * filter('hltQuadCentralJet30') + " \
119  "64 * filter('hltQuadPFCentralJetLooseID30') + " \
120  "128 * max(filter('hltL1sQuadJetC50IorQuadJetC60IorHTT280IorHTT300IorHTT320IorTripleJet846848VBFIorTripleJet887256VBFIorTripleJet927664VBF'), filter('hltL1sQuadJetCIorTripleJetVBFIorHTT')) + " \
121  "256 * filter('hltQuadCentralJet45') + " \
122  "512 * filter('hltQuadPFCentralJetLooseID45') + " \
123  "1024 * max(filter('hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet'), filter('hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet')) + " \
124  "2048 * max(filter('hltBTagCaloCSVp05Double'), filter('hltBTagCaloDeepCSVp17Double')) + " \
125  "4096 * filter('hltPFCentralJetLooseIDQuad30') + " \
126  "8192 * filter('hlt1PFCentralJetLooseID75') + " \
127  "16384 * filter('hlt2PFCentralJetLooseID60') + " \
128  "32768 * filter('hlt3PFCentralJetLooseID45') + " \
129  "65536 * filter('hlt4PFCentralJetLooseID40') + " \
130  "131072 * max(filter('hltBTagPFCSVp070Triple'), max(filter('hltBTagPFDeepCSVp24Triple'), filter('hltBTagPFDeepCSV4p5Triple')) )"
131  ),
132  qualityBitsDoc = cms.string(
133  "Jet bits: bit 0 for VBF cross-cleaned from loose iso PFTau, bit 1 for hltBTagCaloCSVp087Triple, bit 2 for hltDoubleCentralJet90, bit 3 for hltDoublePFCentralJetLooseID90," \
134  " bit 4 for hltL1sTripleJetVBFIorHTTIorDoubleJetCIorSingleJet, bit 5 for hltQuadCentralJet30, bit 6 for hltQuadPFCentralJetLooseID30," \
135  " bit 7 for hltL1sQuadJetC50IorQuadJetC60IorHTT280IorHTT300IorHTT320IorTripleJet846848VBFIorTripleJet887256VBFIorTripleJet927664VBF or hltL1sQuadJetCIorTripleJetVBFIorHTT," \
136  " bit 8 for hltQuadCentralJet45, bit 9 for hltQuadPFCentralJetLooseID45," \
137  " bit 10 for hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet or hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet" \
138  " bit 11 for hltBTagCaloCSVp05Double or hltBTagCaloDeepCSVp17Double, bit 12 for hltPFCentralJetLooseIDQuad30, bit 13 for hlt1PFCentralJetLooseID75," \
139  " bit 14 for hlt2PFCentralJetLooseID60, bit 15 for hlt3PFCentralJetLooseID45, bit 16 for hlt4PFCentralJetLooseID40," \
140  " bit 17 for hltBTagPFCSVp070Triple or hltBTagPFDeepCSVp24Triple or hltBTagPFDeepCSV4p5Triple "),
141  ),
142  cms.PSet(
143  name = cms.string("FatJet"),
144  id = cms.int32(6),
145  sel = cms.string("type(85) && pt > 120 && coll('hltAK8PFJetsCorrected')"),
146  l1seed = cms.string("type(-99)"), l1deltaR = cms.double(0.3),
147  l2seed = cms.string("type(85) && coll('hltAK8CaloJetsCorrectedIDPassed')"), l2deltaR = cms.double(0.3),
148  skipObjectsNotPassingQualityBits = cms.bool(True),
149  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
150  ),
151  cms.PSet(
152  name = cms.string("MET"),
153  id = cms.int32(2),
154  sel = cms.string("type(87) && pt > 30 && coll('hltPFMETProducer')"),
155  l1seed = cms.string("type(-87) && coll('L1ETM')"), l1deltaR = cms.double(9999),
156  l1seed_2 = cms.string("type(-87) && coll('L1ETMHF')"), l1deltaR_2 = cms.double(9999),
157  l2seed = cms.string("type( 87) && coll('hltMetClean')"), l2deltaR = cms.double(9999),
158  skipObjectsNotPassingQualityBits = cms.bool(True),
159  qualityBits = cms.string("0"), qualityBitsDoc = cms.string(""),
160  ),
161  cms.PSet(
162  name = cms.string("HT"),
163  id = cms.int32(3),
164  sel = cms.string("type(89) || type(-89)"),
165  l1seed = cms.string("type(-89) && coll('L1HTT')"), l1deltaR = cms.double(9999),
166  l1seed_2 = cms.string("type(-89) && coll('L1HTTHF')"), l1deltaR_2 = cms.double(9999),
167  l2seed = cms.string("type(89) && coll('hltHtMhtJet30')"), l2deltaR = cms.double(9999),
168  skipObjectsNotPassingQualityBits = cms.bool(True),
169  qualityBits = cms.string(
170  "1 * filter('hltL1sTripleJetVBFIorHTTIorDoubleJetCIorSingleJet') + " \
171  "2 * max(filter('hltL1sQuadJetC50IorQuadJetC60IorHTT280IorHTT300IorHTT320IorTripleJet846848VBFIorTripleJet887256VBFIorTripleJet927664VBF'), filter('hltL1sQuadJetCIorTripleJetVBFIorHTT')) + " \
172  "4 * max(filter('hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet'), filter('hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet')) + " \
173  "8 * max(filter('hltCaloQuadJet30HT300'), filter('hltCaloQuadJet30HT320')) + " \
174  "16 * max(filter('hltPFCentralJetsLooseIDQuad30HT300'), filter('hltPFCentralJetsLooseIDQuad30HT330'))"
175  ),
176  qualityBitsDoc = cms.string(
177  "HT bits: bit 0 for hltL1sTripleJetVBFIorHTTIorDoubleJetCIorSingleJet, bit 1 for hltL1sQuadJetC50IorQuadJetC60IorHTT280IorHTT300IorHTT320IorTripleJet846848VBFIorTripleJet887256VBFIorTripleJet927664VBF or hltL1sQuadJetCIorTripleJetVBFIorHTT, " \
178  "bit 2 for hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet or hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet, " \
179  "bit 3 for hltCaloQuadJet30HT300 or hltCaloQuadJet30HT320, bit 4 for hltPFCentralJetsLooseIDQuad30HT300 or hltPFCentralJetsLooseIDQuad30HT330"
180  ),
181  ),
182  cms.PSet(
183  name = cms.string("MHT"),
184  id = cms.int32(4),
185  sel = cms.string("type(90)"),
186  l1seed = cms.string("type(-90) && coll('L1HTM')"), l1deltaR = cms.double(9999),
187  l1seed_2 = cms.string("type(-90) && coll('L1HTMHF')"), l1deltaR_2 = cms.double(9999),
188  l2seed = cms.string("type(90) && coll('hltHtMhtJet30')"), l2deltaR = cms.double(9999),
189  skipObjectsNotPassingQualityBits = cms.bool(True),
190  qualityBits = cms.string(
191  "1 * max(filter('hltCaloQuadJet30HT300'), filter('hltCaloQuadJet30HT320')) + " \
192  "2 * max(filter('hltPFCentralJetsLooseIDQuad30HT300'), filter('hltPFCentralJetsLooseIDQuad30HT330'))"
193  ),
194  qualityBitsDoc = cms.string
195  (
196  "MHT bits: bit 0 for hltCaloQuadJet30HT300 or hltCaloQuadJet30HT320, bit 1 for hltPFCentralJetsLooseIDQuad30HT300 or hltPFCentralJetsLooseIDQuad30HT330"
197  ),
198  ),
199 
200  ),
201 )
202 
203 # ERA-dependent configuration
204 # Tune filter and collection names to 2016 HLT menus
205 # FIXME: check non-lepton objects and cross check leptons
206 selections80X = copy.deepcopy(triggerObjectTable.selections)
207 for sel in selections80X:
208  if sel.name=='Muon':
209  sel.sel = cms.string("type(83) && pt > 5 && (coll('hlt*L3MuonCandidates') || coll('hlt*TkMuonCands') || coll('hlt*TrkMuonCands'))")
210  sel.qualityBits = cms.string("filter('*RelTrkIso*Filtered0p4') + 2*filter('hltL3cr*IsoFiltered0p09') + 4*filter('*OverlapFilter*IsoMu*PFTau*') + 8*filter('hltL3f*IsoFiltered0p09') + 1024*max(filter('hltL3fL1sMu*L3Filtered50*'),filter('hltL3fL1sMu*TkFiltered50*'))")
211  sel.qualityBitsDoc = cms.string("1 = TrkIsoVVL, 2 = Iso, 4 = OverlapFilter PFTau, 8 = IsoTkMu, 1024 = 1mu (Mu50)")
212  elif sel.name=='Tau':
213  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*') )")
214  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*')")
215  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")
216 
217 (run2_miniAOD_80XLegacy | run2_nanoAOD_94X2016).toModify(
218  triggerObjectTable,
219  selections = selections80X
220 )
221 
222 from PhysicsTools.PatUtils.L1ECALPrefiringWeightProducer_cff import prefiringweight
223 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
224  modifier.toModify(prefiringweight, DataEra = cms.string("2016BtoH"))
225 
226 l1PreFiringEventWeightTable = cms.EDProducer("GlobalVariablesTableProducer",
227  variables = cms.PSet(
228  L1PreFiringWeight_Nom = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProb"), "double", doc = "L1 pre-firing event correction weight (1-probability)", precision=8),
229  L1PreFiringWeight_Up = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbUp"), "double", doc = "L1 pre-firing event correction weight (1-probability), up var.", precision=8),
230  L1PreFiringWeight_Dn = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbDown"), "double", doc = "L1 pre-firing event correction weight (1-probability), down var.", precision=8),
231  )
232 )
233 
234 triggerObjectTables = cms.Sequence( unpackedPatTrigger + triggerObjectTable )
235 
236 _triggerObjectTables_withL1PreFiring = triggerObjectTables.copy()
237 _triggerObjectTables_withL1PreFiring.replace(triggerObjectTable, prefiringweight + l1PreFiringEventWeightTable + triggerObjectTable)
238 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
239  modifier.toReplaceWith(triggerObjectTables, _triggerObjectTables_withL1PreFiring)
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:31