CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
muonCustoms.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 
4 def unganged_me1a_geometry(process):
5  """Customise digi/reco geometry to use unganged ME1/a channels
6  """
7  if hasattr(process,"CSCGeometryESModule"):
8  process.CSCGeometryESModule.useGangedStripsInME1a = False
9  if hasattr(process,"idealForDigiCSCGeometry"):
10  process.idealForDigiCSCGeometry.useGangedStripsInME1a = False
11  return process
12 
13 
15  """CSC digitizer customization
16  with bunchTimingOffsets tuned to center trigger stubs at bx6
17  when pretrigger with 3 layers and median stub timing are used
18  """
19  ## Make sure there's no bad chambers/channels
20  #process.simMuonCSCDigis.strips.readBadChambers = True
21  #process.simMuonCSCDigis.wires.readBadChannels = True
22  #process.simMuonCSCDigis.digitizeBadChambers = True
23 
24  ## Customised timing offsets so that ALCTs and CLCTs times are centered in signal BX.
25  ## These offsets below were tuned for the case of 3 layer pretriggering
26  ## and median stub timing algorithm.
27  process.simMuonCSCDigis.strips.bunchTimingOffsets = cms.vdouble(0.0,
28  37.53, 37.66, 55.4, 48.2, 54.45, 53.78, 53.38, 54.12, 51.98, 51.28)
29  process.simMuonCSCDigis.wires.bunchTimingOffsets = cms.vdouble(0.0,
30  22.88, 22.55, 29.28, 30.0, 30.0, 30.5, 31.0, 29.5, 29.1, 29.88)
31 
32  return process
33 
34 
36  """ Pick up upgrade condions data directly from DB tags using ESPrefer's.
37  Might be useful when dealing with a global tag that doesn't include
38  'unganged' CSC conditions.
39  """
40  myconds = [
41  ('CSCDBGainsRcd', 'CSCDBGains_ungangedME11A_mc'),
42  ('CSCDBNoiseMatrixRcd', 'CSCDBNoiseMatrix_ungangedME11A_mc'),
43  ('CSCDBCrosstalkRcd', 'CSCDBCrosstalk_ungangedME11A_mc'),
44  ('CSCDBPedestalsRcd', 'CSCDBPedestals_ungangedME11A_mc'),
45  ('CSCDBGasGainCorrectionRcd', 'CSCDBGasGainCorrection_ungangedME11A_mc'),
46  ('CSCDBChipSpeedCorrectionRcd', 'CSCDBChipSpeedCorrection_ungangedME11A_mc')
47  ]
48 
50  for (classname, tag) in myconds:
51  print classname, tag
52  sourcename = 'unganged_' + classname
53  process.__setattr__(sourcename, cscConditions.clone())
54  process.__getattribute__(sourcename).toGet = cms.VPSet( cms.PSet( record = cms.string(classname), tag = cms.string(tag)) )
55  process.__getattribute__(sourcename).connect = cms.string('frontier://FrontierProd/CMS_COND_CSC_000')
56  process.__setattr__('esp_' + classname, cms.ESPrefer("PoolDBESSource", sourcename) )
57 
58  del cscConditions
59 
60  return process
61 
62 
64  """Settings for the upgrade raw vs offline condition channel translation
65  """
66  if hasattr(process,"CSCIndexerESProducer"):
67  process.CSCIndexerESProducer.AlgoName=cms.string("CSCIndexerPostls1")
68  if hasattr(process,"CSCChannelMapperESProducer"):
69  process.CSCChannelMapperESProducer.AlgoName=cms.string("CSCChannelMapperPostls1")
70  return process
71 
72 
73 def remove_from_all_paths(process, module_name):
74  """Remove process.module_name from all the paths in process:
75  """
76 
77  # trivial case first:
78  if not hasattr(process, module_name):
79  return process
80 
81  # walk over all the paths:
82  for path_name in process._Process__paths.keys():
83  the_path = getattr(process, path_name)
84  module_names = the_path.moduleNames()
85  if module_name in module_names:
86  the_path.remove(getattr(process, module_name))
87  return process
88 
89 
91  """A sanity check to make sure that standard cmsDriver paths
92  have modules with expected names. If some paths would not have
93  expected modules, the procedure would only print WARNINGs.
94  """
95  # list of (pathName, expected moduleName) tuples:
96  paths_modules = [
97  ('digitisation_step', 'simMuonCSCDigis'),
98  ('L1simulation_step', 'simCscTriggerPrimitiveDigis'),
99  ('L1simulation_step', 'simCsctfTrackDigis'),
100  ('raw2digi_step', 'muonCSCDigis'),
101  ('raw2digi_step', 'csctfDigis'),
102  ('digi2raw_step', 'cscpacker'),
103  ('digi2raw_step', 'csctfpacker'),
104  ('reconstruction', 'csc2DRecHits'),
105  ('dqmoffline_step', 'muonAnalyzer')
106  #('dqmHarvesting', ''),
107 # ('validation_step', 'relvalMuonBits')
108  ]
109  # verify:
110  for path_name, module_name in paths_modules:
111  if hasattr(process, path_name) and not hasattr(process, module_name):
112  print "WARNING: module %s is not in %s path!!!" % (module_name, path_name)
113  print " This path has the following modules:"
114  print " ", getattr(process, path_name).moduleNames(),"\n"
115 
116 
117 # ------------------------------------------------------------------
118 
120  """Customise digi/reco geometry to use unganged ME1/a channels
121  """
122  process = unganged_me1a_geometry(process)
123  return process
124 
125 
127  """Customise CSC digitization to use unganged ME1/a channels
128  """
129  process = customise_csc_Indexing(process)
130  process = digitizer_timing_pre3_median(process)
131  return process
132 
133 
135  """Configure the local CSC trigger stubs emulator with the upgrade
136  algorithm version that efficiently uses unganged ME1a
137  """
138 
139  process = customise_csc_Indexing(process)
140 
141  from L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigisPostLS1_cfi import cscTriggerPrimitiveDigisPostLS1
142  process.simCscTriggerPrimitiveDigis = cscTriggerPrimitiveDigisPostLS1
143  process.simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'simMuonCSCDigis', 'MuonCSCComparatorDigi')
144  process.simCscTriggerPrimitiveDigis.CSCWireDigiProducer = cms.InputTag( 'simMuonCSCDigis', 'MuonCSCWireDigi')
145 
146  return process
147 
148 
150  """Regular CSCTF configuration adapted to deal with unganged ME1a
151  """
152  from L1Trigger.CSCTrackFinder.csctfTrackDigisUngangedME1a_cfi import csctfTrackDigisUngangedME1a
153  process.simCsctfTrackDigis = csctfTrackDigisUngangedME1a
154  process.simCsctfTrackDigis.DTproducer = cms.untracked.InputTag("simDtTriggerPrimitiveDigis")
155  process.simCsctfTrackDigis.SectorReceiverInput = cms.untracked.InputTag("simCscTriggerPrimitiveDigis", "MPCSORTED")
156 
157  return process
158 
159 
161  """Customise both stubs and TF emulators
162  """
163  process = customise_csc_L1Stubs_sim(process)
164  process = customise_csc_L1TrackFinder_sim(process)
165  return process
166 
167 
168 def customise_csc_Packer(process):
169  """Use 2013 a.k.a. post-LS1 version
170  """
171  process.cscpacker.useFormatVersion = cms.uint32(2013)
172  process.cscpacker.usePreTriggers = cms.bool(False)
173  process.cscpacker.packEverything = cms.bool(True)
174  return process
175 
176 
178  """Do nothing at the moment
179  """
180  return process
181 
182 
184  """Adjust L1Extra producer's input tags for the use case
185  when we want to run L1Extra without packing-unpacking first
186  """
187  l1ep = process.l1extraParticles
188  #l1ep.centralBxOnly = cms.bool(True)
189  #l1ep.produceMuonParticles = cms.bool(True)
190  #l1ep.produceCaloParticles = cms.bool(False)
191  #l1ep.ignoreHtMiss = cms.bool(False)
192  l1ep.muonSource = cms.InputTag('simGmtDigis')
193  l1ep.etTotalSource = cms.InputTag('simGctDigis')
194  l1ep.nonIsolatedEmSource = cms.InputTag('simGctDigis', 'nonIsoEm')
195  l1ep.etMissSource = cms.InputTag('simGctDigis')
196  l1ep.forwardJetSource = cms.InputTag('simGctDigis', 'forJets')
197  l1ep.centralJetSource = cms.InputTag('simGctDigis', 'cenJets')
198  l1ep.tauJetSource = cms.InputTag('simGctDigis', 'tauJets')
199  l1ep.isolatedEmSource = cms.InputTag('simGctDigis', 'isoEm')
200  l1ep.etHadSource = cms.InputTag('simGctDigis')
201  l1ep.htMissSource = cms.InputTag("simGctDigis")
202  l1ep.hfRingEtSumsSource = cms.InputTag("simGctDigis")
203  l1ep.hfRingBitCountsSource = cms.InputTag("simGctDigis")
204  return process
205 
206 
208  """Configure the CSC rechit producer
209  to handle unganged ME1a for upgrade studies
210  """
211  #
212  process = customise_csc_Indexing(process)
213 
214  # Turn off some flags for CSCRecHitD that are turned ON in default config
215  process.csc2DRecHits.readBadChannels = cms.bool(False)
216  process.csc2DRecHits.CSCUseGasGainCorrections = cms.bool(False)
217 
218  return process
219 
220 
221 def customise_csc_DQM(process):
222  """Do nothing special. May need some adjustments for unganged ME11
223  """
224  return process
225 
226 
228  """Nothing for now
229  """
230  return process
231 
232 
234  """Full set of the CSC PostLS1 related customizations.
235  It's tied to specific expected module names.
236  Therefore, a sanity check is done first to make sure that
237  standard cmsDriver paths have modules with such expected names.
238  """
239 
240  # a simple sanity check first
242 
243  # use unganged geometry
244  process = customise_csc_Geometry(process)
245 
246  # digitizer
247  if hasattr(process, 'simMuonCSCDigis'):
248  process = customise_csc_Digitizer(process)
249 
250  # L1 stub emulator upgrade algorithm
251  if hasattr(process, 'simCscTriggerPrimitiveDigis'):
252  process = customise_csc_L1Stubs_sim(process)
253 
254  # CSCTF that can deal with unganged ME1a
255  if hasattr(process, 'simCsctfTrackDigis'):
256  process = customise_csc_L1TrackFinder_sim(process)
257 
258  # packer - simply get rid of it
259  if hasattr(process, 'cscpacker') or hasattr(process, 'csctfpacker'):
260  process = customise_csc_Packer(process)
261 
262  # unpacker - simply get rid of it
263  if hasattr(process, 'muonCSCDigis') or hasattr(process, 'csctfDigis'):
264  process = customise_csc_Unpacker(process)
265 
266  # CSC RecHiti producer adjustments
267  if hasattr(process, 'csc2DRecHits'):
268  process = customise_csc_LocalReco(process)
269 
270  # DQM
271  if hasattr(process, 'cscMonitor'):
272  process = customise_csc_DQM(process)
273 
274  # Validation
275  if hasattr(process, 'relvalMuonBits'):
276  process = customise_csc_Validation(process)
277 
278  return process
def customise_csc_L1Extra_allsim
Definition: muonCustoms.py:183
def customise_csc_Unpacker
Definition: muonCustoms.py:177
def customise_csc_Digitizer
Definition: muonCustoms.py:126
def customise_csc_L1Stubs_sim
Definition: muonCustoms.py:134
def unganged_me1a_geometry
Definition: muonCustoms.py:4
def customise_csc_Indexing
Definition: muonCustoms.py:63
def customise_csc_LocalReco
Definition: muonCustoms.py:207
def customise_csc_Geometry
Definition: muonCustoms.py:119
def customise_csc_cond_ungangedME11A_mc
Definition: muonCustoms.py:35
def customise_csc_DQM
Definition: muonCustoms.py:221
def customise_csc_L1TrackFinder_sim
Definition: muonCustoms.py:149
def customise_csc_Validation
Definition: muonCustoms.py:227
def remove_from_all_paths
Definition: muonCustoms.py:73
def csc_PathVsModule_SanityCheck
Definition: muonCustoms.py:90
def customise_csc_L1Emulator_sim
Definition: muonCustoms.py:160
def customise_csc_PostLS1
Definition: muonCustoms.py:233
def digitizer_timing_pre3_median
Definition: muonCustoms.py:14
def customise_csc_Packer
Definition: muonCustoms.py:168