CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
embeddingCustomizeAll_Old.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 *_muonRadiationFilterResult_*_*'
146  ])
147 
148  # CV: keep HepMCProduct for embedded event,
149  # in order to run Validation/EventGenerator/python/TauValidation_cfi.py
150  # for control plots of tau polarization and decay mode information
151  outputModule.outputCommands.extend([
152  'keep *HepMCProduct_generator_*_*'
153  ])
154 
155  # keep distance of muons traversed in ECAL and HCAL,
156  # expected and removed muon energy deposits
157  outputModule.outputCommands.extend([
158  'keep *_muonCaloEnergyDepositsByDistance_totalDistanceMuPlus_*',
159  'keep *_muonCaloEnergyDepositsByDistance_totalEnergyDepositMuPlus_*',
160  'keep *_muonCaloEnergyDepositsByDistance_totalDistanceMuMinus_*',
161  'keep *_muonCaloEnergyDepositsByDistance_totalEnergyDepositMuMinus_*',
162  'keep *_castorreco_removedEnergyMuMinus*_*',
163  'keep *_castorreco_removedEnergyMuPlus*_*',
164  'keep *_hfreco_removedEnergyMuMinus*_*',
165  'keep *_hfreco_removedEnergyMuPlus*_*',
166  'keep *_ecalPreshowerRecHit_removedEnergyMuMinus*_*',
167  'keep *_ecalPreshowerRecHit_removedEnergyMuPlus*_*',
168  'keep *_ecalRecHit_removedEnergyMuMinus*_*',
169  'keep *_ecalRecHit_removedEnergyMuPlus*_*',
170  'keep *_hbhereco_removedEnergyMuMinus*_*',
171  'keep *_hbhereco_removedEnergyMuPlus*_*',
172  'keep *_horeco_removedEnergyMuMinus*_*',
173  'keep *_horeco_removedEnergyMuPlus*_*',
174  ])
175 
176  # replace HLT process name
177  # (needed for certain reprocessed Monte Carlo samples)
178  hltProcessName = "HLT"
179  try:
180  hltProcessName = __HLT__
181  except:
182  pass
183  try:
184  process.dimuonsHLTFilter.TriggerResultsTag.processName = hltProcessName
185  process.goodZToMuMuAtLeast1HLT.TrigTag.processName = hltProcessName
186  process.goodZToMuMuAtLeast1HLT.triggerEvent.processName = hltProcessName
187  process.hltTrigReport,HLTriggerResults.processName = hltProcessName
188  except:
189  pass
190 
191  # disable L1GtTrigReport module
192  # (not used for anything yet, just prints error for every single event)
193  if hasattr(process, 'HLTAnalyzerEndpath'):
194  process.HLTAnalyzerEndpath.remove(process.hltL1GtTrigReport)
195 
196  # apply configuration parameters
197  print "Setting mdtau to %i" % process.customization_options.mdtau.value()
198  process.generator.Ztautau.TauolaOptions.InputCards.mdtau = process.customization_options.mdtau
199  if hasattr(process.generator, "ParticleGun"):
200  process.generator.ParticleGun.ExternalDecays.Tauola.InputCards.mdtau = process.customization_options.mdtau
201  if process.customization_options.useTauolaPolarization.value():
202  print "Enabling tau polarization effects in TAUOLA"
203  # NOTE: polarization effects are only approximate,
204  # because Embedded events do not have proper parton history in HepMC::GenEvent
205  # (cf. arXiv:hep-ph/0101311 and arXiv:1201.0117)
206  process.generator.Ztautau.TauolaOptions.UseTauolaPolarization = cms.bool(True)
207  else:
208  print "Disabling tau polarization effects in TAUOLA"
209  # NOTE: tau polarization effects need to be added by reweighting Embedded events
210  # using weights computed by TauSpinner package
211  process.generator.Ztautau.TauolaOptions.UseTauolaPolarization = cms.bool(False)
212 
213  print "Setting minVisibleTransverseMomentum to '%s'" % process.customization_options.minVisibleTransverseMomentum.value()
214  process.generator.Ztautau.minVisibleTransverseMomentum = process.customization_options.minVisibleTransverseMomentum
215 
216  print "Setting transformationMode to %i" % process.customization_options.transformationMode.value()
217  process.generator.Ztautau.transformationMode = process.customization_options.transformationMode
218 
219  print "Setting rfRotationAngle to %1.0f" % process.customization_options.rfRotationAngle.value()
220  process.generator.Ztautau.rfRotationAngle = process.customization_options.rfRotationAngle
221 
222  if process.customization_options.overrideBeamSpot.value():
223  bs = cms.string("BeamSpotObjects_2009_LumiBased_SigmaZ_v28_offline")
224  process.GlobalTag.toGet = cms.VPSet(
225  cms.PSet(
226  record = cms.string("BeamSpotObjectsRcd"),
227  tag = bs,
228  connect = cms.untracked.string("frontier://FrontierProd/CMS_COND_31X_BEAMSPOT")
229  )
230  )
231  print "BeamSpot in globaltag set to '%s'" % bs
232  else:
233  print "BeamSpot in globaltag not changed"
234 
235  # CV: disable gen. vertex smearing
236  # (embed tau leptons exactly at Z->mumu event vertex)
237  print "Disabling gen. vertex smearing"
238  process.VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator",
239  MaxZ = cms.double(0.0),
240  MaxX = cms.double(0.0),
241  MaxY = cms.double(0.0),
242  MinX = cms.double(0.0),
243  MinY = cms.double(0.0),
244  MinZ = cms.double(0.0),
245  TimeOffset = cms.double(0.0),
246  src = cms.InputTag("generator")
247  )
248 
249  if process.customization_options.useJson.value():
250  print "Enabling event selection by JSON file"
251  import PhysicsTools.PythonAnalysis.LumiList as LumiList
252  import FWCore.ParameterSet.Types as CfgTypes
253  myLumis = LumiList.LumiList(filename = 'my.json').getCMSSWString().split(',')
254  process.source.lumisToProcess = CfgTypes.untracked(CfgTypes.VLuminosityBlockRange())
255  process.source.lumisToProcess.extend(myLumis)
256 
257  #----------------------------------------------------------------------------------------------------------------------
258  # CV: need to rerun particle-flow algorithm in order to create links between PFMuon -> PFBlocks -> PFClusters -> PFRecHits
259  # (configure particle-flow sequence before overwriting modules in order to mix collections
260  # of objects reconstructed and Z -> mu+ mu- event with simulated tau decay products)
261  if process.customization_options.embeddingMode.value() == "RH" and process.customization_options.cleaningMode == 'PF':
262  rerunParticleFlow(process, inputProcess)
263  process.ProductionFilterSequence += process.rerunParticleFlowSequenceForPFMuonCleaning
264  #----------------------------------------------------------------------------------------------------------------------
265 
266  # mix "general" Track collection
267  process.generalTracksORG = process.generalTracks.clone()
268  process.generalTracks = cms.EDProducer("TrackMixer",
269  todo = cms.VPSet(
270  cms.PSet(
271  collection1 = cms.InputTag("generalTracksORG", "", "EmbeddedRECO"),
272  collection2 = cms.InputTag("cleanedGeneralTracks")
273  )
274  ),
275  verbosity = cms.int32(0)
276  )
277 
278  for p in process.paths:
279  pth = getattr(process,p)
280  if "generalTracks" in pth.moduleNames():
281  pth.replace(process.generalTracks, process.generalTracksORG*process.generalTracks)
282 
283  #----------------------------------------------------------------------------------------------------------------------
284  # CV/TF: mixing of std::vector<Trajectory> from Zmumu event and embedded tau decay products does not work yet.
285  # For the time-being, we need to use the Trajectory objects from the embedded event
286  process.trackerDrivenElectronSeedsORG = process.trackerDrivenElectronSeeds.clone()
287  process.trackerDrivenElectronSeedsORG.TkColList = cms.VInputTag(
288  cms.InputTag("generalTracksORG")
289  )
290 
291  process.trackerDrivenElectronSeeds = cms.EDProducer("ElectronSeedTrackRefUpdater",
292  PreIdLabel = process.trackerDrivenElectronSeedsORG.PreIdLabel,
293  PreGsfLabel = process.trackerDrivenElectronSeedsORG.PreGsfLabel,
294  targetTracks = cms.InputTag("generalTracks"),
295  inSeeds = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreGsfLabel.value()),
296  inPreId = cms.InputTag("trackerDrivenElectronSeedsORG", process.trackerDrivenElectronSeedsORG.PreIdLabel.value()),
297  )
298 
299  for p in process.paths:
300  pth = getattr(process,p)
301  if "trackerDrivenElectronSeeds" in pth.moduleNames():
302  pth.replace(process.trackerDrivenElectronSeeds, process.trackerDrivenElectronSeedsORG*process.trackerDrivenElectronSeeds)
303 
304  # CV: need to keep 'generalTracksORG' collection in event-content,
305  # as (at least electron based) PFCandidates will refer to it,
306  # causing exception in 'pfNoPileUp' module otherwise
307  outputModule.outputCommands.extend(['keep recoTracks_generalTracksORG_*_*'])
308  #----------------------------------------------------------------------------------------------------------------------
309 
310  #----------------------------------------------------------------------------------------------------------------------
311  # mix collections of GSF electron tracks
312  process.electronGsfTracksORG = process.electronGsfTracks.clone()
313  process.electronGsfTracks = cms.EDProducer("GsfTrackMixer",
314  collection1 = cms.InputTag("electronGsfTracksORG", "", "EmbeddedRECO"),
315  collection2 = cms.InputTag("electronGsfTracks", "", inputProcess)
316  )
317 
318  process.gsfConversionTrackProducer.TrackProducer = cms.string('electronGsfTracksORG')
319 
320  for p in process.paths:
321  pth = getattr(process,p)
322  if "electronGsfTracks" in pth.moduleNames():
323  pth.replace(process.electronGsfTracks, process.electronGsfTracksORG*process.electronGsfTracks)
324 
325  process.generalConversionTrackProducer.TrackProducer = cms.string('generalTracksORG')
326  process.uncleanedOnlyGeneralConversionTrackProducer.TrackProducer = cms.string('generalTracksORG')
327 
328  process.gsfElectronsORG = process.gsfElectrons.clone()
329  process.gsfElectrons = cms.EDProducer("GSFElectronsMixer",
330  col1 = cms.InputTag("gsfElectronsORG"),
331  col2 = cms.InputTag("gsfElectrons", "", inputProcess)
332  )
333  for p in process.paths:
334  pth = getattr(process,p)
335  if "gsfElectrons" in pth.moduleNames():
336  pth.replace(process.gsfElectrons, process.gsfElectronsORG*process.gsfElectrons)
337  #----------------------------------------------------------------------------------------------------------------------
338 
339  # dE/dx information for mixed track collections not yet implemented in 'TracksMixer' module,
340  # disable usage of dE/dx information in all event reconstruction modules for now
341  for p in process.paths:
342  pth = getattr(process,p)
343  for mod in pth.moduleNames():
344  if mod.find("dedx") != -1 and mod.find("Zmumu") == -1:
345  if mod.find("ForPFMuonCleaning") == -1:
346  print "Removing %s" % mod
347  module = getattr(process, mod)
348  pth.remove(module)
349 
350  # CV: Compute expected energy deposits of muon in EB/EE, HB/HE and HO:
351  # (1) compute distance traversed by muons produced in Z -> mu+ mu- decay
352  # through individual calorimeter cells
353  # (2) scale distances by expected energy loss dE/dx of muon
354  from TrackingTools.TrackAssociator.default_cfi import TrackAssociatorParameterBlock
355  process.muonCaloDistances = cms.EDProducer('MuonCaloDistanceProducer',
356  trackAssociator = TrackAssociatorParameterBlock.TrackAssociatorParameters,
357  selectedMuons = process.customization_options.ZmumuCollection)
358  process.ProductionFilterSequence += process.muonCaloDistances
359 
360  # mix collections of L1Extra objects
361  l1ExtraCollections = [
362  [ "L1EmParticle", "Isolated" ],
363  [ "L1EmParticle", "NonIsolated" ],
364  [ "L1EtMissParticle", "MET" ],
365  [ "L1EtMissParticle", "MHT" ],
366  [ "L1JetParticle", "Central" ],
367  [ "L1JetParticle", "Forward" ],
368  [ "L1JetParticle", "Tau" ],
369  [ "L1MuonParticle", "" ]
370  ]
371  l1extraParticleCollections = []
372  for l1ExtraCollection in l1ExtraCollections:
373  inputType = l1ExtraCollection[0]
374  pluginType = None
375  srcVeto = cms.InputTag('')
376  dRveto = 0.
377  if inputType == "L1EmParticle":
378  pluginType = "L1ExtraEmParticleMixerPlugin"
379  srcSelectedMuons = process.customization_options.ZmumuCollection
380  dRveto = 0.3
381  elif inputType == "L1EtMissParticle":
382  pluginType = "L1ExtraMEtMixerPlugin"
383  elif inputType == "L1JetParticle":
384  pluginType = "L1ExtraJetParticleMixerPlugin"
385  srcSelectedMuons = process.customization_options.ZmumuCollection
386  dRveto = 0.3
387  elif inputType == "L1MuonParticle":
388  pluginType = "L1ExtraMuonParticleMixerPlugin"
389  srcSelectedMuons = process.customization_options.ZmumuCollection
390  dRveto = 0.8
391  else:
392  raise ValueError("Invalid L1Extra type = %s !!" % inputType)
393  instanceLabel = l1ExtraCollection[1]
394  l1extraParticleCollections.append(cms.PSet(
395  pluginType = cms.string(pluginType),
396  instanceLabel = cms.string(instanceLabel),
397  srcSelectedMuons2 = srcSelectedMuons,
398  dRveto2 = cms.double(dRveto)))
399  if inputType == 'L1EtMissParticle':
400  l1extraParticleCollections[-1].srcMuons = cms.InputTag("muonCaloDistances", "muons")
401  l1extraParticleCollections[-1].distanceMapMuPlus = cms.InputTag("muonCaloDistances", "distancesMuPlus")
402  l1extraParticleCollections[-1].distanceMapMuMinus = cms.InputTag("muonCaloDistances", "distancesMuPlus")
403  l1extraParticleCollections[-1].H_Calo_AbsEtaLt12 = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.75)
404  l1extraParticleCollections[-1].H_Calo_AbsEta12to17 = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.6)
405  l1extraParticleCollections[-1].H_Calo_AbsEtaGt17 = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.3)
406 
407  process.l1extraParticlesORG = process.l1extraParticles.clone()
408  process.l1extraParticles = cms.EDProducer('L1ExtraMixer',
409  src1 = cms.InputTag("l1extraParticlesORG"),
410  src2 = cms.InputTag("l1extraParticles", "", inputProcess),
411  collections = cms.VPSet(l1extraParticleCollections)
412  )
413  for p in process.paths:
414  pth = getattr(process,p)
415  if "l1extraParticles" in pth.moduleNames():
416  pth.replace(process.l1extraParticles, process.l1extraParticlesORG*process.l1extraParticles)
417 
418  if process.customization_options.embeddingMode.value() == "PF":
419  print "Using PF-embedding"
420  from TauAnalysis.MCEmbeddingTools.embeddingCustomizePF import customise as customisePF
421  customisePF(process)
422  elif process.customization_options.embeddingMode.value() == "RH":
423  print "Using RH-embedding"
424  from TauAnalysis.MCEmbeddingTools.embeddingCustomizeRH import customise as customiseRH
425  customiseRH(process, inputProcess)
426  else:
427  raise ValueError("Invalid Configuration parameter 'embeddingMode' = %s !!" % process.customization_options.embeddingMode.value())
428 
429  # it should be the best solution to take the original beam spot for the
430  # reconstruction of the new primary vertex
431  # use the one produced earlier, do not produce your own
432  for s in process.sequences:
433  seq = getattr(process,s)
434  seq.remove(process.offlineBeamSpot)
435 
436  try:
437  process.metreco.remove(process.BeamHaloId)
438  except:
439  pass
440 
441  try:
442  outputModule = process.output
443  except:
444  pass
445  try:
446  outputModule = getattr(process, str(getattr(process, list(process.endpaths)[-1])))
447  except:
448  pass
449 
450  process.filterEmptyEv.src = cms.untracked.InputTag("generator", "", "EmbeddedRECO")
451 
452  try:
453  process.schedule.remove(process.DQM_FEDIntegrity_v3)
454  except:
455  pass
456 
457  process.load("TauAnalysis/MCEmbeddingTools/ZmumuStandaloneSelection_cff")
458  process.goldenZmumuFilter.src = process.customization_options.ZmumuCollection
459  if process.customization_options.applyZmumuSkim.value():
460  print "Enabling Zmumu skim"
461  process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
462  for path in process.paths:
463  if process.customization_options.isMC.value():
464  getattr(process,path)._seq = process.goldenZmumuFilterSequence * getattr(process,path)._seq
465  else:
466  getattr(process,path)._seq = process.goldenZmumuFilterSequenceData * getattr(process,path)._seq
467  process.options = cms.untracked.PSet(
468  wantSummary = cms.untracked.bool(True)
469  )
470  # CV: keep track of Z->mumu selection efficiency
471  process.goldenZmumuFilterResult = cms.EDProducer("CandViewCountEventSelFlagProducer",
472  src = process.customization_options.ZmumuCollection,
473  minNumber = cms.uint32(1)
474  )
475  process.goldenZmumuFilterEfficiencyPath = cms.Path(process.goldenZmumuSelectionSequence + process.goldenZmumuFilterResult + process.MEtoEDMConverter)
476  process.schedule.append(process.goldenZmumuFilterEfficiencyPath)
477  else:
478  print "Zmumu skim disabled"
479 
480  process.load("TauAnalysis/MCEmbeddingTools/muonRadiationFilter_cfi")
481  process.muonRadiationFilter.srcSelectedMuons = process.customization_options.ZmumuCollection
482  if process.customization_options.applyMuonRadiationFilter.value():
483  print "Muon -> muon + photon radiation filter enabled"
484  # CV: add filter at the end of reconstruction path
485  # (filter needs mixed 'pfPileUp' and 'pfNoPileUp' collections)
486  process.reconstruction_step += process.muonRadiationFilterSequence
487  process.options = cms.untracked.PSet(
488  wantSummary = cms.untracked.bool(True)
489  )
490  # CV: keep track of which events pass/fail muon -> muon + photon radiation filter
491  process.muonRadiationFilterResult = cms.EDProducer("DummyBoolEventSelFlagProducer")
492  process.muonRadiationFilterEfficiencyPath = cms.Path(process.goldenZmumuSelectionSequence + process.muonRadiationFilterSequence + process.muonRadiationFilterResult)
493  process.schedule.append(process.muonRadiationFilterEfficiencyPath)
494  else:
495  print "Muon -> muon + photon radiation filter disabled"
496 
497  # CV: disable ECAL/HCAL noise simulation
498  if process.customization_options.disableCaloNoise.value():
499  print "Disabling ECAL/HCAL noise simulation"
500  process.simEcalUnsuppressedDigis.doNoise = cms.bool(False)
501  process.simEcalUnsuppressedDigis.doESNoise = cms.bool(False)
502  process.simHcalUnsuppressedDigis.doNoise = cms.bool(False)
503  process.simHcalUnsuppressedDigis.doThermalNoise = cms.bool(False)
504  else:
505  print "Keeping ECAL/HCAL noise simulation enabled"
506 
507  # CV: apply/do not apply muon momentum corrections determined by Rochester group
508  if process.customization_options.replaceGenOrRecMuonMomenta.value() == "rec" and hasattr(process, "goldenZmumuSelectionSequence"):
509  if process.customization_options.applyRochesterMuonCorr.value():
510  print "Enabling Rochester muon momentum corrections"
511  process.patMuonsForZmumuSelectionRochesterMomentumCorr = cms.EDProducer("RochesterCorrPATMuonProducer",
512  src = cms.InputTag('patMuonsForZmumuSelection'),
513  isMC = cms.bool(process.customization_options.isMC.value())
514  )
515  process.goldenZmumuSelectionSequence.replace(process.patMuonsForZmumuSelection, process.patMuonsForZmumuSelection*process.patMuonsForZmumuSelectionRochesterMomentumCorr)
516  process.goodMuons.src = cms.InputTag('patMuonsForZmumuSelectionRochesterMomentumCorr')
517  else:
518  print "Rochester muon momentum corrections disabled"
519 
520  if process.customization_options.applyMuonRadiationCorrection.value() != "":
521  print "Muon -> muon + photon radiation correction enabled"
522  process.load("TauAnalysis/MCEmbeddingTools/muonRadiationCorrWeightProducer_cfi")
523  if process.customization_options.applyMuonRadiationCorrection.value() == "photos":
524  process.muonRadiationCorrWeightProducer.lutDirectoryRef = cms.string('genMuonRadCorrAnalyzerPHOTOS')
525  process.muonRadiationCorrWeightProducer.lutDirectoryOthers = cms.PSet(
526  Summer12mcMadgraph = cms.string('genMuonRadCorrAnalyzer')
527  )
528  elif process.customization_options.applyMuonRadiationCorrection.value() == "pythia":
529  process.muonRadiationCorrWeightProducer.lutDirectoryRef = cms.string('genMuonRadCorrAnalyzerPYTHIA')
530  process.muonRadiationCorrWeightProducer.lutDirectoryOthers = cms.PSet(
531  Summer12mcMadgraph = cms.string('genMuonRadCorrAnalyzer')
532  )
533  else:
534  raise ValueError("Invalid Configuration parameter 'applyMuonRadiationCorrection' = %s !!" % process.customization_options.applyMuonRadiationCorrection.value())
535  process.reconstruction_step += process.muonRadiationCorrWeightProducer
536  outputModule.outputCommands.extend([
537  'keep *_muonRadiationCorrWeightProducer_*_*',
538  'keep *_generator_muonsBeforeRad_*',
539  'keep *_generator_muonsAfterRad_*'
540  ])
541  else:
542  print "Muon -> muon + photon radiation correction disabled"
543 
544  # CV: compute reweighting factors to compensate for smearing of di-muon Pt and mass distributions caused by:
545  # o (mis)reconstruction of muon momenta
546  # o muon -> muon + photon radiation corrections
547  process.load("TauAnalysis/MCEmbeddingTools/embeddingKineReweight_cff")
548  if process.customization_options.applyMuonRadiationCorrection.value() != "":
549  if process.customization_options.mdtau.value() == 116:
550  process.embeddingKineReweightGENtoEmbedded.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/makeEmbeddingKineReweightLUTs_GENtoEmbedded_mutau.root")
551  process.reconstruction_step += process.embeddingKineReweightSequenceGENtoEmbedded
552  elif process.customization_options.mdtau.value() == 115:
553  process.embeddingKineReweightGENtoEmbedded.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/makeEmbeddingKineReweightLUTs_GENtoEmbedded_etau.root")
554  process.reconstruction_step += process.embeddingKineReweightSequenceGENtoEmbedded
555  if process.customization_options.replaceGenOrRecMuonMomenta.value() == 'rec':
556  process.reconstruction_step += process.embeddingKineReweightSequenceGENtoREC
557  outputModule.outputCommands.extend([
558  'keep *_embeddingKineReweight_*_*'
559  ])
560 
561  # CV: compute weights for correcting Embedded samples
562  # for efficiency with which Zmumu events used as input for Embedding production were selected
563  process.load("TauAnalysis/MCEmbeddingTools/ZmumuEvtSelEffCorrWeightProducer_cfi")
564  process.ZmumuEvtSelEffCorrWeightProducer.selectedMuons = process.customization_options.ZmumuCollection
565  process.ZmumuEvtSelEffCorrWeightProducer.verbosity = cms.int32(0)
566  process.reconstruction_step += process.ZmumuEvtSelEffCorrWeightProducer
567  outputModule.outputCommands.extend([
568  'keep *_ZmumuEvtSelEffCorrWeightProducer_*_*'
569  ])
570 
571  return(process)
return((rh^lh)&mask)
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