00047 :
00048
00049
00050
00051 process._Process__name="EmbeddedRECO"
00052 process.TFileService = cms.Service("TFileService", fileName = cms.string("histo_embedded.root") )
00053
00054 try:
00055 outputModule = process.output
00056 except:
00057 pass
00058 try:
00059 outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
00060 except:
00061 pass
00062
00063 print "Changing eventcontent to RAW+AODSIM + misc. "
00064 outputModule.outputCommands = cms.untracked.vstring("drop *")
00065 outputModule.outputCommands.extend(process.RAWEventContent.outputCommands )
00066 outputModule.outputCommands.extend(process.AODSIMEventContent.outputCommands )
00067
00068 keepMC = cms.untracked.vstring("keep *_*_zMusExtracted_*",
00069 "keep *_*_zmmCands_*",
00070 "keep *_removedInputMuons_*_*",
00071 "keep *_generator_*_*",
00072 "keep *_PhotonIDProd_*_*",
00073 "keep *_photons_*_*",
00074 "keep *_photonCore_*_*",
00075 "keep *_genParticles_*_*",
00076 "keep *_particleFlow_*_*",
00077 "keep *_generator_*_*",
00078 "keep *_tmfTracks_*_EmbeddedRECO",
00079 "keep *_offlinePrimaryVertices_*_EmbeddedRECO",
00080 "keep *_offlinePrimaryVerticesWithBS_*_EmbeddedRECO",
00081 "keep *_PhotonIDProd_*_*",
00082 "keep *_photons_*_*",
00083 "keep *_photonCore_*_*",
00084 "keep *_genParticles_*_*",
00085 "keep *_particleFlow_*_*",
00086 )
00087 outputModule.outputCommands.extend(keepMC)
00088
00089
00090 index = 0
00091 for item in outputModule.outputCommands[:]:
00092 if item == "drop *" and index != 0:
00093
00094 del outputModule.outputCommands[index]
00095 index -= 1
00096 index += 1
00097
00098
00099 hltProcessName = "HLT"
00100 RECOproc = "RECO"
00101
00102 try:
00103 hltProcessName = __HLT__
00104 except:
00105 pass
00106
00107 try:
00108 process.dimuonsHLTFilter.TriggerResultsTag.processName = hltProcessName
00109 process.goodZToMuMuAtLeast1HLT.TrigTag.processName = hltProcessName
00110 process.goodZToMuMuAtLeast1HLT.triggerEvent.processName = hltProcessName
00111 process.hltTrigReport,HLTriggerResults.processName = hltProcessName
00112 except:
00113 pass
00114
00115 process.VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator",
00116 MaxZ = cms.double(0.0),
00117 MaxX = cms.double(0.0),
00118 MaxY = cms.double(0.0),
00119 MinX = cms.double(0.0),
00120 MinY = cms.double(0.0),
00121 MinZ = cms.double(0.0),
00122 TimeOffset = cms.double(0.0),
00123 src = cms.InputTag("generator")
00124 )
00125
00126 import FWCore.ParameterSet.VarParsing as VarParsing
00127 options = VarParsing.VarParsing ('analysis')
00128 options.register ('mdtau',
00129 0,
00130 VarParsing.VarParsing.multiplicity.singleton,
00131 VarParsing.VarParsing.varType.int,
00132 "mdtau value for tauola")
00133
00134 options.register ('transformationMode',
00135 1,
00136 VarParsing.VarParsing.multiplicity.singleton,
00137 VarParsing.VarParsing.varType.int,
00138 "transformation mode. 0=mumu->mumu, 1=mumu->tautau")
00139
00140 options.register ('minVisibleTransverseMomentum',
00141 "",
00142 VarParsing.VarParsing.multiplicity.singleton,
00143 VarParsing.VarParsing.varType.string,
00144 "generator level cut on visible transverse momentum (typeN:pT,[...];[...])")
00145
00146 options.register ('useJson',
00147 0,
00148 VarParsing.VarParsing.multiplicity.singleton,
00149 VarParsing.VarParsing.varType.int,
00150 "should I enable json usage?")
00151
00152 options.register ('overrideBeamSpot',
00153 0,
00154 VarParsing.VarParsing.multiplicity.singleton,
00155 VarParsing.VarParsing.varType.int,
00156 "should I override beamspot in globaltag?")
00157
00158
00159
00160
00161
00162
00163
00164
00165 setFromCL = False
00166 if not hasattr(process,"doNotParse"):
00167 import sys
00168 if hasattr(sys, "argv") == True:
00169 if not sys.argv[0].endswith('cmsDriver.py'):
00170 options.parseArguments()
00171 setFromCL = True
00172 else:
00173 print "CL parsing disabled!"
00174 if setFromCL:
00175 print "Setting mdtau to ", options.mdtau
00176 process.generator.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
00177 process.newSource.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
00178 process.generator.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
00179 process.newSource.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
00180
00181 print "Setting minVisibleTransverseMomentum to ", options.minVisibleTransverseMomentum
00182 process.newSource.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
00183 process.generator.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
00184
00185 print "Setting transformationMode to ", options.transformationMode
00186 process.generator.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
00187 process.newSource.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
00188
00189 print "options.overrideBeamSpot", options.overrideBeamSpot
00190 if options.overrideBeamSpot != 0:
00191 bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v26_offline")
00192
00193
00194
00195
00196
00197
00198 process.GlobalTag.toGet = cms.VPSet(
00199 cms.PSet(record = cms.string("BeamSpotObjectsRcd"),
00200 tag = bs,
00201 connect = cms.untracked.string("frontier://FrontierProd/CMS_COND_31X_BEAMSPOT")
00202 )
00203 )
00204 print "BeamSpot in globaltag set to ", bs
00205 else:
00206 print "BeamSpot in globaltag not changed"
00207
00208 if options.useJson != 0:
00209 print "Enabling json usage"
00210 import PhysicsTools.PythonAnalysis.LumiList as LumiList
00211 import FWCore.ParameterSet.Types as CfgTypes
00212 myLumis = LumiList.LumiList(filename = 'my.json').getCMSSWString().split(',')
00213 process.source.lumisToProcess = CfgTypes.untracked(CfgTypes.VLuminosityBlockRange())
00214 process.source.lumisToProcess.extend(myLumis)
00215
00216
00217
00218
00219 process.tmfTracks = cms.EDProducer("RecoTracksMixer",
00220 trackCol1 = cms.InputTag("removedInputMuons","tracks"),
00221 trackCol2 = cms.InputTag("generalTracks","","EmbeddedRECO")
00222 )
00223
00224 process.offlinePrimaryVerticesWithBS.TrackLabel = cms.InputTag("tmfTracks")
00225 process.offlinePrimaryVertices.TrackLabel = cms.InputTag("tmfTracks")
00226
00227 if hasattr(process.muons, "TrackExtractorPSet"):
00228 process.muons.TrackExtractorPSet.inputTrackCollection = cms.InputTag("tmfTracks")
00229 elif hasattr(process, "muons1stStep") and hasattr(process.muons1stStep, "TrackExtractorPSet"):
00230 process.muons1stStep.TrackExtractorPSet.inputTrackCollection = cms.InputTag("tmfTracks")
00231 else:
00232 raise "Problem with muons"
00233
00234
00235
00236 for s in process.sequences:
00237 seq = getattr(process,s)
00238 seq.remove(process.offlineBeamSpot)
00239
00240
00241 try:
00242 process.metreco.remove(process.BeamHaloId)
00243 except:
00244 pass
00245
00246 try:
00247 outputModule = process.output
00248 except:
00249 pass
00250 try:
00251 outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
00252 except:
00253 pass
00254
00255
00256 for p in process.paths:
00257 pth = getattr(process,p)
00258 if "generalTracks" in pth.moduleNames():
00259 pth.replace(process.generalTracks, process.generalTracks*process.tmfTracks)
00260
00261
00262
00263 process.gsfElectronsORG = process.gsfElectrons.clone()
00264
00265
00266
00267 for p in process.paths:
00268 pth = getattr(process,p)
00269
00270 if "gsfElectrons" in pth.moduleNames():
00271 pth.replace(process.gsfElectrons, process.gsfElectronsORG*process.gsfElectrons)
00272
00273
00274
00275 process.gsfElectrons = cms.EDProducer("GSFElectronsMixer",
00276 col1 = cms.InputTag("gsfElectronsORG"),
00277 col2 = cms.InputTag("gsfElectrons","", RECOproc )
00278 )
00279
00280
00281
00282
00283 process.particleFlowORG = process.particleFlow.clone()
00284
00285
00286
00287
00288
00289
00290 if hasattr(process, 'particleFlowTmp'):
00291 process.particleFlowTmpMixed = cms.EDProducer('PFCandidateMixer',
00292 col1 = cms.untracked.InputTag("removedInputMuons","pfCands"),
00293 col2 = cms.untracked.InputTag("particleFlowTmp", ""),
00294 trackCol = cms.untracked.InputTag("tmfTracks"),
00295
00296
00297 muons = cms.untracked.InputTag(""),
00298 gsfElectrons = cms.untracked.InputTag("")
00299 )
00300 process.muons.PFCandidates = cms.InputTag("particleFlowTmpMixed")
00301
00302 for p in process.paths:
00303 if "particleFlow" in pth.moduleNames():
00304 pth.replace(process.particleFlow, process.particleFlowORG*process.particleFlow)
00305 if "muons" in pth.moduleNames():
00306 pth.replace(process.muons, process.particleFlowTmpMixed*process.muons)
00307 else:
00308
00309 if hasattr(process,"famosParticleFlowSequence"):
00310 process.famosParticleFlowSequence.remove(process.pfPhotonTranslatorSequence)
00311 process.famosParticleFlowSequence.remove(process.pfElectronTranslatorSequence)
00312 process.famosParticleFlowSequence.remove(process.particleFlow)
00313 process.famosParticleFlowSequence.__iadd__(process.particleFlowORG)
00314 process.famosParticleFlowSequence.__iadd__(process.particleFlow)
00315 process.famosParticleFlowSequence.__iadd__(process.pfElectronTranslatorSequence)
00316 process.famosParticleFlowSequence.__iadd__(process.pfPhotonTranslatorSequence)
00317 elif hasattr(process,"particleFlowReco"):
00318 process.particleFlowReco.remove(process.pfPhotonTranslatorSequence)
00319 process.particleFlowReco.remove(process.pfElectronTranslatorSequence)
00320 process.particleFlowReco.remove(process.particleFlow)
00321 process.particleFlowReco.__iadd__(process.particleFlowORG)
00322 process.particleFlowReco.__iadd__(process.particleFlow)
00323 process.particleFlowReco.__iadd__(process.pfElectronTranslatorSequence)
00324 process.particleFlowReco.__iadd__(process.pfPhotonTranslatorSequence)
00325 else :
00326 raise "Cannot find particleFlow sequence"
00327
00328 process.pfSelectedElectrons.src = cms.InputTag("particleFlowORG")
00329 process.pfSelectedPhotons.src = cms.InputTag("particleFlowORG")
00330
00331
00332 process.particleFlow = cms.EDProducer('PFCandidateMixer',
00333 col1 = cms.untracked.InputTag("removedInputMuons","pfCands"),
00334 col2 = cms.untracked.InputTag("particleFlowORG", ""),
00335 trackCol = cms.untracked.InputTag("tmfTracks"),
00336
00337 muons = cms.untracked.InputTag("muons"),
00338 gsfElectrons = cms.untracked.InputTag("gsfElectrons")
00339
00340 )
00341
00342 process.filterEmptyEv.src = cms.untracked.InputTag("generator","","EmbeddedRECO")
00343
00344 from FWCore.ParameterSet.Types import InputTag
00345 for p in process.paths:
00346 i = getattr(process,p)
00347 target = process.particleFlow
00348
00349 seqVis = SeqVisitor(target)
00350 seqVis.prepareSearch()
00351 seqVis.setLookFor(target)
00352 i.visit(seqVis)
00353 while ( seqVis.catch != 1 and seqVis.found == 1 ):
00354
00355 target = seqVis.giveNext()
00356
00357 targetAttributes = dir(target)
00358 for targetAttribute in targetAttributes:
00359 attr=getattr(target,targetAttribute)
00360 if isinstance(attr, InputTag) and attr.getModuleLabel()=="particleFlow":
00361 if ( attr.getProductInstanceLabel()!="" ):
00362 print "Changing: ", target, " ", targetAttribute, " ", attr, " to particleFlowORG"
00363 attr.setModuleLabel("particleFlowORG")
00364
00365
00366
00367 seqVis.prepareSearch()
00368 seqVis.setLookFor(target)
00369 i.visit(seqVis)
00370
00371
00372
00373
00374
00375
00376 if hasattr(process, "DQM_FEDIntegrity_v3"):
00377 process.schedule.remove(process.DQM_FEDIntegrity_v3)
00378
00379 skimEnabled = False
00380 if hasattr(process,"doZmumuSkim"):
00381 print "Enabling Zmumu skim"
00382 skimEnabled = True
00383
00384 cmssw_ver = os.environ["CMSSW_VERSION"]
00385 if cmssw_ver.find("CMSSW_4_2") != -1:
00386 print
00387 print "Using legacy version of Zmumu skim. Note, that muon isolation is disabled"
00388 print
00389 process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelectionLegacy_cff")
00390 process.RandomNumberGeneratorService.dummy = cms.PSet(
00391 initialSeed = cms.untracked.uint32(123456789),
00392 engineName = cms.untracked.string('HepJamesRandom')
00393 )
00394
00395 else:
00396 process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelection_cff")
00397
00398
00399 process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
00400
00401
00402 for path in process.paths:
00403 getattr(process,path)._seq = process.goldenZmumuSelectionSequence * getattr(process,path)._seq
00404
00405
00406
00407
00408
00409
00410 if not skimEnabled:
00411 print "Zmumu skim not enabled"
00412
00413
00414 print "# ######################################################################################"
00415 print " Following parameters can be added before customize function "
00416 print " call in order to controll process customization: "
00417 print " process.doNotParse = cms.PSet() # disables CL parsing for crab compat"
00418 print " process.doZmumuSkim = cms.PSet() # adds Zmumu skimming before embedding is run"
00419 print "# ######################################################################################"
00420
00421 return(process)