Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:10

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