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