00006 :
00007
00008 inputProcess="HLT"
00009
00010 process._Process__name="EmbeddedRECO"
00011 process.TFileService = cms.Service("TFileService", fileName = cms.string("histo_embedded.root") )
00012
00013 try:
00014 outputModule = process.output
00015 except:
00016 pass
00017 try:
00018 outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
00019 except:
00020 pass
00021
00022 print "Changing eventcontent to RAW+AODSIM + misc. "
00023 outputModule.outputCommands = cms.untracked.vstring("drop *")
00024 outputModule.outputCommands.extend(process.RAWEventContent.outputCommands )
00025 outputModule.outputCommands.extend(process.AODSIMEventContent.outputCommands )
00026
00027 keepMC = cms.untracked.vstring("keep *_*_zMusExtracted_*",
00028 "keep *_*_zmmCands_*",
00029 "keep *_removedInputMuons_*_*",
00030 "keep *_generator_*_*",
00031 "keep *_PhotonIDProd_*_*",
00032 "keep *_photons_*_*",
00033 "keep *_photonCore_*_*",
00034 "keep *_genParticles_*_*",
00035 "keep *_particleFlow_*_*",
00036 "keep *_generator_*_*",
00037 "keep *_tmfTracks_*_EmbeddedRECO",
00038 "keep *_offlinePrimaryVertices_*_EmbeddedRECO",
00039 "keep *_offlinePrimaryVerticesWithBS_*_EmbeddedRECO",
00040 "keep *_PhotonIDProd_*_*",
00041 "keep *_photons_*_*",
00042 "keep *_photonCore_*_*",
00043 "keep *_genParticles_*_*",
00044 "keep *_particleFlow_*_*",
00045 )
00046 outputModule.outputCommands.extend(keepMC)
00047
00048
00049 index = 0
00050 for item in outputModule.outputCommands[:]:
00051 if item == "drop *" and index != 0:
00052
00053 del outputModule.outputCommands[index]
00054 index -= 1
00055 index += 1
00056
00057
00058 hltProcessName = "HLT"
00059
00060 try:
00061 hltProcessName = __HLT__
00062 except:
00063 pass
00064
00065 try:
00066 process.dimuonsHLTFilter.TriggerResultsTag.processName = hltProcessName
00067 process.goodZToMuMuAtLeast1HLT.TrigTag.processName = hltProcessName
00068 process.goodZToMuMuAtLeast1HLT.triggerEvent.processName = hltProcessName
00069 process.hltTrigReport,HLTriggerResults.processName = hltProcessName
00070 except:
00071 pass
00072
00073 process.VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator",
00074 MaxZ = cms.double(0.0),
00075 MaxX = cms.double(0.0),
00076 MaxY = cms.double(0.0),
00077 MinX = cms.double(0.0),
00078 MinY = cms.double(0.0),
00079 MinZ = cms.double(0.0),
00080 TimeOffset = cms.double(0.0),
00081 src = cms.InputTag("generator")
00082 )
00083
00084 import FWCore.ParameterSet.VarParsing as VarParsing
00085 options = VarParsing.VarParsing ('analysis')
00086 options.register ('mdtau',
00087 0,
00088 VarParsing.VarParsing.multiplicity.singleton,
00089 VarParsing.VarParsing.varType.int,
00090 "mdtau value for tauola")
00091
00092 options.register ('transformationMode',
00093 1,
00094 VarParsing.VarParsing.multiplicity.singleton,
00095 VarParsing.VarParsing.varType.int,
00096 "transformation mode. 0=mumu->mumu, 1=mumu->tautau")
00097
00098 options.register ('minVisibleTransverseMomentum',
00099 "",
00100 VarParsing.VarParsing.multiplicity.singleton,
00101 VarParsing.VarParsing.varType.string,
00102 "generator level cut on visible transverse momentum (typeN:pT,[...];[...])")
00103
00104 options.register ('useJson',
00105 0,
00106 VarParsing.VarParsing.multiplicity.singleton,
00107 VarParsing.VarParsing.varType.int,
00108 "should I enable json usage?")
00109
00110 options.register ('overrideBeamSpot',
00111 0,
00112 VarParsing.VarParsing.multiplicity.singleton,
00113 VarParsing.VarParsing.varType.int,
00114 "should I override beamspot in globaltag?")
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 setFromCL = False
00125 if not hasattr(process,"doNotParse"):
00126 import sys
00127 if hasattr(sys, "argv") == True:
00128 if not sys.argv[0].endswith('cmsDriver.py'):
00129 options.parseArguments()
00130 setFromCL = True
00131 else :
00132 print "CL parsing disabled!"
00133
00134
00135 if setFromCL:
00136 print "Setting mdtau to ", options.mdtau
00137 process.generator.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
00138 process.newSource.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
00139 process.generator.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
00140 process.newSource.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
00141
00142 print "Setting minVisibleTransverseMomentum to ", options.minVisibleTransverseMomentum
00143 process.newSource.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
00144 process.generator.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
00145
00146 print "Setting transformationMode to ", options.transformationMode
00147 process.generator.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
00148 process.newSource.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
00149
00150 if setFromCL and options.overrideBeamSpot != 0 :
00151 print "options.overrideBeamSpot", options.overrideBeamSpot
00152
00153 bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v21_offline")
00154
00155
00156
00157
00158
00159 process.GlobalTag.toGet = cms.VPSet(
00160 cms.PSet(record = cms.string("BeamSpotObjectsRcd"),
00161 tag = bs,
00162 connect = cms.untracked.string("frontier://FrontierProd/CMS_COND_31X_BEAMSPOT")
00163 )
00164 )
00165 print "BeamSpot in globaltag set to ", bs
00166 else:
00167 print "BeamSpot in globaltag not changed"
00168
00169 if setFromCL and options.useJson != 0:
00170 print "Enabling json usage"
00171 import PhysicsTools.PythonAnalysis.LumiList as LumiList
00172 import FWCore.ParameterSet.Types as CfgTypes
00173 myLumis = LumiList.LumiList(filename = 'my.json').getCMSSWString().split(',')
00174 process.source.lumisToProcess = CfgTypes.untracked(CfgTypes.VLuminosityBlockRange())
00175 process.source.lumisToProcess.extend(myLumis)
00176
00177
00178
00179
00180 process.generalTracksORG = process.generalTracks.clone()
00181
00182 process.generalTracks = cms.EDProducer("RecoTracksMixer",
00183 trackCol1 = cms.InputTag("generalTracksORG","","EmbeddedRECO"),
00184 trackCol2 = cms.InputTag("removedInputMuons","tracks")
00185 )
00186
00187 for p in process.paths:
00188 pth = getattr(process,p)
00189 if "generalTracks" in pth.moduleNames():
00190 pth.replace(process.generalTracks, process.generalTracksORG*process.generalTracks)
00191
00192
00193
00194
00195 process.trackerDrivenElectronSeedsORG = process.trackerDrivenElectronSeeds.clone()
00196 process.trackerDrivenElectronSeedsORG.TkColList = cms.VInputTag(cms.InputTag("generalTracksORG"))
00197
00198 process.trackerDrivenElectronSeeds = cms.EDProducer("ElectronSeedTrackRefUpdater",
00199 PreIdLabel = process.trackerDrivenElectronSeedsORG.PreIdLabel,
00200 PreGsfLabel = process.trackerDrivenElectronSeedsORG.PreGsfLabel,
00201 targetTracks = cms.InputTag("generalTracks"),
00202 inSeeds = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreGsfLabel.value()),
00203 inPreId = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreIdLabel.value()),
00204 )
00205
00206 for p in process.paths:
00207 pth = getattr(process,p)
00208 if "trackerDrivenElectronSeeds" in pth.moduleNames():
00209 pth.replace(process.trackerDrivenElectronSeeds, process.trackerDrivenElectronSeedsORG*process.trackerDrivenElectronSeeds)
00210
00211
00212
00213 process.trackerDrivenElectronSeedsMerged = cms.EDProducer("ElectronSeedTrackRefUpdaterAndMerger",
00214 PreIdLabel = process.trackerDrivenElectronSeedsORG.PreIdLabel,
00215 PreGsfLabel = process.trackerDrivenElectronSeedsORG.PreGsfLabel,
00216 targetTracks = cms.InputTag("generalTracks"),
00217 inSeeds1 = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeeds.PreGsfLabel.value()),
00218 inPreId1 = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeeds.PreIdLabel.value()),
00219 inSeeds2 = cms.InputTag("trackerDrivenElectronSeeds", process.trackerDrivenElectronSeeds.PreGsfLabel.value()),
00220 inPreId2 = cms.InputTag("trackerDrivenElectronSeeds", process.trackerDrivenElectronSeeds.PreIdLabel.value())
00221 )
00222
00223 process.electronMergedSeedsPhotonCoreHack = cms.EDProducer("ElectronSeedMerger",
00224 EcalBasedSeeds = cms.InputTag("ecalDrivenElectronSeeds"),
00225 TkBasedSeeds = cms.InputTag("trackerDrivenElectronSeedsMerged","SeedsForGsf")
00226 )
00227
00228 process.photonCore.pixelSeedProducer = cms.string('electronMergedSeedsPhotonCoreHack')
00229
00230
00231 for p in process.paths:
00232 pth = getattr(process,p)
00233 if "photonCore" in pth.moduleNames():
00234 pth.replace(process.photonCore,
00235 process.trackerDrivenElectronSeedsMerged * process.electronMergedSeedsPhotonCoreHack *process.photonCore)
00236
00237
00238
00239
00240
00241 process.electronGsfTracksORG = process.electronGsfTracks.clone()
00242 process.electronGsfTracks = cms.EDProducer("GsfTrackMixer",
00243 col1 = cms.InputTag("electronGsfTracksORG","","EmbeddedRECO"),
00244 col2= cms.InputTag("electronGsfTracks","", inputProcess),
00245 )
00246
00247
00248
00249 process.gsfConversionTrackProducer.TrackProducer = cms.string('electronGsfTracksORG')
00250
00251 for p in process.paths:
00252 pth = getattr(process,p)
00253 if "electronGsfTracks" in pth.moduleNames():
00254 pth.replace(process.electronGsfTracks, process.electronGsfTracksORG*process.electronGsfTracks)
00255
00256
00257
00258
00259
00260 '''
00261 process.electronMergedSeedsORG = process.electronMergedSeeds.clone()
00262 process.electronMergedSeeds = cms.EDProducer("ElectronSeedsMixer",
00263 col1 = cms.InputTag("electronMergedSeeds","", inputProcess),
00264 col2 = cms.InputTag("electronMergedSeedsORG","","EmbeddedRECO")
00265 )
00266 for p in process.paths:
00267 pth = getattr(process,p)
00268 if "electronMergedSeeds" in pth.moduleNames():
00269 pth.replace(process.electronMergedSeeds, process.electronMergedSeedsORG*process.electronMergedSeeds)
00270 '''
00271
00272 process.generalConversionTrackProducer.TrackProducer = cms.string('generalTracksORG')
00273
00274
00275 process.gsfElectronsORG = process.gsfElectrons.clone()
00276 process.gsfElectrons = cms.EDProducer("GSFElectronsMixer",
00277 col1 = cms.InputTag("gsfElectronsORG"),
00278 col2 = cms.InputTag("gsfElectrons","",inputProcess),
00279 )
00280 for p in process.paths:
00281 pth = getattr(process,p)
00282 if "gsfElectrons" in pth.moduleNames():
00283 pth.replace(process.gsfElectrons, process.gsfElectronsORG*process.gsfElectrons)
00284
00285
00286
00287
00288 for p in process.paths:
00289 pth = getattr(process,p)
00290
00291
00292 for mod in pth.moduleNames():
00293 if mod.find("dedx") != -1:
00294 print "Removing", mod
00295 module=getattr(process,mod)
00296 pth.remove(module)
00297
00298
00299
00300 clConfig = cms.PSet (
00301 depsPlus = cms.InputTag("anaDeposits", "plus" ),
00302 depsMinus = cms.InputTag("anaDeposits", "minus" )
00303 )
00304
00305
00306
00307 process.castorrecoORG = process.castorreco.clone()
00308 process.castorreco = cms.EDProducer("CastorRHMixer",
00309 cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
00310 cleaningConfig = clConfig,
00311 todo = cms.VPSet(cms.PSet ( colZmumu = cms.InputTag("castorreco","", inputProcess ), colTauTau = cms.InputTag("castorrecoORG" ) ))
00312 )
00313
00314 for p in process.paths:
00315 pth = getattr(process,p)
00316 if "castorreco" in pth.moduleNames():
00317 pth.replace(process.castorreco, process.castorrecoORG*process.castorreco)
00318
00319 process.ecalRecHitORG = process.ecalRecHit.clone()
00320 process.ecalRecHit = cms.EDProducer("EcalRHMixer",
00321 cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
00322
00323 cleaningConfig = clConfig,
00324 todo = cms.VPSet(
00325 cms.PSet ( colZmumu = cms.InputTag("ecalRecHit","EcalRecHitsEB", inputProcess ),
00326 colTauTau = cms.InputTag("ecalRecHitORG","EcalRecHitsEB" ) ),
00327
00328 cms.PSet ( colZmumu = cms.InputTag("ecalRecHit","EcalRecHitsEE", inputProcess ),
00329 colTauTau = cms.InputTag("ecalRecHitORG","EcalRecHitsEE" ) )
00330 )
00331 )
00332 for p in process.paths:
00333 pth = getattr(process,p)
00334 if "ecalRecHit" in pth.moduleNames():
00335 pth.replace(process.ecalRecHit, process.ecalRecHitORG*process.ecalRecHit)
00336
00337
00338
00339 process.hbherecoORG = process.hbhereco.clone()
00340 process.hbhereco = cms.EDProducer("HBHERHMixer",
00341 cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
00342 cleaningConfig = clConfig,
00343 todo =
00344 cms.VPSet(cms.PSet ( colZmumu = cms.InputTag( "hbhereco","", inputProcess ), colTauTau = cms.InputTag("hbherecoORG","" )))
00345 )
00346 for p in process.paths:
00347 pth = getattr(process,p)
00348 if "hbhereco" in pth.moduleNames():
00349 pth.replace(process.hbhereco, process.hbherecoORG*process.hbhereco)
00350
00351
00352 process.hfrecoORG = process.hfreco.clone()
00353 process.hfreco = cms.EDProducer("HFRHMixer",
00354 cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
00355 cleaningConfig = clConfig,
00356 todo =
00357 cms.VPSet(cms.PSet ( colZmumu = cms.InputTag( "hfreco","", inputProcess ), colTauTau = cms.InputTag("hfrecoORG","" )))
00358 )
00359 for p in process.paths:
00360 pth = getattr(process,p)
00361 if "hfreco" in pth.moduleNames():
00362 pth.replace(process.hfreco, process.hfrecoORG*process.hfreco)
00363
00364
00365
00366 process.horecoORG = process.horeco.clone()
00367 process.horeco = cms.EDProducer("HORHMixer",
00368 cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
00369 cleaningConfig = clConfig,
00370 todo =
00371 cms.VPSet(cms.PSet ( colZmumu = cms.InputTag( "horeco","", inputProcess ), colTauTau = cms.InputTag("horecoORG","" )))
00372 )
00373 for p in process.paths:
00374 pth = getattr(process,p)
00375 if "horeco" in pth.moduleNames():
00376 pth.replace(process.horeco, process.horecoORG*process.horeco)
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386 for s in process.sequences:
00387 seq = getattr(process,s)
00388 seq.remove(process.offlineBeamSpot)
00389
00390
00391 try:
00392 process.metreco.remove(process.BeamHaloId)
00393 except:
00394 pass
00395
00396 try:
00397 outputModule = process.output
00398 except:
00399 pass
00400 try:
00401 outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
00402 except:
00403 pass
00404
00405 process.filterEmptyEv.src = cms.untracked.InputTag("generator","","EmbeddedRECO")
00406
00407
00408 try:
00409 process.schedule.remove(process.DQM_FEDIntegrity_v3)
00410 except:
00411 pass
00412
00413
00414 process.RECOSIMoutput.outputCommands.extend(['keep *_*_*_skimGoldenZmumu2'])
00415
00416
00417 process.RECOSIMoutput.outputCommands.extend(['keep *_*ORG_*_*'])
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 skimEnabled = False
00428 if hasattr(process,"doZmumuSkim"):
00429 print "Enabling Zmumu skim"
00430 skimEnabled = True
00431
00432
00433
00434 cmssw_ver = os.environ["CMSSW_VERSION"]
00435 if cmssw_ver.find("CMSSW_4_2") != -1:
00436 print
00437 print "Using legacy version of Zmumu skim. Note, that muon isolation is disabled"
00438 print
00439 process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelectionLegacy_cff")
00440 else:
00441 process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelection_cff")
00442 process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
00443
00444
00445 for path in process.paths:
00446 getattr(process,path)._seq = process.goldenZmumuSelectionSequence * getattr(process,path)._seq
00447
00448
00449
00450
00451
00452
00453
00454
00455 if not skimEnabled:
00456 print "Zmumu skim not enabled"
00457
00458
00459 print "# ######################################################################################"
00460 print " Following parameters can be added before customize function "
00461 print " call in order to controll process customization: "
00462 print " process.doNotParse = cms.PSet() # disables CL parsing for crab compat"
00463 print " process.doZmumuSkim = cms.PSet() # adds Zmumu skimming before embedding is run"
00464 print "# ######################################################################################"
00465
00466
00467 return(process)