CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
rh_customizeAll.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 import FWCore.ParameterSet.Config as cms
3 import os
4 
5 def customise(process):
6 
7  inputProcess="HLT" # some automagic check possible?
8 
9  process._Process__name="EmbeddedRECO"
10  process.TFileService = cms.Service("TFileService", fileName = cms.string("histo_embedded.root") )
11 
12  try:
13  outputModule = process.output
14  except:
15  pass
16  try:
17  outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
18  except:
19  pass
20 
21  print "Changing eventcontent to RAW+AODSIM + misc. "
22  outputModule.outputCommands = cms.untracked.vstring("drop *")
23  outputModule.outputCommands.extend(process.RAWEventContent.outputCommands )
24  outputModule.outputCommands.extend(process.AODSIMEventContent.outputCommands )
25 
26  keepMC = cms.untracked.vstring("keep *_*_zMusExtracted_*",
27  "keep *_*_zmmCands_*",
28  "keep *_removedInputMuons_*_*",
29  "keep *_generator_*_*",
30  "keep *_PhotonIDProd_*_*",
31  "keep *_photons_*_*",
32  "keep *_photonCore_*_*",
33  "keep *_genParticles_*_*",
34  "keep *_particleFlow_*_*",
35  "keep *_generator_*_*",
36  "keep *_tmfTracks_*_EmbeddedRECO",
37  "keep *_offlinePrimaryVertices_*_EmbeddedRECO",
38  "keep *_offlinePrimaryVerticesWithBS_*_EmbeddedRECO",
39  "keep *_PhotonIDProd_*_*",
40  "keep *_photons_*_*",
41  "keep *_photonCore_*_*",
42  "keep *_genParticles_*_*",
43  "keep *_particleFlow_*_*",
44  )
45  outputModule.outputCommands.extend(keepMC)
46 
47  # getRid of second "drop *"
48  index = 0
49  for item in outputModule.outputCommands[:]:
50  if item == "drop *" and index != 0:
51  #print index," ",outputModule.outputCommands[index]
52  del outputModule.outputCommands[index]
53  index -= 1
54  index += 1
55 
56 
57  hltProcessName = "HLT" #"REDIGI38X"
58  # the following block can be used for more efficient processing by replacing the HLT variable below automatically
59  try:
60  hltProcessName = __HLT__
61  except:
62  pass
63 
64  try:
65  process.dimuonsHLTFilter.TriggerResultsTag.processName = hltProcessName
66  process.goodZToMuMuAtLeast1HLT.TrigTag.processName = hltProcessName
67  process.goodZToMuMuAtLeast1HLT.triggerEvent.processName = hltProcessName
68  process.hltTrigReport,HLTriggerResults.processName = hltProcessName
69  except:
70  pass
71 
72  process.VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator",
73  MaxZ = cms.double(0.0),
74  MaxX = cms.double(0.0),
75  MaxY = cms.double(0.0),
76  MinX = cms.double(0.0),
77  MinY = cms.double(0.0),
78  MinZ = cms.double(0.0),
79  TimeOffset = cms.double(0.0),
80  src = cms.InputTag("generator")
81  )
82 
83  import FWCore.ParameterSet.VarParsing as VarParsing
84  options = VarParsing.VarParsing ('analysis')
85  options.register ('mdtau',
86  0, # default value
87  VarParsing.VarParsing.multiplicity.singleton,
88  VarParsing.VarParsing.varType.int,
89  "mdtau value for tauola")
90 
91  options.register ('transformationMode',
92  1, #default value
93  VarParsing.VarParsing.multiplicity.singleton,
94  VarParsing.VarParsing.varType.int,
95  "transformation mode. 0=mumu->mumu, 1=mumu->tautau")
96 
97  options.register ('minVisibleTransverseMomentum',
98  "", #default value
99  VarParsing.VarParsing.multiplicity.singleton,
100  VarParsing.VarParsing.varType.string,
101  "generator level cut on visible transverse momentum (typeN:pT,[...];[...])")
102 
103  options.register ('useJson',
104  0, # default value, false
105  VarParsing.VarParsing.multiplicity.singleton,
106  VarParsing.VarParsing.varType.int,
107  "should I enable json usage?")
108 
109  options.register ('overrideBeamSpot',
110  0, # default value, false
111  VarParsing.VarParsing.multiplicity.singleton,
112  VarParsing.VarParsing.varType.int,
113  "should I override beamspot in globaltag?")
114 
115 # options.register ('primaryProcess',
116 # 'RECO', # default value
117 # VarParsing.VarParsing.multiplicity.singleton,
118 # VarParsing.VarParsing.varType.string,
119 # "original processName")
120 
121 
122 
123  setFromCL = False
124  if not hasattr(process,"doNotParse"):
125  import sys
126  if hasattr(sys, "argv") == True:
127  if not sys.argv[0].endswith('cmsDriver.py'):
128  options.parseArguments()
129  setFromCL = True
130  else :
131  print "CL parsing disabled!"
132 
133 
134  if setFromCL:
135  print "Setting mdtau to ", options.mdtau
136  process.generator.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
137  process.newSource.ZTauTau.TauolaOptions.InputCards.mdtau = options.mdtau
138  process.generator.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
139  process.newSource.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = options.mdtau
140 
141  print "Setting minVisibleTransverseMomentum to ", options.minVisibleTransverseMomentum
142  process.newSource.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
143  process.generator.ZTauTau.minVisibleTransverseMomentum = cms.untracked.string(options.minVisibleTransverseMomentum)
144 
145  print "Setting transformationMode to ", options.transformationMode
146  process.generator.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
147  process.newSource.ZTauTau.transformationMode = cms.untracked.int32(options.transformationMode)
148 
149  if setFromCL and options.overrideBeamSpot != 0 :
150  print "options.overrideBeamSpot", options.overrideBeamSpot
151  # bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v26_offline") # 52x data PR gt
152  bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v21_offline") # 42x data PR gt
153  # bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v18_offline") # 41x data PR gt
154  # bs = cms.string("BeamSpotObjects_2009_LumiBased_v17_offline") # 38x data gt
155  #bs = cms.string("BeamSpotObjects_2009_v14_offline") # 36x data gt
156  # tag = cms.string("Early10TeVCollision_3p8cm_31X_v1_mc_START"), # 35 default
157  # tag = cms.string("Realistic900GeVCollisions_10cm_STARTUP_v1_mc"), # 36 default
158  process.GlobalTag.toGet = cms.VPSet(
159  cms.PSet(record = cms.string("BeamSpotObjectsRcd"),
160  tag = bs,
161  connect = cms.untracked.string("frontier://FrontierProd/CMS_COND_31X_BEAMSPOT")
162  )
163  )
164  print "BeamSpot in globaltag set to ", bs
165  else:
166  print "BeamSpot in globaltag not changed"
167 
168  if setFromCL and options.useJson != 0:
169  print "Enabling json usage"
170  import PhysicsTools.PythonAnalysis.LumiList as LumiList
171  import FWCore.ParameterSet.Types as CfgTypes
172  myLumis = LumiList.LumiList(filename = 'my.json').getCMSSWString().split(',')
173  process.source.lumisToProcess = CfgTypes.untracked(CfgTypes.VLuminosityBlockRange())
174  process.source.lumisToProcess.extend(myLumis)
175 
176 
177 
178 
179  process.generalTracksORG = process.generalTracks.clone()
180 
181  process.generalTracks = cms.EDProducer("RecoTracksMixer",
182  trackCol1 = cms.InputTag("generalTracksORG","","EmbeddedRECO"),
183  trackCol2 = cms.InputTag("removedInputMuons","tracks")
184  )
185 
186  for p in process.paths:
187  pth = getattr(process,p)
188  if "generalTracks" in pth.moduleNames():
189  pth.replace(process.generalTracks, process.generalTracksORG*process.generalTracks)
190 
191  # We can try mixing seeds or keep std::vector<Trajectory> from Zmumu event and
192  # try mixing it.
193  # note - later approach may have no sense. Different geometries...
194  process.trackerDrivenElectronSeedsORG = process.trackerDrivenElectronSeeds.clone()
195  process.trackerDrivenElectronSeedsORG.TkColList = cms.VInputTag(cms.InputTag("generalTracksORG"))
196 
197  process.trackerDrivenElectronSeeds = cms.EDProducer("ElectronSeedTrackRefUpdater",
198  PreIdLabel = process.trackerDrivenElectronSeedsORG.PreIdLabel,
199  PreGsfLabel = process.trackerDrivenElectronSeedsORG.PreGsfLabel,
200  targetTracks = cms.InputTag("generalTracks"),
201  inSeeds = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreGsfLabel.value()),
202  inPreId = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreIdLabel.value()),
203  )
204 
205  for p in process.paths:
206  pth = getattr(process,p)
207  if "trackerDrivenElectronSeeds" in pth.moduleNames():
208  pth.replace(process.trackerDrivenElectronSeeds, process.trackerDrivenElectronSeedsORG*process.trackerDrivenElectronSeeds)
209 
210 
211  # hack photonCore:
212  process.trackerDrivenElectronSeedsMerged = cms.EDProducer("ElectronSeedTrackRefUpdaterAndMerger",
213  PreIdLabel = process.trackerDrivenElectronSeedsORG.PreIdLabel,
214  PreGsfLabel = process.trackerDrivenElectronSeedsORG.PreGsfLabel,
215  targetTracks = cms.InputTag("generalTracks"),
216  inSeeds1 = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeeds.PreGsfLabel.value()),
217  inPreId1 = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeeds.PreIdLabel.value()),
218  inSeeds2 = cms.InputTag("trackerDrivenElectronSeeds", process.trackerDrivenElectronSeeds.PreGsfLabel.value()),
219  inPreId2 = cms.InputTag("trackerDrivenElectronSeeds", process.trackerDrivenElectronSeeds.PreIdLabel.value())
220  )
221 
222  process.electronMergedSeedsPhotonCoreHack = cms.EDProducer("ElectronSeedMerger",
223  EcalBasedSeeds = cms.InputTag("ecalDrivenElectronSeeds"),
224  TkBasedSeeds = cms.InputTag("trackerDrivenElectronSeedsMerged","SeedsForGsf")
225  )
226 
227  process.photonCore.pixelSeedProducer = cms.string('electronMergedSeedsPhotonCoreHack')
228 
229 
230  for p in process.paths:
231  pth = getattr(process,p)
232  if "photonCore" in pth.moduleNames():
233  pth.replace(process.photonCore,
234  process.trackerDrivenElectronSeedsMerged * process.electronMergedSeedsPhotonCoreHack *process.photonCore)
235 
236 
237 
238 
239  # mix gsfTracks
240  process.electronGsfTracksORG = process.electronGsfTracks.clone()
241  process.electronGsfTracks = cms.EDProducer("GsfTrackMixer",
242  col1 = cms.InputTag("electronGsfTracksORG","","EmbeddedRECO"),
243  col2= cms.InputTag("electronGsfTracks","", inputProcess),
244  )
245 
246  # TODO: in 42x conversions seem not be used anywhere during reco. What about ana?
247  # what about 52X?
248  process.gsfConversionTrackProducer.TrackProducer = cms.string('electronGsfTracksORG')
249 
250  for p in process.paths:
251  pth = getattr(process,p)
252  if "electronGsfTracks" in pth.moduleNames():
253  pth.replace(process.electronGsfTracks, process.electronGsfTracksORG*process.electronGsfTracks)
254 
255 
256 
257 
258 
259  '''
260  process.electronMergedSeedsORG = process.electronMergedSeeds.clone()
261  process.electronMergedSeeds = cms.EDProducer("ElectronSeedsMixer",
262  col1 = cms.InputTag("electronMergedSeeds","", inputProcess),
263  col2 = cms.InputTag("electronMergedSeedsORG","","EmbeddedRECO")
264  )
265  for p in process.paths:
266  pth = getattr(process,p)
267  if "electronMergedSeeds" in pth.moduleNames():
268  pth.replace(process.electronMergedSeeds, process.electronMergedSeedsORG*process.electronMergedSeeds)
269  '''
270 
271  process.generalConversionTrackProducer.TrackProducer = cms.string('generalTracksORG')
272 
273 
274  process.gsfElectronsORG = process.gsfElectrons.clone()
275  process.gsfElectrons = cms.EDProducer("GSFElectronsMixer",
276  col1 = cms.InputTag("gsfElectronsORG"),
277  col2 = cms.InputTag("gsfElectrons","",inputProcess),
278  )
279  for p in process.paths:
280  pth = getattr(process,p)
281  if "gsfElectrons" in pth.moduleNames():
282  pth.replace(process.gsfElectrons, process.gsfElectronsORG*process.gsfElectrons)
283 
284 
285 
286 
287  for p in process.paths:
288  pth = getattr(process,p)
289  #print dir(pth)
290  #sys.exit(0)
291  for mod in pth.moduleNames():
292  if mod.find("dedx") != -1:
293  print "Removing", mod
294  module=getattr(process,mod)
295  pth.remove(module)
296 
297 
298 
299  clConfig = cms.PSet (
300  depsPlus = cms.InputTag("anaDeposits", "plus" ),
301  depsMinus = cms.InputTag("anaDeposits", "minus" )
302  )
303 
304 
305 
306  process.castorrecoORG = process.castorreco.clone()
307  process.castorreco = cms.EDProducer("CastorRHMixer",
308  cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
309  cleaningConfig = clConfig,
310  todo = cms.VPSet(cms.PSet ( colZmumu = cms.InputTag("castorreco","", inputProcess ), colTauTau = cms.InputTag("castorrecoORG" ) ))
311  )
312 
313  for p in process.paths:
314  pth = getattr(process,p)
315  if "castorreco" in pth.moduleNames():
316  pth.replace(process.castorreco, process.castorrecoORG*process.castorreco)
317 
318  process.ecalRecHitORG = process.ecalRecHit.clone()
319  process.ecalRecHit = cms.EDProducer("EcalRHMixer",
320  cleaningAlgo = cms.string("CaloCleanerAllCrossed"), # CaloCleanerMVA
321  #cleaningAlgo = cms.string("CaloCleanerMVA"),
322  cleaningConfig = clConfig,
323  todo = cms.VPSet(
324  cms.PSet ( colZmumu = cms.InputTag("ecalRecHit","EcalRecHitsEB", inputProcess ),
325  colTauTau = cms.InputTag("ecalRecHitORG","EcalRecHitsEB" ) ),
326 
327  cms.PSet ( colZmumu = cms.InputTag("ecalRecHit","EcalRecHitsEE", inputProcess ),
328  colTauTau = cms.InputTag("ecalRecHitORG","EcalRecHitsEE" ) )
329  )
330  )
331  for p in process.paths:
332  pth = getattr(process,p)
333  if "ecalRecHit" in pth.moduleNames():
334  pth.replace(process.ecalRecHit, process.ecalRecHitORG*process.ecalRecHit)
335 
336 
337 
338  process.hbherecoORG = process.hbhereco.clone()
339  process.hbhereco = cms.EDProducer("HBHERHMixer",
340  cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
341  cleaningConfig = clConfig,
342  todo =
343  cms.VPSet(cms.PSet ( colZmumu = cms.InputTag( "hbhereco","", inputProcess ), colTauTau = cms.InputTag("hbherecoORG","" )))
344  )
345  for p in process.paths:
346  pth = getattr(process,p)
347  if "hbhereco" in pth.moduleNames():
348  pth.replace(process.hbhereco, process.hbherecoORG*process.hbhereco)
349 
350  # typedef CaloRecHitMixer< HFRecHit > HFRHMixer;
351  process.hfrecoORG = process.hfreco.clone()
352  process.hfreco = cms.EDProducer("HFRHMixer",
353  cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
354  cleaningConfig = clConfig,
355  todo =
356  cms.VPSet(cms.PSet ( colZmumu = cms.InputTag( "hfreco","", inputProcess ), colTauTau = cms.InputTag("hfrecoORG","" )))
357  )
358  for p in process.paths:
359  pth = getattr(process,p)
360  if "hfreco" in pth.moduleNames():
361  pth.replace(process.hfreco, process.hfrecoORG*process.hfreco)
362 
363 
364  # typedef CaloRecHitMixer< HORecHit > HORHMixer;
365  process.horecoORG = process.horeco.clone()
366  process.horeco = cms.EDProducer("HORHMixer",
367  cleaningAlgo = cms.string("CaloCleanerAllCrossed"),
368  cleaningConfig = clConfig,
369  todo =
370  cms.VPSet(cms.PSet ( colZmumu = cms.InputTag( "horeco","", inputProcess ), colTauTau = cms.InputTag("horecoORG","" )))
371  )
372  for p in process.paths:
373  pth = getattr(process,p)
374  if "horeco" in pth.moduleNames():
375  pth.replace(process.horeco, process.horecoORG*process.horeco)
376 
377 
378 
379 
380 
381 
382  # it should be the best solution to take the original beam spot for the
383  # reconstruction of the new primary vertex
384  # use the one produced earlier, do not produce your own
385  for s in process.sequences:
386  seq = getattr(process,s)
387  seq.remove(process.offlineBeamSpot)
388 
389 
390  try:
391  process.metreco.remove(process.BeamHaloId)
392  except:
393  pass
394 
395  try:
396  outputModule = process.output
397  except:
398  pass
399  try:
400  outputModule = getattr(process,str(getattr(process,list(process.endpaths)[-1])))
401  except:
402  pass
403 
404  process.filterEmptyEv.src = cms.untracked.InputTag("generator","","EmbeddedRECO")
405 
406 
407  try:
408  process.schedule.remove(process.DQM_FEDIntegrity_v3)
409  except:
410  pass
411 
412 
413  process.RECOSIMoutput.outputCommands.extend(['keep *_*_*_skimGoldenZmumu2'])
414 
415  # keep orginal collections, needed for PF2PAT - generalTracksORG, not sure for others
416  process.RECOSIMoutput.outputCommands.extend(['keep *_*ORG_*_*'])
417 
418  #xxx process.globalMuons.TrackerCollectionLabel = cms.InputTag("generalTracksORG")
419  #xxx process.globalSETMuons.TrackerCollectionLabel = cms.InputTag("generalTracksORG")
420  #print "TODO: add xcheck, that this is not changed"
421  #process.muons.inputCollectionLabels = cms.VInputTag(cms.InputTag("generalTracksORG"),
422  # cms.InputTag("globalMuons"),
423  # cms.InputTag("standAloneMuons","UpdatedAtVtx"))
424 
425 
426  skimEnabled = False
427  if hasattr(process,"doZmumuSkim"):
428  print "Enabling Zmumu skim"
429  skimEnabled = True
430  #process.load("TauAnalysis/Skimming/goldenZmmSelectionVBTFrelPFIsolation_cfi")
431 
432 
433  cmssw_ver = os.environ["CMSSW_VERSION"]
434  if cmssw_ver.find("CMSSW_4_2") != -1:
435  print
436  print "Using legacy version of Zmumu skim. Note, that muon isolation is disabled"
437  print
438  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelectionLegacy_cff")
439  else:
440  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandalonSelection_cff")
441  process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
442 
443  # we are allready selecting events from generation step, so following way is ok
444  for path in process.paths:
445  getattr(process,path)._seq = process.goldenZmumuSelectionSequence * getattr(process,path)._seq
446 
447  #process.options = cms.untracked.PSet(
448  # wantSummary = cms.untracked.bool(True)
449  #)
450 
451 
452 
453 
454  if not skimEnabled:
455  print "Zmumu skim not enabled"
456 
457 
458  print "# ######################################################################################"
459  print " Following parameters can be added before customize function "
460  print " call in order to controll process customization: "
461  print " process.doNotParse = cms.PSet() # disables CL parsing for crab compat"
462  print " process.doZmumuSkim = cms.PSet() # adds Zmumu skimming before embedding is run"
463  print "# ######################################################################################"
464 
465 
466  return(process)
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