Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-07 22:22:45

0001 import FWCore.ParameterSet.Config as cms
0002 from FWCore.ParameterSet.VarParsing import VarParsing
0003 from Configuration.Eras.Era_Run3_cff import Run3
0004 from Configuration.Eras.Era_Run2_2018_cff import Run2_2018
0005 
0006 options = VarParsing('analysis')
0007 options.register("unpack", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0008                  "Set to True when you want to unpack the CSC DAQ data.")
0009 options.register("selectCSCs", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0010                  "Set to True when you want to (un)select certain CSCs.")
0011 options.register("maskedChambers", "", VarParsing.multiplicity.list, VarParsing.varType.string,
0012                  "Chambers you want to explicitly mask.")
0013 options.register("selectedChambers", "", VarParsing.multiplicity.list, VarParsing.varType.string,
0014                  "Chambers you want to explicitly mask.")
0015 options.register("unpackGEM", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0016                  "Set to True when you want to unpack the GEM DAQ data.")
0017 options.register("l1", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0018                  "Set to True when you want to re-emulate the CSC trigger primitives.")
0019 options.register("l1GEM", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0020                  "Set to True when you want to re-emulate the GEM trigger primitives.")
0021 options.register("mc", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0022                  "Set to True when running on MC.")
0023 options.register("dqm", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0024                  "Set to True when you want to run the CSC DQM")
0025 options.register("dqmGEM", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0026                  "Set to True when you want to run the GEM DQM")
0027 options.register("useEmtfGEM", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0028                  "Set to True when you want to use GEM clusters from the EMTF in the DQM")
0029 options.register("useB904ME11", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0030                  "Set to True when using B904 ME1/1 data.")
0031 options.register("useB904ME21", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0032                  "Set to True when using B904 ME2/1 data (also works for ME3/1 and ME4/1).")
0033 options.register("useB904ME234s2", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0034                  "Set to True when using B904 ME1/1 data (also works for MEX/2 and ME1/3).")
0035 options.register("run3", True, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0036                  "Set to True when using Run-3 data.")
0037 options.register("runCCLUTOTMB", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0038                  "Set to True when using the CCLUT OTMB algorithm.")
0039 options.register("runCCLUTTMB", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0040                  "Set to True when using the CCLUT TMB algorithm.")
0041 options.register("runME11ILT", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0042                  "Set to True when running the GEM-CSC integrated local trigger algorithm in ME1/1.")
0043 options.register("runME21ILT", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0044                  "Set to True when running the GEM-CSC integrated local trigger algorithm in ME2/1.")
0045 options.register("saveEdmOutput", True, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0046                  "Set to True if you want to keep the EDM ROOT after unpacking and re-emulating.")
0047 options.register("preTriggerAnalysis", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0048                  "Set to True if you want to print out more details about CLCTs and LCTs in the offline CSC DQM module.")
0049 options.register("dropNonMuonCollections", True, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0050                  "Option to drop most non-muon collections generally considered unnecessary for GEM/CSC analysis")
0051 options.register("dqmOutputFile", "step_DQM.root", VarParsing.multiplicity.singleton, VarParsing.varType.string,
0052                  "Name of the DQM output file. Default: step_DQM.root")
0053 options.parseArguments()
0054 
0055 process_era = Run3
0056 if not options.run3:
0057       process_era = Run2_2018
0058 
0059 process = cms.Process("L1CSCTPG", process_era)
0060 process.load("Configuration/StandardSequences/GeometryRecoDB_cff")
0061 process.load("Configuration/StandardSequences/MagneticField_cff")
0062 process.load("Configuration/StandardSequences/FrontierConditions_GlobalTag_cff")
0063 process.load('Configuration.StandardSequences.DQMSaverAtRunEnd_cff')
0064 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0065 process.load('Configuration.EventContent.EventContent_cff')
0066 process.load("EventFilter.CSCRawToDigi.cscUnpacker_cfi")
0067 process.load('EventFilter.GEMRawToDigi.muonGEMDigis_cfi')
0068 process.load('EventFilter.L1TRawToDigi.emtfStage2Digis_cfi')
0069 process.load("L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigis_cfi")
0070 process.load("CalibMuon.CSCCalibration.CSCL1TPLookupTableEP_cff")
0071 process.load('L1Trigger.L1TGEM.simGEMDigis_cff')
0072 process.load("DQM.L1TMonitor.L1TdeCSCTPG_cfi")
0073 process.load("DQM.L1TMonitor.L1TdeGEMTPG_cfi")
0074 
0075 process.maxEvents = cms.untracked.PSet(
0076       input = cms.untracked.int32(options.maxEvents)
0077 )
0078 
0079 process.options = cms.untracked.PSet(
0080       SkipEvent = cms.untracked.vstring('ProductNotFound')
0081 )
0082 
0083 process.source = cms.Source(
0084       "PoolSource",
0085       fileNames = cms.untracked.vstring(options.inputFiles),
0086       inputCommands = cms.untracked.vstring(
0087             'keep *',
0088             'drop CSCDetIdCSCShowerDigiMuonDigiCollection_simCscTriggerPrimitiveDigis_*_*'
0089       )
0090 )
0091 
0092 ## this line is needed to run the GEM unpacker on output from AMC13SpyReadout.py or readFile_b904_Run3.py
0093 if options.unpackGEM:
0094       process.source.labelRawDataLikeMC = cms.untracked.bool(False)
0095 
0096 ## global tag (data or MC, Run-2 or Run-3)
0097 from Configuration.AlCa.GlobalTag import GlobalTag
0098 if options.mc:
0099       process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
0100       if options.run3:
0101             process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2022_realistic', '')
0102 else:
0103       process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '')
0104       if options.run3:
0105             process.GlobalTag = GlobalTag(process.GlobalTag, '112X_dataRun3_Prompt_v5', '')
0106 
0107 ## running on unpacked data, or after running the unpacker
0108 if not options.mc or options.unpack:
0109       process.cscTriggerPrimitiveDigis.CSCComparatorDigiProducer = "muonCSCDigis:MuonCSCComparatorDigi"
0110       process.cscTriggerPrimitiveDigis.CSCWireDigiProducer = "muonCSCDigis:MuonCSCWireDigi"
0111 
0112 ## unpacker
0113 useB904Data = options.useB904ME11 or options.useB904ME21 or options.useB904ME234s2
0114 if useB904Data:
0115       ## CSC
0116       process.muonCSCDigis.DisableMappingCheck = True
0117       process.muonCSCDigis.B904Setup = True
0118       process.muonCSCDigis.InputObjects = "rawDataCollectorCSC"
0119       if options.unpackGEM:
0120             process.muonCSCDigis.useGEMs = True
0121       ## GEM
0122       process.muonGEMDigis.InputLabel = "rawDataCollectorGEM"
0123 
0124 ## l1 emulator
0125 l1csc = process.cscTriggerPrimitiveDigis
0126 if options.l1:
0127       l1csc.commonParam.runCCLUT_OTMB = cms.bool(options.runCCLUTOTMB)
0128       l1csc.commonParam.runCCLUT_TMB = cms.bool(options.runCCLUTTMB)
0129       l1csc.commonParam.runME11ILT = options.runME11ILT
0130       l1csc.commonParam.runME21ILT = options.runME21ILT
0131       ## running on unpacked data, or after running the unpacker
0132       if (not options.mc or options.unpack):
0133             l1csc.CSCComparatorDigiProducer = "muonCSCDigis:MuonCSCComparatorDigi"
0134             l1csc.CSCWireDigiProducer = "muonCSCDigis:MuonCSCWireDigi"
0135             ## GEM-CSC trigger enabled
0136             if options.runME11ILT or options.runME21ILT:
0137                   l1csc.GEMPadDigiClusterProducer = "muonCSCDigis:MuonGEMPadDigiCluster"
0138 
0139 if options.l1GEM:
0140       process.simMuonGEMPadDigis.InputCollection = 'muonGEMDigis'
0141 
0142 ## DQM monitor
0143 if options.dqm:
0144       process.l1tdeCSCTPG.useB904ME11 = options.useB904ME11
0145       process.l1tdeCSCTPG.useB904ME21 = options.useB904ME21
0146       process.l1tdeCSCTPG.useB904ME234s2 = options.useB904ME234s2
0147       process.l1tdeCSCTPG.emulALCT = "cscTriggerPrimitiveDigis"
0148       process.l1tdeCSCTPG.emulCLCT = "cscTriggerPrimitiveDigis"
0149       process.l1tdeCSCTPG.emulLCT = "cscTriggerPrimitiveDigis:MPCSORTED"
0150       process.l1tdeCSCTPG.preTriggerAnalysis = options.preTriggerAnalysis
0151 
0152 if options.dqmGEM:
0153       ## GEM pad clusters from the EMTF
0154       if options.useEmtfGEM:
0155             process.l1tdeGEMTPG.data = "emtfStage2Digis"
0156       ## GEM pad clusters from the CSC TPG
0157       else:
0158             process.l1tdeGEMTPG.data = "muonCSCDigis"
0159       ## GEM pad clusters from the GEM TPG
0160       process.l1tdeGEMTPG.emul = "simMuonGEMPadDigiClusters"
0161 
0162 # Output
0163 process.output = cms.OutputModule(
0164     "PoolOutputModule",
0165       outputCommands = cms.untracked.vstring(
0166             ['keep *',
0167              'drop *_rawDataCollector_*_*',
0168       ]),
0169       fileName = cms.untracked.string("lcts2.root"),
0170 )
0171 
0172 ## for most studies, you don't need these collections.
0173 ## adjust as necessary
0174 if options.dropNonMuonCollections:
0175       outputCom = process.output.outputCommands
0176       outputCom.append('drop *_rawDataCollector_*_*')
0177       outputCom.append('drop *_sim*al*_*_*')
0178       outputCom.append('drop *_hlt*al*_*_*')
0179       outputCom.append('drop *_g4SimHits_*al*_*')
0180       outputCom.append('drop *_simSi*_*_*')
0181       outputCom.append('drop *_hltSi*_*_*')
0182       outputCom.append('drop *_simBmtfDigis_*_*')
0183       outputCom.append('drop *_*_*BMTF*_*')
0184       outputCom.append('drop *_hltGtStage2ObjectMap_*_*')
0185       outputCom.append('drop *_simGtStage2Digis_*_*')
0186       outputCom.append('drop *_hltTriggerSummary*_*_*')
0187 
0188 ## DQM output
0189 process.DQMoutput = cms.OutputModule("DQMRootOutputModule",
0190     dataset = cms.untracked.PSet(
0191         dataTier = cms.untracked.string('DQMIO'),
0192         filterName = cms.untracked.string('')
0193     ),
0194     fileName = cms.untracked.string('file:{}'.format(options.dqmOutputFile)),
0195     outputCommands = process.DQMEventContent.outputCommands,
0196     splitLevel = cms.untracked.int32(0)
0197 )
0198 
0199 ## schedule and path definition
0200 process.unpacksequence = cms.Sequence(process.muonCSCDigis)
0201 
0202 ## when unpacking data only from select chambers...
0203 if options.selectCSCs:
0204 
0205       from EventFilter.CSCRawToDigi.cscDigiFilterDef_cfi import cscDigiFilterDef
0206 
0207       # clone the original producer
0208       process.preCSCDigis = process.muonCSCDigis.clone()
0209 
0210       # now apply the filter
0211       process.muonCSCDigis = cscDigiFilterDef.clone(
0212             stripDigiTag = "preCSCDigis:MuonCSCStripDigi",
0213             wireDigiTag = "preCSCDigis:MuonCSCWireDigi",
0214             compDigiTag = "preCSCDigis:MuonCSCComparatorDigi",
0215             alctDigiTag = "preCSCDigis:MuonCSCALCTDigi",
0216             clctDigiTag = "preCSCDigis:MuonCSCCLCTDigi",
0217             lctDigiTag = "preCSCDigis:MuonCSCCorrelatedLCTDigi",
0218             showerDigiTag = "preCSCDigis:MuonCSCShowerDigi",
0219             gemPadClusterDigiTag = "preCSCDigis:MuonGEMPadDigiCluster",
0220             maskedChambers = options.maskedChambers,
0221             selectedChambers = options.selectedChambers
0222       )
0223 
0224       # these 3 chambers had Phase-2 firmware loaded partially during Run-2
0225       # https://twiki.cern.ch/twiki/bin/viewauth/CMS/CSCOTMB2018
0226       process.muonCSCDigis.maskedChambers = [
0227             "ME+1/1/9", "ME+1/1/10", "ME+1/1/11"]
0228 
0229       process.unpacksequence = cms.Sequence(process.preCSCDigis * process.muonCSCDigis)
0230 
0231 if options.unpackGEM:
0232       ## unpack GEM strip digis
0233       process.unpacksequence += process.muonGEMDigis
0234       ## unpack GEM pad clusters from the EMTF
0235       if options.useEmtfGEM:
0236             process.unpacksequence += process.emtfStage2Digis
0237 process.p1 = cms.Path(process.unpacksequence)
0238 
0239 process.l1sequence = cms.Sequence(l1csc)
0240 if options.l1GEM:
0241       ## not sure if append would work for the GEM-CSC trigger
0242       ## maybe the modules need to come first
0243       process.l1sequence += process.simMuonGEMPadDigis
0244       process.l1sequence += process.simMuonGEMPadDigiClusters
0245 process.p2 = cms.Path(process.l1sequence)
0246 
0247 process.dqmsequence = cms.Sequence(process.l1tdeCSCTPG)
0248 if options.dqmGEM:
0249       process.dqmsequence += process.l1tdeGEMTPG
0250 process.p3 = cms.Path(process.dqmsequence)
0251 
0252 process.p4 = cms.EndPath(process.DQMoutput)
0253 process.p5 = cms.EndPath(process.output)
0254 process.p6 = cms.EndPath(process.endOfProcess)
0255 
0256 process.schedule = cms.Schedule()
0257 ## add the unpacker
0258 if options.unpack:
0259       process.schedule.extend([process.p1])
0260 
0261 ## add the emulator
0262 if options.l1:
0263       process.schedule.extend([process.p2])
0264 
0265 ## add DQM step 1
0266 if options.dqm:
0267       process.schedule.extend([process.p3, process.p4])
0268 
0269 if options.saveEdmOutput:
0270       process.schedule.extend([process.p5])
0271 
0272 process.schedule.extend([process.p6])