File indexing completed on 2024-11-26 02:34:08
0001 from builtins import range
0002 import os, sys
0003 import FWCore.ParameterSet.Config as cms
0004
0005
0006 import FWCore.ParameterSet.VarParsing as VarParsing
0007 from .dqmPythonTypes import *
0008
0009 '''
0010 check that the input directory exists and there are files in it
0011 '''
0012 def checkInputFolder(streamer_folder):
0013 if not (os.path.exists(streamer_folder) and os.path.isdir(os.path.join(streamer_folder))):
0014 raise IOError("Input folder '%s' does not exist in CMSSW_SEARCH_PATH" % streamer_folder)
0015
0016 items = os.listdir(dqm_streamer_folder)
0017 if not items:
0018 raise IOError("Input folder '%s' does not contain any file" % streamer_folder)
0019
0020
0021 options = VarParsing.VarParsing("analysis")
0022
0023
0024 options.register('runkey',
0025 'pp_run',
0026 VarParsing.VarParsing.multiplicity.singleton,
0027 VarParsing.VarParsing.varType.string,
0028 "Run Keys of CMS")
0029
0030
0031 options.register('runUniqueKey',
0032 'InValid',
0033 VarParsing.VarParsing.multiplicity.singleton,
0034 VarParsing.VarParsing.varType.string,
0035 "Unique run key from RCMS for Frontier")
0036
0037 options.register('runNumber',
0038 356383,
0039 VarParsing.VarParsing.multiplicity.singleton,
0040 VarParsing.VarParsing.varType.int,
0041 "Run number. This run number has to be present in https://github.com/cms-data/DQM-Integration")
0042
0043 options.register('datafnPosition',
0044 3,
0045 VarParsing.VarParsing.multiplicity.singleton,
0046 VarParsing.VarParsing.varType.int,
0047 "Data filename position in the positional arguments array 'data' in json file.")
0048
0049 options.register('streamLabel',
0050 '',
0051 VarParsing.VarParsing.multiplicity.singleton,
0052 VarParsing.VarParsing.varType.string,
0053 "Name of the stream")
0054
0055 options.register('noDB',
0056 True,
0057 VarParsing.VarParsing.multiplicity.singleton,
0058 VarParsing.VarParsing.varType.bool,
0059 "Don't upload the BeamSpot conditions to the DB")
0060
0061 options.register('scanOnce',
0062 True,
0063 VarParsing.VarParsing.multiplicity.singleton,
0064 VarParsing.VarParsing.varType.bool,
0065 "Don't repeat file scans: use what was found during the initial scan. EOR file is ignored and the state is set to 'past end of run'.")
0066
0067 options.register('skipFirstLumis',
0068 False,
0069 VarParsing.VarParsing.multiplicity.singleton,
0070 VarParsing.VarParsing.varType.bool,
0071 "Skip (and ignore the minEventsPerLumi parameter) for the files which have been available at the beginning of the processing.")
0072
0073 options.register('BeamSplashRun',
0074 False,
0075 VarParsing.VarParsing.multiplicity.singleton,
0076 VarParsing.VarParsing.varType.bool,
0077 "Set client source settings for beam SPLASH run")
0078
0079
0080
0081 options.register('unitTest',
0082 True,
0083 VarParsing.VarParsing.multiplicity.singleton,
0084 VarParsing.VarParsing.varType.bool,
0085 "Required to avoid the error.")
0086
0087 options.parseArguments()
0088
0089
0090 dqm_integration_data = [os.path.join(dir,'DQM/Integration/data') for dir in os.getenv('CMSSW_SEARCH_PATH','').split(":") if os.path.exists(os.path.join(dir,'DQM/Integration/data'))][0]
0091 dqm_streamer_folder = os.path.join(dqm_integration_data,'run'+str(options.runNumber))
0092 print("Reading streamer files from:\n ",dqm_streamer_folder)
0093 checkInputFolder(dqm_streamer_folder)
0094
0095 maxEvents = cms.untracked.PSet(
0096 input = cms.untracked.int32(-1)
0097 )
0098
0099 runType = RunType()
0100 if not options.runkey.strip():
0101 options.runkey = "pp_run"
0102
0103 runType.setRunType(options.runkey.strip())
0104
0105
0106
0107
0108 streamLabel = options.streamLabel
0109 if streamLabel == '':
0110 if runType.getRunType() == runType.hi_run:
0111 streamLabel = 'streamHIDQM'
0112 else:
0113 streamLabel = 'streamDQM'
0114
0115
0116 source = cms.Source("DQMStreamerReader",
0117 runNumber = cms.untracked.uint32(options.runNumber),
0118 runInputDir = cms.untracked.string(dqm_integration_data),
0119 SelectEvents = cms.untracked.vstring('*'),
0120 streamLabel = cms.untracked.string(streamLabel),
0121 scanOnce = cms.untracked.bool(options.scanOnce),
0122 datafnPosition = cms.untracked.uint32(options.datafnPosition),
0123 minEventsPerLumi = cms.untracked.int32(1000),
0124 delayMillis = cms.untracked.uint32(500),
0125 nextLumiTimeoutMillis = cms.untracked.int32(0),
0126 skipFirstLumis = cms.untracked.bool(options.skipFirstLumis),
0127 deleteDatFiles = cms.untracked.bool(False),
0128 endOfRunKills = cms.untracked.bool(False),
0129 inputFileTransitionsEachEvent = cms.untracked.bool(False),
0130 unitTest = cms.untracked.bool(True)
0131 )