test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
customizeGEMDigi.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 # from SimGeneral.MixingModule.mixObjects_cfi import *
5 # from SimGeneral.MixingModule.digitizers_cfi import *
8 # from SimGeneral.MixingModule.trackingTruthProducer_cfi import *
9 
10 # PSet of mixObjects that only keeps muon collections (and SimTracks with SimVertices)
11 mixObjects_dt_csc_rpc = cms.PSet(
12  mixCH = cms.PSet(
13  crossingFrames = cms.untracked.vstring(),
14  input = cms.VInputTag(),
15  type = cms.string('PCaloHit'),
16  subdets = cms.vstring()
17  ),
18  mixHepMC = cms.PSet(
19  input = cms.VInputTag(cms.InputTag("generatorSmeared"),cms.InputTag("generator")),
20  makeCrossingFrame = cms.untracked.bool(True),
21  type = cms.string('HepMCProduct')
22  ),
23  mixVertices = cms.PSet(
24  input = cms.VInputTag(cms.InputTag("g4SimHits")),
25  makeCrossingFrame = cms.untracked.bool(True),
26  type = cms.string('SimVertex')
27  ),
28  mixSH = cms.PSet(
29  crossingFrames = cms.untracked.vstring(
30  'MuonCSCHits',
31  'MuonDTHits',
32  'MuonRPCHits',
33  'TrackerHitsPixelBarrelHighTof',
34  'TrackerHitsPixelBarrelLowTof',
35  'TrackerHitsPixelEndcapHighTof',
36  'TrackerHitsPixelEndcapLowTof',
37  'TrackerHitsTECHighTof',
38  'TrackerHitsTECLowTof',
39  'TrackerHitsTIBHighTof',
40  'TrackerHitsTIBLowTof',
41  'TrackerHitsTIDHighTof',
42  'TrackerHitsTIDLowTof',
43  'TrackerHitsTOBHighTof',
44  'TrackerHitsTOBLowTof'
45  ),
46  input = cms.VInputTag(
47  cms.InputTag("g4SimHits","MuonCSCHits"),
48  cms.InputTag("g4SimHits","MuonDTHits"),
49  cms.InputTag("g4SimHits","MuonRPCHits"),
50  cms.InputTag("g4SimHits","TrackerHitsPixelBarrelHighTof"),
51  cms.InputTag("g4SimHits","TrackerHitsPixelBarrelLowTof"),
52  cms.InputTag("g4SimHits","TrackerHitsPixelEndcapHighTof"),
53  cms.InputTag("g4SimHits","TrackerHitsPixelEndcapLowTof"),
54  cms.InputTag("g4SimHits","TrackerHitsTECHighTof"),
55  cms.InputTag("g4SimHits","TrackerHitsTECLowTof"),
56  cms.InputTag("g4SimHits","TrackerHitsTIBHighTof"),
57  cms.InputTag("g4SimHits","TrackerHitsTIBLowTof"),
58  cms.InputTag("g4SimHits","TrackerHitsTIDHighTof"),
59  cms.InputTag("g4SimHits","TrackerHitsTIDLowTof"),
60  cms.InputTag("g4SimHits","TrackerHitsTOBHighTof"),
61  cms.InputTag("g4SimHits","TrackerHitsTOBLowTof"),
62  ),
63  type = cms.string('PSimHit'),
64  subdets = cms.vstring(
65  'MuonCSCHits',
66  'MuonDTHits',
67  'MuonRPCHits',
68  'TrackerHitsPixelBarrelHighTof',
69  'TrackerHitsPixelBarrelLowTof',
70  'TrackerHitsPixelEndcapHighTof',
71  'TrackerHitsPixelEndcapLowTof',
72  'TrackerHitsTECHighTof',
73  'TrackerHitsTECLowTof',
74  'TrackerHitsTIBHighTof',
75  'TrackerHitsTIBLowTof',
76  'TrackerHitsTIDHighTof',
77  'TrackerHitsTIDLowTof',
78  'TrackerHitsTOBHighTof',
79  'TrackerHitsTOBLowTof'
80  )
81  ),
82  mixTracks = cms.PSet(
83  input = cms.VInputTag(cms.InputTag("g4SimHits")),
84  makeCrossingFrame = cms.untracked.bool(True),
85  type = cms.string('SimTrack')
86  )
87 )
88 
89 # PSet of mixObjects that only keep muon and tracker collections (and SimTracks with SimVertices)
90 mixObjects_dt_csc_rpc_trk = cms.PSet(
91  mixCH = cms.PSet(
92  crossingFrames = cms.untracked.vstring(),
93  input = cms.VInputTag(),
94  type = cms.string('PCaloHit'),
95  subdets = cms.vstring()
96  ),
97  mixHepMC = cms.PSet(
98  input = cms.VInputTag(cms.InputTag("generatorSmeared"),cms.InputTag("generator")),
99  makeCrossingFrame = cms.untracked.bool(True),
100  type = cms.string('HepMCProduct')
101  ),
102  mixVertices = cms.PSet(
103  input = cms.VInputTag(cms.InputTag("g4SimHits")),
104  makeCrossingFrame = cms.untracked.bool(True),
105  type = cms.string('SimVertex')
106  ),
107  mixSH = cms.PSet(
108  crossingFrames = cms.untracked.vstring(
109  'MuonCSCHits',
110  'MuonDTHits',
111  'MuonRPCHits',
112  'TrackerHitsPixelBarrelHighTof',
113  'TrackerHitsPixelBarrelLowTof',
114  'TrackerHitsPixelEndcapHighTof',
115  'TrackerHitsPixelEndcapLowTof',
116  'TrackerHitsTECHighTof',
117  'TrackerHitsTECLowTof',
118  'TrackerHitsTIBHighTof',
119  'TrackerHitsTIBLowTof',
120  'TrackerHitsTIDHighTof',
121  'TrackerHitsTIDLowTof',
122  'TrackerHitsTOBHighTof',
123  'TrackerHitsTOBLowTof'
124  ),
125  input = cms.VInputTag(
126  cms.InputTag("g4SimHits","MuonCSCHits"),
127  cms.InputTag("g4SimHits","MuonDTHits"),
128  cms.InputTag("g4SimHits","MuonRPCHits"),
129  cms.InputTag("g4SimHits","TrackerHitsPixelBarrelHighTof"),
130  cms.InputTag("g4SimHits","TrackerHitsPixelBarrelLowTof"),
131  cms.InputTag("g4SimHits","TrackerHitsPixelEndcapHighTof"),
132  cms.InputTag("g4SimHits","TrackerHitsPixelEndcapLowTof"),
133  cms.InputTag("g4SimHits","TrackerHitsTECHighTof"),
134  cms.InputTag("g4SimHits","TrackerHitsTECLowTof"),
135  cms.InputTag("g4SimHits","TrackerHitsTIBHighTof"),
136  cms.InputTag("g4SimHits","TrackerHitsTIBLowTof"),
137  cms.InputTag("g4SimHits","TrackerHitsTIDHighTof"),
138  cms.InputTag("g4SimHits","TrackerHitsTIDLowTof"),
139  cms.InputTag("g4SimHits","TrackerHitsTOBHighTof"),
140  cms.InputTag("g4SimHits","TrackerHitsTOBLowTof"),
141  ),
142  type = cms.string('PSimHit'),
143  subdets = cms.vstring(
144  'MuonCSCHits',
145  'MuonDTHits',
146  'MuonRPCHits',
147  'TrackerHitsPixelBarrelHighTof',
148  'TrackerHitsPixelBarrelLowTof',
149  'TrackerHitsPixelEndcapHighTof',
150  'TrackerHitsPixelEndcapLowTof',
151  'TrackerHitsTECHighTof',
152  'TrackerHitsTECLowTof',
153  'TrackerHitsTIBHighTof',
154  'TrackerHitsTIBLowTof',
155  'TrackerHitsTIDHighTof',
156  'TrackerHitsTIDLowTof',
157  'TrackerHitsTOBHighTof',
158  'TrackerHitsTOBLowTof'
159  )
160  ),
161  mixTracks = cms.PSet(
162  input = cms.VInputTag(cms.InputTag("g4SimHits")),
163  makeCrossingFrame = cms.untracked.bool(True),
164  type = cms.string('SimTrack')
165  ),
166 )
167 
168 
169 # Customize process.mix to be used for running muon (DT, CSC, RPC) digi only.
170 # - remove non-muon digitizers that are now run as part of mixing process
171 # - delete all the digitizers' aliases.
172 # - drop unnecessary mixObjects
174  process.mix.digitizers = digitizers = cms.PSet()
175  digi_aliases = filter(lambda n: 'Digi' in n, process.aliases.keys())
176  for a in digi_aliases: process.__delattr__(a)
177  process.mix.mixObjects = mixObjects_dt_csc_rpc
178  return process
179 
180 # Customize process.mix to be used for running muon and tracker digi only.
181 # - remove calo digitizers that are now run as part of mixing process
182 # - delete all the digitizers' aliases apart of pixel and strip aliasses.
183 # - reset the simCastorDigis, simEcalUnsuppressedDigis
184 # and simHcalUnsuppressedDigis
185 # - drop unnecessary mixObjects
186 def customize_mix_nocalo(process):
187  process.mix.digitizers = digitizers = cms.PSet(
188  pixel = cms.PSet(
189  pixelDigitizer
190  ),
191  strip = cms.PSet(
192  stripDigitizer
193  ),
194  )
195  process.mix.theDigitizersValid = cms.PSet(
196  pixel = cms.PSet(
197  pixelDigitizer
198  ),
199  strip = cms.PSet(
200  stripDigitizer
201  )
202  )
203  # delete some contents of SimGeneral/MixingModule/python/aliases_cfi.py
204  # i was not able to delete these processes in a different way
205  process.simCastorDigis = cms.EDAlias()
206  process.simEcalUnsuppressedDigis = cms.EDAlias()
207  process.simHcalUnsuppressedDigis = cms.EDAlias()
208  # delete all digitizer aliasses apart of pixel and strip aliases
209  digi_aliases = filter(lambda n: 'Digi' in n, process.aliases.keys())
210  print("digi aliases before clean up: ")
211  for a in digi_aliases:
212  print(a)
213  if ('Strip' not in a) and ('Pixel' not in a):
214  process.__delattr__(a)
215  process.mix.mixObjects = mixObjects_dt_csc_rpc_trk
216  return process
217 
218 # Customize process.mix to be used for running muon (DT, CSC, RPC + GEM) digi only.
219 # - first do such customization for (DT, CSC, RPC)
220 # - append GEM SimHit collection definitions to mix.mixObjects.mixSH
222  process = customize_mix_muon_only(process)
223  process = customize_mix_addGEM(process)
224  return process
225 
227  process = customize_mix_nocalo(process)
228  process = customize_mix_addGEM(process)
229  return process
230 
231 # customize the digitization sequence pdigi to only digitize DT+CSC+RPC+GEM
233  process = load_GEM_digitizers(process)
234  process = customize_random_GEMDigi(process)
235  process = customize_mix_addGEM_muon_only(process)
236  process.muonDigi = cms.Sequence(
237  process.simMuonCSCDigis +
238  process.simMuonDTDigis +
239  process.simMuonRPCDigis +
240  process.simMuonGEMDigis +
241  process.simMuonGEMPadDigis
242  )
243  process.pdigi = cms.Sequence(
244  cms.SequencePlaceholder("randomEngineStateProducer")*
245  cms.SequencePlaceholder("mix")*
246  process.muonDigi
247  )
248  process = append_GEMDigi_event(process)
249  return process
250 
251 # customize the digitization sequence pdigi to only digitize DT+CSC+RPC+GEM
253  process = load_GEM_digitizers(process)
254  process = customize_random_GEMDigi(process)
255  process = customize_mix_addGEM_nocalo(process)
256  process.muonDigi = cms.Sequence(
257  process.simMuonCSCDigis +
258  process.simMuonDTDigis +
259  process.simMuonRPCDigis +
260  process.simMuonGEMDigis +
261  process.simMuonGEMPadDigis
262  )
263  process.pdigi = cms.Sequence(
264  cms.SequencePlaceholder("randomEngineStateProducer")*
265  cms.SequencePlaceholder("mix")*
266  process.muonDigi
267  )
268  # process.pdigi.remove(simCastorDigis)
269  process = append_GEMDigi_event(process)
270  return process
271 
272 
273 
274 
275 
276 # customize process.mix by appending GEM SimHit collection definitions to mix.mixObjects.mixSH
277 def customize_mix_addGEM(process):
278  process.mix.mixObjects.mixSH.crossingFrames.append('MuonGEMHits')
279  process.mix.mixObjects.mixSH.input.append(cms.InputTag("g4SimHits","MuonGEMHits"))
280  process.mix.mixObjects.mixSH.subdets.append('MuonGEMHits')
281  return process
282 
283 
284 # customize process.mix by appending ME0 SimHit collection definitions to mix.mixObjects.mixSH
285 def customize_mix_addME0(process):
286  process.mix.mixObjects.mixSH.crossingFrames.append('MuonME0Hits')
287  process.mix.mixObjects.mixSH.input.append(cms.InputTag("g4SimHits","MuonME0Hits"))
288  process.mix.mixObjects.mixSH.subdets.append('MuonME0Hits')
289  return process
290 
291 
292 # Customize process.mix to be used for running muon (DT, CSC, RPC + GEM) digi only.
293 # - first do such customization for (DT, CSC, RPC)
294 # - append GEM SimHit collection definitions to mix.mixObjects.mixSH
296  process = customize_mix_muon_only(process)
297  process = customize_mix_addGEM(process)
298  process = customize_mix_addME0(process)
299  return process
300 
302  process = customize_mix_nocalo(process)
303  process = customize_mix_addGEM(process)
304  process = customize_mix_addME0(process)
305  return process
306 
307 
308 # Add simMuonGEMDigis to the list of modules served by RandomNumberGeneratorService
310  process.RandomNumberGeneratorService.simMuonGEMDigis = cms.PSet(
311  initialSeed = cms.untracked.uint32(1234567),
312  engineName = cms.untracked.string('HepJamesRandom')
313  )
314  return process
315 
316 
317 # Add simMuonME0Digis to the list of modules served by RandomNumberGeneratorService
319  process.RandomNumberGeneratorService.simMuonME0Digis = cms.PSet(
320  initialSeed = cms.untracked.uint32(1234567),
321  engineName = cms.untracked.string('HepJamesRandom')
322  )
323  return process
324 
325 
326 ## load the digitizer and pad producer
327 def load_GEM_digitizers(process):
328  process.load('SimMuon.GEMDigitizer.muonGEMDigi_cff')
329  return process
330 
331 
332 ## load the digitizer and pad producer
333 def load_ME0_digitizers(process):
334  process.load('SimMuon.GEMDigitizer.muonME0DigisPreReco_cfi')
335  return process
336 
337 
338 # customize the full digitization sequence pdigi by adding GEMs
340  process = load_GEM_digitizers(process)
341  process = customize_random_GEMDigi(process)
342  process = customize_mix_addGEM(process)
343  process.doAllDigi = cms.Sequence(
344  process.calDigi +
345  process.muonDigi
346  )
347  process.pdigi = cms.Sequence(
348  cms.SequencePlaceholder("randomEngineStateProducer")*
349  cms.SequencePlaceholder("mix")*
350  process.doAllDigi*
351  process.addPileupInfo
352  )
353  process = append_GEMDigi_event(process)
354  return process
355 
356 
357 # customize the digitization sequence pdigi to only digitize GEM
359  process = load_GEM_digitizers(process)
360  process = customize_random_GEMDigi(process)
361  process = customize_mix_addGEM_muon_only(process)
362  process.pdigi = cms.Sequence(
363  cms.SequencePlaceholder("randomEngineStateProducer")*
364  cms.SequencePlaceholder("mix")*
365  process.simMuonGEMDigis*
366  process.simMuonGEMPadDigis
367  )
368  process = append_GEMDigi_event(process)
369  return process
370 
371 
372 # customize the full digitization sequence pdigi by adding GEMs
374  process = load_GEM_digitizers(process)
375  process = load_ME0_digitizers(process)
376  process = customize_random_GEMDigi(process)
377  process = customize_random_ME0Digi(process)
378  process = customize_mix_addGEM(process)
379  process = customize_mix_addME0(process)
380  process.muonDigi = cms.Sequence(
381  process.simMuonCSCDigis +
382  process.simMuonDTDigis +
383  process.simMuonRPCDigis +
384  process.simMuonGEMDigis +
385  process.simMuonGEMPadDigis +
386  process.simMuonME0Digis
387  )
388  process.doAllDigi = cms.Sequence(
389  process.calDigi +
390  process.muonDigi
391  )
392  process.pdigi = cms.Sequence(
393  cms.SequencePlaceholder("randomEngineStateProducer")*
394  cms.SequencePlaceholder("mix")*
395  process.doAllDigi*
396  process.addPileupInfo
397  )
398  process = append_GEMDigi_event(process)
399  return process
400 
401 
402 # customize the digitization sequence pdigi to only digitize DT+CSC+RPC+GEM
404  process = load_GEM_digitizers(process)
405  process = load_ME0_digitizers(process)
406  process = customize_random_GEMDigi(process)
407  process = customize_random_ME0Digi(process)
408  process = customize_mix_addGEM_addME0_muon_only(process)
409  process.muonDigi = cms.Sequence(
410  process.simMuonCSCDigis +
411  process.simMuonDTDigis +
412  process.simMuonRPCDigis +
413  process.simMuonGEMDigis +
414  process.simMuonGEMPadDigis +
415  process.simMuonME0Digis
416  )
417  process.pdigi = cms.Sequence(
418  cms.SequencePlaceholder("randomEngineStateProducer")*
419  cms.SequencePlaceholder("mix")*
420  process.muonDigi
421  )
422  process = append_GEMDigi_event(process)
423  return process
424 
425 
426 # customize the digitization sequence pdigi to only digitize GEM
428  process = load_GEM_digitizers(process)
429  process = load_ME0_digitizers(process)
430  process = customize_random_GEMDigi(process)
431  process = customize_random_ME0Digi(process)
432  process = customize_mix_addGEM_addME0_muon_only(process)
433  process.pdigi = cms.Sequence(
434  cms.SequencePlaceholder("randomEngineStateProducer")*
435  cms.SequencePlaceholder("mix")*
436  process.simMuonGEMDigis*
437  process.simMuonGEMPadDigis*
438  process.simMuonME0Digis
439  )
440  process = append_GEMDigi_event(process)
441  return process
442 
443 
444 # insert the GEMDigi and GEMPadDigi collection to the event
445 def append_GEMDigi_event(process):
446  alist=['AODSIM','RECOSIM','FEVTSIM','FEVTDEBUG','FEVTDEBUGHLT','RECODEBUG','RAWRECOSIMHLT','RAWRECODEBUGHLT']
447  for a in alist:
448  b=a+'output'
449  if hasattr(process,b):
450  getattr(process,b).outputCommands.append('drop *')
451  # getattr(process,b).outputCommands.append('keep *_mix_*_*')
452  getattr(process,b).outputCommands.append('keep *_g4SimHits__*')
453  getattr(process,b).outputCommands.append('keep *_g4SimHits_Muon*_*')
454  getattr(process,b).outputCommands.append('keep *_g4SimHits_Tracker*_*')
455  getattr(process,b).outputCommands.append('keep *_generator_*_*')
456  getattr(process,b).outputCommands.append('keep *_genParticles_*_*')
457  getattr(process,b).outputCommands.append('keep *_*Muon*_*_*')
458  getattr(process,b).outputCommands.append('keep *_*Strip*_*_*')
459  getattr(process,b).outputCommands.append('keep *_*Pixel*_*_*')
460  # getattr(process,b).outputCommands.append('keep *_*_*_*')
461  # getattr(process,b).outputCommands.append('keep *_simSiPixelDigis_*_*')
462  # getattr(process,b).outputCommands.append('keep *_simSiStripDigis_*_*')
463 
464  return process
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
def load_ME0_digitizers
load the digitizer and pad producer
def customize_mix_addGEM_addME0_nocalo
def customize_digi_addGEM_addME0_gem_only
def load_GEM_digitizers
load the digitizer and pad producer
def customize_digi_addGEM_addME0_muon_only
def customize_mix_addGEM_addME0_muon_only