CMS 3D CMS Logo

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

Functions

def customise
 

Function Documentation

def rh_customizeAll.customise (   process)

Definition at line 5 of file rh_customizeAll.py.

References list(), hitfit.return, and split.

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