CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
pf_01_customizeAll Namespace Reference

Classes

class  SeqVisitor
 

Functions

def customise
 

Function Documentation

def pf_01_customizeAll.customise (   process)

Definition at line 42 of file pf_01_customizeAll.py.

42 
43 def customise(process):
44 
45  process._Process__name="EmbeddedRECO"
46  process.TFileService = cms.Service("TFileService", fileName = cms.string("histo_embedded.root") )
47 
48  try:
49  outputModule = process.output
50  except:
51  pass
52  try:
53  outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
54  except:
55  pass
56 
57  print "Changing eventcontent to RAW+AODSIM + misc. "
58  outputModule.outputCommands = cms.untracked.vstring("drop *")
59  outputModule.outputCommands.extend(process.RAWEventContent.outputCommands )
60  outputModule.outputCommands.extend(process.AODSIMEventContent.outputCommands )
61 
62  keepMC = cms.untracked.vstring("keep *_*_zMusExtracted_*",
63  "keep *_*_zmmCands_*",
64  "keep *_removedInputMuons_*_*",
65  "keep *_generator_*_*",
66  "keep *_PhotonIDProd_*_*",
67  "keep *_photons_*_*",
68  "keep *_photonCore_*_*",
69  "keep *_genParticles_*_*",
70  "keep *_particleFlow_*_*",
71  "keep *_generator_*_*",
72  "keep *_tmfTracks_*_EmbeddedRECO",
73  "keep *_offlinePrimaryVertices_*_EmbeddedRECO",
74  "keep *_offlinePrimaryVerticesWithBS_*_EmbeddedRECO",
75  "keep *_PhotonIDProd_*_*",
76  "keep *_photons_*_*",
77  "keep *_photonCore_*_*",
78  "keep *_genParticles_*_*",
79  "keep *_particleFlow_*_*",
80  )
81  outputModule.outputCommands.extend(keepMC)
82 
83  # getRid of second "drop *"
84  index = 0
85  for item in outputModule.outputCommands[:]:
86  if item == "drop *" and index != 0:
87  #print index," ",outputModule.outputCommands[index]
88  del outputModule.outputCommands[index]
89  index -= 1
90  index += 1
91 
92 
93  hltProcessName = "HLT" #"REDIGI38X"
94  RECOproc = "RECO"
95  # the following block can be used for more efficient processing by replacing the HLT variable below automatically
96  try:
97  hltProcessName = __HLT__
98  except:
99  pass
100 
101  try:
102  process.dimuonsHLTFilter.TriggerResultsTag.processName = hltProcessName
103  process.goodZToMuMuAtLeast1HLT.TrigTag.processName = hltProcessName
104  process.goodZToMuMuAtLeast1HLT.triggerEvent.processName = hltProcessName
105  process.hltTrigReport,HLTriggerResults.processName = hltProcessName
106  except:
107  pass
108 
109  process.VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator",
110  MaxZ = cms.double(0.0),
111  MaxX = cms.double(0.0),
112  MaxY = cms.double(0.0),
113  MinX = cms.double(0.0),
114  MinY = cms.double(0.0),
115  MinZ = cms.double(0.0),
116  TimeOffset = cms.double(0.0),
117  src = cms.InputTag("generator","unsmeared")
118  )
119 
120  import FWCore.ParameterSet.VarParsing as VarParsing
121  options = VarParsing.VarParsing ('analysis')
122  options.register ('mdtau',
123  0, # default value
124  VarParsing.VarParsing.multiplicity.singleton,
125  VarParsing.VarParsing.varType.int,
126  "mdtau value for tauola")
127 
128  options.register ('transformationMode',
129  1, #default value
130  VarParsing.VarParsing.multiplicity.singleton,
131  VarParsing.VarParsing.varType.int,
132  "transformation mode. 0=mumu->mumu, 1=mumu->tautau")
133 
134  options.register ('minVisibleTransverseMomentum',
135  "", #default value
136  VarParsing.VarParsing.multiplicity.singleton,
137  VarParsing.VarParsing.varType.string,
138  "generator level cut on visible transverse momentum (typeN:pT,[...];[...])")
139 
140  options.register ('useJson',
141  0, # default value, false
142  VarParsing.VarParsing.multiplicity.singleton,
143  VarParsing.VarParsing.varType.int,
144  "should I enable json usage?")
145 
146  options.register ('overrideBeamSpot',
147  0, # default value, false
148  VarParsing.VarParsing.multiplicity.singleton,
149  VarParsing.VarParsing.varType.int,
150  "should I override beamspot in globaltag?")
151 
152  options.register ('skimEnabled',
153  0, # default value, true
154  VarParsing.VarParsing.multiplicity.singleton,
155  VarParsing.VarParsing.varType.int,
156  "should I apply Zmumu event selection cuts?")
157 
158 # options.register ('primaryProcess',
159 # 'RECO', # default value
160 # VarParsing.VarParsing.multiplicity.singleton,
161 # VarParsing.VarParsing.varType.string,
162 # "original processName")
163 
164 
165  setFromCL = False
166  if not hasattr(process,"doNotParse"):
167  import sys
168  if hasattr(sys, "argv") == True:
169  if not sys.argv[0].endswith('cmsDriver.py'):
170  options.parseArguments()
171  setFromCL = True
172  else:
173  print "CL parsing disabled!"
174  if setFromCL:
175  print "Setting mdtau to ", options.mdtau
176  process.generator.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
177  process.newSource.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
178  process.generator.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
179  process.newSource.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
180 
181  print "Setting minVisibleTransverseMomentum to ", options.minVisibleTransverseMomentum
182  process.newSource.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
183  process.generator.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
184 
185  print "Setting transformationMode to ", options.transformationMode
186  process.generator.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
187  process.newSource.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
188 
189  print "options.overrideBeamSpot", options.overrideBeamSpot
190  if options.overrideBeamSpot != 0:
191  bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v26_offline") # 52x data PR gt
192  # bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v21_offline") # 42x data PR gt
193  # bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v18_offline") # 41x data PR gt
194  # bs = cms.string("BeamSpotObjects_2009_LumiBased_v17_offline") # 38x data gt
195  #bs = cms.string("BeamSpotObjects_2009_v14_offline") # 36x data gt
196  # tag = cms.string("Early10TeVCollision_3p8cm_31X_v1_mc_START"), # 35 default
197  # tag = cms.string("Realistic900GeVCollisions_10cm_STARTUP_v1_mc"), # 36 default
198  process.GlobalTag.toGet = cms.VPSet(
199  cms.PSet(record = cms.string("BeamSpotObjectsRcd"),
200  tag = bs,
201  connect = cms.untracked.string("frontier://FrontierProd/CMS_COND_31X_BEAMSPOT")
202  )
203  )
204  print "BeamSpot in globaltag set to ", bs
205  else:
206  print "BeamSpot in globaltag not changed"
207 
208  if options.useJson != 0:
209  print "Enabling json usage"
210  import PhysicsTools.PythonAnalysis.LumiList as LumiList
211  import FWCore.ParameterSet.Types as CfgTypes
212  myLumis = LumiList.LumiList(filename = 'my.json').getCMSSWString().split(',')
213  process.source.lumisToProcess = CfgTypes.untracked(CfgTypes.VLuminosityBlockRange())
214  process.source.lumisToProcess.extend(myLumis)
215 
216 # -*- coding: utf-8 -*-
217 
218  process.tmfTracks = cms.EDProducer("RecoTracksMixer",
219  trackCol1 = cms.InputTag("removedInputMuons","tracks"),
220  trackCol2 = cms.InputTag("generalTracks","","EmbeddedRECO")
221  )
222 
223  process.offlinePrimaryVerticesWithBS.TrackLabel = cms.InputTag("tmfTracks")
224  process.offlinePrimaryVertices.TrackLabel = cms.InputTag("tmfTracks")
225 
226  if hasattr(process.muons, "TrackExtractorPSet"):
227  process.muons.TrackExtractorPSet.inputTrackCollection = cms.InputTag("tmfTracks")
228  elif hasattr(process, "muons1stStep") and hasattr(process.muons1stStep, "TrackExtractorPSet"):
229  process.muons1stStep.TrackExtractorPSet.inputTrackCollection = cms.InputTag("tmfTracks")
230  else:
231  raise "Problem with muons"
232  # it should be the best solution to take the original beam spot for the
233  # reconstruction of the new primary vertex
234  # use the one produced earlier, do not produce your own
235  for s in process.sequences:
236  seq = getattr(process,s)
237  seq.remove(process.offlineBeamSpot)
238 
239  try:
240  process.metreco.remove(process.BeamHaloId)
241  except:
242  pass
243 
244  try:
245  outputModule = process.output
246  except:
247  pass
248  try:
249  outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
250  except:
251  pass
252 
253  for p in process.paths:
254  pth = getattr(process,p)
255  if "generalTracks" in pth.moduleNames():
256  pth.replace(process.generalTracks, process.generalTracks*process.tmfTracks)
257 
258  #'''
259  process.gsfElectronsORG = process.gsfElectrons.clone()
260  #print dir(process)
261  #for p in dir(process):
262 
263  for p in process.paths:
264  pth = getattr(process,p)
265  #if hasattr(pth,"gsfElectrons"):
266  if "gsfElectrons" in pth.moduleNames():
267  pth.replace(process.gsfElectrons, process.gsfElectronsORG*process.gsfElectrons)
268  #print p, dir(pth.moduleNames())
269 
270  # xxx
271  process.gsfElectrons = cms.EDProducer("GSFElectronsMixer",
272  col1 = cms.InputTag("gsfElectronsORG"),
273  col2 = cms.InputTag("gsfElectrons","", RECOproc )
274  )
275  #'''
276 
277  process.particleFlowORG = process.particleFlow.clone()
278 
279  # Since CMSSW 4_4 the particleFlow reco works a bit differently. The step is
280  # twofold, first particleFlowTmp is created and then the final particleFlow
281  # collection. What we do in this case is that we merge the final ParticleFlow
282  # collection. For the muon reconstruction, we also merge particleFlowTmp in
283  # order to get PF-based isolation right.
284  if hasattr(process, 'particleFlowTmp'):
285  process.particleFlowTmpMixed = cms.EDProducer('PFCandidateMixer',
286  col1 = cms.untracked.InputTag("removedInputMuons","pfCands"),
287  col2 = cms.untracked.InputTag("particleFlowTmp", ""),
288  trackCol = cms.untracked.InputTag("tmfTracks"),
289 
290  # Don't produce value maps:
291  muons = cms.untracked.InputTag(""),
292  gsfElectrons = cms.untracked.InputTag("")
293  )
294  process.muons.PFCandidates = cms.InputTag("particleFlowTmpMixed")
295 
296  for p in process.paths:
297  if "particleFlow" in pth.moduleNames():
298  pth.replace(process.particleFlow, process.particleFlowORG*process.particleFlow)
299  if "muons" in pth.moduleNames():
300  pth.replace(process.muons, process.particleFlowTmpMixed*process.muons)
301  else:
302  # CMSSW_4_2
303  if hasattr(process,"famosParticleFlowSequence"):
304  process.famosParticleFlowSequence.remove(process.pfPhotonTranslatorSequence)
305  process.famosParticleFlowSequence.remove(process.pfElectronTranslatorSequence)
306  process.famosParticleFlowSequence.remove(process.particleFlow)
307  process.famosParticleFlowSequence.__iadd__(process.particleFlowORG)
308  process.famosParticleFlowSequence.__iadd__(process.particleFlow)
309  process.famosParticleFlowSequence.__iadd__(process.pfElectronTranslatorSequence)
310  process.famosParticleFlowSequence.__iadd__(process.pfPhotonTranslatorSequence)
311  elif hasattr(process,"particleFlowReco"):
312  process.particleFlowReco.remove(process.pfPhotonTranslatorSequence)
313  process.particleFlowReco.remove(process.pfElectronTranslatorSequence)
314  process.particleFlowReco.remove(process.particleFlow)
315  process.particleFlowReco.__iadd__(process.particleFlowORG)
316  process.particleFlowReco.__iadd__(process.particleFlow)
317  process.particleFlowReco.__iadd__(process.pfElectronTranslatorSequence)
318  process.particleFlowReco.__iadd__(process.pfPhotonTranslatorSequence)
319  else :
320  raise "Cannot find particleFlow sequence"
321 
322  process.pfSelectedElectrons.src = cms.InputTag("particleFlowORG")
323  process.pfSelectedPhotons.src = cms.InputTag("particleFlowORG")
324 
325  process.particleFlow = cms.EDProducer('PFCandidateMixer',
326  col1 = cms.untracked.InputTag("removedInputMuons","pfCands"),
327  col2 = cms.untracked.InputTag("particleFlowORG", ""),
328  trackCol = cms.untracked.InputTag("tmfTracks"),
329 
330  muons = cms.untracked.InputTag("muons"),
331  gsfElectrons = cms.untracked.InputTag("gsfElectrons")
332  # TODO: photons???
333  )
334 
335  process.filterEmptyEv.src = cms.untracked.InputTag("generatorSmeared","","EmbeddedRECO")
336 
337  from FWCore.ParameterSet.Types import InputTag
338  for p in process.paths:
339  i = getattr(process,p)
340  target = process.particleFlow
341 
342  seqVis = SeqVisitor(target)
343  seqVis.prepareSearch()
344  seqVis.setLookFor(target)
345  i.visit(seqVis)
346  while ( seqVis.catch != 1 and seqVis.found == 1 ):
347 
348  target = seqVis.giveNext()
349 
350  targetAttributes = dir(target)
351  for targetAttribute in targetAttributes:
352  attr=getattr(target,targetAttribute) # get actual attribute, not just the name
353  if isinstance(attr, InputTag) and attr.getModuleLabel()=="particleFlow":
354  if ( attr.getProductInstanceLabel()!="" ):
355  print "Changing: ", target, " ", targetAttribute, " ", attr, " to particleFlowORG"
356  attr.setModuleLabel("particleFlowORG")
357 
358  #i.replace(target, source)
359  seqVis.prepareSearch()
360  seqVis.setLookFor(target)
361  i.visit(seqVis)
362 
363  #if (seqVis.catch==1):
364  #seqVis.catch=0
365  #i.__iadd__(source)
366 
367  # CV: mix L1Extra collections
368  l1ExtraCollections = [
369  [ "L1EmParticle", "Isolated" ],
370  [ "L1EmParticle", "NonIsolated" ],
371  [ "L1EtMissParticle", "MET" ],
372  [ "L1EtMissParticle", "MHT" ],
373  [ "L1JetParticle", "Central" ],
374  [ "L1JetParticle", "Forward" ],
375  [ "L1JetParticle", "Tau" ],
376  [ "L1MuonParticle", "" ]
377  ]
378  l1extraParticleCollections = []
379  for l1ExtraCollection in l1ExtraCollections:
380  inputType = l1ExtraCollection[0]
381  pluginType = None
382  if inputType == "L1EmParticle":
383  pluginType = "L1ExtraEmParticleMixerPlugin"
384  elif inputType == "L1EtMissParticle":
385  pluginType = "L1ExtraMEtMixerPlugin"
386  elif inputType == "L1JetParticle":
387  pluginType = "L1ExtraJetParticleMixerPlugin"
388  elif inputType == "L1MuonParticle":
389  pluginType = "L1ExtraMuonParticleMixerPlugin"
390  else:
391  raise ValueError("Invalid L1Extra type = %s !!" % inputType)
392  instanceLabel = l1ExtraCollection[1]
393  l1extraParticleCollections.append(cms.PSet(
394  pluginType = cms.string(pluginType),
395  instanceLabel = cms.string(instanceLabel)))
396  process.l1extraParticlesORG = process.l1extraParticles.clone()
397  process.l1extraParticles = cms.EDProducer('L1ExtraMixer',
398  src1 = cms.InputTag('l1extraParticles::HLT'),
399  src2 = cms.InputTag('l1extraParticlesORG'),
400  collections = cms.VPSet(l1extraParticleCollections)
401  )
402  for p in process.paths:
403  pth = getattr(process,p)
404  if "l1extraParticles" in pth.moduleNames():
405  pth.replace(process.l1extraParticles, process.l1extraParticlesORG*process.l1extraParticles)
406 
407  #if hasattr(process, "DQM_FEDIntegrity_v3"):
408  # process.schedule.remove(process.DQM_FEDIntegrity_v3)
409  fedIntRemoved = False
410  for i in range(1,30):
411  attrName = "DQM_FEDIntegrity_v"+str(i)
412  if hasattr(process, attrName ):
413  process.schedule.remove(process.DQM_FEDIntegrity_v11)
414  del process.DTDataIntegrityTask
415  fedIntRemoved = True
416  break
417 
418  if fedIntRemoved:
419  print "Removed", attrName
420  else:
421  print "DQM_FEDIntegrity_vXX not found, expect problems"
422 
423  skimEnabled = False
424  if setFromCL:
425  if options.skimEnabled != 0:
426  skimEnabled = True
427  else:
428  if hasattr(process,"doZmumuSkim"):
429  skimEnabled = True
430  if skimEnabled:
431  print "Enabling Zmumu skim"
432  skimEnabled = True
433 
434  cmssw_ver = os.environ["CMSSW_VERSION"]
435  if cmssw_ver.find("CMSSW_4_2") != -1:
436  print
437  print "Using legacy version of Zmumu skim. Note, that muon isolation is disabled"
438  print
439  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelectionLegacy_cff")
440  process.RandomNumberGeneratorService.dummy = cms.PSet(
441  initialSeed = cms.untracked.uint32(123456789),
442  engineName = cms.untracked.string('HepJamesRandom')
443  )
444 
445  else:
446  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelection_cff")
447 
448  #process.load("TauAnalysis/Skimming/goldenZmmSelectionVBTFrelPFIsolation_cfi")
449  process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
450 
451  # we are allready selecting events from generation step, so following way is ok
452  for path in process.paths:
453  getattr(process,path)._seq = process.goldenZmumuSelectionSequence * getattr(process,path)._seq
454 
455  #process.options = cms.untracked.PSet(
456  # wantSummary = cms.untracked.bool(True)
457  #)
458  else:
459  print "Zmumu skim not enabled"
460  # CV: add path for keeping track of skimming efficiency
461  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelection_cff")
462  process.skimEffFlag = cms.EDProducer("DummyBoolEventSelFlagProducer")
463  process.skimEffPath = cms.Path(process.goldenZmumuSelectionSequence * process.skimEffFlag)
464 
465  process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
466 
467  print "# ######################################################################################"
468  print " Following parameters can be added before customize function "
469  print " call in order to controll process customization: "
470  print " process.doNotParse = cms.PSet() # disables CL parsing for crab compat"
471  print " process.doZmumuSkim = cms.PSet() # adds Zmumu skimming before embedding is run"
472  print "# ######################################################################################"
473 
474  return(process)
return(e1-e2)*(e1-e2)+dp *dp
dbl *** dir
Definition: mlp_gen.cc:35
double split
Definition: MVATrainer.cc:139
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run