5 from __future__
import print_function
6 import FWCore.ParameterSet.Config
as cms
7 from FWCore.ParameterSet.Utilities
import cleanUnscheduled
26 def __init__(self, module_name, manipulator_name, steps = ["SELECT","CLEAN","SIM","MERGE"], instance=[""], merge_prefix = ""):
41 to_bemanipulate.append(
module_manipulate(module_name =
'siPixelClusters', manipulator_name =
"Pixel", steps = [
"SELECT",
"CLEAN"] ))
42 to_bemanipulate.append(
module_manipulate(module_name =
'siStripClusters', manipulator_name =
"Strip", steps = [
"SELECT",
"CLEAN"] ))
44 to_bemanipulate.append(
module_manipulate(module_name =
'generalTracks', manipulator_name =
"Track", steps = [
"SIM",
"MERGE"]))
45 to_bemanipulate.append(
module_manipulate(module_name =
'muons1stStep', manipulator_name =
"Muon", steps = [
"SIM",
"MERGE"]))
46 to_bemanipulate.append(
module_manipulate(module_name =
'gedGsfElectronsTmp', manipulator_name =
"GsfElectron", steps = [
"SIM",
"MERGE"]))
47 to_bemanipulate.append(
module_manipulate(module_name =
'gedPhotonsTmp', manipulator_name =
"Photon", steps = [
"SIM",
"MERGE"]))
48 to_bemanipulate.append(
module_manipulate(module_name =
'particleFlowTmp', manipulator_name =
"PF", steps = [
"SIM",
"MERGE"], instance=[
"",
"CleanedHF",
"CleanedCosmicsMuons",
"CleanedTrackerAndGlobalMuons",
"CleanedFakeMuons",
"CleanedPunchThroughMuons",
"CleanedPunchThroughNeutralHadrons",
"AddedMuonsAndHadrons"]))
51 to_bemanipulate.append(
module_manipulate(module_name =
'ecalRecHit', manipulator_name =
"EcalRecHit", instance= [
"EcalRecHitsEB",
"EcalRecHitsEE"]))
52 to_bemanipulate.append(
module_manipulate(module_name =
'ecalPreshowerRecHit', manipulator_name =
"EcalRecHit", instance= [
"EcalRecHitsES"]))
54 to_bemanipulate.append(
module_manipulate(module_name =
'hbheprereco', manipulator_name =
"HBHERecHit"))
55 to_bemanipulate.append(
module_manipulate(module_name =
'hbhereco', manipulator_name =
"HBHERecHit"))
56 to_bemanipulate.append(
module_manipulate(module_name =
'zdcreco', manipulator_name =
"ZDCRecHit"))
58 to_bemanipulate.append(
module_manipulate(module_name =
'horeco', manipulator_name =
"HORecHit"))
59 to_bemanipulate.append(
module_manipulate(module_name =
'hfreco', manipulator_name =
"HFRecHit"))
60 to_bemanipulate.append(
module_manipulate(module_name =
'castorreco', manipulator_name =
"CastorRecHit"))
63 to_bemanipulate.append(
module_manipulate(module_name =
'dt1DRecHits', manipulator_name =
"DTRecHit", steps = [
"SELECT",
"CLEAN"] ))
64 to_bemanipulate.append(
module_manipulate(module_name =
'dt1DCosmicRecHits', manipulator_name =
"DTRecHit", steps = [
"SELECT",
"CLEAN"] ))
66 to_bemanipulate.append(
module_manipulate(module_name =
'csc2DRecHits', manipulator_name =
"CSCRecHit", steps = [
"SELECT",
"CLEAN"] ))
67 to_bemanipulate.append(
module_manipulate(module_name =
'rpcRecHits', manipulator_name =
"RPCRecHit", steps = [
"SELECT",
"CLEAN"] ))
71 outputModulesList = [key
for key,value
in six.iteritems(process.outputModules)]
72 for outputModule
in outputModulesList:
73 if outputModule
in module_veto_list:
75 outputModule = getattr(process, outputModule)
76 for add_element
in keep_drop_list:
77 outputModule.outputCommands.extend(add_element)
85 ret_vstring = cms.untracked.vstring(
87 "keep *_patMuonsAfterID_*_"+dataTier,
88 "keep *_slimmedMuons_*_"+dataTier,
89 "keep *_selectedMuonsForEmbedding_*_"+dataTier,
90 "keep recoVertexs_offlineSlimmedPrimaryVertices_*_"+dataTier,
91 "keep *_firstStepPrimaryVertices_*_"+dataTier,
92 "keep *_offlineBeamSpot_*_"+dataTier
94 for akt_manimod
in to_bemanipulate:
95 if "CLEAN" in akt_manimod.steps:
96 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_"+dataTier)
101 process._Process__name =
"RESELECT"
104 process._Process__name =
"SELECT"
107 process.load(
'TauAnalysis.MCEmbeddingTools.SelectingProcedure_cff')
108 process.patMuonsAfterKinCuts.src = cms.InputTag(
"slimmedMuons",
"",dataTier)
109 process.patMuonsAfterID = process.patMuonsAfterLooseID.clone()
111 process.selecting = cms.Path(process.makePatMuonsZmumuSelection)
112 process.schedule.insert(-1, process.selecting)
114 outputModulesList = [key
for key,value
in six.iteritems(process.outputModules)]
115 for outputModule
in outputModulesList:
116 outputModule = getattr(process, outputModule)
117 outputModule.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
"selecting"))
118 outputModule.outputCommands.extend(
keepSelected(dataTier))
128 ret_vstring = cms.untracked.vstring(
133 for akt_manimod
in to_bemanipulate:
134 if "MERGE" in akt_manimod.steps:
135 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_LHEembeddingCLEAN")
136 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_CLEAN")
137 ret_vstring.append(
"keep *_standAloneMuons_*_LHEembeddingCLEAN")
138 ret_vstring.append(
"keep *_glbTrackQual_*_LHEembeddingCLEAN")
144 if changeProcessname:
145 process._Process__name =
"CLEAN"
152 TrackAssociatorParameterBlock.TrackAssociatorParameters.CSCSegmentCollectionLabel = cms.InputTag(
"cscSegments",
"",dataTier)
153 TrackAssociatorParameterBlock.TrackAssociatorParameters.CaloTowerCollectionLabel = cms.InputTag(
"towerMaker",
"",dataTier)
154 TrackAssociatorParameterBlock.TrackAssociatorParameters.DTRecSegment4DCollectionLabel = cms.InputTag(
"dt4DSegments",
"",dataTier)
155 TrackAssociatorParameterBlock.TrackAssociatorParameters.EBRecHitCollectionLabel = cms.InputTag(
"ecalRecHit",
"EcalRecHitsEB",dataTier)
156 TrackAssociatorParameterBlock.TrackAssociatorParameters.EERecHitCollectionLabel = cms.InputTag(
"ecalRecHit",
"EcalRecHitsEE",dataTier)
157 TrackAssociatorParameterBlock.TrackAssociatorParameters.HBHERecHitCollectionLabel = cms.InputTag(
"hbhereco",
"",dataTier)
158 TrackAssociatorParameterBlock.TrackAssociatorParameters.HORecHitCollectionLabel = cms.InputTag(
"horeco",
"",dataTier)
161 MuonImput = cms.InputTag(
"selectedMuonsForEmbedding",
"",
"")
162 for akt_manimod
in to_bemanipulate:
163 if "CLEAN" in akt_manimod.steps:
164 oldCollections_in = cms.VInputTag()
165 for instance
in akt_manimod.instance:
166 oldCollections_in.append(cms.InputTag(akt_manimod.module_name,instance,dataTier))
167 setattr(process, akt_manimod.module_name, cms.EDProducer(akt_manimod.cleaner_name,MuonCollection = MuonImput,TrackAssociatorParameters = TrackAssociatorParameterBlock.TrackAssociatorParameters,oldCollection = oldCollections_in))
168 process.ecalPreshowerRecHit.TrackAssociatorParameters.usePreshower = cms.bool(
True)
175 ret_vstring = cms.untracked.vstring()
176 ret_vstring.append(
"keep *_externalLHEProducer_*_LHEembedding")
177 ret_vstring.append(
"keep *_externalLHEProducer_*_LHEembeddingCLEAN")
182 ret_vstring = cms.untracked.vstring()
183 for akt_manimod
in to_bemanipulate:
184 if "MERGE" in akt_manimod.steps:
185 ret_vstring.append(
"keep *_"+akt_manimod.module_name+
"_*_SIMembedding")
186 ret_vstring.append(
"keep *_genParticles_*_SIMembedding")
187 ret_vstring.append(
"keep *_standAloneMuons_*_SIMembedding")
188 ret_vstring.append(
"keep *_glbTrackQual_*_SIMembedding")
189 ret_vstring.append(
"keep *_generator_*_SIMembedding")
190 ret_vstring.append(
"keep *_addPileupInfo_*_SIMembedding")
191 ret_vstring.append(
"keep *_slimmedAddPileupInfo_*_*")
202 if changeProcessname:
203 process._Process__name =
"LHEembedding"
204 process.load(
'TauAnalysis.MCEmbeddingTools.EmbeddingLHEProducer_cfi')
206 process.externalLHEProducer.vertices=cms.InputTag(
"offlineSlimmedPrimaryVertices",
"",
"RESELECT")
207 process.lheproduction = cms.Path(process.makeexternalLHEProducer)
208 process.schedule.insert(0,process.lheproduction)
220 if changeProcessname:
221 process._Process__name =
"SIMembedding"
225 process.load(
'TauAnalysis.MCEmbeddingTools.EmbeddingVertexCorrector_cfi')
226 process.VtxSmeared = process.VtxCorrectedToInput.clone()
227 print(
"Correcting Vertex in genEvent to one from input. Replaced 'VtxSmeared' with the Corrector.")
230 process.reconstruction.remove(process.offlineBeamSpot)
233 process.mix.digitizers.castor.doNoise = cms.bool(
False)
235 process.mix.digitizers.ecal.doESNoise = cms.bool(
False)
236 process.mix.digitizers.ecal.doENoise = cms.bool(
False)
238 process.mix.digitizers.hcal.doNoise = cms.bool(
False)
239 process.mix.digitizers.hcal.doThermalNoise = cms.bool(
False)
240 process.mix.digitizers.hcal.doHPDNoise = cms.bool(
False)
242 process.mix.digitizers.pixel.AddNoisyPixels = cms.bool(
False)
243 process.mix.digitizers.pixel.AddNoise = cms.bool(
False)
245 process.mix.digitizers.strip.Noise = cms.bool(
False)
258 ret_vstring = cms.untracked.vstring()
259 ret_vstring.append(
"drop *_*_*_"+dataTier)
260 ret_vstring.append(
"keep *_prunedGenParticles_*_MERGE")
261 ret_vstring.append(
"keep *_generator_*_SIMembedding")
271 process.load(
'PhysicsTools.PatAlgos.slimming.genParticles_cff')
272 process.merge_step += process.prunedGenParticlesWithStatusOne
273 process.load(
'PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi')
274 process.merge_step += process.prunedGenParticles
275 process.load(
'PhysicsTools.PatAlgos.slimming.packedGenParticles_cfi')
276 process.merge_step += process.packedGenParticles
278 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi')
279 process.merge_step += process.muonMatch
280 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.electronMatch_cfi')
281 process.merge_step += process.electronMatch
282 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.photonMatch_cfi')
283 process.merge_step += process.photonMatch
284 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.tauMatch_cfi')
285 process.merge_step += process.tauMatch
286 process.load(
'PhysicsTools.JetMCAlgos.TauGenJets_cfi')
287 process.merge_step += process.tauGenJets
288 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff')
289 process.merge_step += process.patJetPartons
290 process.load(
'PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi')
291 process.merge_step += process.patJetPartonMatch
293 process.muonMatch.matched =
"prunedGenParticles"
294 process.electronMatch.matched =
"prunedGenParticles"
295 process.electronMatch.src = cms.InputTag(
"reducedEgamma",
"reducedGedGsfElectrons")
296 process.photonMatch.matched =
"prunedGenParticles"
297 process.photonMatch.src = cms.InputTag(
"reducedEgamma",
"reducedGedPhotons")
298 process.tauMatch.matched =
"prunedGenParticles"
299 process.tauGenJets.GenParticles =
"prunedGenParticles"
303 process.patJetPartons.particles =
"prunedGenParticles"
304 process.patJetPartonMatch.matched =
"prunedGenParticles"
305 process.patJetPartonMatch.mcStatus = [ 3, 23 ]
306 process.patJetGenJetMatch.matched =
"slimmedGenJets"
307 process.patJetGenJetMatchAK8.matched =
"slimmedGenJetsAK8"
308 process.patJetGenJetMatchAK8Puppi.matched =
"slimmedGenJetsAK8"
309 process.patMuons.embedGenMatch =
False
310 process.patElectrons.embedGenMatch =
False
311 process.patPhotons.embedGenMatch =
False
312 process.patTaus.embedGenMatch =
False
313 process.patTausBoosted.embedGenMatch =
False
314 process.patJets.embedGenPartonMatch =
False
316 process.patJetFlavourAssociation.rParam = 0.4
318 process.schedule.insert(0,process.merge_step)
324 if changeProcessname:
325 process._Process__name =
"MERGE"
332 process.source.inputCommands = cms.untracked.vstring()
333 process.source.inputCommands.append(
"keep *_*_*_*")
341 process.load(
'Configuration.StandardSequences.Reconstruction_Data_cff')
342 process.merge_step = cms.Path()
345 for akt_manimod
in to_bemanipulate:
346 if "MERGE" in akt_manimod.steps:
349 print(akt_manimod.module_name)
350 mergCollections_in = cms.VInputTag()
351 for instance
in akt_manimod.instance:
352 mergCollections_in.append(cms.InputTag(akt_manimod.merge_prefix+akt_manimod.module_name,instance,
"SIMembedding"))
353 mergCollections_in.append(cms.InputTag(akt_manimod.merge_prefix+akt_manimod.module_name,instance,
"LHEembeddingCLEAN"))
354 setattr(process, akt_manimod.module_name, cms.EDProducer(akt_manimod.merger_name,
355 mergCollections = mergCollections_in
358 process.merge_step +=getattr(process, akt_manimod.module_name)
361 process.merge_step += process.doAlldEdXEstimators
362 process.merge_step += process.vertexreco
363 process.unsortedOfflinePrimaryVertices.beamSpotLabel = cms.InputTag(
"offlineBeamSpot",
"",dataTier)
364 process.ak4CaloJetsForTrk.srcPVs = cms.InputTag(
"firstStepPrimaryVertices",
"",dataTier)
366 process.muons.FillDetectorBasedIsolation = cms.bool(
False)
367 process.muons.FillSelectorMaps = cms.bool(
False)
368 process.muons.FillShoweringInfo = cms.bool(
False)
369 process.muons.FillCosmicsIdMap = cms.bool(
False)
371 process.muonsFromCosmics.fillShowerDigis = cms.bool(
False)
372 process.muonsFromCosmics1Leg.fillShowerDigis = cms.bool(
False)
374 process.merge_step += process.highlevelreco
379 process.merge_step.remove(process.ak4JetTracksAssociatorExplicit)
381 process.merge_step.remove(process.pfTrack)
382 process.merge_step.remove(process.pfConversions)
383 process.merge_step.remove(process.pfV0)
384 process.merge_step.remove(process.particleFlowDisplacedVertexCandidate)
385 process.merge_step.remove(process.particleFlowDisplacedVertex)
386 process.merge_step.remove(process.pfDisplacedTrackerVertex)
387 process.merge_step.remove(process.pfTrackElec)
388 process.merge_step.remove(process.electronsWithPresel)
389 process.merge_step.remove(process.mvaElectrons)
390 process.merge_step.remove(process.particleFlowBlock)
391 process.merge_step.remove(process.particleFlowEGamma)
392 process.merge_step.remove(process.gedGsfElectronCores)
394 process.merge_step.remove(process.gedPhotonCore)
395 process.merge_step.remove(process.ecalDrivenGsfElectronCores)
396 process.merge_step.remove(process.ecalDrivenGsfElectrons)
397 process.merge_step.remove(process.uncleanedOnlyElectronSeeds)
398 process.merge_step.remove(process.uncleanedOnlyAllConversions)
399 process.merge_step.remove(process.uncleanedOnlyPfTrack)
400 process.merge_step.remove(process.uncleanedOnlyPfTrackElec)
401 process.merge_step.remove(process.uncleanedOnlyGsfElectrons)
402 process.merge_step.remove(process.uncleanedOnlyElectronCkfTrackCandidates)
403 process.merge_step.remove(process.cosmicsVeto)
404 process.merge_step.remove(process.cosmicsVetoTrackCandidates)
409 process.merge_step.remove(process.hcalnoise)
411 process.load(
'CommonTools.ParticleFlow.genForPF2PAT_cff')
413 process.merge_step += process.genForPF2PATSequence
415 process.schedule.insert(0,process.merge_step)
422 return customiseMerging(process, changeProcessname=changeProcessname, reselect=
True)
427 process._Process__name =
"LHEembeddingCLEAN"
429 process =
customiseLHE(process,changeProcessname=
False,reselect=reselect)
438 if not hasattr(process,
"options"):
439 process.options = cms.untracked.PSet()
440 process.options.emptyRunLumiMode = cms.untracked.string(
'doNotHandleEmptyRunsAndLumis')
441 if not hasattr(process,
"bunchSpacingProducer"):
442 process.bunchSpacingProducer = cms.EDProducer(
"BunchSpacingProducer")
443 process.bunchSpacingProducer.bunchSpacingOverride = cms.uint32(25)
444 process.bunchSpacingProducer.overrideBunchSpacing = cms.bool(
True)
445 process.options.numberOfThreads = cms.untracked.uint32(1)
446 process.options.numberOfStreams = cms.untracked.uint32(0)
452 process.load(
"TauAnalysis.MCEmbeddingTools.DYToMuMuGenFilter_cfi")
453 process.ZToMuMuFilter = cms.Path(process.dYToMuMuGenFilter)
454 process.schedule.insert(-1,process.ZToMuMuFilter)
458 process.load(
"TauAnalysis.MCEmbeddingTools.TTbartoMuMuGenFilter_cfi")
459 process.MCFilter = cms.Path(process.TTbartoMuMuGenFilter)
463 process.schedule.insert(-1,process.MCFilter)
464 outputModulesList = [key
for key,value
in six.iteritems(process.outputModules)]
465 for outputModule
in outputModulesList:
466 outputModule = getattr(process, outputModule)
467 outputModule.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
"MCFilter"))
470 def fix_input_tags(process, formodules = ["generalTracks","cscSegments","dt4DSegments","rpcRecHits"]):
471 def change_tags_process(test_input):
472 if isinstance(test_input, cms.InputTag):
473 if test_input.getModuleLabel()
in formodules:
474 test_input.setProcessName(process._Process__name)
476 def search_for_tags(pset):
477 if isinstance(pset, dict):
479 if isinstance(pset[key], cms.VInputTag):
480 for akt_inputTag
in pset[key]:
481 change_tags_process(akt_inputTag)
482 elif isinstance(pset[key], cms.PSet):
483 search_for_tags(pset[key].__dict__)
484 elif isinstance(pset[key], cms.VPSet):
485 for akt_pset
in pset[key]:
486 search_for_tags(akt_pset.__dict__)
488 change_tags_process(pset[key])
490 print(
"must be python dict not a ",type(pset))
492 for module
in process.producers_():
493 search_for_tags(getattr(process, module).__dict__)
494 for module
in process.filters_():
495 search_for_tags(getattr(process, module).__dict__)
496 for module
in process.analyzers_():
497 search_for_tags(getattr(process, module).__dict__)