5 from __future__
import print_function
6 import FWCore.ParameterSet.Config
as cms
25 def __init__(self, module_name, manipulator_name, steps = ["SELECT","CLEAN","SIM","MERGE"], instance=[""], merge_prefix = ""):
40 to_bemanipulate.append(
module_manipulate(module_name =
'siPixelClusters', manipulator_name =
"Pixel", steps = [
"SELECT",
"CLEAN"] ))
41 to_bemanipulate.append(
module_manipulate(module_name =
'siStripClusters', manipulator_name =
"Strip", steps = [
"SELECT",
"CLEAN"] ))
43 to_bemanipulate.append(
module_manipulate(module_name =
'generalTracks', manipulator_name =
"Track", steps = [
"SIM",
"MERGE"]))
44 to_bemanipulate.append(
module_manipulate(module_name =
'muons1stStep', manipulator_name =
"Muon", steps = [
"SIM",
"MERGE"]))
45 to_bemanipulate.append(
module_manipulate(module_name =
'gedGsfElectronsTmp', manipulator_name =
"GsfElectron", steps = [
"SIM",
"MERGE"]))
46 to_bemanipulate.append(
module_manipulate(module_name =
'gedPhotonsTmp', manipulator_name =
"Photon", steps = [
"SIM",
"MERGE"]))
47 to_bemanipulate.append(
module_manipulate(module_name =
'particleFlowTmp', manipulator_name =
"PF", steps = [
"SIM",
"MERGE"], instance=[
"",
"CleanedHF",
"CleanedCosmicsMuons",
"CleanedTrackerAndGlobalMuons",
"CleanedFakeMuons",
"CleanedPunchThroughMuons",
"CleanedPunchThroughNeutralHadrons",
"AddedMuonsAndHadrons"]))
50 to_bemanipulate.append(
module_manipulate(module_name =
'ecalRecHit', manipulator_name =
"EcalRecHit", instance= [
"EcalRecHitsEB",
"EcalRecHitsEE"]))
51 to_bemanipulate.append(
module_manipulate(module_name =
'ecalPreshowerRecHit', manipulator_name =
"EcalRecHit", instance= [
"EcalRecHitsES"]))
53 to_bemanipulate.append(
module_manipulate(module_name =
'hbheprereco', manipulator_name =
"HBHERecHit"))
54 to_bemanipulate.append(
module_manipulate(module_name =
'hbhereco', manipulator_name =
"HBHERecHit"))
55 to_bemanipulate.append(
module_manipulate(module_name =
'zdcreco', manipulator_name =
"ZDCRecHit"))
57 to_bemanipulate.append(
module_manipulate(module_name =
'horeco', manipulator_name =
"HORecHit"))
58 to_bemanipulate.append(
module_manipulate(module_name =
'hfreco', manipulator_name =
"HFRecHit"))
59 to_bemanipulate.append(
module_manipulate(module_name =
'castorreco', manipulator_name =
"CastorRecHit"))
62 to_bemanipulate.append(
module_manipulate(module_name =
'dt1DRecHits', manipulator_name =
"DTRecHit", steps = [
"SELECT",
"CLEAN"] ))
63 to_bemanipulate.append(
module_manipulate(module_name =
'dt1DCosmicRecHits', manipulator_name =
"DTRecHit", steps = [
"SELECT",
"CLEAN"] ))
65 to_bemanipulate.append(
module_manipulate(module_name =
'csc2DRecHits', manipulator_name =
"CSCRecHit", steps = [
"SELECT",
"CLEAN"] ))
66 to_bemanipulate.append(
module_manipulate(module_name =
'rpcRecHits', manipulator_name =
"RPCRecHit", steps = [
"SELECT",
"CLEAN"] ))
70 outputModulesList = [key
for key,value
in six.iteritems(process.outputModules)]
71 for outputModule
in outputModulesList:
72 if outputModule
in module_veto_list:
74 outputModule = getattr(process, outputModule)
75 for add_element
in keep_drop_list:
76 outputModule.outputCommands.extend(add_element)
84 ret_vstring = cms.untracked.vstring(
86 "keep *_patMuonsAfterID_*_"+dataTier,
87 "keep *_slimmedMuons_*_"+dataTier,
88 "keep *_selectedMuonsForEmbedding_*_"+dataTier,
89 "keep recoVertexs_offlineSlimmedPrimaryVertices_*_"+dataTier,
90 "keep *_firstStepPrimaryVertices_*_"+dataTier,
91 "keep *_offlineBeamSpot_*_"+dataTier
93 for akt_manimod
in to_bemanipulate:
94 if "CLEAN" in akt_manimod.steps:
95 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_"+dataTier)
100 process._Process__name =
"RESELECT"
103 process._Process__name =
"SELECT"
106 process.load(
'TauAnalysis.MCEmbeddingTools.SelectingProcedure_cff')
108 process.slimmedMuons.trackExtraAssocs = []
109 process.patMuonsAfterKinCuts.src = cms.InputTag(
"slimmedMuons",
"",dataTier)
110 process.patMuonsAfterID = process.patMuonsAfterLooseID.clone()
112 process.selecting = cms.Path(process.makePatMuonsZmumuSelection)
113 process.schedule.insert(-1, process.selecting)
115 outputModulesList = [key
for key,value
in six.iteritems(process.outputModules)]
116 for outputModule
in outputModulesList:
117 outputModule = getattr(process, outputModule)
118 outputModule.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
"selecting"))
119 outputModule.outputCommands.extend(
keepSelected(dataTier))
129 ret_vstring = cms.untracked.vstring(
134 for akt_manimod
in to_bemanipulate:
135 if "MERGE" in akt_manimod.steps:
136 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_LHEembeddingCLEAN")
137 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_CLEAN")
138 ret_vstring.append(
"keep *_standAloneMuons_*_LHEembeddingCLEAN")
139 ret_vstring.append(
"keep *_glbTrackQual_*_LHEembeddingCLEAN")
145 if changeProcessname:
146 process._Process__name =
"CLEAN"
153 TrackAssociatorParameterBlock.TrackAssociatorParameters.CSCSegmentCollectionLabel = cms.InputTag(
"cscSegments",
"",dataTier)
154 TrackAssociatorParameterBlock.TrackAssociatorParameters.CaloTowerCollectionLabel = cms.InputTag(
"towerMaker",
"",dataTier)
155 TrackAssociatorParameterBlock.TrackAssociatorParameters.DTRecSegment4DCollectionLabel = cms.InputTag(
"dt4DSegments",
"",dataTier)
156 TrackAssociatorParameterBlock.TrackAssociatorParameters.EBRecHitCollectionLabel = cms.InputTag(
"ecalRecHit",
"EcalRecHitsEB",dataTier)
157 TrackAssociatorParameterBlock.TrackAssociatorParameters.EERecHitCollectionLabel = cms.InputTag(
"ecalRecHit",
"EcalRecHitsEE",dataTier)
158 TrackAssociatorParameterBlock.TrackAssociatorParameters.HBHERecHitCollectionLabel = cms.InputTag(
"hbhereco",
"",dataTier)
159 TrackAssociatorParameterBlock.TrackAssociatorParameters.HORecHitCollectionLabel = cms.InputTag(
"horeco",
"",dataTier)
162 MuonImput = cms.InputTag(
"selectedMuonsForEmbedding",
"",
"")
163 for akt_manimod
in to_bemanipulate:
164 if "CLEAN" in akt_manimod.steps:
165 oldCollections_in = cms.VInputTag()
166 for instance
in akt_manimod.instance:
167 oldCollections_in.append(cms.InputTag(akt_manimod.module_name,instance,dataTier))
168 setattr(process, akt_manimod.module_name, cms.EDProducer(akt_manimod.cleaner_name,MuonCollection = MuonImput,TrackAssociatorParameters = TrackAssociatorParameterBlock.TrackAssociatorParameters,oldCollection = oldCollections_in))
169 process.ecalPreshowerRecHit.TrackAssociatorParameters.usePreshower = cms.bool(
True)
176 ret_vstring = cms.untracked.vstring()
177 ret_vstring.append(
"keep *_externalLHEProducer_*_LHEembedding")
178 ret_vstring.append(
"keep *_externalLHEProducer_*_LHEembeddingCLEAN")
183 ret_vstring = cms.untracked.vstring()
184 for akt_manimod
in to_bemanipulate:
185 if "MERGE" in akt_manimod.steps:
186 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_SIMembedding")
187 ret_vstring.append(
"keep *_genParticles_*_SIMembedding")
188 ret_vstring.append(
"keep *_standAloneMuons_*_SIMembedding")
189 ret_vstring.append(
"keep *_glbTrackQual_*_SIMembedding")
190 ret_vstring.append(
"keep *_generator_*_SIMembedding")
191 ret_vstring.append(
"keep *_addPileupInfo_*_SIMembedding")
192 ret_vstring.append(
"keep *_slimmedAddPileupInfo_*_*")
203 if changeProcessname:
204 process._Process__name =
"LHEembedding"
205 process.load(
'TauAnalysis.MCEmbeddingTools.EmbeddingLHEProducer_cfi')
207 process.externalLHEProducer.vertices=cms.InputTag(
"offlineSlimmedPrimaryVertices",
"",
"RESELECT")
208 process.lheproduction = cms.Path(process.makeexternalLHEProducer)
209 process.schedule.insert(0,process.lheproduction)
221 if changeProcessname:
222 process._Process__name =
"SIMembedding"
226 process.load(
'TauAnalysis.MCEmbeddingTools.EmbeddingVertexCorrector_cfi')
227 process.VtxSmeared = process.VtxCorrectedToInput.clone()
228 print(
"Correcting Vertex in genEvent to one from input. Replaced 'VtxSmeared' with the Corrector.")
231 process.reconstruction.remove(process.offlineBeamSpot)
234 process.mix.digitizers.castor.doNoise = cms.bool(
False)
236 process.mix.digitizers.ecal.doESNoise = cms.bool(
False)
237 process.mix.digitizers.ecal.doENoise = cms.bool(
False)
239 process.mix.digitizers.hcal.doNoise = cms.bool(
False)
240 process.mix.digitizers.hcal.doThermalNoise = cms.bool(
False)
241 process.mix.digitizers.hcal.doHPDNoise = cms.bool(
False)
243 process.mix.digitizers.pixel.AddNoisyPixels = cms.bool(
False)
244 process.mix.digitizers.pixel.AddNoise = cms.bool(
False)
246 process.mix.digitizers.strip.Noise = cms.bool(
False)
259 ret_vstring = cms.untracked.vstring()
260 ret_vstring.append(
"drop *_*_*_"+dataTier)
261 ret_vstring.append(
"keep *_prunedGenParticles_*_MERGE")
262 ret_vstring.append(
"keep *_generator_*_SIMembedding")
272 process.load(
'PhysicsTools.PatAlgos.slimming.genParticles_cff')
273 process.merge_step += process.prunedGenParticlesWithStatusOne
274 process.load(
'PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi')
275 process.merge_step += process.prunedGenParticles
276 process.load(
'PhysicsTools.PatAlgos.slimming.packedGenParticles_cfi')
277 process.merge_step += process.packedGenParticles
279 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi')
280 process.merge_step += process.muonMatch
281 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.electronMatch_cfi')
282 process.merge_step += process.electronMatch
283 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.photonMatch_cfi')
284 process.merge_step += process.photonMatch
285 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.tauMatch_cfi')
286 process.merge_step += process.tauMatch
287 process.load(
'PhysicsTools.JetMCAlgos.TauGenJets_cfi')
288 process.merge_step += process.tauGenJets
289 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff')
290 process.merge_step += process.patJetPartons
291 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi')
292 process.merge_step += process.patJetPartonMatch
294 process.muonMatch.matched =
"prunedGenParticles"
295 process.electronMatch.matched =
"prunedGenParticles"
296 process.electronMatch.src = cms.InputTag(
"reducedEgamma",
"reducedGedGsfElectrons")
297 process.photonMatch.matched =
"prunedGenParticles"
298 process.photonMatch.src = cms.InputTag(
"reducedEgamma",
"reducedGedPhotons")
299 process.tauMatch.matched =
"prunedGenParticles"
300 process.tauGenJets.GenParticles =
"prunedGenParticles"
304 process.patJetPartons.particles =
"prunedGenParticles"
305 process.patJetPartonMatch.matched =
"prunedGenParticles"
306 process.patJetPartonMatch.mcStatus = [ 3, 23 ]
307 process.patJetGenJetMatch.matched =
"slimmedGenJets"
308 process.patJetGenJetMatchAK8.matched =
"slimmedGenJetsAK8"
309 process.patJetGenJetMatchAK8Puppi.matched =
"slimmedGenJetsAK8"
310 process.patMuons.embedGenMatch =
False
311 process.patElectrons.embedGenMatch =
False
312 process.patPhotons.embedGenMatch =
False
313 process.patTaus.embedGenMatch =
False
314 process.patTausBoosted.embedGenMatch =
False
315 process.patJets.embedGenPartonMatch =
False
317 process.patJetFlavourAssociation.rParam = 0.4
319 process.schedule.insert(0,process.merge_step)
325 if changeProcessname:
326 process._Process__name =
"MERGE"
333 process.source.inputCommands = cms.untracked.vstring()
334 process.source.inputCommands.append(
"keep *_*_*_*")
342 process.load(
'Configuration.StandardSequences.Reconstruction_Data_cff')
343 process.merge_step = cms.Path()
346 for akt_manimod
in to_bemanipulate:
347 if "MERGE" in akt_manimod.steps:
350 print(akt_manimod.module_name)
351 mergCollections_in = cms.VInputTag()
352 for instance
in akt_manimod.instance:
353 mergCollections_in.append(cms.InputTag(akt_manimod.merge_prefix+akt_manimod.module_name,instance,
"SIMembedding"))
354 mergCollections_in.append(cms.InputTag(akt_manimod.merge_prefix+akt_manimod.module_name,instance,
"LHEembeddingCLEAN"))
355 setattr(process, akt_manimod.module_name, cms.EDProducer(akt_manimod.merger_name,
356 mergCollections = mergCollections_in
359 process.merge_step +=getattr(process, akt_manimod.module_name)
362 process.merge_step += process.doAlldEdXEstimators
363 process.merge_step += process.vertexreco
364 process.unsortedOfflinePrimaryVertices.beamSpotLabel = cms.InputTag(
"offlineBeamSpot",
"",dataTier)
365 process.ak4CaloJetsForTrk.srcPVs = cms.InputTag(
"firstStepPrimaryVertices",
"",dataTier)
367 process.muons.FillDetectorBasedIsolation = cms.bool(
False)
368 process.muons.FillSelectorMaps = cms.bool(
False)
369 process.muons.FillShoweringInfo = cms.bool(
False)
370 process.muons.FillCosmicsIdMap = cms.bool(
False)
372 process.muonsFromCosmics.fillShowerDigis = cms.bool(
False)
373 process.muonsFromCosmics1Leg.fillShowerDigis = cms.bool(
False)
375 process.merge_step += process.highlevelreco
380 process.merge_step.remove(process.ak4JetTracksAssociatorExplicit)
382 process.merge_step.remove(process.pfTrack)
383 process.merge_step.remove(process.pfConversions)
384 process.merge_step.remove(process.pfV0)
385 process.merge_step.remove(process.particleFlowDisplacedVertexCandidate)
386 process.merge_step.remove(process.particleFlowDisplacedVertex)
387 process.merge_step.remove(process.pfDisplacedTrackerVertex)
388 process.merge_step.remove(process.pfTrackElec)
389 process.merge_step.remove(process.electronsWithPresel)
390 process.merge_step.remove(process.mvaElectrons)
391 process.merge_step.remove(process.particleFlowBlock)
392 process.merge_step.remove(process.particleFlowEGamma)
393 process.merge_step.remove(process.gedGsfElectronCores)
395 process.merge_step.remove(process.gedPhotonCore)
396 process.merge_step.remove(process.ecalDrivenGsfElectronCores)
397 process.merge_step.remove(process.ecalDrivenGsfElectrons)
398 process.merge_step.remove(process.uncleanedOnlyElectronSeeds)
399 process.merge_step.remove(process.uncleanedOnlyAllConversions)
400 process.merge_step.remove(process.uncleanedOnlyPfTrack)
401 process.merge_step.remove(process.uncleanedOnlyPfTrackElec)
402 process.merge_step.remove(process.uncleanedOnlyGsfElectrons)
403 process.merge_step.remove(process.uncleanedOnlyElectronCkfTrackCandidates)
404 process.merge_step.remove(process.cosmicsVeto)
405 process.merge_step.remove(process.cosmicsVetoTrackCandidates)
410 process.merge_step.remove(process.hcalnoise)
411 process.merge_step.remove(process.lowPtGsfElectronTask)
412 process.merge_step.remove(process.gsfTracksOpenConversions)
414 process.load(
'CommonTools.ParticleFlow.genForPF2PAT_cff')
416 process.merge_step += process.genForPF2PATSequence
418 process.slimmingTask.remove(process.slimmedLowPtElectronsTask)
420 process.schedule.insert(0,process.merge_step)
427 return customiseMerging(process, changeProcessname=changeProcessname, reselect=
True)
432 process._Process__name =
"LHEembeddingCLEAN"
434 process =
customiseLHE(process,changeProcessname=
False,reselect=reselect)
443 if not hasattr(process,
"options"):
444 process.options = cms.untracked.PSet()
445 process.options.emptyRunLumiMode = cms.untracked.string(
'doNotHandleEmptyRunsAndLumis')
446 if not hasattr(process,
"bunchSpacingProducer"):
447 process.bunchSpacingProducer = cms.EDProducer(
"BunchSpacingProducer")
448 process.bunchSpacingProducer.bunchSpacingOverride = cms.uint32(25)
449 process.bunchSpacingProducer.overrideBunchSpacing = cms.bool(
True)
450 process.options.numberOfThreads = cms.untracked.uint32(1)
451 process.options.numberOfStreams = cms.untracked.uint32(0)
457 process.load(
"TauAnalysis.MCEmbeddingTools.DYToMuMuGenFilter_cfi")
458 process.ZToMuMuFilter = cms.Path(process.dYToMuMuGenFilter)
459 process.schedule.insert(-1,process.ZToMuMuFilter)
463 process.load(
"TauAnalysis.MCEmbeddingTools.TTbartoMuMuGenFilter_cfi")
464 process.MCFilter = cms.Path(process.TTbartoMuMuGenFilter)
468 process.schedule.insert(-1,process.MCFilter)
469 outputModulesList = [key
for key,value
in six.iteritems(process.outputModules)]
470 for outputModule
in outputModulesList:
471 outputModule = getattr(process, outputModule)
472 outputModule.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
"MCFilter"))
475 def fix_input_tags(process, formodules = ["generalTracks","cscSegments","dt4DSegments","rpcRecHits"]):
476 def change_tags_process(test_input):
477 if isinstance(test_input, cms.InputTag):
478 if test_input.getModuleLabel()
in formodules:
479 test_input.setProcessName(process._Process__name)
481 def search_for_tags(pset):
482 if isinstance(pset, dict):
484 if isinstance(pset[key], cms.VInputTag):
485 for akt_inputTag
in pset[key]:
486 change_tags_process(akt_inputTag)
487 elif isinstance(pset[key], cms.PSet):
488 search_for_tags(pset[key].__dict__)
489 elif isinstance(pset[key], cms.VPSet):
490 for akt_pset
in pset[key]:
491 search_for_tags(akt_pset.__dict__)
493 change_tags_process(pset[key])
495 print(
"must be python dict not a ",type(pset))
497 for module
in process.producers_():
498 search_for_tags(getattr(process, module).__dict__)
499 for module
in process.filters_():
500 search_for_tags(getattr(process, module).__dict__)
501 for module
in process.analyzers_():
502 search_for_tags(getattr(process, module).__dict__)