/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
HLTrigger/Tools/python/convertToRaw.py
134 строки
5 KB
Marino Missiroli
fix PSet of EvFDaqDirector in convertToRaw.py
15 апр 2024, 11:03
15 апр 2024, 11:03
d25081c
Код
Авторство
О чём код?
# Convert the RAW data from EDM .root files into DAQ .raw format # # usage: cmsRun $CMSSW_RELEASE_BASE/HLTrigger/Tools/python/convertToRaw.py \ # inputFiles=/store/path/file.root[,/store/path/file.root,...] \ # runNumber=NNNNNN \ # [lumiNumber=NNNN] \ # [eventsPerFile=50] \ # [eventsPerLumi=11650] \ # [rawDataCollection=rawDataCollector] \ # [outputPath=output_directory] # # The output files will appear as output_directory/runNNNNNN/runNNNNNN_lumiNNNN_indexNNNNNN.raw . import sys import os import FWCore.ParameterSet.Config as cms import FWCore.ParameterSet.VarParsing as VarParsing process = cms.Process("FAKE") process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) # to be overwritten after parsing the command line options ) process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring() # to be overwritten after parsing the command line options ) from EventFilter.Utilities.EvFDaqDirector_cfi import EvFDaqDirector as _EvFDaqDirector process.EvFDaqDirector = _EvFDaqDirector.clone( baseDir = "", # to be overwritten after parsing the command line options buBaseDir = "", # to be overwritten after parsing the command line options runNumber = 0 # to be overwritten after parsing the command line options ) process.writer = cms.OutputModule("RawStreamFileWriterForBU", source = cms.InputTag('rawDataCollector'), # to be overwritten after parsing the command line options numEventsPerFile = cms.uint32(0) # to be overwritten after parsing the command line options ) process.endpath = cms.EndPath(process.writer) process.load('FWCore.MessageService.MessageLogger_cfi') process.MessageLogger.cerr.FwkReport.reportEvery = 0 # to be overwritten after parsing the command line options # parse command line options options = VarParsing.VarParsing ('python') for name in 'filePrepend', 'maxEvents', 'outputFile', 'secondaryOutputFile', 'section', 'tag', 'storePrepend', 'totalSections': del options._register[name] del options._beenSet[name] del options._info[name] del options._types[name] if name in options._singletons: del options._singletons[name] if name in options._lists: del options._lists[name] if name in options._noCommaSplit: del options._noCommaSplit[name] if name in options._noDefaultClear: del options._noDefaultClear[name] options.register('runNumber', 0, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Run number to use") options.register('lumiNumber', None, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Luminosity section number to use") options.register('eventsPerLumi', 11650, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Number of events in the given luminosity section to process") options.register('eventsPerFile', 50, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Split the output into files with at most this number of events") options.register('rawDataCollection', 'rawDataCollector', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "FEDRawDataCollection to be repacked into RAW format") options.register('outputPath', os.getcwd(), VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Output directory for the FED RAW data files") options.parseArguments() # check that the option values are valide if options.runNumber <= 0: sys.stderr.write('Invalid run number\n') sys.exit(1) if options.lumiNumber is not None and options.lumiNumber <= 0: sys.stderr.write('Invalid luminosity section number\n') sys.exit(1) if options.eventsPerLumi == 0 or options.eventsPerLumi < -1: sys.stderr.write('Invalid number of events per luminosity section\n') sys.exit(1) if options.eventsPerFile <= 0: sys.stderr.write('Invalid number of events per output file\n') sys.exit(1) # configure the job based on the command line options process.source.fileNames = options.inputFiles if options.lumiNumber is not None: # process only one lumisection process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange('%d:%d' % (options.runNumber, options.lumiNumber)) process.maxEvents.input = options.eventsPerLumi process.EvFDaqDirector.runNumber = options.runNumber process.EvFDaqDirector.baseDir = options.outputPath process.EvFDaqDirector.buBaseDir = options.outputPath process.writer.source = options.rawDataCollection process.writer.numEventsPerFile = options.eventsPerFile process.MessageLogger.cerr.FwkReport.reportEvery = options.eventsPerFile # create the output directory, if it does not exist outputRunPath = f'{options.outputPath}/run{options.runNumber:06d}' os.makedirs(outputRunPath, exist_ok=True) open(f'{outputRunPath}/fu.lock', 'w').close()