Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-17 22:33:09

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 # load modules for producing Type 1 / Type 1 + 2 corrections for reco::PFMET objects
0004 from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import *
0005 
0006 #from PhysicsTools.PatAlgos.producerLayer1.jetProducer_cfi import patJets
0007 
0008 
0009 #--------------------------------------------------------------------------------
0010 # produce "raw" (uncorrected) pat::MET of PF-type
0011 from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs
0012 patPFMet = patMETs.clone(
0013     metSource = 'pfMet'
0014 )
0015 #--------------------------------------------------------------------------------
0016 
0017 #--------------------------------------------------------------------------------
0018 # select collection of pat::Jets entering Type 1 + 2 MET corrections
0019 #
0020 
0021 selectedPatJetsForMetT1T2Corr = cms.EDFilter("PATJetSelector",
0022     src = cms.InputTag('patJets'),
0023     cut = cms.string('abs(eta) < 9.9'),
0024     filter = cms.bool(False)
0025 )
0026 
0027 selectedPatJetsForMetT2Corr = cms.EDFilter("PATJetSelector",
0028     src = cms.InputTag('patJets'),
0029     cut = cms.string('abs(eta) > 9.9'),
0030     filter = cms.bool(False)
0031 )
0032 #--------------------------------------------------------------------------------
0033 
0034 #--------------------------------------------------------------------------------
0035 # produce Type 1 + 2 MET corrections for pat::Jets of PF-type
0036 import PhysicsTools.PatUtils.pfJetMETcorrInputProducerTPatJetPATJetCorrExtractor_cfi as _mod
0037 
0038 patPFMetT1T2Corr = _mod.pfJetMETcorrInputProducerTPatJetPATJetCorrExtractor.clone(
0039     src             = 'selectedPatJetsForMetT1T2Corr',
0040     offsetCorrLabel = "L1FastJet",
0041     jetCorrLabel    = "L3Absolute",  # for MC
0042     jetCorrLabelRes = "L2L3Residual" # for Data automatic switch
0043 )
0044 patPFMetT1T2CorrTask = cms.Task(selectedPatJetsForMetT1T2Corr,
0045                                 patPFMetT1T2Corr)
0046 patPFMetT1T2CorrSequence = cms.Sequence(patPFMetT1T2CorrTask)
0047 
0048 patPFMetT2Corr = patPFMetT1T2Corr.clone(
0049     src = 'selectedPatJetsForMetT2Corr'
0050 )
0051 patPFMetT2CorrTask = cms.Task(patPFMetT2Corr)
0052 patPFMetT2CorrSequence = cms.Sequence(patPFMetT2CorrTask)
0053 
0054 #--------------------------------------------------------------------------------
0055 
0056 #--------------------------------------------------------------------------------
0057 # produce Type 0 MET corrections
0058 from JetMETCorrections.Type1MET.pfMETCorrectionType0_cfi import *
0059 
0060 patPFMetT0Corr = pfMETcorrType0.clone()
0061 patPFMetT0CorrTask = cms.Task(type0PFMEtCorrectionPFCandToVertexAssociationTask, patPFMetT0Corr)
0062 patPFMetT0CorrSequence = cms.Sequence(patPFMetT0CorrTask)
0063 #--------------------------------------------------------------------------------
0064 
0065 #--------------------------------------------------------------------------------
0066 # produce Type xy MET corrections
0067 import JetMETCorrections.Type1MET.pfMETmultShiftCorrections_cfi as _shiftMod
0068 #dummy module
0069 
0070 patPFMetTxyCorr = _shiftMod.pfMEtMultShiftCorr.clone()
0071 
0072 patMultPhiCorrParams_Txy_50ns         = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_Txy_50ns])
0073 patMultPhiCorrParams_T0pcTxy_50ns     = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcTxy_50ns])
0074 patMultPhiCorrParams_T0pcT1Txy_50ns   = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1Txy_50ns])
0075 patMultPhiCorrParams_T0pcT1T2Txy_50ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1T2Txy_50ns])
0076 patMultPhiCorrParams_T1Txy_50ns       = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1Txy_50ns])
0077 patMultPhiCorrParams_T1T2Txy_50ns     = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1T2Txy_50ns])
0078 patMultPhiCorrParams_T1SmearTxy_50ns  = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1Txy_50ns])
0079 patMultPhiCorrParams_T1T2SmearTxy_50ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1T2Txy_50ns])
0080 patMultPhiCorrParams_T0pcT1SmearTxy_50ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1Txy_50ns])
0081 patMultPhiCorrParams_T0pcT1T2SmearTxy_50ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1T2Txy_50ns])
0082 
0083 patMultPhiCorrParams_Txy_25ns         = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_Txy_25ns])
0084 patMultPhiCorrParams_T0pcTxy_25ns     = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcTxy_25ns])
0085 patMultPhiCorrParams_T0pcT1Txy_25ns   = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1Txy_25ns])
0086 patMultPhiCorrParams_T0pcT1T2Txy_25ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1T2Txy_25ns])
0087 patMultPhiCorrParams_T1Txy_25ns       = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1Txy_25ns])
0088 patMultPhiCorrParams_T1T2Txy_25ns     = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1T2Txy_25ns])
0089 patMultPhiCorrParams_T1SmearTxy_25ns  = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1Txy_25ns])
0090 patMultPhiCorrParams_T1T2SmearTxy_25ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T1T2Txy_25ns])
0091 patMultPhiCorrParams_T0pcT1SmearTxy_25ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1Txy_25ns])
0092 patMultPhiCorrParams_T0pcT1T2SmearTxy_25ns = cms.VPSet( [pset for pset in _shiftMod.multPhiCorrParams_T0pcT1T2Txy_25ns])
0093 
0094 # Run2 UL MC XY(Type1 PFMET Phi) corrections
0095 import JetMETCorrections.Type1MET.multPhiCorr_Run2_ULMC_cfi as multPhiCorrParams_Run2_ULMC
0096 import JetMETCorrections.Type1MET.multPhiCorr_Run2_ULDATA_cfi as multPhiCorrParams_Run2_ULDATA
0097 import JetMETCorrections.Type1MET.multPhiCorr_Puppi_Run2_ULMC_cfi as multPhiCorrParams_Puppi_Run2_ULMC
0098 import JetMETCorrections.Type1MET.multPhiCorr_Puppi_Run2_ULDATA_cfi as multPhiCorrParams_Puppi_Run2_ULDATA
0099 
0100 # PFMET XY corrections
0101 patMultPhiCorrParams_ULMC2018 = multPhiCorrParams_Run2_ULMC.multPhiCorr_ULMC2018
0102 patMultPhiCorrParams_ULMC2017 = multPhiCorrParams_Run2_ULMC.multPhiCorr_ULMC2017
0103 patMultPhiCorrParams_ULMC2016preVFP = multPhiCorrParams_Run2_ULMC.multPhiCorr_ULMC2016preVFP
0104 patMultPhiCorrParams_ULMC2016postVFP = multPhiCorrParams_Run2_ULMC.multPhiCorr_ULMC2016postVFP
0105 
0106 patMultPhiCorrParams_ULDATA2018A = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2018A
0107 patMultPhiCorrParams_ULDATA2018B = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2018B
0108 patMultPhiCorrParams_ULDATA2018C = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2018C
0109 patMultPhiCorrParams_ULDATA2018D = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2018D
0110 
0111 patMultPhiCorrParams_ULDATA2017B = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2017B
0112 patMultPhiCorrParams_ULDATA2017C = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2017C
0113 patMultPhiCorrParams_ULDATA2017D = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2017D
0114 patMultPhiCorrParams_ULDATA2017E = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2017E
0115 patMultPhiCorrParams_ULDATA2017F = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2017F
0116 
0117 patMultPhiCorrParams_ULDATA2016preVFPB = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016preVFPB
0118 patMultPhiCorrParams_ULDATA2016preVFPC = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016preVFPC
0119 patMultPhiCorrParams_ULDATA2016preVFPD = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016preVFPD
0120 patMultPhiCorrParams_ULDATA2016preVFPE = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016preVFPE
0121 patMultPhiCorrParams_ULDATA2016preVFPF = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016preVFPF
0122 
0123 patMultPhiCorrParams_ULDATA2016postVFPF = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016postVFPF
0124 patMultPhiCorrParams_ULDATA2016postVFPG = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016postVFPG
0125 patMultPhiCorrParams_ULDATA2016postVFPH = multPhiCorrParams_Run2_ULDATA.multPhiCorr_ULDATA2016postVFPH
0126 
0127 # PuppiMET XY corrections
0128 patMultPhiCorrParams_Puppi_ULMC2018 = multPhiCorrParams_Puppi_Run2_ULMC.multPhiCorr_Puppi_ULMC2018
0129 patMultPhiCorrParams_Puppi_ULMC2017 = multPhiCorrParams_Puppi_Run2_ULMC.multPhiCorr_Puppi_ULMC2017
0130 patMultPhiCorrParams_Puppi_ULMC2016preVFP = multPhiCorrParams_Puppi_Run2_ULMC.multPhiCorr_Puppi_ULMC2016preVFP
0131 patMultPhiCorrParams_Puppi_ULMC2016postVFP = multPhiCorrParams_Puppi_Run2_ULMC.multPhiCorr_Puppi_ULMC2016postVFP
0132 
0133 patMultPhiCorrParams_Puppi_ULDATA2018A = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2018A
0134 patMultPhiCorrParams_Puppi_ULDATA2018B = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2018B
0135 patMultPhiCorrParams_Puppi_ULDATA2018C = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2018C
0136 patMultPhiCorrParams_Puppi_ULDATA2018D = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2018D
0137 
0138 patMultPhiCorrParams_Puppi_ULDATA2017B = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2017B
0139 patMultPhiCorrParams_Puppi_ULDATA2017C = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2017C
0140 patMultPhiCorrParams_Puppi_ULDATA2017D = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2017D
0141 patMultPhiCorrParams_Puppi_ULDATA2017E = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2017E
0142 patMultPhiCorrParams_Puppi_ULDATA2017F = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2017F
0143 
0144 patMultPhiCorrParams_Puppi_ULDATA2016preVFPB = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016preVFPB
0145 patMultPhiCorrParams_Puppi_ULDATA2016preVFPC = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016preVFPC
0146 patMultPhiCorrParams_Puppi_ULDATA2016preVFPD = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016preVFPD
0147 patMultPhiCorrParams_Puppi_ULDATA2016preVFPE = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016preVFPE
0148 patMultPhiCorrParams_Puppi_ULDATA2016preVFPF = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016preVFPF
0149 
0150 patMultPhiCorrParams_Puppi_ULDATA2016postVFPF = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016postVFPF
0151 patMultPhiCorrParams_Puppi_ULDATA2016postVFPG = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016postVFPG
0152 patMultPhiCorrParams_Puppi_ULDATA2016postVFPH = multPhiCorrParams_Puppi_Run2_ULDATA.multPhiCorr_Puppi_ULDATA2016postVFPH
0153 
0154 patPFMetTxyCorrTask = cms.Task(patPFMetTxyCorr)
0155 patPFMetTxyCorrSequence = cms.Sequence(patPFMetTxyCorrTask)
0156 
0157 #--------------------------------------------------------------------------------
0158 from RecoMET.METProducers.METSigParams_cfi import *
0159 patSmearedJets = cms.EDProducer("SmearedPATJetProducer",
0160     src = cms.InputTag("patJets"),
0161 
0162     enabled = cms.bool(True),  # If False, no smearing is performed
0163 
0164     rho = cms.InputTag("fixedGridRhoFastjetAll"),
0165 
0166     skipGenMatching = cms.bool(False),  # If True, always skip gen jet matching and smear jet with a random gaussian
0167 
0168     # Resolution and scale factors source.
0169     # Can be either from GT or text files
0170     # For GT: only 'algo' must be set
0171     # For text files: both 'resolutionFile' and 'scaleFactorFile' must point to valid files
0172 
0173     # Read from GT
0174     algopt = cms.string('AK4PFchs_pt'),
0175     algo = cms.string('AK4PFchs'),
0176 
0177     # Or from text files
0178     #resolutionFile = cms.FileInPath('path/to/resolution_file.txt'),
0179     #scaleFactorFile = cms.FileInPath('path/to/scale_factor_file.txt'),
0180 
0181     # Gen jet matching
0182     genJets = cms.InputTag("ak4GenJetsNoNu"),
0183     dRMax = cms.double(0.2),  # = cone size (0.4) / 2
0184     dPtMaxFactor = cms.double(3),  # dPt < 3 * resolution
0185 
0186     # Systematic variation
0187     # 0: Nominal
0188     # -1: -1 sigma (down variation)
0189     # 1: +1 sigma (up variation)
0190     variation = cms.int32(0),  # If not specified, default to 0
0191 
0192     seed = cms.uint32(37428479),  # If not specified, default to 37428479
0193     useDeterministicSeed = cms.bool(True),
0194 
0195     debug = cms.untracked.bool(False)
0196 )
0197 
0198 selectedPatJetsForMetT1T2SmearCorr = cms.EDFilter("PATJetSelector",
0199     src = cms.InputTag('patSmearedJets'),
0200     cut = cms.string('abs(eta) < 9.9'),
0201     filter = cms.bool(False)
0202 )
0203 
0204 selectedPatJetsForMetT2SmearCorr = cms.EDFilter("PATJetSelector",
0205     src = cms.InputTag('patSmearedJets'),
0206     cut = cms.string('abs(eta) > 9.9'),
0207     filter = cms.bool(False)
0208 )
0209 
0210 patPFMetT1T2SmearCorr = patPFMetT1T2Corr.clone(
0211     src = 'selectedPatJetsForMetT1T2SmearCorr'
0212 )
0213 
0214 patPFMetT2SmearCorr = patPFMetT2Corr.clone(
0215     src = 'selectedPatJetsForMetT2SmearCorr'
0216 )
0217 
0218 patPFMetSmearCorrTask = cms.Task(patSmearedJets,
0219                                  selectedPatJetsForMetT1T2SmearCorr,
0220                                  patPFMetT1T2SmearCorr)
0221 patPFMetSmearCorrSequence = cms.Sequence(patPFMetSmearCorrTask)
0222 
0223 #specific sequence for handling type2 correction with smeared jets
0224 patPFMetT2SmearCorrTask = cms.Task(patSmearedJets,
0225                                    selectedPatJetsForMetT1T2SmearCorr,
0226                                    selectedPatJetsForMetT2SmearCorr,
0227                                    patPFMetT1T2SmearCorr,
0228                                    patPFMetT2SmearCorr)
0229 patPFMetT2SmearCorrSequence = cms.Sequence(patPFMetT2SmearCorrTask)
0230 
0231 #--------------------------------------------------------------------------------
0232 # use MET corrections to produce Type 1 / Type 1 + 2 corrected PFMET objects
0233 patPFMetT1 = cms.EDProducer("CorrectedPATMETProducer",
0234     src = cms.InputTag('patPFMet'),
0235     srcCorrections = cms.VInputTag(
0236         cms.InputTag('patPFMetT1T2Corr', 'type1'),
0237     ),
0238 )
0239 
0240 patPFMetT1T2 = patPFMetT1.clone()
0241 patPFMetT1T2.srcCorrections.append( cms.InputTag('patPFMetT2Corr',   'type2') )
0242 #--------------------------------------------------------------------------------
0243 #extra modules for naming scheme
0244 patPFMetT1Txy = patPFMetT1.clone()
0245 patPFMetT1Txy.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0246 
0247 patPFMetT0pcT1 = patPFMetT1.clone()
0248 patPFMetT0pcT1.srcCorrections.append( cms.InputTag('patPFMetT0Corr') )
0249 
0250 patPFMetT0pcT1Txy = patPFMetT0pcT1.clone()
0251 patPFMetT0pcT1Txy.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0252 
0253 patPFMetT1T2Txy = patPFMetT1T2.clone()
0254 patPFMetT1T2Txy.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0255 
0256 patPFMetT0pcT1T2 = patPFMetT1T2.clone()
0257 patPFMetT0pcT1T2.srcCorrections.append( cms.InputTag('patPFMetT0Corr') )
0258 
0259 patPFMetT0pcT1T2Txy = patPFMetT0pcT1T2.clone()
0260 patPFMetT0pcT1T2Txy.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0261 
0262 
0263 ## smeared METs
0264 patPFMetT1Smear = patPFMetT1.clone( 
0265     srcCorrections = ['patPFMetT1T2SmearCorr:type1']
0266 )
0267 
0268 patPFMetT1T2Smear = patPFMetT1Smear.clone()
0269 patPFMetT1T2Smear.srcCorrections.append( cms.InputTag('patPFMetT2SmearCorr',   'type2') )
0270 
0271 patPFMetT1TxySmear = patPFMetT1Smear.clone()
0272 patPFMetT1TxySmear.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0273 
0274 patPFMetT0pcT1Smear = patPFMetT1Smear.clone()
0275 patPFMetT0pcT1Smear.srcCorrections.append( cms.InputTag('patPFMetT0Corr') )
0276 
0277 patPFMetT0pcT1TxySmear = patPFMetT0pcT1Smear.clone()
0278 patPFMetT0pcT1TxySmear.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0279 
0280 patPFMetT1T2TxySmear = patPFMetT1T2Smear.clone()
0281 patPFMetT1T2TxySmear.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0282 
0283 patPFMetT0pcT1T2Smear = patPFMetT1T2Smear.clone()
0284 patPFMetT0pcT1T2Smear.srcCorrections.append( cms.InputTag('patPFMetT0Corr') )
0285 
0286 patPFMetT0pcT1T2TxySmear = patPFMetT0pcT1T2Smear.clone()
0287 patPFMetT0pcT1T2TxySmear.srcCorrections.append( cms.InputTag('patPFMetTxyCorr') )
0288 
0289 #--------------------------------------------------------------------------------
0290 # define sequence to run all modules
0291 producePatPFMETCorrectionsTask = cms.Task(
0292     patPFMet,
0293     pfCandsNotInJetsForMetCorr,
0294     selectedPatJetsForMetT1T2Corr,
0295     selectedPatJetsForMetT2Corr,
0296     patPFMetT1T2Corr,
0297     patPFMetT2Corr,
0298     type0PFMEtCorrectionPFCandToVertexAssociationTask,
0299     patPFMetT0Corr,
0300     pfCandMETcorr,
0301     patPFMetT1,
0302     patPFMetT1T2,
0303     patPFMetT0pcT1,
0304     patPFMetT0pcT1T2
0305 )
0306 producePatPFMETCorrections = cms.Sequence(producePatPFMETCorrectionsTask)
0307 #--------------------------------------------------------------------------------
0308 
0309 #
0310 # define special sequence for PAT runType1uncertainty tool
0311 # only preliminary modules processed
0312 # pat met producer modules cloned accordingly to what is needed
0313 producePatPFMETCorrectionsUncTask = cms.Task(
0314     patPFMet,
0315     pfCandsNotInJetsForMetCorr,
0316     selectedPatJetsForMetT1T2Corr,
0317     selectedPatJetsForMetT2Corr,
0318     patPFMetT1T2Corr,
0319     patPFMetT2Corr,
0320     type0PFMEtCorrectionPFCandToVertexAssociationTask,
0321     patPFMetT0Corr,
0322     pfCandMETcorr
0323 )
0324 producePatPFMETCorrectionsUnc = cms.Sequence(producePatPFMETCorrectionsUncTask)