Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-02-09 06:19:29

0001 import FWCore.ParameterSet.Config as cms
0002 from PhysicsTools.NanoAOD.nano_eras_cff import *
0003 from PhysicsTools.NanoAOD.common_cff import *
0004 from PhysicsTools.NanoAOD.triggerObjectTableProducer_cfi import triggerObjectTableProducer
0005 from PhysicsTools.NanoAOD.globalVariablesTableProducer_cfi import globalVariablesTableProducer
0006 import copy
0007 
0008 unpackedPatTrigger = cms.EDProducer("PATTriggerObjectStandAloneUnpacker",
0009     patTriggerObjectsStandAlone = cms.InputTag('slimmedPatTrigger'),
0010     triggerResults              = cms.InputTag('TriggerResults::HLT'),
0011     unpackFilterLabels = cms.bool(True)
0012 )
0013 
0014 def mksel( selection, doc=None, bit=None):
0015     ddoc=""
0016     if 'OR' in selection:
0017         selection,ddoc=OR(selection)
0018     if 'AND' in selection:
0019         selection,ddoc=AND(selection)
0020     if type(selection)==list:
0021         selection,ddoc=OR(selection)
0022     if type(selection)==tuple:
0023         selection,ddoc=AND(selection)
0024     if doc==None:
0025         doc=ddoc
0026     #print("creating an entry with",selection,doc)
0027     return cms.PSet(selection=cms.string(selection),doc=cms.string(doc),bit=cms.uint32(bit)) if bit is not None else cms.PSet(selection=cms.string(selection),doc=cms.string(doc))
0028 
0029 def chaintoken_(tokens,f,OR_or_AND=None):
0030     if (not type(tokens) in [list,tuple]):
0031         doc=tokens
0032         tokens= [t.strip().rstrip() for t in tokens.split(OR_or_AND)]
0033     else:
0034         doc=f' {OR_or_AND} '.join(tokens)
0035     selection = f"filter('{tokens[0]}')"
0036     for token in tokens[1:]:
0037         filter = f"filter('{token}')"
0038         selection = f"{f}({filter},{selection})"
0039     return selection,doc
0040 def OR(tokens):
0041     return chaintoken_(tokens,"max","OR")
0042 def AND(tokens):
0043     return chaintoken_(tokens,"min","AND")
0044 
0045 triggerObjectTable = triggerObjectTableProducer.clone(
0046     name= cms.string("TrigObj"),
0047     src = cms.InputTag("unpackedPatTrigger"),
0048     l1EG = cms.InputTag("caloStage2Digis","EGamma"),
0049     l1Sum = cms.InputTag("caloStage2Digis","EtSum"),
0050     l1Jet = cms.InputTag("caloStage2Digis","Jet"),
0051     l1Muon = cms.InputTag("gmtStage2Digis","Muon"),
0052     l1Tau = cms.InputTag("caloStage2Digis","Tau"),
0053     selections = cms.PSet(
0054         Electron = cms.PSet(
0055             doc = cms.string("PixelMatched e/gamma"), # this may also select photons!
0056             id = cms.int32(11),
0057             sel = cms.string("type(92) && pt > 7 && coll('hltEgammaCandidates') && filter('*PixelMatchFilter')"),
0058             l1seed = cms.string("type(-98)"),  l1deltaR = cms.double(0.3),
0059             #l2seed = cms.string("type(92) && coll('')"),  l2deltaR = cms.double(0.5),
0060             skipObjectsNotPassingQualityBits = cms.bool(True),
0061             qualityBits = cms.VPSet(
0062                 mksel("filter('*CaloIdLTrackIdLIsoVL*TrackIso*Filter')","CaloIdL_TrackIdL_IsoVL"),
0063                 mksel("filter('hltEle*WPTight*TrackIsoFilter*')","1e (WPTight)"),
0064                 mksel("filter('hltEle*WPLoose*TrackIsoFilter')","1e (WPLoose)"),
0065                 mksel("filter('*OverlapFilter*IsoEle*PFTau*')","OverlapFilter PFTau"),
0066                 mksel("filter('hltEle*Ele*CaloIdLTrackIdLIsoVL*Filter')","2e"),
0067                 mksel("filter('hltMu*TrkIsoVVL*Ele*CaloIdLTrackIdLIsoVL*Filter*')","1e-1mu"),
0068                 mksel("filter('hlt*OverlapFilterIsoEle*PFTau*')","1e-1tau"),
0069                 mksel("filter('hltEle*Ele*Ele*CaloIdLTrackIdLDphiLeg*Filter')","3e"),
0070                 mksel(["hltL3fL1Mu*DoubleEG*Filtered*","hltMu*DiEle*CaloIdLTrackIdLElectronleg*Filter"],"2e-1mu"),
0071                 mksel(["hltL3fL1DoubleMu*EG*Filter*","hltDiMu*Ele*CaloIdLTrackIdLElectronleg*Filter"],"1e-2mu"),
0072                 mksel(("hltEle32L1DoubleEGWPTightGsfTrackIsoFilter","hltEGL1SingleEGOrFilter"),"1e (32_L1DoubleEG_AND_L1SingleEGOr)"),
0073                 mksel("filter('hltEle*CaloIdVTGsfTrkIdTGsfDphiFilter')","1e (CaloIdVT_GsfTrkIdT)"),
0074                 mksel("path('HLT_Ele*PFJet*')","1e (PFJet)"),
0075                 mksel(["hltEG175HEFilter","hltEG200HEFilter"],"1e (Photon175_OR_Photon200)"),
0076                 )
0077         ),
0078         Photon = cms.PSet(
0079             id = cms.int32(22),
0080             sel = cms.string("type(92) && pt > 20 && coll('hltEgammaCandidates')"),
0081             l1seed = cms.string("type(-98)"),  l1deltaR = cms.double(0.3),
0082             #l2seed = cms.string("type(92) && coll('')"),  l2deltaR = cms.double(0.5),
0083             skipObjectsNotPassingQualityBits = cms.bool(True),
0084             qualityBits = cms.VPSet(
0085                 mksel("filter('hltEG33L1EG26HEFilter')","hltEG33L1EG26HEFilter"),
0086                 mksel("filter('hltEG50HEFilter')","hltEG50HEFilter"),
0087                 mksel("filter('hltEG75HEFilter')","hltEG75HEFilter"),
0088                 mksel("filter('hltEG90HEFilter')","hltEG90HEFilter"),
0089                 mksel("filter('hltEG120HEFilter')","hltEG120HEFilter"),
0090                 mksel("filter('hltEG150HEFilter')","hltEG150HEFilter"),
0091                 mksel("filter('hltEG175HEFilter')","hltEG150HEFilter"),
0092                 mksel("filter('hltEG200HEFilter')","hltEG200HEFilter"),
0093                 mksel("filter('hltHtEcal800')","hltHtEcal800"),
0094                 mksel("filter('hltEG110EBTightIDTightIsoTrackIsoFilter')","hltEG110EBTightIDTightIsoTrackIsoFilter"),
0095                 mksel("filter('hltEG120EBTightIDTightIsoTrackIsoFilter')","hltEG120EBTightIDTightIsoTrackIsoFilter"),
0096                 mksel("filter('hltMu17Photon30IsoCaloIdPhotonlegTrackIsoFilter')","1mu-1photon"),
0097                 mksel("filter('hltEG30LR9Id85b90eHE12R9Id50b80eR9IdLastFilter')","hltEG30LR9Id85b90eHE12R9Id50b80eR9IdLastFilter"),
0098                 mksel("filter('hltEG30LIso60CaloId15b35eHE12R9Id50b80eEcalIsoLastFilter')","hltEG30LIso60CaloId15b35eHE12R9Id50b80eEcalIsoLastFilter"),
0099                 mksel("filter('hltEG22Iso60CaloId15b35eHE12R9Id50b80eTrackIsoUnseededLastFilter')","hltEG22Iso60CaloId15b35eHE12R9Id50b80eTrackIsoUnseededLastFilter"),
0100                 mksel("filter('hltEG22R9Id85b90eHE12R9Id50b80eR9UnseededLastFilter')","hltEG22R9Id85b90eHE12R9Id50b80eR9UnseededLastFilter"),
0101                 mksel("filter('hltEG30Iso60CaloId15b35eR9Id50b90eHE12b10eR9Id50b80eEcalIsoFilter')","hltEG30Iso60CaloId15b35eR9Id50b90eHE12b10eR9Id50b80eEcalIsoFilter"),
0102                 mksel("filter('hltEG18TrackIso60Iso60CaloId15b35eR9Id50b90eHE12b10eR9Id50b80eTrackIsoUnseededFilter')","hltEG18TrackIso60Iso60CaloId15b35eR9Id50b90eHE12b10eR9Id50b80eTrackIsoUnseededFilter")
0103             )
0104         ),
0105         Muon = cms.PSet(
0106             id = cms.int32(13),
0107             sel = cms.string("type(83) && pt > 5 && (coll('hltIterL3MuonCandidates') || (pt > 45 && coll('hltHighPtTkMuonCands')) || (pt > 95 && coll('hltOldL3MuonCandidates')))"),
0108             l1seed = cms.string("type(-81)"), l1deltaR = cms.double(0.5),
0109             l2seed = cms.string("type(83) && coll('hltL2MuonCandidates')"),  l2deltaR = cms.double(0.3),
0110             skipObjectsNotPassingQualityBits = cms.bool(True),
0111             qualityBits = cms.VPSet(
0112                 mksel(["*RelTrkIsoVVLFiltered0p4","*RelTrkIsoVVLFiltered"],"TrkIsoVVL"),
0113                 mksel(["hltL3crIso*IsoFiltered0p07","hltL3crIso*IsoFiltered0p08","hltL3crIso*IsoFiltered"],"Iso"),
0114                 mksel("filter('*OverlapFilterIsoMu*PFTau*')","OverlapFilter PFTau"),
0115                 mksel(["hltL3crIsoL1*SingleMu*IsoFiltered0p07","hltL3crIsoL1sMu*IsoFiltered0p07","hltL3crIsoL1*SingleMu*IsoFiltered0p08","hltL3crIsoL1sMu*IsoFiltered0p08","hltL3crIsoL1*SingleMu*IsoFiltered","hltL3crIsoL1sMu*IsoFiltered"],"1mu"),
0116                 mksel("filter('hltDiMuon*Filtered*')","2mu"),
0117                 mksel("filter('hltMu*TrkIsoVVL*Ele*CaloIdLTrackIdLIsoVL*Filter*')","1mu-1e"),
0118                 mksel("filter('hlt*OverlapFilterIsoMu*PFTau*')","1mu-1tau"),
0119                 mksel("filter('hltL3fL1TripleMu*')","3mu"),
0120                 mksel(["hltL3fL1DoubleMu*EG*Filtered*","hltDiMu*Ele*CaloIdLTrackIdLElectronleg*Filter"],"2mu-1e"),
0121                 mksel(["hltL3fL1Mu*DoubleEG*Filtered*","hltMu*DiEle*CaloIdLTrackIdLElectronleg*Filter"],"1mu-2e"),
0122                 mksel(["hltL3fL1sMu*L3Filtered50*","hltL3fL1sMu*TkFiltered50*"],"1mu (Mu50)"),
0123                 mksel(["hltL3fL1sMu*L3Filtered100*","hltL3fL1sMu*TkFiltered100*"],"1mu (Mu100)"),
0124                 mksel("filter('hltMu17Photon30IsoCaloIdMuonlegL3Filtered17Q')","1mu-1photon")
0125             )
0126         ),
0127         Tau = cms.PSet(
0128             id = cms.int32(15),
0129             sel = cms.string("type(84) && pt > 5 && coll('*Tau*') && ( filter('*LooseChargedIso*') || filter('*MediumChargedIso*') || filter('*DeepTau*') || filter('*TightChargedIso*') || filter('*TightOOSCPhotons*') || filter('hltL2TauIsoFilter') || filter('*OverlapFilterIsoMu*') || filter('*OverlapFilterIsoEle*') || filter('*L1HLTMatched*') || filter('*Dz02*') || filter('*DoublePFTau*') || filter('*SinglePFTau*') || filter('hlt*SelectedPFTau') || filter('*DisplPFTau*') )"), #All trigger objects from a Tau collection + passing at least one filter
0130             l1seed = cms.string("type(-100)"), l1deltaR = cms.double(0.3),
0131             l2seed = cms.string("type(84) && coll('hltL2TauJetsL1IsoTauSeeded')"),  l2deltaR = cms.double(0.3),
0132             skipObjectsNotPassingQualityBits = cms.bool(True),
0133             qualityBits = cms.VPSet(
0134                 mksel("filter('*LooseChargedIso*')","LooseChargedIso"),
0135                 mksel("filter('*MediumChargedIso*')","MediumChargedIso"),
0136                 mksel("filter('*TightChargedIso*')","TightChargedIso"),
0137                 mksel("filter('*DeepTau*')","DeepTau"),
0138                 mksel("filter('*TightOOSCPhotons*')","TightID OOSC photons"),
0139                 mksel("filter('*Hps*')","HPS"),
0140                 mksel("filter('hlt*DoublePFTau*TrackPt1*ChargedIsolation*Dz02*')","charged iso di-tau"),
0141                 mksel("filter('hlt*DoublePFTau*DeepTau*L1HLTMatched')","deeptau di-tau"),
0142                 mksel("filter('hlt*OverlapFilterIsoEle*WPTightGsf*PFTau*')","e-tau"),
0143                 mksel("filter('hlt*OverlapFilterIsoMu*PFTau*')","mu-tau"),
0144                 mksel("filter('hlt*SelectedPFTau*L1HLTMatched')","single-tau/tau+MET"),
0145                 mksel("filter('hlt*DoublePFTau*TrackPt1*ChargedIso*')","run 2 VBF+ditau"),
0146                 mksel("filter('hlt*DoublePFTau*Track*ChargedIso*AgainstMuon')","run 3 VBF+ditau"),
0147                 mksel("filter('hltHpsSinglePFTau*HLTMatched')","run 3 double PF jets + ditau"),
0148                 mksel("filter('hltHpsOverlapFilterDeepTauDoublePFTau*PFJet*')","di-tau + PFJet"),
0149                 mksel("filter('hlt*Double*ChargedIsoDisplPFTau*Dxy*')","Displaced Tau"),
0150                 mksel("filter('*Monitoring')","Monitoring"),
0151                 mksel("filter('*Reg')","regional paths"),
0152                 mksel("filter('*L1Seeded')","L1 seeded paths"),
0153                 mksel("filter('*1Prong')","1 prong tau paths")
0154             )
0155         ),
0156         BoostedTau = cms.PSet(
0157             id = cms.int32(1515),
0158             sel = cms.string("type(85) && pt > 120 && coll('hltAK8PFJetsCorrected') && filter('hltAK8SinglePFJets*SoftDropMass40*ParticleNetTauTau')"),
0159             l1seed = cms.string("type(-99)"), l1deltaR = cms.double(0.3),
0160             l2seed = cms.string("type(85)  && coll('hltAK8CaloJetsCorrectedIDPassed')"),  l2deltaR = cms.double(0.3),
0161             skipObjectsNotPassingQualityBits = cms.bool(True),
0162             qualityBits = cms.VPSet(
0163                 mksel("filter('hltAK8SinglePFJets*SoftDropMass40*ParticleNetTauTau')","HLT_AK8PFJetX_SoftDropMass40_PFAK8ParticleNetTauTau0p30")
0164             )
0165         ),
0166         Jet = cms.PSet(
0167             id = cms.int32(1),
0168             sel = cms.string("( type(0) || type(85) || type(86) || type(-99) )"),
0169             l1seed = cms.string("type(-99)"), l1deltaR = cms.double(0.3),
0170             l2seed = cms.string("type(85) || type(86) || type(-99)"),  l2deltaR = cms.double(0.3),
0171             skipObjectsNotPassingQualityBits = cms.bool(True),
0172             qualityBits = cms.VPSet(
0173                 mksel(["hlt4PixelOnlyPFCentralJetTightIDPt20"]), # 0
0174                 mksel(["hlt3PixelOnlyPFCentralJetTightIDPt30"]), # 1
0175                 mksel(["hltPFJetFilterTwoC30"]), # 2
0176                 mksel(["hlt4PFCentralJetTightIDPt30"]), # 3
0177                 mksel(["hlt4PFCentralJetTightIDPt35"]), # 4
0178                 mksel(["hltQuadCentralJet30"]), # 5
0179                 mksel(["hlt2PixelOnlyPFCentralJetTightIDPt40"]), # 6
0180                 mksel(["hltL1sTripleJet1008572VBFIorHTTIorDoubleJetCIorSingleJet","hltL1sTripleJet1058576VBFIorHTTIorDoubleJetCIorSingleJet","hltL1sTripleJetVBFIorHTTIorSingleJet"]), # 7
0181                 mksel(["hlt3PFCentralJetTightIDPt40"]), # 8
0182                 mksel(["hlt3PFCentralJetTightIDPt45"]), # 9
0183                 mksel(["hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet","hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet"]), # 10
0184                 mksel(["hltBTagCaloDeepCSVp17Double"]), # 11
0185                 mksel(["hltPFCentralJetLooseIDQuad30"]), # 12
0186                 mksel(["hlt1PFCentralJetLooseID75"]), # 13
0187                 mksel(["hlt2PFCentralJetLooseID60"]), # 14
0188                 mksel(["hlt3PFCentralJetLooseID45"]), # 15
0189                 mksel(["hlt4PFCentralJetLooseID40"]), # 16
0190                 mksel(["hltBTagPFDeepCSV4p5Triple"]), # 17
0191                 mksel("filter('hltHpsOverlapFilterDeepTauDoublePFTau*PFJet*')","(Double tau + jet) hltHpsOverlapFilterDeepTauDoublePFTau*PFJet*"), # 18
0192                 mksel("filter('*CrossCleaned*MediumDeepTauDitauWPPFTau*')","(VBF cross-cleaned from medium deeptau PFTau) *CrossCleaned*MediumDeepTauDitauWPPFTau*"), # 19
0193                 mksel("filter('*CrossCleanedUsingDiJetCorrChecker*')","(VBF cross-cleaned using dijet correlation checker) *CrossCleanedUsingDiJetCorrChecker*"), # 20
0194                 mksel("filter('hltHpsOverlapFilterDeepTauPFTau*PFJet*')","(monitoring muon + tau + jet)  hltHpsOverlapFilterDeepTauPFTau*PFJet*"), # 21
0195                 mksel(["hlt2PFCentralJetTightIDPt50"]), # 22
0196                 mksel(["hlt1PixelOnlyPFCentralJetTightIDPt60"]), # 23
0197                 mksel(["hlt1PFCentralJetTightIDPt70"]), # 24
0198                 mksel(["hltBTagPFDeepJet1p5Single"]), # 25
0199                 mksel(["hltBTagPFDeepJet4p5Triple"]), # 26
0200                 mksel(["hltBTagCentralJetPt35PFParticleNet2BTagSum0p65","hltBTagCentralJetPt30PFParticleNet2BTagSum0p65","hltPFJetTwoC30PFBTagParticleNet2BTagSum0p65"]), # 27
0201                 mksel(["hltBTagPFDeepCSV1p5Single"]) # 28
0202             ),
0203         ),
0204         FatJet = cms.PSet(
0205             id = cms.int32(6),
0206             sel = cms.string("type(85) && pt > 120 && coll('hltAK8PFJetsCorrected')"),
0207             l1seed = cms.string("type(-99)"), l1deltaR = cms.double(0.3),
0208             l2seed = cms.string("type(85)  && coll('hltAK8CaloJetsCorrectedIDPassed')"),  l2deltaR = cms.double(0.3),
0209             skipObjectsNotPassingQualityBits = cms.bool(True),
0210             qualityBits = cms.VPSet()
0211         ),
0212         MET = cms.PSet(
0213             id = cms.int32(2),
0214             sel = cms.string("type(87) && pt > 30 && coll('hltPFMETProducer')"),
0215             l1seed = cms.string("type(-87) && coll('L1ETM')"), l1deltaR = cms.double(9999),
0216             l1seed_2 = cms.string("type(-87) && coll('L1ETMHF')"), l1deltaR_2 = cms.double(9999),
0217             l2seed = cms.string("type( 87) && coll('hltMetClean')"),  l2deltaR = cms.double(9999),
0218             skipObjectsNotPassingQualityBits = cms.bool(True),
0219             qualityBits = cms.VPSet()
0220         ),
0221         HT = cms.PSet(
0222             id = cms.int32(3),
0223             sel = cms.string("type(89) || type(-89)"),
0224             l1seed = cms.string("type(-89) && coll('L1HTT')"), l1deltaR = cms.double(9999),
0225             l1seed_2 = cms.string("type(-89) && coll('L1HTTHF')"), l1deltaR_2 = cms.double(9999),
0226             l2seed = cms.string("type(89) && coll('hltHtMhtJet30')"),  l2deltaR = cms.double(9999),
0227             skipObjectsNotPassingQualityBits = cms.bool(True),
0228             qualityBits = cms.VPSet(
0229                 mksel(["hltL1sTripleJetVBFIorHTTIorDoubleJetCIorSingleJet"]),
0230                 mksel(["hltL1sQuadJetC50IorQuadJetC60IorHTT280IorHTT300IorHTT320IorTripleJet846848VBFIorTripleJet887256VBFIorTripleJet927664VBF","hltL1sQuadJetCIorTripleJetVBFIorHTT"]),
0231                 mksel(["hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet","hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet"]),
0232                 mksel(["hltCaloQuadJet30HT300","hltCaloQuadJet30HT320"]),
0233                 mksel(["hltPFCentralJetsLooseIDQuad30HT300","hltPFCentralJetsLooseIDQuad30HT330"])
0234             ),
0235         ),
0236         MHT = cms.PSet(
0237             id = cms.int32(4),
0238             sel = cms.string("type(90)"),
0239             l1seed = cms.string("type(-90) && coll('L1HTM')"), l1deltaR = cms.double(9999),
0240             l1seed_2 = cms.string("type(-90) && coll('L1HTMHF')"), l1deltaR_2 = cms.double(9999),
0241             l2seed = cms.string("type(90) && coll('hltHtMhtJet30')"),  l2deltaR = cms.double(9999),
0242             skipObjectsNotPassingQualityBits = cms.bool(True),
0243             qualityBits = cms.VPSet(
0244                 mksel(["hltCaloQuadJet30HT300","hltCaloQuadJet30HT320"]),
0245                 mksel(["hltPFCentralJetsLooseIDQuad30HT300","hltPFCentralJetsLooseIDQuad30HT330"])
0246             ),
0247         ),
0248     ),
0249 )
0250 
0251 # ERA-dependent configuration
0252 # Tune filter and collection names to 2016 HLT menus
0253 # FIXME: check non-lepton objects and cross check leptons
0254 run2_HLTconditions_2016.toModify(
0255     triggerObjectTable.selections.Muon,
0256     sel = "type(83) && pt > 5 && (coll('hlt*L3MuonCandidates') || coll('hlt*TkMuonCands') || coll('hlt*TrkMuonCands'))",
0257     qualityBits = cms.VPSet(
0258             mksel("filter('*RelTrkIso*Filtered0p4')","TrkIsoVVL"),
0259             mksel("filter('hltL3cr*IsoFiltered0p09')","Iso"),
0260             mksel("filter('*OverlapFilter*IsoMu*PFTau*')","OverlapFilter PFTau"),
0261             mksel("filter('hltL3f*IsoFiltered0p09')","IsoTkMu"),
0262             mksel(["hltL3fL1sMu*L3Filtered50*","hltL3fL1sMu*TkFiltered50*"],"1mu (Mu50)", bit=10)
0263     )
0264 ).toModify(
0265     triggerObjectTable.selections.Tau,
0266     sel = "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*') )",
0267     qualityBits = cms.VPSet(
0268         mksel("(filter('*LooseIso*')-filter('*VLooseIso*'))","LooseIso"),
0269         mksel("filter('*Medium*Iso*')","Medium(Comb)Iso"),
0270         mksel("filter('*VLooseIso*')","VLooseIso"),
0271         mksel("0","None"),
0272         mksel("filter('hltL2TauIsoFilter')","L2p5 pixel iso"),
0273         mksel("filter('*OverlapFilter*IsoMu*')","OverlapFilter IsoMu"),
0274         mksel("filter('*OverlapFilter*IsoEle*')","OverlapFilter IsoEle"),
0275         mksel("filter('*L1HLTMatched*')","L1-HLT matched"),
0276         mksel("filter('*Dz02*')","Dz")
0277     )
0278 )
0279 
0280 _run2_HLTconditions = run2_HLTconditions_2016 | run2_HLTconditions_2017 | run2_HLTconditions_2018
0281 
0282 _run2_2016_jet_filters = [
0283         mksel(["*CrossCleaned*LooseChargedIsoPFTau*"], "VBF cross-cleaned from loose iso PFTau"), # 0
0284         mksel(["hltBTagCaloCSVp087Triple"], "hltBTagCaloCSVp087Triple"), # 1
0285         mksel(["hltDoubleCentralJet90"], "hltDoubleCentralJet90"), # 2
0286         mksel(["hltDoublePFCentralJetLooseID90"], "hltDoublePFCentralJetLooseID90"), # 3
0287         mksel(["hltL1sTripleJetVBFIorHTTIorDoubleJetCIorSingleJet"], "hltL1sTripleJetVBFIorHTTIorDoubleJetCIorSingleJet"), # 4
0288         mksel(["hltQuadCentralJet30"], "hltQuadCentralJet30"), # 5
0289         mksel(["hltQuadPFCentralJetLooseID30"], "hltQuadPFCentralJetLooseID30"), # 6
0290         mksel(["hltL1sQuadJetC50IorQuadJetC60IorHTT280IorHTT300IorHTT320IorTripleJet846848VBFIorTripleJet887256VBFIorTripleJet927664VBF", "hltL1sQuadJetCIorTripleJetVBFIorHTT"], "hltL1sQuadJetC50IorQuadJetC60IorHTT280IorHTT300IorHTT320IorTripleJet846848VBFIorTripleJet887256VBFIorTripleJet927664VBF or hltL1sQuadJetCIorTripleJetVBFIorHTT"), # 7
0291         mksel(["hltQuadCentralJet45"], "hltQuadCentralJet45"), # 8
0292         mksel(["hltQuadPFCentralJetLooseID45"], "hltQuadPFCentralJetLooseID45"), # 9
0293         mksel(["hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet", "hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet"], "hltL1sQuadJetC60IorHTT380IorHTT280QuadJetIorHTT300QuadJet or hltL1sQuadJetC50to60IorHTT280to500IorHTT250to340QuadJet"), # 10
0294         mksel(["hltBTagCaloCSVp05Double", "hltBTagCaloDeepCSVp17Double"], "hltBTagCaloCSVp05Double or hltBTagCaloDeepCSVp17Double"), # 11
0295         mksel(["hltPFCentralJetLooseIDQuad30"], "hltPFCentralJetLooseIDQuad30"), # 12
0296         mksel(["hlt1PFCentralJetLooseID75"], "hlt1PFCentralJetLooseID75"), # 13
0297         mksel(["hlt2PFCentralJetLooseID60"], "hlt2PFCentralJetLooseID60"), # 14
0298         mksel(["hlt3PFCentralJetLooseID45"], "hlt3PFCentralJetLooseID45"), # 15
0299         mksel(["hlt4PFCentralJetLooseID40"], "hlt4PFCentralJetLooseID40"), # 16
0300         mksel(["hltBTagPFCSVp070Triple", "hltBTagPFDeepCSVp24Triple", "hltBTagPFDeepCSV4p5Triple"], "hltBTagPFCSVp070Triple or hltBTagPFDeepCSVp24Triple or hltBTagPFDeepCSV4p5Triple"), # 17
0301         mksel(["hltHpsOverlapFilterDeepTauDoublePFTau*PFJet*"], "Double tau + jet"), # 18
0302         mksel(["*CrossCleaned*MediumDeepTauDitauWPPFTau*"], "VBF cross-cleaned from medium deeptau PFTau"), # 19
0303         mksel(["*CrossCleanedUsingDiJetCorrChecker*"], "VBF cross-cleaned using dijet correlation checker"), # 20
0304         mksel(["hltHpsOverlapFilterDeepTauPFTau*PFJet*"], "monitoring muon + tau + jet"), # 21
0305 ]
0306 run2_HLTconditions_2016.toModify(triggerObjectTable.selections.Jet, qualityBits = cms.VPSet(_run2_2016_jet_filters))
0307 
0308 _run2_2017_jet_filters = copy.deepcopy(_run2_2016_jet_filters)
0309 _run2_2017_jet_filters[7] = mksel(["hltL1sTripleJet1008572VBFIorHTTIorDoubleJetCIorSingleJet","hltL1sTripleJet1058576VBFIorHTTIorDoubleJetCIorSingleJet","hltL1sTripleJetVBFIorHTTIorSingleJet"])
0310 run2_HLTconditions_2017.toModify(triggerObjectTable.selections.Jet, qualityBits = cms.VPSet(_run2_2017_jet_filters))
0311 
0312 _run2_2018_jet_filters = copy.deepcopy(_run2_2017_jet_filters)
0313 _run2_2018_jet_filters[2] = mksel(["hltPFJetFilterTwoC30"])
0314 _run2_2018_jet_filters.append(mksel(["hltBTagPFDeepCSV1p5Single"])) # 22
0315 run2_HLTconditions_2018.toModify(triggerObjectTable.selections.Jet, qualityBits = cms.VPSet(_run2_2018_jet_filters))
0316 
0317 
0318 from PhysicsTools.PatUtils.L1PrefiringWeightProducer_cff import prefiringweight
0319 #Next lines are for UL2016 maps
0320 (run2_muon_2016 & tracker_apv_vfp30_2016).toModify(
0321     prefiringweight,
0322     DataEraECAL = cms.string("UL2016preVFP"),
0323     DataEraMuon = cms.string("2016preVFP")
0324 )
0325 (run2_muon_2016 & ~tracker_apv_vfp30_2016).toModify(
0326     prefiringweight,
0327     DataEraECAL = cms.string("UL2016postVFP"),
0328     DataEraMuon = cms.string("2016postVFP")
0329 )
0330 #Next line is for UL2017 maps 
0331 run2_jme_2017.toModify(
0332     prefiringweight,
0333     DataEraECAL = cms.string("UL2017BtoF"),
0334     DataEraMuon = cms.string("20172018")
0335 )
0336 #Next line is for UL2018 maps
0337 run2_muon_2018.toModify(
0338     prefiringweight,
0339     DataEraECAL = cms.string("None"),
0340     DataEraMuon = cms.string("20172018")
0341 )
0342 
0343 l1PreFiringEventWeightTable = globalVariablesTableProducer.clone(
0344     name = cms.string("L1PreFiringWeight"),
0345     variables = cms.PSet(
0346         Nom = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProb"), "float", doc = "L1 pre-firing event correction weight (1-probability)", precision=8),
0347         Up = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbUp"), "float", doc = "L1 pre-firing event correction weight (1-probability), up var.", precision=8),
0348         Dn = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbDown"), "float", doc = "L1 pre-firing event correction weight (1-probability), down var.", precision=8),
0349         Muon_Nom = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbMuon"), "float", doc = "Muon L1 pre-firing event correction weight (1-probability)", precision=8),
0350         Muon_SystUp = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbMuonSystUp"), "float", doc = "Muon L1 pre-firing event correction weight (1-probability), up var. syst.", precision=8),
0351         Muon_SystDn = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbMuonSystDown"), "float", doc = "Muon L1 pre-firing event correction weight (1-probability), down var. syst.", precision=8),
0352         Muon_StatUp = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbMuonStatUp"), "float", doc = "Muon L1 pre-firing event correction weight (1-probability), up var. stat.", precision=8),
0353         Muon_StatDn = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbMuonStatDown"), "float", doc = "Muon L1 pre-firing event correction weight (1-probability), down var. stat.", precision=8),
0354         ECAL_Nom = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbECAL"), "float", doc = "ECAL L1 pre-firing event correction weight (1-probability)", precision=8),
0355         ECAL_Up = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbECALUp"), "float", doc = "ECAL L1 pre-firing event correction weight (1-probability), up var.", precision=8),
0356         ECAL_Dn = ExtVar(cms.InputTag("prefiringweight:nonPrefiringProbECALDown"), "float", doc = "ECAL L1 pre-firing event correction weight (1-probability), down var.", precision=8),
0357     )
0358 )
0359 
0360 l1bits=cms.EDProducer("L1TriggerResultsConverter",
0361                        src=cms.InputTag("gtStage2Digis"),
0362                        legacyL1=cms.bool(False),
0363                        storeUnprefireableBit=cms.bool(True),
0364                        src_ext=cms.InputTag("simGtExtUnprefireable"))
0365 
0366 triggerObjectTablesTask = cms.Task( unpackedPatTrigger,triggerObjectTable,l1bits)
0367 
0368 _run2_HLTconditions.toReplaceWith(
0369     triggerObjectTablesTask, triggerObjectTablesTask.copyAndAdd(prefiringweight,l1PreFiringEventWeightTable)
0370 )