File indexing completed on 2024-12-01 23:40:43
0001 import FWCore.ParameterSet.Config as cms
0002
0003
0004 def unganged_me1a_geometry(process):
0005 """Customise digi/reco geometry to use unganged ME1/a channels
0006 """
0007 if hasattr(process,"CSCGeometryESModule"):
0008 process.CSCGeometryESModule.useGangedStripsInME1a = False
0009 if hasattr(process,"idealForDigiCSCGeometry"):
0010 process.idealForDigiCSCGeometry.useGangedStripsInME1a = False
0011 return process
0012
0013
0014 def digitizer_timing_pre3_median(process):
0015 """CSC digitizer customization
0016 with bunchTimingOffsets tuned to center trigger stubs at bx6
0017 when pretrigger with 3 layers and median stub timing are used
0018 """
0019
0020
0021
0022
0023
0024
0025
0026
0027 process.simMuonCSCDigis.strips.bunchTimingOffsets = cms.vdouble(0.0,
0028 37.53, 37.66, 55.4, 48.2, 54.45, 53.78, 53.38, 54.12, 51.98, 51.28)
0029 process.simMuonCSCDigis.wires.bunchTimingOffsets = cms.vdouble(0.0,
0030 22.88, 22.55, 29.28, 30.0, 30.0, 30.5, 31.0, 29.5, 29.1, 29.88)
0031
0032 return process
0033
0034
0035 def customise_csc_cond_ungangedME11A_mc(process):
0036 """ Pick up upgrade condions data directly from DB tags using ESPrefer's.
0037 Might be useful when dealing with a global tag that doesn't include
0038 'unganged' CSC conditions.
0039 """
0040 myconds = [
0041 ('CSCDBGainsRcd', 'CSCDBGains_ungangedME11A_mc'),
0042 ('CSCDBNoiseMatrixRcd', 'CSCDBNoiseMatrix_ungangedME11A_mc'),
0043 ('CSCDBCrosstalkRcd', 'CSCDBCrosstalk_ungangedME11A_mc'),
0044 ('CSCDBPedestalsRcd', 'CSCDBPedestals_ungangedME11A_mc'),
0045 ('CSCDBGasGainCorrectionRcd', 'CSCDBGasGainCorrection_ungangedME11A_mc'),
0046 ('CSCDBChipSpeedCorrectionRcd', 'CSCDBChipSpeedCorrection_ungangedME11A_mc')
0047 ]
0048
0049 from CalibMuon.Configuration.getCSCConditions_frontier_cff import cscConditions
0050 for (classname, tag) in myconds:
0051 print(classname, tag)
0052 sourcename = 'unganged_' + classname
0053 process.__setattr__(sourcename, cscConditions.clone())
0054 process.__getattribute__(sourcename).toGet = cms.VPSet( cms.PSet( record = cms.string(classname), tag = cms.string(tag)) )
0055 process.__getattribute__(sourcename).connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS')
0056 process.__setattr__('esp_' + classname, cms.ESPrefer("PoolDBESSource", sourcename) )
0057
0058 del cscConditions
0059
0060 return process
0061
0062
0063 def customise_csc_Indexing(process):
0064 """Settings for the upgrade raw vs offline condition channel translation
0065 """
0066 if hasattr(process,"CSCIndexerESProducer"):
0067 process.CSCIndexerESProducer.AlgoName=cms.string("CSCIndexerPostls1")
0068 if hasattr(process,"CSCChannelMapperESProducer"):
0069 process.CSCChannelMapperESProducer.AlgoName=cms.string("CSCChannelMapperPostls1")
0070 return process
0071
0072
0073 def remove_from_all_paths(process, module_name):
0074 """Remove process.module_name from all the paths in process:
0075 """
0076
0077
0078 if not hasattr(process, module_name):
0079 return process
0080
0081
0082 for path_name in process._Process__paths.keys():
0083 the_path = getattr(process, path_name)
0084 module_names = the_path.moduleNames()
0085 if module_name in module_names:
0086 the_path.remove(getattr(process, module_name))
0087 return process
0088
0089
0090 def csc_PathVsModule_SanityCheck(process):
0091 """A sanity check to make sure that standard cmsDriver paths
0092 have modules with expected names. If some paths would not have
0093 expected modules, the procedure would only print WARNINGs.
0094 """
0095
0096 paths_modules = [
0097 ('digitisation_step', 'simMuonCSCDigis'),
0098 ('L1simulation_step', 'simCscTriggerPrimitiveDigis'),
0099 ('L1simulation_step', 'simCsctfTrackDigis'),
0100 ('raw2digi_step', 'muonCSCDigis'),
0101 ('raw2digi_step', 'csctfDigis'),
0102 ('digi2raw_step', 'cscpacker'),
0103 ('digi2raw_step', 'csctfpacker'),
0104 ('reconstruction', 'csc2DRecHits'),
0105 ('dqmoffline_step', 'muonAnalyzer')
0106
0107
0108 ]
0109
0110 for path_name, module_name in paths_modules:
0111 if hasattr(process, path_name) and not hasattr(process, module_name):
0112 print("WARNING: module %s is not in %s path!!!" % (module_name, path_name))
0113 print(" This path has the following modules:")
0114 print(" ", getattr(process, path_name).moduleNames(),"\n")
0115
0116
0117
0118
0119 def customise_csc_Geometry(process):
0120 """Customise digi/reco geometry to use unganged ME1/a channels
0121 """
0122 process = unganged_me1a_geometry(process)
0123 return process
0124
0125
0126 def customise_csc_Digitizer(process):
0127 """Customise CSC digitization to use unganged ME1/a channels
0128 """
0129 process = customise_csc_Indexing(process)
0130 process = digitizer_timing_pre3_median(process)
0131 return process
0132
0133
0134 def customise_csc_L1Stubs_sim(process):
0135 """Configure the local CSC trigger stubs emulator with the upgrade
0136 algorithm version that efficiently uses unganged ME1a
0137 """
0138
0139 process = customise_csc_Indexing(process)
0140
0141 from L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigisPostLS1_cfi import cscTriggerPrimitiveDigisPostLS1
0142 process.simCscTriggerPrimitiveDigis = cscTriggerPrimitiveDigisPostLS1
0143 process.simCscTriggerPrimitiveDigis.CSCComparatorDigiProducer = cms.InputTag( 'simMuonCSCDigis', 'MuonCSCComparatorDigi')
0144 process.simCscTriggerPrimitiveDigis.CSCWireDigiProducer = cms.InputTag( 'simMuonCSCDigis', 'MuonCSCWireDigi')
0145
0146 return process
0147
0148
0149 def customise_csc_L1TrackFinder_sim(process):
0150 """Regular CSCTF configuration adapted to deal with unganged ME1a
0151 """
0152 from L1Trigger.CSCTrackFinder.csctfTrackDigisUngangedME1a_cfi import csctfTrackDigisUngangedME1a
0153 process.simCsctfTrackDigis = csctfTrackDigisUngangedME1a
0154 process.simCsctfTrackDigis.DTproducer = cms.untracked.InputTag("simDtTriggerPrimitiveDigis")
0155 process.simCsctfTrackDigis.SectorReceiverInput = cms.untracked.InputTag("simCscTriggerPrimitiveDigis", "MPCSORTED")
0156
0157 return process
0158
0159
0160 def customise_csc_L1Emulator_sim(process):
0161 """Customise both stubs and TF emulators
0162 """
0163 process = customise_csc_L1Stubs_sim(process)
0164 process = customise_csc_L1TrackFinder_sim(process)
0165 return process
0166
0167
0168 def customise_csc_Packer(process):
0169 """Use 2013 a.k.a. post-LS1 version
0170 """
0171 process.cscpacker.formatVersion = cms.uint32(2013)
0172 process.cscpacker.usePreTriggers = cms.bool(False)
0173 process.cscpacker.packEverything = cms.bool(True)
0174 return process
0175
0176
0177 def customise_csc_Unpacker(process):
0178 """Do nothing at the moment
0179 """
0180 return process
0181
0182
0183 def customise_csc_L1Extra_allsim(process):
0184 """Adjust L1Extra producer's input tags for the use case
0185 when we want to run L1Extra without packing-unpacking first
0186 """
0187 l1ep = process.l1extraParticles
0188
0189
0190
0191
0192 l1ep.muonSource = cms.InputTag('simGmtDigis')
0193 l1ep.etTotalSource = cms.InputTag('simGctDigis')
0194 l1ep.nonIsolatedEmSource = cms.InputTag('simGctDigis', 'nonIsoEm')
0195 l1ep.etMissSource = cms.InputTag('simGctDigis')
0196 l1ep.forwardJetSource = cms.InputTag('simGctDigis', 'forJets')
0197 l1ep.centralJetSource = cms.InputTag('simGctDigis', 'cenJets')
0198 l1ep.tauJetSource = cms.InputTag('simGctDigis', 'tauJets')
0199 l1ep.isolatedEmSource = cms.InputTag('simGctDigis', 'isoEm')
0200 l1ep.etHadSource = cms.InputTag('simGctDigis')
0201 l1ep.htMissSource = cms.InputTag("simGctDigis")
0202 l1ep.hfRingEtSumsSource = cms.InputTag("simGctDigis")
0203 l1ep.hfRingBitCountsSource = cms.InputTag("simGctDigis")
0204 return process
0205
0206
0207 def customise_csc_LocalReco(process):
0208 """Configure the CSC rechit producer
0209 to handle unganged ME1a for upgrade studies
0210 """
0211
0212 process = customise_csc_Indexing(process)
0213
0214
0215 process.csc2DRecHits.readBadChannels = cms.bool(False)
0216 process.csc2DRecHits.CSCUseGasGainCorrections = cms.bool(False)
0217
0218 return process
0219
0220
0221 def customise_csc_DQM(process):
0222 """Do nothing special. May need some adjustments for unganged ME11
0223 """
0224 return process
0225
0226
0227 def customise_csc_Validation(process):
0228 """Nothing for now
0229 """
0230 return process
0231
0232
0233 def customise_csc_PostLS1(process):
0234 """Full set of the CSC PostLS1 related customizations.
0235 It's tied to specific expected module names.
0236 Therefore, a sanity check is done first to make sure that
0237 standard cmsDriver paths have modules with such expected names.
0238 """
0239
0240
0241 csc_PathVsModule_SanityCheck(process)
0242
0243
0244 process = customise_csc_Geometry(process)
0245
0246
0247 if hasattr(process, 'simMuonCSCDigis'):
0248 process = customise_csc_Digitizer(process)
0249
0250
0251 if hasattr(process, 'simCscTriggerPrimitiveDigis'):
0252 process = customise_csc_L1Stubs_sim(process)
0253
0254
0255 if hasattr(process, 'simCsctfTrackDigis'):
0256 process = customise_csc_L1TrackFinder_sim(process)
0257
0258
0259 if hasattr(process, 'cscpacker') or hasattr(process, 'csctfpacker'):
0260 process = customise_csc_Packer(process)
0261
0262
0263 if hasattr(process, 'muonCSCDigis') or hasattr(process, 'csctfDigis'):
0264 process = customise_csc_Unpacker(process)
0265
0266
0267 if hasattr(process, 'csc2DRecHits'):
0268 process = customise_csc_LocalReco(process)
0269
0270
0271 if hasattr(process, 'cscMonitor'):
0272 process = customise_csc_DQM(process)
0273
0274
0275 if hasattr(process, 'relvalMuonBits'):
0276 process = customise_csc_Validation(process)
0277
0278 return process