Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-04 01:26:10

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 from PhysicsTools.NanoAOD.nano_eras_cff import *
0004 from PhysicsTools.NanoAOD.common_cff import *
0005 
0006 ##################### User floats producers, selectors ##########################
0007 
0008 from  PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import *
0009 # Note: Safe to always add 'L2L3Residual' as MC contains dummy L2L3Residual corrections (always set to 1)
0010 #      (cf. https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CMSSW_7_6_4_and_above )
0011 jetPuppiCorrFactorsNano = patJetCorrFactors.clone(src='slimmedJetsPuppi',
0012     levels = cms.vstring('L1FastJet',
0013         'L2Relative',
0014         'L3Absolute',
0015         'L2L3Residual'),
0016     payload = cms.string('AK4PFPuppi'),
0017     primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
0018 )
0019 
0020 from  PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cfi import *
0021 
0022 updatedJetsPuppi = updatedPatJets.clone(
0023     addBTagInfo=False,
0024     jetSource='slimmedJetsPuppi',
0025     jetCorrFactorsSource=cms.VInputTag(cms.InputTag("jetPuppiCorrFactorsNano") ),
0026 )
0027 
0028 tightJetPuppiId = cms.EDProducer("PatJetIDValueMapProducer",
0029     filterParams=cms.PSet(
0030         version = cms.string('RUN2ULPUPPI'),
0031         quality = cms.string('TIGHT'),
0032     ),
0033     src = cms.InputTag("updatedJetsPuppi")
0034 )
0035 tightJetPuppiIdLepVeto = cms.EDProducer("PatJetIDValueMapProducer",
0036     filterParams=cms.PSet(
0037         version = cms.string('RUN2ULPUPPI'),
0038         quality = cms.string('TIGHTLEPVETO'),
0039     ),
0040     src = cms.InputTag("updatedJetsPuppi")
0041 )
0042 
0043 #HF shower shape recomputation
0044 from RecoJets.JetProducers.hfJetShowerShape_cfi import hfJetShowerShape
0045 hfJetPuppiShowerShapeforNanoAOD = hfJetShowerShape.clone(jets="updatedJetsPuppi",vertices="offlineSlimmedPrimaryVertices")
0046 
0047 updatedJetsPuppiWithUserData = cms.EDProducer("PATJetUserDataEmbedder",
0048     src = cms.InputTag("updatedJetsPuppi"),
0049     userFloats = cms.PSet(
0050         hfsigmaEtaEta = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:sigmaEtaEta'),
0051         hfsigmaPhiPhi = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:sigmaPhiPhi'),
0052     ),
0053     userInts = cms.PSet(
0054         tightId = cms.InputTag("tightJetPuppiId"),
0055         tightIdLepVeto = cms.InputTag("tightJetPuppiIdLepVeto"),
0056         hfcentralEtaStripSize = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:centralEtaStripSize'),
0057         hfadjacentEtaStripsSize = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:adjacentEtaStripsSize'),
0058     ),
0059 )
0060 
0061 finalJetsPuppi = cms.EDFilter("PATJetRefSelector",
0062     src = cms.InputTag("updatedJetsPuppiWithUserData"),
0063     cut = cms.string("pt > 15")
0064 )
0065 
0066 ##################### Tables for final output and docs ##########################
0067 jetPuppiTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0068     src = cms.InputTag("linkedObjects","jets"),
0069     cut = cms.string(""), #we should not filter on cross linked collections
0070     name = cms.string("Jet"),
0071     doc  = cms.string("slimmedJetsPuppi, i.e. ak4 PFJets Puppi with JECs applied, after basic selection (" + finalJetsPuppi.cut.value()+")"),
0072     singleton = cms.bool(False), # the number of entries is variable
0073     extension = cms.bool(False), # this is the main table for the jets
0074     externalVariables = cms.PSet(),
0075     variables = cms.PSet(P4Vars,
0076         area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
0077         nMuons = Var("?hasOverlaps('muons')?overlaps('muons').size():0", int, doc="number of muons in the jet"),
0078         muonIdx1 = Var("?overlaps('muons').size()>0?overlaps('muons')[0].key():-1", int, doc="index of first matching muon"),
0079         muonIdx2 = Var("?overlaps('muons').size()>1?overlaps('muons')[1].key():-1", int, doc="index of second matching muon"),
0080         electronIdx1 = Var("?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1", int, doc="index of first matching electron"),
0081         electronIdx2 = Var("?overlaps('electrons').size()>1?overlaps('electrons')[1].key():-1", int, doc="index of second matching electron"),
0082         nElectrons = Var("?hasOverlaps('electrons')?overlaps('electrons').size():0", int, doc="number of electrons in the jet"),
0083         btagDeepB = Var("?(bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc="DeepCSV b+bb tag discriminator",precision=10),
0084         btagDeepFlavB = Var("bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')",float,doc="DeepJet b+bb+lepb tag discriminator",precision=10),
0085         btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
0086         btagDeepCvL = Var("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1", float,doc="DeepCSV c vs udsg discriminator",precision=10),
0087         btagDeepCvB = Var("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')):-1",float,doc="DeepCSV c vs b+bb discriminator",precision=10),
0088         btagDeepFlavCvL = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1",float,doc="DeepJet c vs uds+g discriminator",precision=10),
0089         btagDeepFlavCvB = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1",float,doc="DeepJet c vs b+bb+lepb discriminator",precision=10),
0090         btagDeepFlavQG = Var("?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1",float,doc="DeepJet g vs uds discriminator",precision=10),
0091         jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc="Jet ID flag: bit2 is tight, bit3 is tightLepVeto"),
0092         hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10),
0093         hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10),
0094         hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable)"),
0095         hfadjacentEtaStripsSize = Var("userInt('hfadjacentEtaStripsSize')", int, doc="eta size of the strips next to the central tower strip in HF (noise discriminating variable)"),
0096         nConstituents = Var("numberOfDaughters()","uint8",doc="Number of particles in the jet"),
0097         rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
0098         chHEF = Var("chargedHadronEnergyFraction()", float, doc="charged Hadron Energy Fraction", precision= 6),
0099         neHEF = Var("neutralHadronEnergyFraction()", float, doc="neutral Hadron Energy Fraction", precision= 6),
0100         chEmEF = Var("chargedEmEnergyFraction()", float, doc="charged Electromagnetic Energy Fraction", precision= 6),
0101         neEmEF = Var("neutralEmEnergyFraction()", float, doc="neutral Electromagnetic Energy Fraction", precision= 6),
0102         muEF = Var("muonEnergyFraction()", float, doc="muon Energy Fraction", precision= 6),
0103     )
0104 )
0105 
0106 #jets are not as precise as muons
0107 jetPuppiTable.variables.pt.precision=10
0108 
0109 ################################################################################
0110 # JETS FOR MET type1 
0111 ################################################################################
0112 basicJetsPuppiForMetForT1METNano = cms.EDProducer("PATJetCleanerForType1MET",
0113     src = updatedJetsPuppiWithUserData.src,
0114     jetCorrEtaMax = cms.double(9.9),
0115     jetCorrLabel = cms.InputTag("L3Absolute"),
0116     jetCorrLabelRes = cms.InputTag("L2L3Residual"),
0117     offsetCorrLabel = cms.InputTag("L1FastJet"),
0118     skipEM = cms.bool(False),
0119     skipEMfractionThreshold = cms.double(0.9),
0120     skipMuonSelection = cms.string('isGlobalMuon | isStandAloneMuon'),
0121     skipMuons = cms.bool(True),
0122     type1JetPtThreshold = cms.double(0.0),
0123     calcMuonSubtrRawPtAsValueMap = cms.bool(True)
0124 )
0125 
0126 updatedJetsPuppiWithUserData.userFloats.muonSubtrRawPt = cms.InputTag("basicJetsPuppiForMetForT1METNano:MuonSubtrRawPt")
0127 
0128 corrT1METJetPuppiTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0129     src = finalJetsPuppi.src,
0130     cut = cms.string("pt<15 && abs(eta)<9.9"),
0131     name = cms.string("CorrT1METJet"),
0132     doc  = cms.string("Additional low-pt ak4 Puppi jets for Type-1 MET re-correction"),
0133     singleton = cms.bool(False), # the number of entries is variable
0134     extension = cms.bool(False), # this is the main table for the jets
0135     variables = cms.PSet(
0136         rawPt = Var("pt()*jecFactor('Uncorrected')",float,precision=10),
0137         eta  = Var("eta",  float,precision=12),
0138         phi = Var("phi", float, precision=12),
0139         area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
0140     )
0141 )
0142 
0143 corrT1METJetPuppiTable.variables.muonSubtrFactor = Var("1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc="1-(muon-subtracted raw pt)/(raw pt)",precision=6)
0144 jetPuppiTable.variables.muonSubtrFactor = Var("1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc="1-(muon-subtracted raw pt)/(raw pt)",precision=6)
0145 
0146 jetPuppiForMETTask =  cms.Task(basicJetsPuppiForMetForT1METNano,corrT1METJetPuppiTable)
0147 
0148 #before cross linking
0149 jetPuppiUserDataTask = cms.Task(tightJetPuppiId, tightJetPuppiIdLepVeto, hfJetPuppiShowerShapeforNanoAOD)
0150 
0151 #before cross linking
0152 jetPuppiTask = cms.Task(jetPuppiCorrFactorsNano,updatedJetsPuppi,jetPuppiUserDataTask,updatedJetsPuppiWithUserData,finalJetsPuppi)
0153 
0154 #after cross linkining
0155 jetPuppiTablesTask = cms.Task(jetPuppiTable)