CMS 3D CMS Logo

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

Functions

def customise
 
def replaceModule_or_Sequence
 

Function Documentation

def embeddingCustomizeRH.customise (   process,
  inputProcess 
)

Definition at line 25 of file embeddingCustomizeRH.py.

References reco.print(), replaceModule_or_Sequence(), and rerunParticleFlow.updateInputTags().

25 
26 def customise(process, inputProcess):
27 
28  # Determine detIds of calorimeter cells crossed by muon track
29  trackAssocParamsForMuonCleaning = TrackAssociatorParameterBlock.TrackAssociatorParameters
30  updateInputTags(process, trackAssocParamsForMuonCleaning, inputProcess)
31  process.muonCaloEnergyDepositsAllCrossed = cms.EDProducer('MuonCaloCleanerAllCrossed',
32  trackAssociator = trackAssocParamsForMuonCleaning,
33  selectedMuons = process.customization_options.ZmumuCollection,
34  esRecHits = cms.InputTag("ecalPreshowerRecHit", "EcalRecHitsES", inputProcess)
35  )
36  process.ProductionFilterSequence += process.muonCaloEnergyDepositsAllCrossed
37 
38  recHitCaloCleanerAllCrossedConfig = cms.PSet(
39  srcEnergyDepositMapMuPlus = cms.InputTag("muonCaloEnergyDepositsAllCrossed", "energyDepositsMuPlus"),
40  srcEnergyDepositMapMuMinus = cms.InputTag("muonCaloEnergyDepositsAllCrossed", "energyDepositsMuMinus"),
41  typeEnergyDepositMap = cms.string("absolute"), # CV: use 'absolute' for 'MuonCaloCleanerAllCrossed' module
42  )
43 
44  recHitCaloCleanerByDistanceConfig = None
45  if process.customization_options.cleaningMode == 'DEDX':
46  process.muonCaloEnergyDepositsByDistance = cms.EDProducer('MuonCaloCleanerByDistance',
47  muons = cms.InputTag("muonCaloDistances", "muons"),
48  distanceMapMuPlus = cms.InputTag("muonCaloDistances", "distancesMuPlus"),
49  distanceMapMuMinus = cms.InputTag("muonCaloDistances", "distancesMuMinus"),
50  energyDepositCorrection = cms.PSet(
51  H_Ecal_EcalBarrel = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.9),
52  H_Ecal_EcalEndcap = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.9), # AB: use barrel value for now
53  H_Hcal_HcalBarrel = cms.double(process.customization_options.muonCaloCleaningSF.value()*1.1),
54  H_Hcal_HcalOuter = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.8),
55  H_Hcal_HcalEndcap = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.9),
56  H_Hcal_HcalForward = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.000), # CV: simulated tau decay products are not expected to deposit eny energy in HF calorimeter
57  H_Hcal_HcalOther = cms.double(process.customization_options.muonCaloCleaningSF.value()*0.000)
58  ),
59  verbosity = cms.int32(0)
60  )
61  process.ProductionFilterSequence += process.muonCaloEnergyDepositsByDistance
62 
63  recHitCaloCleanerByDistanceConfig = cms.PSet(
64  srcEnergyDepositMapMuPlus = cms.InputTag("muonCaloEnergyDepositsByDistance", "energyDepositsMuPlus"),
65  srcEnergyDepositMapMuMinus = cms.InputTag("muonCaloEnergyDepositsByDistance", "energyDepositsMuMinus"),
66  typeEnergyDepositMap = cms.string("absolute"), # CV: use 'absolute' ('relative') for 'MuonCaloCleanerByDistance' ('PFMuonCleaner') module
67  )
68  elif process.customization_options.cleaningMode == 'PF':
69  # Take energy deposits associated to muon by particle-flow algorithm
70  process.pfMuonCaloEnergyDeposits = cms.EDProducer('PFMuonCaloCleaner',
71  selectedMuons = process.customization_options.ZmumuCollection,
72  pfCandidates = cms.InputTag("particleFlowForPFMuonCleaning"),
73  dRmatch = cms.double(0.3),
74  verbosity = cms.int32(0)
75  )
76  process.ProductionFilterSequence += process.pfMuonCaloEnergyDeposits
77 
78  recHitCaloCleanerByDistanceConfig = cms.PSet(
79  srcEnergyDepositMapMuPlus = cms.InputTag("pfMuonCaloEnergyDeposits", "energyDepositsMuPlus"),
80  srcEnergyDepositMapMuMinus = cms.InputTag("pfMuonCaloEnergyDeposits", "energyDepositsMuMinus"),
81  typeEnergyDepositMap = cms.string("absolute"), # CV: use 'absolute' for 'PFMuonCaloCleaner'
82  )
83  else:
84  raise ValueError("Invalid Configuration parameter 'cleaningMode' = %s !!" % process.customization_options.cleaningMode)
85 
86  # mix recHits in CASTOR calorimeter
87  #
88  # NOTE: CASTOR is not expected to contain any energy from the simulated tau decay products;
89  # the mixing is necessary to get the energy deposits from the Z -> mu+ mu- event
90  # into the embedded event
91  #
92  if not process.customization_options.skipCaloRecHitMixing.value():
93  process.castorrecoORG = process.castorreco.clone()
94  process.castorreco = cms.EDProducer("CastorRecHitMixer",
95  recHitCaloCleanerAllCrossedConfig,
96  todo = cms.VPSet(
97  cms.PSet(
98  collection1 = cms.InputTag("castorrecoORG"),
99  collection2 = cms.InputTag("castorreco", "", inputProcess),
100  killNegEnergyBeforeMixing1 = cms.bool(False),
101  killNegEnergyBeforeMixing2 = cms.bool(True),
102  muonEnSutractionMode = cms.string("subtractFromCollection2BeforeMixing"),
103  killNegEnergyAfterMixing = cms.bool(False)
104  )
105  ),
106  verbosity = cms.int32(0)
107  )
108  replaceModule_or_Sequence(process, process.castorreco, process.castorrecoORG*process.castorreco)
109  else:
110  print("WARNING: disabling mixing of CASTOR recHit collection, this setting should be used for DEBUGGING only !!")
111 
112  # mix recHits in HF calorimeter
113  #
114  # NOTE: HF calorimeter is not expected to contain any energy from the simulated tau decay products;
115  # the mixing is necessary to get the energy deposits from the Z -> mu+ mu- event
116  # into the embedded event
117  #
118  if not process.customization_options.skipCaloRecHitMixing.value():
119  process.hfrecoORG = process.hfreco.clone()
120  process.hfreco = cms.EDProducer("HFRecHitMixer",
121  recHitCaloCleanerAllCrossedConfig,
122  todo = cms.VPSet(
123  cms.PSet(
124  collection1 = cms.InputTag("hfrecoORG"),
125  collection2 = cms.InputTag("hfreco", "", inputProcess),
126  killNegEnergyBeforeMixing1 = cms.bool(False),
127  killNegEnergyBeforeMixing2 = cms.bool(True),
128  muonEnSutractionMode = cms.string("subtractFromCollection2BeforeMixing"),
129  killNegEnergyAfterMixing = cms.bool(False)
130  )
131  ),
132  verbosity = cms.int32(0)
133  )
134  replaceModule_or_Sequence(process, process.hfreco, process.hfrecoORG*process.hfreco)
135  else:
136  print("WARNING: disabling mixing of HF recHit collection, this setting should be used for DEBUGGING only !!")
137 
138  # mix recHits in preshower
139  if not process.customization_options.skipCaloRecHitMixing.value():
140  process.ecalPreshowerRecHitORG = process.ecalPreshowerRecHit.clone()
141  process.ecalPreshowerRecHit = cms.EDProducer("EcalRecHitMixer",
142  recHitCaloCleanerAllCrossedConfig,
143  todo = cms.VPSet(
144  cms.PSet (
145  collection1 = cms.InputTag("ecalPreshowerRecHitORG", "EcalRecHitsES"),
146  collection2 = cms.InputTag("ecalPreshowerRecHit", "EcalRecHitsES", inputProcess),
147  killNegEnergyBeforeMixing1 = cms.bool(False),
148  killNegEnergyBeforeMixing2 = cms.bool(True),
149  muonEnSutractionMode = cms.string("subtractFromCollection2BeforeMixing"),
150  killNegEnergyAfterMixing = cms.bool(False)
151  )
152  ),
153  verbosity = cms.int32(0)
154  )
155  replaceModule_or_Sequence(process, process.ecalPreshowerRecHit, process.ecalPreshowerRecHitORG*process.ecalPreshowerRecHit)
156  else:
157  print("WARNING: disabling mixing of ES recHit collection, this setting should be used for DEBUGGING only !!")
158 
159  # mix recHits in ECAL
160  if not process.customization_options.skipCaloRecHitMixing.value():
161  print "Mixing ECAL recHit collections"
162  process.ecalRecHitORG = process.ecalRecHit.clone()
163  process.ecalRecHit = cms.EDProducer("EcalRecHitMixer",
164  recHitCaloCleanerByDistanceConfig,
165  todo = cms.VPSet(
166  cms.PSet(
167  collection1 = cms.InputTag("ecalRecHitORG", "EcalRecHitsEB"),
168  collection2 = cms.InputTag("ecalRecHit", "EcalRecHitsEB", inputProcess),
169  killNegEnergyBeforeMixing1 = cms.bool(False),
170  killNegEnergyBeforeMixing2 = cms.bool(True),
171  muonEnSutractionMode = cms.string("subtractFromCollection2BeforeMixing"),
172  killNegEnergyAfterMixing = cms.bool(False)
173  ),
174  cms.PSet (
175  collection1 = cms.InputTag("ecalRecHitORG", "EcalRecHitsEE"),
176  collection2 = cms.InputTag("ecalRecHit", "EcalRecHitsEE", inputProcess),
177  killNegEnergyBeforeMixing1 = cms.bool(False),
178  killNegEnergyBeforeMixing2 = cms.bool(True),
179  muonEnSutractionMode = cms.string("subtractFromCollection2BeforeMixing"),
180  killNegEnergyAfterMixing = cms.bool(False)
181  )
182  ),
183  verbosity = cms.int32(0)
184  )
185  replaceModule_or_Sequence(process, process.ecalRecHit, process.ecalRecHitORG*process.ecalRecHit)
186  else:
187  print("WARNING: disabling mixing of EB and EE recHit collections, this setting should be used for DEBUGGING only !!")
188 
189  # mix recHits in HCAL
190  if not process.customization_options.skipCaloRecHitMixing.value():
191  print "Mixing HCAL recHit collection"
192  process.hbherecoORG = process.hbhereco.clone()
193  process.hbhereco = cms.EDProducer("HBHERecHitMixer",
194  recHitCaloCleanerByDistanceConfig,
195  todo = cms.VPSet(
196  cms.PSet(
197  collection1 = cms.InputTag("hbherecoORG", ""),
198  collection2 = cms.InputTag("hbhereco", "", inputProcess),
199  killNegEnergyBeforeMixing1 = cms.bool(False),
200  killNegEnergyBeforeMixing2 = cms.bool(True),
201  muonEnSutractionMode = cms.string("subtractFromCollection2BeforeMixing"),
202  killNegEnergyAfterMixing = cms.bool(False)
203  )
204  ),
205  verbosity = cms.int32(0)
206  )
207  replaceModule_or_Sequence(process, process.hbhereco, process.hbherecoORG*process.hbhereco)
208 
209  process.horecoORG = process.horeco.clone()
210  process.horeco = cms.EDProducer("HORecHitMixer",
211  recHitCaloCleanerByDistanceConfig,
212  todo = cms.VPSet(
213  cms.PSet(
214  collection1 = cms.InputTag("horecoORG", ""),
215  collection2 = cms.InputTag("horeco", "", inputProcess),
216  killNegEnergyBeforeMixing1 = cms.bool(False),
217  killNegEnergyBeforeMixing2 = cms.bool(True),
218  muonEnSutractionMode = cms.string("subtractFromCollection2BeforeMixing"),
219  killNegEnergyAfterMixing = cms.bool(False)
220  )
221  ),
222  verbosity = cms.int32(0)
223  )
224  replaceModule_or_Sequence(process, process.horeco, process.horecoORG*process.horeco)
225  else:
226  print("WARNING: disabling mixing of HB, HE and HO recHit collections, this setting should be used for DEBUGGING only !!")
227 
228  # CV: Compute hits in muon detectors of the two muons produced in Z -> mu+ mu- decay
229  process.muonDetHits = cms.EDProducer('MuonDetCleaner',
230  trackAssociator = trackAssocParamsForMuonCleaning,
231  selectedMuons = process.customization_options.ZmumuCollection,
232  verbosity = cms.int32(0)
233  )
234  if process.customization_options.replaceGenOrRecMuonMomenta.value() == "gen":
235  process.muonDetHits.trackAssociator.muonMaxDistanceX = cms.double(1.e+3)
236  process.muonDetHits.trackAssociator.muonMaxDistanceX = cms.double(1.e+3)
237  process.muonDetHits.trackAssociator.dRMuonPreselection = cms.double(0.5)
238  process.ProductionFilterSequence += process.muonDetHits
239 
240  recHitMuonDetCleanerConfig = cms.PSet(
241  srcHitMapMuPlus = cms.InputTag("muonDetHits", "hitsMuPlus"),
242  srcHitMapMuMinus = cms.InputTag("muonDetHits", "hitsMuMinus"),
243  verbosity = cms.int32(0)
244  )
245 
246  if process.customization_options.muonMixingMode.value() == 2:
247  # CV: clone muon sequence for muon track segment reconstruction
248  configtools.cloneProcessingSnippet(process, process.muonlocalreco, "ORG")
249  process.reconstruction_step.replace(process.dt1DRecHits, process.muonlocalrecoORG*process.dt1DRecHits)
250 
251  if process.customization_options.muonMixingMode.value() == 1 or \
252  process.customization_options.muonMixingMode.value() == 2:
253  # mix recHits in CSC
254  print "Mixing CSC recHit collection"
255  process.csc2DRecHitsORG = process.csc2DRecHits.clone()
256  process.csc2DRecHits = cms.EDProducer("CSCRecHitMixer",
257  recHitMuonDetCleanerConfig,
258  todo = cms.VPSet(
259  cms.PSet(
260  collection1 = cms.InputTag("csc2DRecHitsORG", ""),
261  cleanCollection1 = cms.bool(False),
262  collection2 = cms.InputTag("csc2DRecHits", "", inputProcess),
263  cleanCollection2 = cms.bool(True)
264  )
265  )
266  )
267  replaceModule_or_Sequence(process, process.csc2DRecHits, process.csc2DRecHitsORG*process.csc2DRecHits)
268 
269  # mix recHits in DT
270  print "Mixing DT recHit collection"
271  process.dt1DRecHitsORG = process.dt1DRecHits.clone()
272  process.dt1DRecHits = cms.EDProducer("DTRecHitMixer",
273  recHitMuonDetCleanerConfig,
274  todo = cms.VPSet(
275  cms.PSet(
276  collection1 = cms.InputTag("dt1DRecHitsORG", ""),
277  cleanCollection1 = cms.bool(False),
278  collection2 = cms.InputTag("dt1DRecHits", "", inputProcess),
279  cleanCollection2 = cms.bool(True)
280  )
281  )
282  )
283  replaceModule_or_Sequence(process, process.dt1DRecHits, process.dt1DRecHitsORG*process.dt1DRecHits)
284 
285  # mix recHits in RPC
286  print "Mixing RPC recHit collection"
287  process.rpcRecHitsORG = process.rpcRecHits.clone()
288  process.rpcRecHits = cms.EDProducer("RPCRecHitMixer",
289  recHitMuonDetCleanerConfig,
290  todo = cms.VPSet(
291  cms.PSet(
292  collection1 = cms.InputTag("rpcRecHitsORG", ""),
293  cleanCollection1 = cms.bool(False),
294  collection2 = cms.InputTag("rpcRecHits", "", inputProcess),
295  cleanCollection2 = cms.bool(True)
296  )
297  )
298  )
299  replaceModule_or_Sequence(process, process.rpcRecHits, process.rpcRecHitsORG*process.rpcRecHits)
300 
301  if process.customization_options.muonMixingMode.value() == 2 or \
302  process.customization_options.muonMixingMode.value() == 3:
303 
304  # CV: need to switch to coarse positions to prevent exception
305  # when running 'glbTrackQual' module on mixed globalMuon collection
306  process.MuonTransientTrackingRecHitBuilderESProducerFromDisk = process.MuonTransientTrackingRecHitBuilderESProducer.clone(
307  ComponentName = cms.string('MuonRecHitBuilderFromDisk'),
308  ComputeCoarseLocalPositionFromDisk = cms.bool(True)
309  )
310  process.ttrhbwrFromDisk = process.ttrhbwr.clone(
311  ComponentName = cms.string('WithTrackAngleFromDisk'),
312  ComputeCoarseLocalPositionFromDisk = cms.bool(True)
313  )
314  process.glbTrackQual.RefitterParameters.MuonRecHitBuilder = cms.string('MuonRecHitBuilderFromDisk')
315  process.glbTrackQual.RefitterParameters.TrackerRecHitBuilder = cms.string('WithTrackAngleFromDisk')
316 
317  process.globalMuonsORG = process.globalMuons.clone()
318  process.cleanedGlobalMuons = cms.EDProducer("GlobalMuonTrackCleaner",
319  selectedMuons = process.customization_options.ZmumuCollection,
320  tracks = cms.VInputTag("globalMuons"),
321  dRmatch = cms.double(3.e-1),
322  removeDuplicates = cms.bool(True),
323  type = cms.string("links"),
324  srcMuons = cms.InputTag("muons"),
325  verbosity = cms.int32(0)
326  )
327  process.globalMuons = cms.EDProducer("GlobalMuonTrackMixer",
328  todo = cms.VPSet(
329  cms.PSet(
330  collection1 = cms.InputTag("globalMuonsORG", "", "EmbeddedRECO"),
331  collection2 = cms.InputTag("cleanedGlobalMuons"),
332  )
333  ),
334  verbosity = cms.int32(0)
335  )
336  replaceModule_or_Sequence(process, process.globalMuons, process.cleanedGlobalMuons*process.globalMuonsORG*process.globalMuons)
337 
338  process.standAloneMuonsORG = process.standAloneMuons.clone()
339  process.cleanedStandAloneMuons = process.cleanedGeneralTracks.clone(
340  tracks = cms.VInputTag(
341  cms.InputTag("standAloneMuons" ,""),
342  cms.InputTag("standAloneMuons", "UpdatedAtVtx"),
343  ),
344  type = cms.string("outer tracks"),
345  verbosity = cms.int32(0)
346  )
347  process.standAloneMuons = cms.EDProducer("TrackMixer",
348  todo = cms.VPSet(
349  cms.PSet(
350  collection1 = cms.InputTag("standAloneMuonsORG", "", "EmbeddedRECO"),
351  collection2 = cms.InputTag("cleanedStandAloneMuons", "")
352  ),
353  cms.PSet(
354  collection1 = cms.InputTag("standAloneMuonsORG", "UpdatedAtVtx", "EmbeddedRECO"),
355  collection2 = cms.InputTag("cleanedStandAloneMuons", "UpdatedAtVtx")
356  )
357  ),
358  verbosity = cms.int32(0)
359  )
360  replaceModule_or_Sequence(process, process.standAloneMuons, process.cleanedStandAloneMuons*process.standAloneMuonsORG*process.standAloneMuons)
361 
362  process.tevMuonsORG = process.tevMuons.clone()
363  if not process.customization_options.skipMuonDetRecHitMixing.value():
364  process.tevMuonsORG.RefitterParameters.CSCRecSegmentLabel = cms.InputTag("csc2DRecHitsORG")
365  process.tevMuonsORG.RefitterParameters.DTRecSegmentLabel = cms.InputTag("dt1DRecHitsORG")
366  process.tevMuonsORG.RefitterParameters.RPCRecSegmentLabel = cms.InputTag("rpcRecHitsORG")
367  process.tevMuonsORG.MuonCollectionLabel = cms.InputTag("globalMuonsORG")
368  process.cleanedTeVMuons = cms.EDProducer("TeVMuonTrackCleaner",
369  selectedMuons = process.customization_options.ZmumuCollection,
370  tracks = cms.VInputTag(
371  cms.InputTag("tevMuons", "default"),
372  cms.InputTag("tevMuons", "dyt"),
373  cms.InputTag("tevMuons", "firstHit"),
374  cms.InputTag("tevMuons", "picky")
375  ),
376  dRmatch = cms.double(3.e-1),
377  removeDuplicates = cms.bool(True),
378  type = cms.string("tev"),
379  srcGlobalMuons_cleaned = cms.InputTag("cleanedGlobalMuons"),
380  verbosity = cms.int32(0)
381  )
382  process.tevMuons = cms.EDProducer("TeVMuonTrackMixer",
383  todo = cms.VPSet(
384  cms.PSet(
385  collection1 = cms.InputTag("tevMuonsORG", "default", "EmbeddedRECO"),
386  collection2 = cms.InputTag("cleanedTeVMuons", "default")
387  ),
388  cms.PSet(
389  collection1 = cms.InputTag("tevMuonsORG", "dyt", "EmbeddedRECO"),
390  collection2 = cms.InputTag("cleanedTeVMuons", "dyt")
391  ),
392  cms.PSet(
393  collection1 = cms.InputTag("tevMuonsORG", "firstHit", "EmbeddedRECO"),
394  collection2 = cms.InputTag("cleanedTeVMuons", "firstHit")
395  ),
396  cms.PSet(
397  collection1 = cms.InputTag("tevMuonsORG", "picky", "EmbeddedRECO"),
398  collection2 = cms.InputTag("cleanedTeVMuons", "picky")
399  )
400  ),
401  srcGlobalMuons_cleaned = cms.InputTag("cleanedGlobalMuons"),
402  verbosity = cms.int32(0)
403  )
404  replaceModule_or_Sequence(process, process.tevMuons, process.cleanedTeVMuons*process.tevMuonsORG*process.tevMuons)
405 
406  return process
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
def embeddingCustomizeRH.replaceModule_or_Sequence (   process,
  moduleOld,
  modulesNew 
)

Definition at line 10 of file embeddingCustomizeRH.py.

Referenced by customise().

10 
11 def replaceModule_or_Sequence(process, moduleOld, modulesNew):
12  for sequenceName in process.sequences:
13  sequence = getattr(process, sequenceName)
14  #print("sequence = %s: modules = %s" % (sequenceName, sequence.moduleNames()))
15  moduleNameOld = moduleOld.label()
16  if moduleNameOld in sequence.moduleNames():
17  #print("replacing Module '%s' in Sequence '%s'." % (moduleNameOld, sequenceName))
18  sequence.replace(moduleOld, modulesNew)
19  for pathName in process.paths:
20  path = getattr(process, pathName)
21  #print("path = %s: modules = %s" % (pathName, path.moduleNames()))
22  if moduleNameOld in path.moduleNames():
23  #print("replacing Module '%s' in Path '%s'." % (moduleNameOld, pathName))
24  path.replace(moduleOld, modulesNew)