CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
embeddingCustomizeAll.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 
3 import FWCore.ParameterSet.Config as cms
4 
5 from TauAnalysis.MCEmbeddingTools.rerunParticleFlow import rerunParticleFlow
6 
7 import os
8 
9 def customise(process):
10 
11  # Define configuration parameter default values
12  from TauAnalysis.MCEmbeddingTools.setDefaults import setDefaults
13  setDefaults(process)
14 
15  inputProcess = process.customization_options.inputProcessRECO.value()
16  print "Input process set to '%s'" % inputProcess
17 
18  process._Process__name = "EmbeddedRECO"
19 
20  # DQM store output for muon acceptance histograms
21  process.DQMStore = cms.Service("DQMStore")
22 
23  if process.customization_options.isMC.value():
24  print "Input is MC"
25 
26  # select generator level muons
27  process.genMuonsFromZs = cms.EDProducer("GenParticlesFromZsSelectorForMCEmbedding",
28  src = cms.InputTag("genParticles", "", process.customization_options.inputProcessSIM.value()),
29  pdgIdsMothers = cms.vint32(23, 22),
30  pdgIdsDaughters = cms.vint32(13),
31  maxDaughters = cms.int32(2),
32  minDaughters = cms.int32(2),
33  before_or_afterFSR = cms.string("afterFSR"),
34  verbosity = cms.int32(0)
35  )
36  process.ProductionFilterSequence.replace(process.cleanedGeneralTracks, process.genMuonsFromZs*process.cleanedGeneralTracks)
37  process.ProductionFilterSequence.replace(process.cleanedParticleFlow, process.genMuonsFromZs*process.cleanedParticleFlow)
38 
39  # produce generator level MET (= sum of neutrino momenta)
40  # in case Embedding is run on Monte Carlo input
41  process.genMetCalo = cms.EDProducer("MixedGenMEtProducer",
42  srcGenParticles1 = cms.InputTag("genParticles", "", process.customization_options.inputProcessSIM.value()),
43  srcGenParticles2 = cms.InputTag("genParticles"),
44  srcRemovedMuons = cms.InputTag(process.customization_options.ZmumuCollection.getModuleLabel()),
45  type = cms.string("calo"),
46  isMC = cms.bool(True)
47  )
48  process.genMetTrue = process.genMetCalo.clone(
49  type = cms.string("pf")
50  )
51  else:
52  print "Input is Data"
53 
54  # produce generator level MET (= sum of neutrino momenta)
55  # in case Embedding is run on real Data
56  process.genMetCalo = cms.EDProducer("MixedGenMEtProducer",
57  srcGenParticles1 = cms.InputTag(""),
58  srcGenParticles2 = cms.InputTag("genParticles"),
59  srcRemovedMuons = cms.InputTag(process.customization_options.ZmumuCollection.getModuleLabel()),
60  type = cms.string("calo"),
61  isMC = cms.bool(False)
62  )
63  process.genMetTrue = process.genMetCalo.clone(
64  type = cms.string("pf")
65  )
66  for p in process.paths:
67  pth = getattr(process, p)
68  if "genParticles" in pth.moduleNames():
69  pth.replace(process.genParticles, process.genParticles*process.genMetCalo*process.genMetTrue)
70 
71  # update InputTags defined in PFEmbeddingSource_cff.py
72  print "Setting collection of Z->mumu candidates to '%s'" % process.customization_options.ZmumuCollection.getModuleLabel()
73  if not (hasattr(process, "cleanedGeneralTracks") and hasattr(process, "cleanedParticleFlow")):
74  process.load("TauAnalysis.MCEmbeddingTools.PFEmbeddingSource_cff")
75  if process.customization_options.replaceGenOrRecMuonMomenta.value() == 'gen':
76  print "Taking momenta of generated tau leptons from generator level muons"
77  process.generator.src = cms.InputTag('genMuonsFromZs')
78  elif process.customization_options.replaceGenOrRecMuonMomenta.value() == 'rec':
79  print "Taking momenta of generated tau leptons from reconstructed muons"
80  process.generator.src = process.customization_options.ZmumuCollection
81  else:
82  raise ValueError("Invalid Configuration parameter 'replaceGenOrRecMuonMomenta' = %s !!" % process.customization_options.replaceGenOrRecMuonMomenta.value())
83  # update option for removing tracks/charged PFCandidates matched to reconstructed muon
84  process.cleanedGeneralTracks.selectedMuons = process.customization_options.ZmumuCollection
85  process.cleanedParticleFlow.selectedMuons = process.customization_options.ZmumuCollection
86  if process.customization_options.muonTrackCleaningMode.value() == 1:
87  process.cleanedGeneralTracks.removeDuplicates = cms.bool(False)
88  process.cleanedParticleFlow.removeDuplicates = cms.bool(False)
89  elif process.customization_options.muonTrackCleaningMode.value() == 2:
90  process.cleanedGeneralTracks.removeDuplicates = cms.bool(True)
91  process.cleanedParticleFlow.removeDuplicates = cms.bool(True)
92  else:
93  raise ValueError("Invalid Configuration parameter 'muonTrackCleaningMode' = %i !!" % process.customization_options.muonTrackCleaningMode.value())
94 
95  try:
96  outputModule = process.output
97  except:
98  pass
99  try:
100  outputModule = getattr(process, str(getattr(process, list(process.endpaths)[-1])))
101  except:
102  pass
103 
104  print "Changing event-content to AODSIM + Z->mumu candidates"
105  outputModule.outputCommands = cms.untracked.vstring("drop *")
106  outputModule.outputCommands.extend(process.AODSIMEventContent.outputCommands)
107 
108  # get rid of second "drop *"
109  index = 0
110  for item in outputModule.outputCommands[:]:
111  if item == "drop *" and index != 0:
112  del outputModule.outputCommands[index]
113  index -= 1
114  index += 1
115 
116  # keep collections of generator level muons
117  outputModule.outputCommands.extend([
118  'keep *_genMuonsFromZs_*_*'
119  ])
120 
121  # keep collections of reconstructed muons
122  outputModule.outputCommands.extend([
123  'keep *_goodMuons_*_*',
124  'keep *_goodMuonsPFIso_*_*',
125  'keep *_highestPtMuPlus_*_*',
126  'keep *_highestPtMuMinus_*_*',
127  'keep *_highestPtMuPlusPFIso_*_*',
128  'keep *_highestPtMuMinusPFIso_*_*'
129  ])
130 
131  # keep collections of reconstructed Z -> mumu candidates
132  # (with different muon isolation criteria applied)
133  outputModule.outputCommands.extend([
134  'keep *_goldenZmumuCandidatesGe0IsoMuons_*_*',
135  'keep *_goldenZmumuCandidatesGe1IsoMuons_*_*',
136  'keep *_goldenZmumuCandidatesGe2IsoMuons_*_*',
137  'keep TH2DMEtoEDM_MEtoEDMConverter_*_*'
138  ])
139 
140  # keep flag indicating whether event passes or fails
141  # o Z -> mumu event selection
142  # o muon -> muon + photon radiation filter
143  outputModule.outputCommands.extend([
144  'keep *_goldenZmumuFilterResult_*_*',
145  'keep *_genMuonRadiationFilter_*_*',
146  'keep *_muonRadiationFilter_*_*'
147  ])
148 
149  # CV: keep HepMCProduct for embedded event,
150  # in order to run Validation/EventGenerator/python/TauValidation_cfi.py
151  # for control plots of tau polarization and decay mode information
152  outputModule.outputCommands.extend([
153  'keep *HepMCProduct_generator_*_*'
154  ])
155 
156  # keep distance of muons traversed in ECAL and HCAL,
157  # expected and removed muon energy deposits
158  outputModule.outputCommands.extend([
159  'keep *_muonCaloEnergyDepositsByDistance_totalDistanceMuPlus_*',
160  'keep *_muonCaloEnergyDepositsByDistance_totalEnergyDepositMuPlus_*',
161  'keep *_muonCaloEnergyDepositsByDistance_totalDistanceMuMinus_*',
162  'keep *_muonCaloEnergyDepositsByDistance_totalEnergyDepositMuMinus_*',
163  'keep *_castorreco_removedEnergyMuMinus*_*',
164  'keep *_castorreco_removedEnergyMuPlus*_*',
165  'keep *_hfreco_removedEnergyMuMinus*_*',
166  'keep *_hfreco_removedEnergyMuPlus*_*',
167  'keep *_ecalPreshowerRecHit_removedEnergyMuMinus*_*',
168  'keep *_ecalPreshowerRecHit_removedEnergyMuPlus*_*',
169  'keep *_ecalRecHit_removedEnergyMuMinus*_*',
170  'keep *_ecalRecHit_removedEnergyMuPlus*_*',
171  'keep *_hbhereco_removedEnergyMuMinus*_*',
172  'keep *_hbhereco_removedEnergyMuPlus*_*',
173  'keep *_horeco_removedEnergyMuMinus*_*',
174  'keep *_horeco_removedEnergyMuPlus*_*',
175  ])
176 
177  # replace HLT process name
178  # (needed for certain reprocessed Monte Carlo samples)
179  hltProcessName = "HLT"
180  try:
181  hltProcessName = __HLT__
182  except:
183  pass
184  try:
185  process.dimuonsHLTFilter.TriggerResultsTag.processName = hltProcessName
186  process.goodZToMuMuAtLeast1HLT.TrigTag.processName = hltProcessName
187  process.goodZToMuMuAtLeast1HLT.triggerEvent.processName = hltProcessName
188  process.hltTrigReport,HLTriggerResults.processName = hltProcessName
189  except:
190  pass
191 
192  # disable L1GtTrigReport module
193  # (not used for anything yet, just prints error for every single event)
194  if hasattr(process, 'HLTAnalyzerEndpath'):
195  process.HLTAnalyzerEndpath.remove(process.hltL1GtTrigReport)
196 
197  # apply configuration parameters
198  print "Setting mdtau to %i" % process.customization_options.mdtau.value()
199  process.generator.Ztautau.TauolaOptions.InputCards.mdtau = process.customization_options.mdtau
200  if hasattr(process.generator, "ParticleGun"):
201  process.generator.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = process.customization_options.mdtau
202  if process.customization_options.useTauolaPolarization.value():
203  print "Enabling tau polarization effects in TAUOLA"
204  # NOTE: polarization effects are only approximate,
205  # because Embedded events do not have proper parton history in HepMC::GenEvent
206  # (cf. arXiv:hep-ph/0101311 and arXiv:1201.0117)
207  process.generator.Ztautau.TauolaOptions.UseTauolaPolarization = cms.bool(True)
208  else:
209  print "Disabling tau polarization effects in TAUOLA"
210  # NOTE: tau polarization effects need to be added by reweighting Embedded events
211  # using weights computed by TauSpinner package
212  process.generator.Ztautau.TauolaOptions.UseTauolaPolarization = cms.bool(False)
213 
214  print "Setting minVisibleTransverseMomentum to '%s'" % process.customization_options.minVisibleTransverseMomentum.value()
215  process.generator.Ztautau.minVisibleTransverseMomentum = process.customization_options.minVisibleTransverseMomentum
216 
217  print "Setting transformationMode to %i" % process.customization_options.transformationMode.value()
218  process.generator.Ztautau.transformationMode = process.customization_options.transformationMode
219 
220  print "Setting rfRotationAngle to %1.0f" % process.customization_options.rfRotationAngle.value()
221  process.generator.Ztautau.rfRotationAngle = process.customization_options.rfRotationAngle
222 
223  print "Setting rfMirror to %s" % process.customization_options.rfMirror.value()
224  process.generator.Ztautau.rfMirror = process.customization_options.rfMirror
225 
226  print "Setting muon radiation corrections to \"%s\"" % process.customization_options.applyMuonRadiationCorrection.value()
227  process.generator.Ztautau.applyMuonRadiationCorrection = process.customization_options.applyMuonRadiationCorrection
228 
229  if process.customization_options.overrideBeamSpot.value():
230  bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v28_offline")
231  process.GlobalTag.toGet = cms.VPSet(
232  cms.PSet(
233  record = cms.string("BeamSpotObjectsRcd"),
234  tag = bs,
235  connect = cms.untracked.string("frontier://FrontierProd/CMS_COND_31X_BEAMSPOT")
236  )
237  )
238  print "BeamSpot in globaltag set to '%s'" % bs
239  else:
240  print "BeamSpot in globaltag not changed"
241 
242  # CV: disable gen. vertex smearing
243  # (embed tau leptons exactly at Z->mumu event vertex)
244  print "Disabling gen. vertex smearing"
245  process.VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator",
246  MaxZ = cms.double(0.0),
247  MaxX = cms.double(0.0),
248  MaxY = cms.double(0.0),
249  MinX = cms.double(0.0),
250  MinY = cms.double(0.0),
251  MinZ = cms.double(0.0),
252  TimeOffset = cms.double(0.0),
253  src = cms.InputTag("generator","unsmeared")
254  )
255 
256  if process.customization_options.useJson.value():
257  print "Enabling event selection by JSON file"
258  import PhysicsTools.PythonAnalysis.LumiList as LumiList
259  import FWCore.ParameterSet.Types as CfgTypes
260  myLumis = LumiList.LumiList(filename = 'my.json').getCMSSWString().split(',')
261  process.source.lumisToProcess = CfgTypes.untracked(CfgTypes.VLuminosityBlockRange())
262  process.source.lumisToProcess.extend(myLumis)
263 
264  #----------------------------------------------------------------------------------------------------------------------
265  # CV: need to rerun particle-flow algorithm in order to create links between PFMuon -> PFBlocks -> PFClusters -> PFRecHits
266  # (configure particle-flow sequence before overwriting modules in order to mix collections
267  # of objects reconstructed and Z -> mu+ mu- event with simulated tau decay products)
268  if process.customization_options.embeddingMode.value() == "RH" and process.customization_options.cleaningMode == 'PF':
269  rerunParticleFlow(process, inputProcess)
270  process.ProductionFilterSequence += process.rerunParticleFlowSequenceForPFMuonCleaning
271  #----------------------------------------------------------------------------------------------------------------------
272 
273  # mix "general" Track collection
274  process.generalTracksORG = process.generalTracks.clone()
275  process.generalTracks = cms.EDProducer("TrackMixer",
276  todo = cms.VPSet(
277  cms.PSet(
278  collection1 = cms.InputTag("generalTracksORG", "", "EmbeddedRECO"),
279  collection2 = cms.InputTag("cleanedGeneralTracks")
280  )
281  ),
282  verbosity = cms.int32(0)
283  )
284 
285  for p in process.paths:
286  pth = getattr(process,p)
287  if "generalTracks" in pth.moduleNames():
288  pth.replace(process.generalTracks, process.generalTracksORG*process.generalTracks)
289 
290  #----------------------------------------------------------------------------------------------------------------------
291  # CV/TF: mixing of std::vector<Trajectory> from Zmumu event and embedded tau decay products does not work yet.
292  # For the time-being, we need to use the Trajectory objects from the embedded event
293  process.trackerDrivenElectronSeedsORG = process.trackerDrivenElectronSeeds.clone()
294  process.trackerDrivenElectronSeedsORG.TkColList = cms.VInputTag(
295  cms.InputTag("generalTracksORG")
296  )
297 
298  process.trackerDrivenElectronSeeds = cms.EDProducer("ElectronSeedTrackRefUpdater",
299  PreIdLabel = process.trackerDrivenElectronSeedsORG.PreIdLabel,
300  PreGsfLabel = process.trackerDrivenElectronSeedsORG.PreGsfLabel,
301  targetTracks = cms.InputTag("generalTracks"),
302  inSeeds = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreGsfLabel.value()),
303  inPreId = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreIdLabel.value()),
304  )
305 
306  for p in process.paths:
307  pth = getattr(process,p)
308  if "trackerDrivenElectronSeeds" in pth.moduleNames():
309  pth.replace(process.trackerDrivenElectronSeeds, process.trackerDrivenElectronSeedsORG*process.trackerDrivenElectronSeeds)
310 
311  # CV: need to keep 'generalTracksORG' collection in event-content,
312  # as (at least electron based) PFCandidates will refer to it,
313  # causing exception in 'pfNoPileUp' module otherwise
314  outputModule.outputCommands.extend(['keep recoTracks_generalTracksORG_*_*'])
315  #----------------------------------------------------------------------------------------------------------------------
316 
317  #----------------------------------------------------------------------------------------------------------------------
318  # mix collections of GSF electron tracks
319  process.electronGsfTracksORG = process.electronGsfTracks.clone()
320  process.electronGsfTracks = cms.EDProducer("GsfTrackMixer",
321  collection1 = cms.InputTag("electronGsfTracksORG", "", "EmbeddedRECO"),
322  collection2 = cms.InputTag("electronGsfTracks", "", inputProcess)
323  )
324 
325  process.gsfConversionTrackProducer.TrackProducer = cms.string('electronGsfTracksORG')
326 
327  for p in process.paths:
328  pth = getattr(process,p)
329  if "electronGsfTracks" in pth.moduleNames():
330  pth.replace(process.electronGsfTracks, process.electronGsfTracksORG*process.electronGsfTracks)
331 
332  process.generalConversionTrackProducer.TrackProducer = cms.string('generalTracksORG')
333  process.uncleanedOnlyGeneralConversionTrackProducer.TrackProducer = cms.string('generalTracksORG')
334 
335  process.gsfElectronsORG = process.gsfElectrons.clone()
336  process.gsfElectrons = cms.EDProducer("GSFElectronsMixer",
337  col1 = cms.InputTag("gsfElectronsORG"),
338  col2 = cms.InputTag("gsfElectrons", "", inputProcess)
339  )
340  for p in process.paths:
341  pth = getattr(process,p)
342  if "gsfElectrons" in pth.moduleNames():
343  pth.replace(process.gsfElectrons, process.gsfElectronsORG*process.gsfElectrons)
344  #----------------------------------------------------------------------------------------------------------------------
345 
346  # dE/dx information for mixed track collections not yet implemented in 'TracksMixer' module,
347  # disable usage of dE/dx information in all event reconstruction modules for now
348  for p in process.paths:
349  pth = getattr(process,p)
350  for mod in pth.moduleNames():
351  if mod.find("dedx") != -1 and mod.find("Zmumu") == -1:
352  if mod.find("ForPFMuonCleaning") == -1:
353  print "Removing %s" % mod
354  module = getattr(process, mod)
355  pth.remove(module)
356 
357  # CV: Compute expected energy deposits of muon in EB/EE, HB/HE and HO:
358  # (1) compute distance traversed by muons produced in Z -> mu+ mu- decay
359  # through individual calorimeter cells
360  # (2) scale distances by expected energy loss dE/dx of muon
361  from TrackingTools.TrackAssociator.default_cfi import TrackAssociatorParameterBlock
362  process.muonCaloDistances = cms.EDProducer('MuonCaloDistanceProducer',
363  trackAssociator = TrackAssociatorParameterBlock.TrackAssociatorParameters,
364  selectedMuons = process.customization_options.ZmumuCollection)
365  process.ProductionFilterSequence += process.muonCaloDistances
366 
367  # mix collections of L1Extra objects
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  srcVeto = cms.InputTag('')
383  dRveto = 0.
384  if inputType == "L1EmParticle":
385  pluginType = "L1ExtraEmParticleMixerPlugin"
386  srcSelectedMuons = process.customization_options.ZmumuCollection
387  dRveto = 0.3
388  elif inputType == "L1EtMissParticle":
389  pluginType = "L1ExtraMEtMixerPlugin"
390  elif inputType == "L1JetParticle":
391  pluginType = "L1ExtraJetParticleMixerPlugin"
392  srcSelectedMuons = process.customization_options.ZmumuCollection
393  dRveto = 0.3
394  elif inputType == "L1MuonParticle":
395  pluginType = "L1ExtraMuonParticleMixerPlugin"
396  srcSelectedMuons = process.customization_options.ZmumuCollection
397  dRveto = 0.8
398  else:
399  raise ValueError("Invalid L1Extra type = %s !!" % inputType)
400  instanceLabel = l1ExtraCollection[1]
401  l1extraParticleCollections.append(cms.PSet(
402  pluginType = cms.string(pluginType),
403  instanceLabel = cms.string(instanceLabel),
404  srcSelectedMuons2 = srcSelectedMuons,
405  dRveto2 = cms.double(dRveto)))
406  if inputType == 'L1EtMissParticle':
407  l1extraParticleCollections[-1].srcMuons = cms.InputTag("muonCaloDistances", "muons")
408  l1extraParticleCollections[-1].distanceMapMuPlus = cms.InputTag("muonCaloDistances", "distancesMuPlus")
409  l1extraParticleCollections[-1].distanceMapMuMinus = cms.InputTag("muonCaloDistances", "distancesMuPlus")
410  l1extraParticleCollections[-1].H_Calo_AbsEtaLt12 = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.75)
411  l1extraParticleCollections[-1].H_Calo_AbsEta12to17 = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.6)
412  l1extraParticleCollections[-1].H_Calo_AbsEtaGt17 = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.3)
413 
414  process.l1extraParticlesORG = process.l1extraParticles.clone()
415  process.l1extraParticles = cms.EDProducer('L1ExtraMixer',
416  src1 = cms.InputTag("l1extraParticlesORG"),
417  src2 = cms.InputTag("l1extraParticles", "", inputProcess),
418  collections = cms.VPSet(l1extraParticleCollections)
419  )
420  for p in process.paths:
421  pth = getattr(process,p)
422  if "l1extraParticles" in pth.moduleNames():
423  pth.replace(process.l1extraParticles, process.l1extraParticlesORG*process.l1extraParticles)
424 
425  if process.customization_options.embeddingMode.value() == "PF":
426  print "Using PF-embedding"
427  from TauAnalysis.MCEmbeddingTools.embeddingCustomizePF import customise as customisePF
428  customisePF(process, inputProcess)
429  elif process.customization_options.embeddingMode.value() == "RH":
430  print "Using RH-embedding"
431  from TauAnalysis.MCEmbeddingTools.embeddingCustomizeRH import customise as customiseRH
432  customiseRH(process, inputProcess)
433  else:
434  raise ValueError("Invalid Configuration parameter 'embeddingMode' = %s !!" % process.customization_options.embeddingMode.value())
435 
436  # it should be the best solution to take the original beam spot for the
437  # reconstruction of the new primary vertex
438  # use the one produced earlier, do not produce your own
439  for s in process.sequences:
440  seq = getattr(process,s)
441  seq.remove(process.offlineBeamSpot)
442 
443  try:
444  process.metreco.remove(process.BeamHaloId)
445  except:
446  pass
447 
448  try:
449  outputModule = process.output
450  except:
451  pass
452  try:
453  outputModule = getattr(process, str(getattr(process, list(process.endpaths)[-1])))
454  except:
455  pass
456 
457  process.filterEmptyEv.src = cms.untracked.InputTag("generatorSmeared", "", "EmbeddedRECO")
458 
459  try:
460  process.schedule.remove(process.DQM_FEDIntegrity_v3)
461  except:
462  pass
463 
464  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandaloneSelection_cff")
465  process.goldenZmumuFilter.src = process.customization_options.ZmumuCollection
466  if process.customization_options.applyZmumuSkim.value():
467  print "Enabling Zmumu skim"
468  process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
469  for path in process.paths:
470  if process.customization_options.isMC.value():
471  getattr(process,path)._seq = process.goldenZmumuFilterSequence * getattr(process,path)._seq
472  else:
473  getattr(process,path)._seq = process.goldenZmumuFilterSequenceData * getattr(process,path)._seq
474  process.options = cms.untracked.PSet(
475  wantSummary = cms.untracked.bool(True)
476  )
477  # CV: keep track of Z->mumu selection efficiency
478  process.goldenZmumuFilterResult = cms.EDProducer("CandViewCountEventSelFlagProducer",
479  src = process.customization_options.ZmumuCollection,
480  minNumber = cms.uint32(1)
481  )
482  process.goldenZmumuFilterEfficiencyPath = cms.Path(process.goldenZmumuSelectionSequence + process.goldenZmumuFilterResult + process.MEtoEDMConverter)
483  process.schedule.append(process.goldenZmumuFilterEfficiencyPath)
484  else:
485  print "Zmumu skim disabled"
486 
487  # CV: keep track of which events pass/fail muon -> muon + photon radiation filters
488  # on generator and reconstruction level, but do not actually reject any events
489  if process.customization_options.isMC.value():
490  process.load("TauAnalysis/MCEmbeddingTools/genMuonRadiationFilter_cfi")
491  process.genMuonRadiationFilter.srcGenParticles = cms.InputTag('genParticles::%s' % process.customization_options.inputProcessSIM.value())
492  process.genMuonRadiationFilter.invert = cms.bool(False)
493  process.genMuonRadiationFilter.filter = cms.bool(False)
494  process.reconstruction_step += process.genMuonRadiationFilter
495  # CV: keep track of which events pass/fail muon -> muon + photon radiation filter,
496  # but do not actually reject any events
497  process.load("TauAnalysis/MCEmbeddingTools/muonRadiationFilter_cfi")
498  process.particleFlowPtrsForMuonRadiationFilter.src = cms.InputTag('particleFlow', '', inputProcess)
499  process.muonRadiationFilter.srcSelectedMuons = process.customization_options.ZmumuCollection
500  process.muonRadiationFilter.invert = cms.bool(False)
501  process.muonRadiationFilter.filter = cms.bool(False)
502  process.reconstruction_step += process.muonRadiationFilterSequence
503 
504  # CV: disable ECAL/HCAL noise simulation
505  if process.customization_options.disableCaloNoise.value():
506  print "Disabling ECAL/HCAL noise simulation"
507  process.simEcalUnsuppressedDigis.doNoise = cms.bool(False)
508  process.simEcalUnsuppressedDigis.doESNoise = cms.bool(False)
509  process.simHcalUnsuppressedDigis.doNoise = cms.bool(False)
510  process.simHcalUnsuppressedDigis.doThermalNoise = cms.bool(False)
511  else:
512  print "Keeping ECAL/HCAL noise simulation enabled"
513 
514  # AB: The following producers are currently commented out. These mostly produce correction
515  # factors from input .root files. Such binary files are not desirable to have in a CMSSW
516  # release, so they are not included at the moment. A possible solution is to store and look
517  # up the correction factors via the Frontier DB.
518  """
519  # CV: apply/do not apply muon momentum corrections determined by Rochester group
520  if process.customization_options.replaceGenOrRecMuonMomenta.value() == "rec" and hasattr(process, "goldenZmumuSelectionSequence"):
521  if process.customization_options.applyRochesterMuonCorr.value():
522  print "Enabling Rochester muon momentum corrections"
523  process.patMuonsForZmumuSelectionRochesterMomentumCorr = cms.EDProducer("RochesterCorrPATMuonProducer",
524  src = cms.InputTag('patMuonsForZmumuSelection'),
525  isMC = cms.bool(process.customization_options.isMC.value())
526  )
527  process.goldenZmumuSelectionSequence.replace(process.patMuonsForZmumuSelection, process.patMuonsForZmumuSelection*process.patMuonsForZmumuSelectionRochesterMomentumCorr)
528  process.goodMuons.src = cms.InputTag('patMuonsForZmumuSelectionRochesterMomentumCorr')
529  else:
530  print "Rochester muon momentum corrections disabled"
531 
532  if process.customization_options.applyMuonRadiationCorrection.value() != "":
533  print "Muon -> muon + photon radiation correction enabled"
534  process.load("TauAnalysis/MCEmbeddingTools/muonRadiationCorrWeightProducer_cfi")
535  if process.customization_options.applyMuonRadiationCorrection.value() == "photos":
536  process.muonRadiationCorrWeightProducer.lutDirectoryRef = cms.string('genMuonRadCorrAnalyzerPHOTOS')
537  process.muonRadiationCorrWeightProducer.lutDirectoryOthers = cms.PSet(
538  Summer12mcMadgraph = cms.string('genMuonRadCorrAnalyzer')
539  )
540  elif process.customization_options.applyMuonRadiationCorrection.value() == "pythia":
541  process.muonRadiationCorrWeightProducer.lutDirectoryRef = cms.string('genMuonRadCorrAnalyzerPYTHIA')
542  process.muonRadiationCorrWeightProducer.lutDirectoryOthers = cms.PSet(
543  Summer12mcMadgraph = cms.string('genMuonRadCorrAnalyzer')
544  )
545  else:
546  raise ValueError("Invalid Configuration parameter 'applyMuonRadiationCorrection' = %s !!" % process.customization_options.applyMuonRadiationCorrection.value())
547  process.reconstruction_step += process.muonRadiationCorrWeightProducer
548  outputModule.outputCommands.extend([
549  'keep *_muonRadiationCorrWeightProducer_*_*',
550  'keep *_generator_muonsBeforeRad_*',
551  'keep *_generator_muonsAfterRad_*'
552  ])
553  else:
554  print "Muon -> muon + photon radiation correction disabled"
555 
556  # CV: compute reweighting factors to compensate for smearing of di-muon Pt and mass distributions caused by:
557  # o (mis)reconstruction of muon momenta
558  # o muon -> muon + photon radiation corrections
559  #
560  # mdtau values are defined in http:marpix1.in2p3.fr/Physics/biblio_top/mc_toprex_405.ps.gz
561  #
562  embeddingKineReweightTable = {
563  (115, 'elec1_9to30had1_15'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePt9to30tauPtGt18_genEmbedded.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePt9to30tauPtGt18_recEmbedded.root'),
564  (115, 'elec1_20had1_18'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePtGt20tauPtGt18_genEmbedded.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePtGt20tauPtGt18_recEmbedded.root'),
565  (116, 'mu1_7to25had1_15'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPt7to25tauPtGt18_genEmbedded.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPt7to25tauPtGt18_recEmbedded.root'),
566  (116, 'mu1_16had1_18'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPtGt16tauPtGt18_genEmbedded.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPtGt16tauPtGt18_recEmbedded.root'),
567  (121, 'elec1_17elec2_8'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_emu_genEmbedding.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_emu_recEmbedding.root'),
568  (122, 'mu1_18mu2_8'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_emu_genEmbedding.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_emu_recEmbedding.root'),
569  (123, 'tau1_18tau2_8'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_emu_genEmbedding.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_emu_recEmbedding.root'),
570  (132, 'had1_30had2_30'): ('TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_tautau_genEmbedding.root', 'TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_tautau_recEmbedding.root')
571  }
572 
573  key = (process.customization_options.mdtau.value(), process.customization_options.minVisibleTransverseMomentum.value())
574  if key in embeddingKineReweightTable:
575  process.load("TauAnalysis/MCEmbeddingTools/embeddingKineReweight_cff")
576 
577  genEmbeddingReweightFile, recEmbeddingReweightFile = embeddingKineReweightTable[key]
578  process.embeddingKineReweightGENembedding.inputFileName = cms.FileInPath(genEmbeddingReweightFile)
579  process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath(recEmbeddingReweightFile)
580 
581  process.reconstruction_step += process.embeddingKineReweightSequence
582  outputModule.outputCommands.extend([
583  'keep *_embeddingKineReweight*_*_*'
584  ])
585  else:
586  print 'Do not produce embeddingKineWeights for mdtau=%d, minVisibleTransverseMomuntem=%s !!' % (key[0], key[1])
587 
588  # CV: compute weights for correcting Embedded samples
589  # for efficiency with which Zmumu events used as input for Embedding production were selected
590  process.load("TauAnalysis/MCEmbeddingTools/ZmumuEvtSelEffCorrWeightProducer_cfi")
591  process.ZmumuEvtSelEffCorrWeightProducer.selectedMuons = process.customization_options.ZmumuCollection
592  process.ZmumuEvtSelEffCorrWeightProducer.verbosity = cms.int32(0)
593  process.reconstruction_step += process.ZmumuEvtSelEffCorrWeightProducer
594  outputModule.outputCommands.extend([
595  'keep *_ZmumuEvtSelEffCorrWeightProducer_*_*'
596  ])
597  """
598 
599  # TauSpinner
600 # process.RandomNumberGeneratorService.TauSpinnerReco = cms.PSet(
601 # initialSeed = cms.untracked.uint32(123456789),
602 # engineName = cms.untracked.string('HepJamesRandom')
603 # )
604 
605 # process.load('GeneratorInterface.ExternalDecays.TauSpinner_cfi')
606 # #process.TauSpinnerReco.isTauolaConfigured = cms.bool(True)
607 # process.reconstruction_step += process.TauSpinnerReco
608 # outputModule.outputCommands.extend([
609 # 'keep *_TauSpinnerReco_*_*'
610 # ])
611 
612  return(process)
return(e1-e2)*(e1-e2)+dp *dp
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