1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
20 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
21 from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff
import run2_nanoAOD_92X
22 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff
import run2_nanoAOD_94X2016
23 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff
import run2_nanoAOD_94XMiniAODv1
24 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff
import run2_nanoAOD_94XMiniAODv2
25 from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff
import run2_nanoAOD_102Xv1
27 nanoMetadata = cms.EDProducer(
"UniqueStringProducer",
29 tag = cms.string(
"untagged"),
33 linkedObjects = cms.EDProducer(
"PATObjectCrossLinker",
34 jets=cms.InputTag(
"finalJets"),
35 muons=cms.InputTag(
"finalMuons"),
36 electrons=cms.InputTag(
"finalElectrons"),
37 taus=cms.InputTag(
"finalTaus"),
38 photons=cms.InputTag(
"finalPhotons"),
41 simpleCleanerTable = cms.EDProducer(
"NanoAODSimpleCrossCleaner",
42 name=cms.string(
"cleanmask"),
43 doc=cms.string(
"simple cleaning mask with priority to leptons"),
44 jets=cms.InputTag(
"linkedObjects",
"jets"),
45 muons=cms.InputTag(
"linkedObjects",
"muons"),
46 electrons=cms.InputTag(
"linkedObjects",
"electrons"),
47 taus=cms.InputTag(
"linkedObjects",
"taus"),
48 photons=cms.InputTag(
"linkedObjects",
"photons"),
49 jetSel=cms.string(
"pt>15"),
50 muonSel=cms.string(
"isPFMuon && innerTrack.validFraction >= 0.49 && ( isGlobalMuon && globalTrack.normalizedChi2 < 3 && combinedQuality.chi2LocalPosition < 12 && combinedQuality.trkKink < 20 && segmentCompatibility >= 0.303 || segmentCompatibility >= 0.451 )"),
51 electronSel=cms.string(
""),
52 tauSel=cms.string(
""),
53 photonSel=cms.string(
""),
54 jetName=cms.string(
"Jet"),muonName=cms.string(
"Muon"),electronName=cms.string(
"Electron"),
55 tauName=cms.string(
"Tau"),photonName=cms.string(
"Photon")
58 btagSFdir=
"PhysicsTools/NanoAOD/data/btagSF/" 60 btagWeightTable = cms.EDProducer(
"BTagSFProducer",
61 src = cms.InputTag(
"linkedObjects",
"jets"),
62 cut = cms.string(
"pt > 25. && abs(eta) < 2.5"),
63 discNames = cms.vstring(
64 "pfCombinedInclusiveSecondaryVertexV2BJetTags",
65 "pfDeepCSVJetTags:probb+pfDeepCSVJetTags:probbb",
66 "pfCombinedMVAV2BJetTags" 68 discShortNames = cms.vstring(
73 weightFiles = cms.vstring(
74 btagSFdir+
"CSVv2_94XSF_V2_B_F.csv",
75 btagSFdir+
"DeepCSV_94XSF_V2_B_F.csv",
78 operatingPoints = cms.vstring(
"3",
"3",
"3"),
79 measurementTypesB = cms.vstring(
"iterativefit",
"iterativefit",
"iterativefit"),
80 measurementTypesC = cms.vstring(
"iterativefit",
"iterativefit",
"iterativefit"),
81 measurementTypesUDSG = cms.vstring(
"iterativefit",
"iterativefit",
"iterativefit"),
82 sysTypes = cms.vstring(
"central",
"central",
"central")
85 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
86 modifier.toModify(btagWeightTable,
87 cut = cms.string(
"pt > 25. && abs(eta) < 2.4"),
88 weightFiles = cms.vstring(
89 btagSFdir+
"CSVv2_Moriond17_B_H.csv",
91 btagSFdir+
"cMVAv2_Moriond17_B_H.csv" 95 run2_nanoAOD_92X.toModify(btagWeightTable,
96 weightFiles = cms.vstring(
103 genWeightsTable = cms.EDProducer(
"GenWeightsTableProducer",
104 genEvent = cms.InputTag(
"generator"),
105 lheInfo = cms.InputTag(
"externalLHEProducer"),
106 preferredPDFs = cms.VPSet(
107 cms.PSet( name = cms.string(
"PDF4LHC15_nnlo_30_pdfas"), lhaid = cms.uint32(91400) ),
108 cms.PSet( name = cms.string(
"NNPDF31_nnlo_hessian_pdfas"), lhaid = cms.uint32(306000) ),
109 cms.PSet( name = cms.string(
"NNPDF30_nlo_as_0118"), lhaid = cms.uint32(260000) ),
110 cms.PSet( name = cms.string(
"NNPDF30_lo_as_0130"), lhaid = cms.uint32(262000) ),
111 cms.PSet( name = cms.string(
"NNPDF30_nlo_nf_4_pdfas"), lhaid = cms.uint32(292000) ),
112 cms.PSet( name = cms.string(
"NNPDF30_nlo_nf_5_pdfas"), lhaid = cms.uint32(292200) ),
114 namedWeightIDs = cms.vstring(),
115 namedWeightLabels = cms.vstring(),
116 lheWeightPrecision = cms.int32(14),
117 maxPdfWeights = cms.uint32(150),
118 debug = cms.untracked.bool(
False),
120 lheInfoTable = cms.EDProducer(
"LHETablesProducer",
121 lheInfo = cms.InputTag(
"externalLHEProducer"),
122 precision = cms.int32(14),
123 storeLHEParticles = cms.bool(
True)
126 l1bits=cms.EDProducer(
"L1TriggerResultsConverter", src=cms.InputTag(
"gtStage2Digis"), legacyL1=cms.bool(
False))
128 nanoSequenceCommon = cms.Sequence(
129 nanoMetadata + jetSequence + muonSequence + tauSequence + electronSequence+photonSequence+vertexSequence+
132 jetTables + muonTables + tauTables + electronTables + photonTables + globalTables +vertexTables+ metTables+simpleCleanerTable + isoTrackTables
134 nanoSequenceOnlyFullSim = cms.Sequence(triggerObjectTables + l1bits)
136 nanoSequence = cms.Sequence(nanoSequenceCommon + nanoSequenceOnlyFullSim)
138 nanoSequenceFS = cms.Sequence(genParticleSequence + particleLevelSequence + nanoSequenceCommon + jetMC + muonMC + electronMC + photonMC + tauMC + metMC + ttbarCatMCProducers + globalTablesMC + btagWeightTable + genWeightsTable + genParticleTables + particleLevelTables + lheInfoTable + ttbarCategoryTable )
140 nanoSequenceMC = nanoSequenceFS.copy()
141 nanoSequenceMC.insert(nanoSequenceFS.index(nanoSequenceCommon)+1,nanoSequenceOnlyFullSim)
144 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1:
145 modifier.toModify(extraFlagsTable, variables= cms.PSet())
146 modifier.toModify(extraFlagsTable, variables =
dict(Flag_ecalBadCalibFilterV2 =
ExtVar(cms.InputTag(
"ecalBadCalibFilterNanoTagger"), bool, doc =
"Bad ECAL calib flag (updated xtal list)")))
150 _btagDiscriminators=[]
152 print(
"Updating process to run DeepCSV btag")
153 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc']
155 print(
"Updating process to run DeepFlavour btag")
156 _btagDiscriminators += [
'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb']
157 if len(_btagDiscriminators)==0:
return process
158 print(
"Will recalculate the following discriminators: "+
", ".
join(_btagDiscriminators))
161 jetSource = cms.InputTag(
'slimmedJets'),
162 jetCorrections = (
'AK4PFchs', cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
163 btagDiscriminators = _btagDiscriminators,
164 postfix =
'WithDeepInfo',
166 process.load(
"Configuration.StandardSequences.MagneticField_cff")
167 process.looseJetId.src=
"selectedUpdatedPatJetsWithDeepInfo" 168 process.tightJetId.src=
"selectedUpdatedPatJetsWithDeepInfo" 169 process.tightJetIdLepVeto.src=
"selectedUpdatedPatJetsWithDeepInfo" 170 process.bJetVars.src=
"selectedUpdatedPatJetsWithDeepInfo" 171 process.slimmedJetsWithUserData.src=
"selectedUpdatedPatJetsWithDeepInfo" 172 process.qgtagger80x.srcJets=
"selectedUpdatedPatJetsWithDeepInfo" 174 process.pfDeepFlavourJetTagsWithDeepInfo.graph_path =
'RecoBTag/Combined/data/DeepFlavourV03_10X_training/constant_graph.pb' 175 process.pfDeepFlavourJetTagsWithDeepInfo.lp_names = [
"cpf_input_batchnorm/keras_learning_phase"]
178 from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties
import runMetCorAndUncFromMiniAOD
182 process.nanoSequenceCommon.insert(process.nanoSequenceCommon.index(jetSequence),cms.Sequence(process.fullPatMetSequence))
193 for modname
in electron_id_modules_WorkingPoints_nanoAOD.modules:
195 process.electronSequence.insert(process.electronSequence.index(bitmapVIDForEle),process.egmGsfElectronIDSequence)
196 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_92X:
197 modifier.toModify(process.electronMVAValueMapProducer, srcMiniAOD =
"slimmedElectronsUpdated")
198 modifier.toModify(process.electronMVAVariableHelper, srcMiniAOD =
"slimmedElectronsUpdated")
199 modifier.toModify(process.egmGsfElectronIDs, physicsObjectSrc =
"slimmedElectronsUpdated")
200 if hasattr(process,
"heepIDVarValueMaps"):
201 modifier.toModify(process.heepIDVarValueMaps, elesMiniAOD =
"slimmedElectronsUpdated")
203 for modname
in photon_id_modules_WorkingPoints_nanoAOD.modules:
205 process.photonSequence.insert(process.photonSequence.index(bitmapVIDForPho),process.egmPhotonIDSequence)
209 _btagDiscriminators=[]
211 print(
"Updating process to run DeepCSV btag to AK8 jets")
212 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb']
213 if addDeepBoostedJet:
214 print(
"Updating process to run DeepBoostedJet on datasets before 103X")
216 _btagDiscriminators += pfDeepBoostedJetTagsAll
217 if len(_btagDiscriminators)==0:
return process
218 print(
"Will recalculate the following discriminators on AK8 jets: "+
", ".
join(_btagDiscriminators))
221 jetSource = cms.InputTag(
'slimmedJetsAK8'),
222 pvSource = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
223 svSource = cms.InputTag(
'slimmedSecondaryVertices'),
225 jetCorrections = (jecPayload.value(), cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
226 btagDiscriminators = _btagDiscriminators,
227 postfix=
'AK8WithDeepInfo',
230 process.looseJetIdAK8.src =
"selectedUpdatedPatJetsAK8WithDeepInfo" 231 process.tightJetIdAK8.src =
"selectedUpdatedPatJetsAK8WithDeepInfo" 232 process.tightJetIdLepVetoAK8.src =
"selectedUpdatedPatJetsAK8WithDeepInfo" 233 process.slimmedJetsAK8WithUserData.src =
"selectedUpdatedPatJetsAK8WithDeepInfo" 236 from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties
import runMetCorAndUncFromMiniAOD
240 fixEE2017Params = {
'userawPt':
True,
'ptThreshold':50.0,
'minEtaThreshold':2.65,
'maxEtaThreshold': 3.139},
241 postfix =
"FixEE2017")
242 process.nanoSequenceCommon.insert(process.nanoSequenceCommon.index(jetSequence),process.fullPatMetSequenceFixEE2017)
247 nanoAOD_addDeepInfo_switch = cms.PSet(
248 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
249 nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(
False),
251 run2_miniAOD_80XLegacy.toModify(nanoAOD_addDeepInfo_switch, nanoAOD_addDeepBTag_switch = cms.untracked.bool(
True))
252 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
253 modifier.toModify(nanoAOD_addDeepInfo_switch, nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(
True))
255 addDeepBTag=nanoAOD_addDeepInfo_switch.nanoAOD_addDeepBTag_switch,
256 addDeepFlavour=nanoAOD_addDeepInfo_switch.nanoAOD_addDeepFlavourTag_switch)
257 nanoAOD_addDeepInfoAK8_switch = cms.PSet(
258 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
259 nanoAOD_addDeepBoostedJet_switch = cms.untracked.bool(
True),
260 jecPayload = cms.untracked.string(
'AK8PFPuppi')
263 run2_miniAOD_80XLegacy.toModify(nanoAOD_addDeepInfoAK8_switch,
264 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
True),
265 nanoAOD_addDeepBoostedJet_switch = cms.untracked.bool(
False),
266 jecPayload = cms.untracked.string(
'AK8PFchs'))
268 addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
269 addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBoostedJet_switch,
270 jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload)
276 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
283 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
288 _80x_sequence = nanoSequenceCommon.copy()
290 _80x_sequence.remove(isoTrackTables)
291 _80x_sequence.remove(isoTrackSequence)
293 _80x_sequence.insert(_80x_sequence.index(jetSequence), extraFlagsProducers)
294 _80x_sequence.insert(_80x_sequence.index(simpleCleanerTable)+1, extraFlagsTable)
296 run2_miniAOD_80XLegacy.toReplaceWith( nanoSequenceCommon, _80x_sequence)
298 _102x_sequence = nanoSequenceCommon.copy()
300 _102x_sequence.insert(_102x_sequence.index(jetSequence),extraFlagsProducers102x)
301 _102x_sequence.insert(_102x_sequence.index(simpleCleanerTable)+1,extraFlagsTable)
303 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1:
304 modifier.toReplaceWith(nanoSequenceCommon, _102x_sequence)
def nanoAOD_addDeepInfo(process, addDeepBTag, addDeepFlavour)
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
S & print(S &os, JobReport::InputFile const &f)
def nanoAOD_customizeMC(process)
def nanoAOD_activateVID(process)
def nanoAOD_customizeCommon(process)
def nanoAOD_recalibrateMETs(process, isData)
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, jecPayload)
def nanoAOD_runMETfixEE2017(process, isData)
static std::string join(char **cmd)
def runMetCorAndUncFromMiniAOD(process, metType="PF", jetCollUnskimmed="slimmedJets", photonColl="slimmedPhotons", electronColl="slimmedElectrons", muonColl="slimmedMuons", tauColl="slimmedTaus", pfCandColl="packedPFCandidates", jetFlavor="AK4PFchs", jetCleaning="LepClean", isData=False, manualJetConfig=False, reclusterJets=None, jetSelection="pt>15 && abs(eta)<9.9", recoMetFromPFCs=None, jetCorLabelL3="ak4PFCHSL1FastL2L3Corrector", jetCorLabelRes="ak4PFCHSL1FastL2L3ResidualCorrector", CHS=False, reapplyJEC=True, jecUncFile="", computeMETSignificance=True, fixEE2017=False, fixEE2017Params=None, postfix="")
def nanoAOD_customizeData(process)