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 46 of file pf_01_customizeAll.py.

46 
47 def customise(process):
48 
49 
50 
51  process._Process__name="EmbeddedRECO"
52  process.TFileService = cms.Service("TFileService", fileName = cms.string("histo_embedded.root") )
53 
54  try:
55  outputModule = process.output
56  except:
57  pass
58  try:
59  outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
60  except:
61  pass
62 
63  print "Changing eventcontent to RAW+AODSIM + misc. "
64  outputModule.outputCommands = cms.untracked.vstring("drop *")
65  outputModule.outputCommands.extend(process.RAWEventContent.outputCommands )
66  outputModule.outputCommands.extend(process.AODSIMEventContent.outputCommands )
67 
68  keepMC = cms.untracked.vstring("keep *_*_zMusExtracted_*",
69  "keep *_*_zmmCands_*",
70  "keep *_removedInputMuons_*_*",
71  "keep *_generator_*_*",
72  "keep *_PhotonIDProd_*_*",
73  "keep *_photons_*_*",
74  "keep *_photonCore_*_*",
75  "keep *_genParticles_*_*",
76  "keep *_particleFlow_*_*",
77  "keep *_generator_*_*",
78  "keep *_tmfTracks_*_EmbeddedRECO",
79  "keep *_offlinePrimaryVertices_*_EmbeddedRECO",
80  "keep *_offlinePrimaryVerticesWithBS_*_EmbeddedRECO",
81  "keep *_PhotonIDProd_*_*",
82  "keep *_photons_*_*",
83  "keep *_photonCore_*_*",
84  "keep *_genParticles_*_*",
85  "keep *_particleFlow_*_*",
86  )
87  outputModule.outputCommands.extend(keepMC)
88 
89  # getRid of second "drop *"
90  index = 0
91  for item in outputModule.outputCommands[:]:
92  if item == "drop *" and index != 0:
93  #print index," ",outputModule.outputCommands[index]
94  del outputModule.outputCommands[index]
95  index -= 1
96  index += 1
97 
98 
99  hltProcessName = "HLT" #"REDIGI38X"
100  RECOproc = "RECO"
101  # the following block can be used for more efficient processing by replacing the HLT variable below automatically
102  try:
103  hltProcessName = __HLT__
104  except:
105  pass
106 
107  try:
108  process.dimuonsHLTFilter.TriggerResultsTag.processName = hltProcessName
109  process.goodZToMuMuAtLeast1HLT.TrigTag.processName = hltProcessName
110  process.goodZToMuMuAtLeast1HLT.triggerEvent.processName = hltProcessName
111  process.hltTrigReport,HLTriggerResults.processName = hltProcessName
112  except:
113  pass
114 
115  process.VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator",
116  MaxZ = cms.double(0.0),
117  MaxX = cms.double(0.0),
118  MaxY = cms.double(0.0),
119  MinX = cms.double(0.0),
120  MinY = cms.double(0.0),
121  MinZ = cms.double(0.0),
122  TimeOffset = cms.double(0.0),
123  src = cms.InputTag("generator")
124  )
125 
126  import FWCore.ParameterSet.VarParsing as VarParsing
127  options = VarParsing.VarParsing ('analysis')
128  options.register ('mdtau',
129  0, # default value
130  VarParsing.VarParsing.multiplicity.singleton,
131  VarParsing.VarParsing.varType.int,
132  "mdtau value for tauola")
133 
134  options.register ('transformationMode',
135  1, #default value
136  VarParsing.VarParsing.multiplicity.singleton,
137  VarParsing.VarParsing.varType.int,
138  "transformation mode. 0=mumu->mumu, 1=mumu->tautau")
139 
140  options.register ('minVisibleTransverseMomentum',
141  "", #default value
142  VarParsing.VarParsing.multiplicity.singleton,
143  VarParsing.VarParsing.varType.string,
144  "generator level cut on visible transverse momentum (typeN:pT,[...];[...])")
145 
146  options.register ('useJson',
147  0, # default value, false
148  VarParsing.VarParsing.multiplicity.singleton,
149  VarParsing.VarParsing.varType.int,
150  "should I enable json usage?")
151 
152  options.register ('overrideBeamSpot',
153  0, # default value, false
154  VarParsing.VarParsing.multiplicity.singleton,
155  VarParsing.VarParsing.varType.int,
156  "should I override beamspot in globaltag?")
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 
219  process.tmfTracks = cms.EDProducer("RecoTracksMixer",
220  trackCol1 = cms.InputTag("removedInputMuons","tracks"),
221  trackCol2 = cms.InputTag("generalTracks","","EmbeddedRECO")
222  )
223 
224  process.offlinePrimaryVerticesWithBS.TrackLabel = cms.InputTag("tmfTracks")
225  process.offlinePrimaryVertices.TrackLabel = cms.InputTag("tmfTracks")
226 
227  if hasattr(process.muons, "TrackExtractorPSet"):
228  process.muons.TrackExtractorPSet.inputTrackCollection = cms.InputTag("tmfTracks")
229  elif hasattr(process, "muons1stStep") and hasattr(process.muons1stStep, "TrackExtractorPSet"):
230  process.muons1stStep.TrackExtractorPSet.inputTrackCollection = cms.InputTag("tmfTracks")
231  else:
232  raise "Problem with muons"
233  # it should be the best solution to take the original beam spot for the
234  # reconstruction of the new primary vertex
235  # use the one produced earlier, do not produce your own
236  for s in process.sequences:
237  seq = getattr(process,s)
238  seq.remove(process.offlineBeamSpot)
239 
240 
241  try:
242  process.metreco.remove(process.BeamHaloId)
243  except:
244  pass
245 
246  try:
247  outputModule = process.output
248  except:
249  pass
250  try:
251  outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
252  except:
253  pass
254 
255 
256  for p in process.paths:
257  pth = getattr(process,p)
258  if "generalTracks" in pth.moduleNames():
259  pth.replace(process.generalTracks, process.generalTracks*process.tmfTracks)
260 
261 
262  #'''
263  process.gsfElectronsORG = process.gsfElectrons.clone()
264  #print dir(process)
265  #for p in dir(process):
266 
267  for p in process.paths:
268  pth = getattr(process,p)
269  #if hasattr(pth,"gsfElectrons"):
270  if "gsfElectrons" in pth.moduleNames():
271  pth.replace(process.gsfElectrons, process.gsfElectronsORG*process.gsfElectrons)
272  #print p, dir(pth.moduleNames())
273 
274  # xxx
275  process.gsfElectrons = cms.EDProducer("GSFElectronsMixer",
276  col1 = cms.InputTag("gsfElectronsORG"),
277  col2 = cms.InputTag("gsfElectrons","", RECOproc )
278  )
279  #'''
280 
281 
282 
283  process.particleFlowORG = process.particleFlow.clone()
284 
285  # Since CMSSW 4_4 the particleFlow reco works a bit differently. The step is
286  # twofold, first particleFlowTmp is created and then the final particleFlow
287  # collection. What we do in this case is that we merge the final ParticleFlow
288  # collection. For the muon reconstruction, we also merge particleFlowTmp in
289  # order to get PF-based isolation right.
290  if hasattr(process, 'particleFlowTmp'):
291  process.particleFlowTmpMixed = cms.EDProducer('PFCandidateMixer',
292  col1 = cms.untracked.InputTag("removedInputMuons","pfCands"),
293  col2 = cms.untracked.InputTag("particleFlowTmp", ""),
294  trackCol = cms.untracked.InputTag("tmfTracks"),
295 
296  # Don't produce value maps:
297  muons = cms.untracked.InputTag(""),
298  gsfElectrons = cms.untracked.InputTag("")
299  )
300  process.muons.PFCandidates = cms.InputTag("particleFlowTmpMixed")
301 
302  for p in process.paths:
303  if "particleFlow" in pth.moduleNames():
304  pth.replace(process.particleFlow, process.particleFlowORG*process.particleFlow)
305  if "muons" in pth.moduleNames():
306  pth.replace(process.muons, process.particleFlowTmpMixed*process.muons)
307  else:
308  # CMSSW_4_2
309  if hasattr(process,"famosParticleFlowSequence"):
310  process.famosParticleFlowSequence.remove(process.pfPhotonTranslatorSequence)
311  process.famosParticleFlowSequence.remove(process.pfElectronTranslatorSequence)
312  process.famosParticleFlowSequence.remove(process.particleFlow)
313  process.famosParticleFlowSequence.__iadd__(process.particleFlowORG)
314  process.famosParticleFlowSequence.__iadd__(process.particleFlow)
315  process.famosParticleFlowSequence.__iadd__(process.pfElectronTranslatorSequence)
316  process.famosParticleFlowSequence.__iadd__(process.pfPhotonTranslatorSequence)
317  elif hasattr(process,"particleFlowReco"):
318  process.particleFlowReco.remove(process.pfPhotonTranslatorSequence)
319  process.particleFlowReco.remove(process.pfElectronTranslatorSequence)
320  process.particleFlowReco.remove(process.particleFlow)
321  process.particleFlowReco.__iadd__(process.particleFlowORG)
322  process.particleFlowReco.__iadd__(process.particleFlow)
323  process.particleFlowReco.__iadd__(process.pfElectronTranslatorSequence)
324  process.particleFlowReco.__iadd__(process.pfPhotonTranslatorSequence)
325  else :
326  raise "Cannot find particleFlow sequence"
327 
328  process.pfSelectedElectrons.src = cms.InputTag("particleFlowORG")
329  process.pfSelectedPhotons.src = cms.InputTag("particleFlowORG")
330 
331 
332  process.particleFlow = cms.EDProducer('PFCandidateMixer',
333  col1 = cms.untracked.InputTag("removedInputMuons","pfCands"),
334  col2 = cms.untracked.InputTag("particleFlowORG", ""),
335  trackCol = cms.untracked.InputTag("tmfTracks"),
336 
337  muons = cms.untracked.InputTag("muons"),
338  gsfElectrons = cms.untracked.InputTag("gsfElectrons")
339  # TODO: photons???
340  )
341 
342  process.filterEmptyEv.src = cms.untracked.InputTag("generator","","EmbeddedRECO")
343 
344  from FWCore.ParameterSet.Types import InputTag
345  for p in process.paths:
346  i = getattr(process,p)
347  target = process.particleFlow
348 
349  seqVis = SeqVisitor(target)
350  seqVis.prepareSearch()
351  seqVis.setLookFor(target)
352  i.visit(seqVis)
353  while ( seqVis.catch != 1 and seqVis.found == 1 ):
354 
355  target = seqVis.giveNext()
356 
357  targetAttributes = dir(target)
358  for targetAttribute in targetAttributes:
359  attr=getattr(target,targetAttribute) # get actual attribute, not just the name
360  if isinstance(attr, InputTag) and attr.getModuleLabel()=="particleFlow":
361  if ( attr.getProductInstanceLabel()!="" ):
362  print "Changing: ", target, " ", targetAttribute, " ", attr, " to particleFlowORG"
363  attr.setModuleLabel("particleFlowORG")
364 
365 
366  #i.replace(target, source)
367  seqVis.prepareSearch()
368  seqVis.setLookFor(target)
369  i.visit(seqVis)
370 
371  #if (seqVis.catch==1):
372  #seqVis.catch=0
373  #i.__iadd__(source)
374 
375 
376  if hasattr(process, "DQM_FEDIntegrity_v3"):
377  process.schedule.remove(process.DQM_FEDIntegrity_v3)
378 
379  skimEnabled = False
380  if hasattr(process,"doZmumuSkim"):
381  print "Enabling Zmumu skim"
382  skimEnabled = True
383 
384  cmssw_ver = os.environ["CMSSW_VERSION"]
385  if cmssw_ver.find("CMSSW_4_2") != -1:
386  print
387  print "Using legacy version of Zmumu skim. Note, that muon isolation is disabled"
388  print
389  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelectionLegacy_cff")
390  process.RandomNumberGeneratorService.dummy = cms.PSet(
391  initialSeed = cms.untracked.uint32(123456789),
392  engineName = cms.untracked.string('HepJamesRandom')
393  )
394 
395  else:
396  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelection_cff")
397 
398  #process.load("TauAnalysis/Skimming/goldenZmmSelectionVBTFrelPFIsolation_cfi")
399  process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
400 
401  # we are allready selecting events from generation step, so following way is ok
402  for path in process.paths:
403  getattr(process,path)._seq = process.goldenZmumuSelectionSequence * getattr(process,path)._seq
404 
405  #process.options = cms.untracked.PSet(
406  # wantSummary = cms.untracked.bool(True)
407  #)
408 
409 
410  if not skimEnabled:
411  print "Zmumu skim not enabled"
412 
413 
414  print "# ######################################################################################"
415  print " Following parameters can be added before customize function "
416  print " call in order to controll process customization: "
417  print " process.doNotParse = cms.PSet() # disables CL parsing for crab compat"
418  print " process.doZmumuSkim = cms.PSet() # adds Zmumu skimming before embedding is run"
419  print "# ######################################################################################"
420 
421  return(process)
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