Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-22 22:47:11

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 ME4/2 data (also works for MEX/2 and ME1/3).")
0035 options.register('useB904ME11PositiveEndcap',False,VarParsing.multiplicity.singleton,VarParsing.varType.bool,
0036                  "Set to True when using data from ME1/1 set as Positive Endcap chamber in B904.")
0037 options.register('useB904ME11NegativeEndcap',False,VarParsing.multiplicity.singleton,VarParsing.varType.bool,
0038                  "Set to True when using data from ME1/1 set as Negative Endcap chamber in B904.")
0039 options.register('useB904GE11Short',False,VarParsing.multiplicity.singleton,VarParsing.varType.bool,
0040                  "Set to True when using data from GE1/1 Short super chamber in B904.")
0041 options.register('useB904GE11Long',False,VarParsing.multiplicity.singleton,VarParsing.varType.bool,
0042                  "Set to True when using data from GE1/1 Long super chamber in B904.")
0043 options.register("run3", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0044                  "Set to True when using Run-3 data.")
0045 options.register("runCCLUTOTMB", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0046                  "Set to True when using the CCLUT OTMB algorithm.")
0047 options.register("runCCLUTTMB", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0048                  "Set to True when using the CCLUT TMB algorithm.")
0049 options.register("runME11ILT", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0050                  "Set to True when running the GEM-CSC integrated local trigger algorithm in ME1/1.")
0051 options.register("runME21ILT", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0052                  "Set to True when running the GEM-CSC integrated local trigger algorithm in ME2/1.")
0053 options.register("saveEdmOutput", True, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0054                  "Set to True if you want to keep the EDM ROOT after unpacking and re-emulating.")
0055 options.register("preTriggerAnalysis", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0056                  "Set to True if you want to print out more details about CLCTs and LCTs in the offline CSC DQM module.")
0057 options.register("dropNonMuonCollections", True, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0058                  "Option to drop most non-muon collections generally considered unnecessary for GEM/CSC analysis")
0059 options.register("dqmOutputFile", "step_DQM.root", VarParsing.multiplicity.singleton, VarParsing.varType.string,
0060                  "Name of the DQM output file. Default: step_DQM.root")
0061 options.parseArguments()
0062 
0063 process_era = Run3
0064 if not options.run3:
0065       process_era = Run2_2018
0066 
0067 process = cms.Process("L1CSCTPG", process_era)
0068 process.load("Configuration/StandardSequences/GeometryRecoDB_cff")
0069 process.load("Configuration/StandardSequences/MagneticField_cff")
0070 process.load("Configuration/StandardSequences/FrontierConditions_GlobalTag_cff")
0071 process.load('Configuration.StandardSequences.DQMSaverAtRunEnd_cff')
0072 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0073 process.load('Configuration.EventContent.EventContent_cff')
0074 process.load("EventFilter.CSCRawToDigi.cscUnpacker_cfi")
0075 process.load('EventFilter.GEMRawToDigi.muonGEMDigis_cfi')
0076 process.load('EventFilter.L1TRawToDigi.emtfStage2Digis_cfi')
0077 process.load("L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigis_cfi")
0078 process.load("CalibMuon.CSCCalibration.CSCL1TPLookupTableEP_cff")
0079 process.load('L1Trigger.L1TGEM.simGEMDigis_cff')
0080 process.load("DQM.L1TMonitor.L1TdeCSCTPG_cfi")
0081 process.load("DQM.L1TMonitor.L1TdeGEMTPG_cfi")
0082 
0083 process.maxEvents = cms.untracked.PSet(
0084       input = cms.untracked.int32(options.maxEvents)
0085 )
0086 
0087 process.options = cms.untracked.PSet(
0088       SkipEvent = cms.untracked.vstring('ProductNotFound')
0089 )
0090 
0091 process.source = cms.Source(
0092       "PoolSource",
0093       fileNames = cms.untracked.vstring(options.inputFiles),
0094       inputCommands = cms.untracked.vstring(
0095             'keep *',
0096             'drop CSCDetIdCSCShowerDigiMuonDigiCollection_simCscTriggerPrimitiveDigis_*_*'
0097       )
0098 )
0099 
0100 ## this line is needed to run the GEM unpacker on output from AMC13SpyReadout.py or readFile_b904_Run3.py
0101 if options.unpackGEM:
0102       process.source.labelRawDataLikeMC = cms.untracked.bool(False)
0103 
0104 ## global tag (data or MC, Run-2 or Run-3)
0105 from Configuration.AlCa.GlobalTag import GlobalTag
0106 if options.mc:
0107       process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
0108       if options.run3:
0109             process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2022_realistic', '')
0110 else:
0111       process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '')
0112       if options.run3:
0113             process.GlobalTag = GlobalTag(process.GlobalTag, '112X_dataRun3_Prompt_v5', '')
0114 
0115 ## running on unpacked data, or after running the unpacker
0116 if not options.mc or options.unpack:
0117       process.cscTriggerPrimitiveDigis.CSCComparatorDigiProducer = "muonCSCDigis:MuonCSCComparatorDigi"
0118       process.cscTriggerPrimitiveDigis.CSCWireDigiProducer = "muonCSCDigis:MuonCSCWireDigi"
0119 
0120 ## unpacker
0121 useB904Data = options.useB904ME11 or options.useB904ME21 or options.useB904ME234s2
0122 if useB904Data:
0123       ## CSC
0124       process.muonCSCDigis.DisableMappingCheck = True
0125       process.muonCSCDigis.B904Setup = True
0126       process.muonCSCDigis.InputObjects = "rawDataCollectorCSC"
0127       
0128       if options.useB904ME11:
0129       
0130         if options.useB904ME11PositiveEndcap + options.useB904ME11NegativeEndcap == 2:
0131             print("Choose at most one between useB904ME11PositiveEndcap and useB904ME11NegativeEndcap!")
0132         elif options.useB904ME11NegativeEndcap: # Set manually the VME crate number for ME-1/1/02
0133             process.muonCSCDigis.B904vmecrate = 31
0134         else: # Set manually the VME crate number for ME+1/1/02
0135             process.muonCSCDigis.B904vmecrate = 1
0136             
0137         if options.useB904GE11Short + options.useB904GE11Long == 2:
0138             print("Choose at most one between useB904GE11Short and useB904GE11Long!")
0139         elif options.useB904GE11Short: # Set manually the DMB slot for ME+-1/1/01
0140             process.muonCSCDigis.B904dmb = 2
0141         else: # Set manually the DMB slot for ME+-1/1/02
0142             process.muonCSCDigis.B904dmb = 3
0143       
0144       elif options.useB904ME21: # Set manually the VME crate number and default DMB for ME+2/1/01
0145           process.muonCSCDigis.B904vmecrate = 18
0146           process.muonCSCDigis.B904dmb = 3
0147       
0148       elif options.useB904ME234s2: # Set manually the VME crate number and default DMB for ME+4/2/01
0149           process.muonCSCDigis.B904vmecrate = 30
0150           process.muonCSCDigis.B904dmb = 9
0151           
0152       else: # Set manually the VME crate number and default DMB for ME+1/1/02
0153           process.muonCSCDigis.B904vmecrate = 1
0154           process.muonCSCDigis.B904dmb = 3
0155 
0156       if options.unpackGEM:
0157           process.muonCSCDigis.useGEMs = True
0158 
0159       ## GEM mapping for b904 GEM-CSC integration stand
0160       process.GlobalTag.toGet = cms.VPSet(
0161               cms.PSet(record = cms.string("GEMChMapRcd"),
0162                        tag = cms.string("GEMeMap_GE11_b904_v1"),
0163                        connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS")
0164                       )
0165       )
0166       process.muonGEMDigis.useDBEMap = True
0167       process.muonGEMDigis.InputLabel = "rawDataCollectorGEM"
0168       process.muonGEMDigis.fedIdStart = 1478
0169       process.muonGEMDigis.fedIdEnd = 1478
0170 
0171 ## l1 emulator
0172 l1csc = process.cscTriggerPrimitiveDigis
0173 if options.l1:
0174       l1csc.commonParam.run3 = cms.bool(options.run3)
0175       l1csc.commonParam.runCCLUT_OTMB = cms.bool(options.runCCLUTOTMB)
0176       l1csc.commonParam.runCCLUT_TMB = cms.bool(options.runCCLUTTMB)
0177       l1csc.commonParam.runME11ILT = options.runME11ILT
0178       l1csc.commonParam.runME21ILT = options.runME21ILT
0179       ## running on unpacked data, or after running the unpacker
0180       if (not options.mc or options.unpack):
0181             l1csc.CSCComparatorDigiProducer = "muonCSCDigis:MuonCSCComparatorDigi"
0182             l1csc.CSCWireDigiProducer = "muonCSCDigis:MuonCSCWireDigi"
0183             ## GEM-CSC trigger enabled
0184             if options.runME11ILT or options.runME21ILT:
0185                   l1csc.GEMPadDigiClusterProducer = "muonCSCDigis:MuonGEMPadDigiCluster"
0186 
0187 if options.l1GEM:
0188       process.simMuonGEMPadDigis.InputCollection = 'muonGEMDigis'
0189 
0190 ## DQM monitor
0191 if options.dqm:
0192       process.l1tdeCSCTPG.useB904ME11 = options.useB904ME11
0193       process.l1tdeCSCTPG.useB904ME21 = options.useB904ME21
0194       process.l1tdeCSCTPG.useB904ME234s2 = options.useB904ME234s2
0195       process.l1tdeCSCTPG.emulALCT = "cscTriggerPrimitiveDigis"
0196       process.l1tdeCSCTPG.emulCLCT = "cscTriggerPrimitiveDigis"
0197       process.l1tdeCSCTPG.emulLCT = "cscTriggerPrimitiveDigis:MPCSORTED"
0198       process.l1tdeCSCTPG.preTriggerAnalysis = options.preTriggerAnalysis
0199 
0200 if options.dqmGEM:
0201       ## GEM pad clusters from the EMTF
0202       if options.useEmtfGEM:
0203             process.l1tdeGEMTPG.data = "emtfStage2Digis"
0204       ## GEM pad clusters from the CSC TPG
0205       else:
0206             process.l1tdeGEMTPG.data = "muonCSCDigis:MuonGEMPadDigiCluster"
0207       ## GEM pad clusters from the GEM TPG
0208       process.l1tdeGEMTPG.emul = "simMuonGEMPadDigiClusters"
0209 
0210 # Output
0211 process.output = cms.OutputModule(
0212     "PoolOutputModule",
0213       outputCommands = cms.untracked.vstring(
0214             ['keep *',
0215              'drop *_rawDataCollector_*_*',
0216       ]),
0217       fileName = cms.untracked.string("lcts2.root"),
0218 )
0219 
0220 ## for most studies, you don't need these collections.
0221 ## adjust as necessary
0222 if options.dropNonMuonCollections:
0223       outputCom = process.output.outputCommands
0224       outputCom.append('drop *_rawDataCollector_*_*')
0225       outputCom.append('drop *_sim*al*_*_*')
0226       outputCom.append('drop *_hlt*al*_*_*')
0227       outputCom.append('drop *_g4SimHits_*al*_*')
0228       outputCom.append('drop *_simSi*_*_*')
0229       outputCom.append('drop *_hltSi*_*_*')
0230       outputCom.append('drop *_simBmtfDigis_*_*')
0231       outputCom.append('drop *_*_*BMTF*_*')
0232       outputCom.append('drop *_hltGtStage2ObjectMap_*_*')
0233       outputCom.append('drop *_simGtStage2Digis_*_*')
0234       outputCom.append('drop *_hltTriggerSummary*_*_*')
0235 
0236 ## DQM output
0237 process.DQMoutput = cms.OutputModule("DQMRootOutputModule",
0238     dataset = cms.untracked.PSet(
0239         dataTier = cms.untracked.string('DQMIO'),
0240         filterName = cms.untracked.string('')
0241     ),
0242     fileName = cms.untracked.string('file:{}'.format(options.dqmOutputFile)),
0243     outputCommands = process.DQMEventContent.outputCommands,
0244     splitLevel = cms.untracked.int32(0)
0245 )
0246 
0247 ## schedule and path definition
0248 process.unpacksequence = cms.Sequence(process.muonCSCDigis)
0249 
0250 ## when unpacking data only from select chambers...
0251 if options.selectCSCs:
0252 
0253       from EventFilter.CSCRawToDigi.cscDigiFilterDef_cfi import cscDigiFilterDef
0254 
0255       # clone the original producer
0256       process.preCSCDigis = process.muonCSCDigis.clone()
0257 
0258       # now apply the filter
0259       process.muonCSCDigis = cscDigiFilterDef.clone(
0260             stripDigiTag = "preCSCDigis:MuonCSCStripDigi",
0261             wireDigiTag = "preCSCDigis:MuonCSCWireDigi",
0262             compDigiTag = "preCSCDigis:MuonCSCComparatorDigi",
0263             alctDigiTag = "preCSCDigis:MuonCSCALCTDigi",
0264             clctDigiTag = "preCSCDigis:MuonCSCCLCTDigi",
0265             lctDigiTag = "preCSCDigis:MuonCSCCorrelatedLCTDigi",
0266             showerDigiTag = "preCSCDigis:MuonCSCShowerDigi",
0267             gemPadClusterDigiTag = "preCSCDigis:MuonGEMPadDigiCluster",
0268             maskedChambers = options.maskedChambers,
0269             selectedChambers = options.selectedChambers
0270       )
0271 
0272       # these 3 chambers had Phase-2 firmware loaded partially during Run-2
0273       # https://twiki.cern.ch/twiki/bin/viewauth/CMS/CSCOTMB2018
0274       process.muonCSCDigis.maskedChambers = [
0275             "ME+1/1/9", "ME+1/1/10", "ME+1/1/11"]
0276 
0277       process.unpacksequence = cms.Sequence(process.preCSCDigis * process.muonCSCDigis)
0278 
0279 if options.unpackGEM:
0280       ## unpack GEM strip digis
0281       process.unpacksequence += process.muonGEMDigis
0282       ## unpack GEM pad clusters from the EMTF
0283       if options.useEmtfGEM:
0284             process.unpacksequence += process.emtfStage2Digis
0285 process.p1 = cms.Path(process.unpacksequence)
0286 
0287 process.l1sequence = cms.Sequence(l1csc)
0288 if options.l1GEM:
0289       ## not sure if append would work for the GEM-CSC trigger
0290       ## maybe the modules need to come first
0291       process.l1sequence += process.simMuonGEMPadDigis
0292       process.l1sequence += process.simMuonGEMPadDigiClusters
0293 process.p2 = cms.Path(process.l1sequence)
0294 
0295 process.dqmsequence = cms.Sequence(process.l1tdeCSCTPG)
0296 if options.dqmGEM:
0297       process.dqmsequence += process.l1tdeGEMTPG
0298 process.p3 = cms.Path(process.dqmsequence)
0299 
0300 process.p4 = cms.EndPath(process.DQMoutput)
0301 process.p5 = cms.EndPath(process.output)
0302 process.p6 = cms.EndPath(process.endOfProcess)
0303 
0304 process.schedule = cms.Schedule()
0305 ## add the unpacker
0306 if options.unpack:
0307       process.schedule.extend([process.p1])
0308 
0309 ## add the emulator
0310 if options.l1:
0311       process.schedule.extend([process.p2])
0312 
0313 ## add DQM step 1
0314 if options.dqm:
0315       process.schedule.extend([process.p3, process.p4])
0316 
0317 if options.saveEdmOutput:
0318       process.schedule.extend([process.p5])
0319 
0320 process.schedule.extend([process.p6])