Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:14

0001 import FWCore.ParameterSet.Config as cms
0002 from FWCore.ParameterSet.VarParsing import VarParsing
0003 
0004 process = cms.Process("reader")
0005 
0006 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0007 process.MessageLogger.cout.threshold = cms.untracked.string('INFO')
0008 process.MessageLogger.debugModules = cms.untracked.vstring('*')
0009 
0010 process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )
0011 
0012 options = VarParsing ('analysis')
0013 options.register("firstRun", 341761, VarParsing.multiplicity.singleton, VarParsing.varType.int,
0014                  "The first run for this data. Typically for Run-3 it needs to be set high enough, so that \
0015                   cmsRun recognizes GEM detectors as valid. That is the case starting run 341761. Beyond making \
0016                   sure that the GEM detectors are there, firstRun does not have a meaning.")
0017 options.register("inputFilesGEM", "", VarParsing.multiplicity.singleton, VarParsing.varType.string,
0018                  "The GEM input file (if applicable). This needs to be filled for joint GEM-CSC runs with B904 ME1/1 test-stand.")
0019 options.register("readGEMData", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0020                  "Set to True when you want to process the GEM data as well as the CSC data.")
0021 options.register("useB904ME11", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0022                  "Set to True when using B904 ME1/1 data.")
0023 options.register("useB904ME21", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0024                  "Set to True when using B904 ME2/1 data (also works for ME3/1 and ME4/1).")
0025 options.register("useB904ME234s2", False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0026                  "Set to True when using B904 ME1/1 data (also works for MEX/2 and ME1/3).")
0027 options.maxEvents = 10000
0028 options.parseArguments()
0029 
0030 # Better to know actual number of events in the .raw data file to set maxEvents.
0031 # Otherwise it doesn't stop automatically at the end of reading of .raw data file
0032 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) )
0033 
0034 ## when reading GEM data and CSC data, use the FRDStreamSource
0035 ## this source can read the GEM data
0036 if options.readGEMData:
0037     process.source = cms.Source(
0038         "FRDStreamSource",
0039         fileNames = cms.untracked.vstring(options.inputFilesGEM),
0040         verifyAdler32 = cms.untracked.bool(False),
0041         verifyChecksum = cms.untracked.bool(False),
0042         useL1EventID = cms.untracked.bool(False),
0043         firstLuminosityBlockForEachRun = cms.untracked.VLuminosityBlockID(*[cms.LuminosityBlockID(options.firstRun,0)]),
0044     )
0045 ## otherwise, just use an empty source
0046 ## reading the CSC data is done with a the CSCFileReader producer
0047 else:
0048     process.source = cms.Source(
0049         "EmptySource",
0050         firstRun= cms.untracked.uint32(options.firstRun),
0051         numberEventsInLuminosityBlock = cms.untracked.uint32(200),
0052         numberEventsInRun       = cms.untracked.uint32(0)
0053     )
0054 
0055 ## this block ensures that the GEM output collection is named rawDataCollectorGEM, not source
0056 process.rawDataCollectorGEM = cms.EDAlias(
0057     source = cms.VPSet(
0058         cms.PSet(
0059             type = cms.string('FEDRawDataCollection')
0060         )
0061     )
0062 )
0063 
0064 # For B904 setup ME11 chamber, which corresponds to ME+1/1/02 in the production system mapping
0065 # changing to FED837 and RUI16 could let to pass data without disabling mapping consistency check unpacking flags
0066 if options.useB904ME11:
0067     FEDRUI = cms.PSet(
0068         FED846 = cms.untracked.vstring('RUI01'),
0069         RUI01 = cms.untracked.vstring(options.inputFiles[0])
0070     )
0071 # For B904 setup ME21 chamber, which corresponds to ME+2/1/03 VMECrate13 / DMBSlot2 RUI17 / FED838 in the production system mapping
0072 elif options.useB904ME21:
0073     FEDRUI = cms.PSet(
0074         FED838 = cms.untracked.vstring('RUI17'),
0075         RUI17 = cms.untracked.vstring(options.inputFiles[0])
0076     )
0077 # Please note that after passing mapping check this chamber still would be recognized as production chamber
0078 # ME+2/2/03, which is OK, because this is the same chamber type as ME42 hardware-wise.
0079 elif options.useB904ME234s2:
0080     FEDRUI = cms.PSet(
0081         FED839 = cms.untracked.vstring('RUI18'),
0082         RUI18 = cms.untracked.vstring(options.inputFiles[0])
0083     )
0084 ## default case
0085 else:
0086     FEDRUI = cms.PSet(
0087         FED837 = cms.untracked.vstring('RUI16'),
0088         RUI16 = cms.untracked.vstring('/afs/cern.ch/user/b/barvic/public/cscgem_tests/csc_00000001_EmuRUI01_Local_000_210519_162820_UTC.raw')
0089     )
0090 
0091 # Note by Sven Dildick: I had to change the CSC producer module name to process.rawDataCollectorCSC so
0092 # that the name would not conflict with the GEM source.
0093 process.rawDataCollectorCSC = cms.EDProducer(
0094     'CSCFileReader',
0095     FEDRUI,
0096     firstEvent  = cms.untracked.int32(0),
0097 )
0098 
0099 process.FEVT = cms.OutputModule(
0100     "PoolOutputModule",
0101     fileName = cms.untracked.string(options.inputFiles[0].replace('.raw','.root')),
0102     outputCommands = cms.untracked.vstring(
0103         "keep *",
0104         ## drop the collection named "source" - incompatible with later CMSSW
0105         "drop FEDRawDataCollection_source_*_*",
0106         "keep FEDRawDataCollection_rawDataCollectorCSC_*_*",
0107         "keep FEDRawDataCollection_rawDataCollectorGEM_*_*"
0108     )
0109 )
0110 
0111 process.p = cms.Path(process.rawDataCollectorCSC)
0112 
0113 process.outpath = cms.EndPath(process.FEVT)