Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-16 23:01:09

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 from PhysicsTools.NanoAOD.common_cff import *
0004 from PhysicsTools.NanoAOD.nano_eras_cff import *
0005 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
0006 
0007 ##################### User floats producers, selectors ##########################
0008 
0009 from  PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import *
0010 # Note: Safe to always add 'L2L3Residual' as MC contains dummy L2L3Residual corrections (always set to 1)
0011 #      (cf. https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CMSSW_7_6_4_and_above )
0012 jetPuppiCorrFactorsNano = patJetCorrFactors.clone(src='slimmedJetsPuppi',
0013     levels = cms.vstring('L1FastJet',
0014         'L2Relative',
0015         'L3Absolute',
0016         'L2L3Residual'),
0017     payload = cms.string('AK4PFPuppi'),
0018     primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
0019 )
0020 
0021 from  PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cfi import *
0022 
0023 updatedJetsPuppi = updatedPatJets.clone(
0024     addBTagInfo=False,
0025     jetSource='slimmedJetsPuppi',
0026     jetCorrFactorsSource=cms.VInputTag(cms.InputTag("jetPuppiCorrFactorsNano") ),
0027 )
0028 
0029 tightJetPuppiId = cms.EDProducer("PatJetIDValueMapProducer",
0030     filterParams=cms.PSet(
0031         version = cms.string('RUN3PUPPIruns2022FGruns2023CD'),
0032         quality = cms.string('TIGHT'),
0033     ),
0034     src = cms.InputTag("updatedJetsPuppi")
0035 )
0036 tightJetPuppiIdLepVeto = cms.EDProducer("PatJetIDValueMapProducer",
0037     filterParams=cms.PSet(
0038         version = cms.string('RUN3PUPPIruns2022FGruns2023CD'),
0039         quality = cms.string('TIGHTLEPVETO'),
0040     ),
0041     src = cms.InputTag("updatedJetsPuppi")
0042 )
0043 
0044 run2_jme_2016.toModify(
0045     tightJetPuppiId.filterParams, version = "RUN2UL16PUPPI"
0046 ).toModify(
0047     tightJetPuppiIdLepVeto.filterParams, version = "RUN2UL16PUPPI"
0048 )
0049 
0050 (run2_jme_2017 | run2_jme_2018 | run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
0051     tightJetPuppiId.filterParams, version = "RUN2ULPUPPI"
0052 ).toModify(
0053     tightJetPuppiIdLepVeto.filterParams, version = "RUN2ULPUPPI"
0054 )
0055 
0056 run3_jme_Winter22runsBCDEprompt.toModify(
0057     tightJetPuppiId.filterParams, version = "RUN3PUPPIruns2022BCDEprompt"
0058 ).toModify(
0059     tightJetPuppiIdLepVeto.filterParams, version = "RUN3PUPPIruns2022BCDEprompt"
0060 )
0061 
0062 #HF shower shape recomputation
0063 from RecoJets.JetProducers.hfJetShowerShape_cfi import hfJetShowerShape
0064 hfJetPuppiShowerShapeforNanoAOD = hfJetShowerShape.clone(jets="updatedJetsPuppi",vertices="offlineSlimmedPrimaryVertices")
0065 
0066 updatedJetsPuppiWithUserData = cms.EDProducer("PATJetUserDataEmbedder",
0067     src = cms.InputTag("updatedJetsPuppi"),
0068     userFloats = cms.PSet(
0069         hfsigmaEtaEta = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:sigmaEtaEta'),
0070         hfsigmaPhiPhi = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:sigmaPhiPhi'),
0071     ),
0072     userInts = cms.PSet(
0073         tightId = cms.InputTag("tightJetPuppiId"),
0074         tightIdLepVeto = cms.InputTag("tightJetPuppiIdLepVeto"),
0075         hfcentralEtaStripSize = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:centralEtaStripSize'),
0076         hfadjacentEtaStripsSize = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:adjacentEtaStripsSize'),
0077     ),
0078 )
0079 
0080 finalJetsPuppi = cms.EDFilter("PATJetRefSelector",
0081     src = cms.InputTag("updatedJetsPuppiWithUserData"),
0082     cut = cms.string("pt > 15")
0083 )
0084 
0085 ##################### Tables for final output and docs ##########################
0086 jetPuppiTable = simpleCandidateFlatTableProducer.clone(
0087     src = cms.InputTag("linkedObjects","jets"),
0088     name = cms.string("Jet"),
0089     doc  = cms.string("slimmedJetsPuppi, i.e. ak4 PFJets Puppi with JECs applied, after basic selection (" + finalJetsPuppi.cut.value()+")"),
0090     externalVariables = cms.PSet(),
0091     variables = cms.PSet(P4Vars,
0092         area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
0093         nMuons = Var("?hasOverlaps('muons')?overlaps('muons').size():0", "uint8", doc="number of muons in the jet"),
0094         muonIdx1 = Var("?overlaps('muons').size()>0?overlaps('muons')[0].key():-1", "int16", doc="index of first matching muon"),
0095         muonIdx2 = Var("?overlaps('muons').size()>1?overlaps('muons')[1].key():-1", "int16", doc="index of second matching muon"),
0096         electronIdx1 = Var("?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1", "int16", doc="index of first matching electron"),
0097         electronIdx2 = Var("?overlaps('electrons').size()>1?overlaps('electrons')[1].key():-1", "int16", doc="index of second matching electron"),
0098         nElectrons = Var("?hasOverlaps('electrons')?overlaps('electrons').size():0", "uint8", doc="number of electrons in the jet"),
0099         svIdx1 = Var("?overlaps('vertices').size()>0?overlaps('vertices')[0].key():-1", "int16", doc="index of first matching secondary vertex"),
0100         svIdx2 = Var("?overlaps('vertices').size()>1?overlaps('vertices')[1].key():-1", "int16", doc="index of second matching secondary vertex"),
0101         nSVs = Var("?hasOverlaps('vertices')?overlaps('vertices').size():0", "uint8", doc="number of secondary vertices in the jet"),
0102         btagDeepFlavB = Var("bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')",float,doc="DeepJet b+bb+lepb tag discriminator",precision=10),
0103         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),
0104         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),
0105         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),
0106         btagPNetB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc="ParticleNet b vs. udscg"),
0107         btagPNetCvNotB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probb')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')/(1.-bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probb')):-1",float,precision=10,doc="ParticleNet C vs notB"),
0108         btagPNetCvL = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc="ParticleNet c vs. udsg"),
0109         btagPNetCvB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc="ParticleNet c vs. b"),
0110         btagPNetQvG = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:QvsG'):bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags:QvsG')",float,precision=10,doc="ParticleNet q (udsbc) vs. g"),
0111         btagPNetTauVJet = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc="ParticleNet tau vs. jet"),
0112         PNetRegPtRawCorr = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptcorr'):bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptcorr')",float,precision=10,doc="ParticleNet universal flavor-aware visible pT regression (no neutrinos), correction relative to raw jet pT"),
0113         PNetRegPtRawCorrNeutrino = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptnu'):bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptnu')",float,precision=10,doc="ParticleNet universal flavor-aware pT regression neutrino correction, relative to visible. To apply full regression, multiply raw jet pT by both PNetRegPtRawCorr and PNetRegPtRawCorrNeutrino."),
0114         PNetRegPtRawRes = Var("?abs(eta())<2.5?0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptreslow')):0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptreslow'))",float,precision=10,doc="ParticleNet universal flavor-aware jet pT resolution estimator, (q84 - q16)/2"),
0115         btagUParTAK4B = Var("?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc="UnifiedParT b vs. udscg"),
0116         btagUParTAK4CvL = Var("?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc="UnifiedParT c vs. udsg"),
0117         btagUParTAK4CvB = Var("?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc="UnifiedParT c vs. b"),
0118         btagUParTAK4CvNotB = Var("?((bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probb')+bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:problepb')))>0?((bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probc'))/(1.-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probb')-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:probbb')-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:problepb'))):-1",float,precision=10,doc="UnifiedParT c vs. not b"),
0119         btagUParTAK4QvG = Var("?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:QvsG')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:QvsG'):-1",float,precision=10,doc="UnifiedParT q (udsbc) vs. g"),
0120         btagUParTAK4TauVJet = Var("?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfUnifiedParticleTransformerAK4DiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc="UnifiedParT tau vs. jet"),
0121         UParTAK4RegPtRawCorr = Var("?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptcorr')>0?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptcorr'):-1",float,precision=10,doc="UnifiedParT universal flavor-aware visible pT regression (no neutrinos), correction relative to raw jet pT"),
0122         UParTAK4RegPtRawCorrNeutrino = Var("?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptnu')>0?bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptnu'):-1",float,precision=10,doc="UnifiedParT universal flavor-aware pT regression neutrino correction, relative to visible. To apply full regression, multiply raw jet pT by both UParTAK4RegPtRawCorr and UParTAK4RegPtRawCorrNeutrino."),
0123         UParTAK4RegPtRawRes = Var("?(bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreshigh')+bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreslow'))>0?0.5*(bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreshigh')-bDiscriminator('pfUnifiedParticleTransformerAK4JetTags:ptreslow')):-1",float,precision=10,doc="UnifiedParT universal flavor-aware jet pT resolution estimator, (q84 - q16)/2"),
0124         jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')", "uint8",doc="Jet ID flag: bit2 is tight, bit3 is tightLepVeto"),
0125         hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10),
0126         hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10),
0127         hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable)"),
0128         hfadjacentEtaStripsSize = Var("userInt('hfadjacentEtaStripsSize')", int, doc="eta size of the strips next to the central tower strip in HF (noise discriminating variable)"),
0129         nConstituents = Var("numberOfDaughters()","uint8",doc="Number of particles in the jet"),
0130         chMultiplicity = Var("chargedMultiplicity()","uint8",doc="(Puppi-weighted) Number of charged particles in the jet"),
0131         neMultiplicity = Var("neutralMultiplicity()","uint8",doc="(Puppi-weighted) Number of neutral particles in the jet"),
0132         rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6),
0133         chHEF = Var("chargedHadronEnergyFraction()", float, doc="charged Hadron Energy Fraction", precision= 6),
0134         neHEF = Var("neutralHadronEnergyFraction()", float, doc="neutral Hadron Energy Fraction", precision= 6),
0135         chEmEF = Var("chargedEmEnergyFraction()", float, doc="charged Electromagnetic Energy Fraction", precision= 6),
0136         neEmEF = Var("neutralEmEnergyFraction()", float, doc="neutral Electromagnetic Energy Fraction", precision= 6),
0137         hfHEF = Var("HFHadronEnergyFraction()",float,doc="hadronic Energy Fraction in HF",precision= 6),
0138         hfEmEF = Var("HFEMEnergyFraction()",float,doc="electromagnetic Energy Fraction in HF",precision= 6),
0139         muEF = Var("muonEnergyFraction()", float, doc="muon Energy Fraction", precision= 6),
0140     )
0141 )
0142 
0143 run2_nanoAOD_ANY.toModify(
0144     jetPuppiTable.variables,
0145     btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
0146     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),
0147     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),
0148     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)
0149 )
0150 
0151 (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
0152     jetPuppiTable.variables,
0153     # New ParticleNet trainings are not available in MiniAOD until Run3 13X
0154     btagPNetB = None,
0155     btagPNetCvL = None,
0156     btagPNetCvB = None,
0157     btagPNetQvG = None,
0158     btagPNetTauVJet = None,
0159     PNetRegPtRawCorr = None,
0160     PNetRegPtRawCorrNeutrino = None,
0161     PNetRegPtRawRes = None,
0162     # Remove for V11 and earlier Run3 versions
0163     chMultiplicity = None,
0164     neMultiplicity = None,
0165     hfHEF = None,
0166     hfEmEF = None
0167 )
0168 
0169 #jets are not as precise as muons
0170 jetPuppiTable.variables.pt.precision=10
0171 
0172 ##############################################################
0173 ## DeepInfoAK4:Start
0174 ## - To be used in nanoAOD_customizeCommon() in nano_cff.py
0175 ###############################################################
0176 from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
0177 def nanoAOD_addDeepInfoAK4(process,addParticleNet,addRobustParTAK4=False,addUnifiedParTAK4=False):
0178     _btagDiscriminators=[]
0179     if addParticleNet:
0180         print("Updating process to run ParticleNetAK4")
0181         from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4PuppiCentralJetTagsAll as pfParticleNetFromMiniAODAK4PuppiCentralJetTagsAll
0182         from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4PuppiForwardJetTagsAll as pfParticleNetFromMiniAODAK4PuppiForwardJetTagsAll
0183         _btagDiscriminators += pfParticleNetFromMiniAODAK4PuppiCentralJetTagsAll
0184         _btagDiscriminators += pfParticleNetFromMiniAODAK4PuppiForwardJetTagsAll
0185     if addRobustParTAK4:
0186         print("Updating process to run RobustParTAK4")
0187         from RecoBTag.ONNXRuntime.pfParticleTransformerAK4_cff import _pfParticleTransformerAK4JetTagsAll as pfParticleTransformerAK4JetTagsAll
0188         _btagDiscriminators += pfParticleTransformerAK4JetTagsAll
0189     if addUnifiedParTAK4:
0190         print("Updating process to run UnifiedParTAK4")
0191         from RecoBTag.ONNXRuntime.pfUnifiedParticleTransformerAK4_cff import _pfUnifiedParticleTransformerAK4JetTagsAll as pfUnifiedParticleTransformerAK4JetTagsAll
0192         _btagDiscriminators += pfUnifiedParticleTransformerAK4JetTagsAll
0193     if len(_btagDiscriminators)==0: return process
0194     print("Will recalculate the following discriminators: "+", ".join(_btagDiscriminators))
0195     updateJetCollection(
0196         process,
0197         jetSource = cms.InputTag('slimmedJetsPuppi'),
0198         jetCorrections = ('AK4PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'),
0199         btagDiscriminators = _btagDiscriminators,
0200         postfix = 'PuppiWithDeepInfo',
0201     )
0202     process.load("Configuration.StandardSequences.MagneticField_cff")
0203     process.jetPuppiCorrFactorsNano.src = "selectedUpdatedPatJetsPuppiWithDeepInfo"
0204     process.updatedJetsPuppi.jetSource = "selectedUpdatedPatJetsPuppiWithDeepInfo"
0205     return process
0206 
0207 nanoAOD_addDeepInfoAK4_switch = cms.PSet(
0208     nanoAOD_addParticleNet_switch = cms.untracked.bool(False),
0209     nanoAOD_addRobustParTAK4Tag_switch = cms.untracked.bool(False),
0210     nanoAOD_addUnifiedParTAK4Tag_switch = cms.untracked.bool(False)
0211 )
0212 
0213 ################################################
0214 ## DeepInfoAK4:End
0215 #################################################
0216 
0217 ################################################################################
0218 # JETS FOR MET type1
0219 ################################################################################
0220 basicJetsPuppiForMetForT1METNano = cms.EDProducer("PATJetCleanerForType1MET",
0221     src = updatedJetsPuppiWithUserData.src,
0222     jetCorrEtaMax = cms.double(9.9),
0223     jetCorrLabel = cms.InputTag("L3Absolute"),
0224     jetCorrLabelRes = cms.InputTag("L2L3Residual"),
0225     offsetCorrLabel = cms.InputTag("L1FastJet"),
0226     skipEM = cms.bool(False),
0227     skipEMfractionThreshold = cms.double(0.9),
0228     skipMuonSelection = cms.string('isGlobalMuon | isStandAloneMuon'),
0229     skipMuons = cms.bool(True),
0230     type1JetPtThreshold = cms.double(0.0),
0231     calcMuonSubtrRawPtAsValueMap = cms.bool(True)
0232 )
0233 
0234 updatedJetsPuppiWithUserData.userFloats.muonSubtrRawPt = cms.InputTag("basicJetsPuppiForMetForT1METNano:MuonSubtrRawPt")
0235 
0236 corrT1METJetPuppiTable = simpleCandidateFlatTableProducer.clone(
0237     src = finalJetsPuppi.src,
0238     cut = cms.string("pt<15 && abs(eta)<9.9"),
0239     name = cms.string("CorrT1METJet"),
0240     doc  = cms.string("Additional low-pt ak4 Puppi jets for Type-1 MET re-correction"),
0241     variables = cms.PSet(
0242         rawPt = Var("pt()*jecFactor('Uncorrected')",float,precision=10),
0243         eta  = Var("eta",  float,precision=12),
0244         phi = Var("phi", float, precision=12),
0245         area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10),
0246         EmEF = Var("chargedEmEnergyFraction()+neutralEmEnergyFraction()", float, doc="charged+neutral Electromagnetic Energy Fraction", precision=6),
0247     )
0248 )
0249 
0250 corrT1METJetPuppiTable.variables.muonSubtrFactor = Var("1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc="1-(muon-subtracted raw pt)/(raw pt)",precision=6)
0251 jetPuppiTable.variables.muonSubtrFactor = Var("1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc="1-(muon-subtracted raw pt)/(raw pt)",precision=6)
0252 
0253 jetPuppiForMETTask =  cms.Task(basicJetsPuppiForMetForT1METNano,corrT1METJetPuppiTable)
0254 
0255 #before cross linking
0256 jetPuppiUserDataTask = cms.Task(tightJetPuppiId, tightJetPuppiIdLepVeto, hfJetPuppiShowerShapeforNanoAOD)
0257 
0258 #before cross linking
0259 jetPuppiTask = cms.Task(jetPuppiCorrFactorsNano,updatedJetsPuppi,jetPuppiUserDataTask,updatedJetsPuppiWithUserData,finalJetsPuppi)
0260 
0261 #after cross linkining
0262 jetPuppiTablesTask = cms.Task(jetPuppiTable)