Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-22 02:23:32

0001 from __future__ import print_function
0002 from __future__ import absolute_import
0003 from builtins import range
0004 import os, sys
0005 import FWCore.ParameterSet.Config as cms
0006 
0007 # Parameters for runType
0008 import FWCore.ParameterSet.VarParsing as VarParsing
0009 from .dqmPythonTypes import *
0010 
0011 '''
0012 check that the input directory exists and there are files in it
0013 '''
0014 def checkInputFolder(streamer_folder):
0015     if not (os.path.exists(streamer_folder) and os.path.isdir(os.path.join(streamer_folder))):
0016         raise IOError("Input folder '%s' does not exist in CMSSW_SEARCH_PATH" % streamer_folder)
0017 
0018     items = os.listdir(dqm_streamer_folder)
0019     if not items:
0020         raise IOError("Input folder '%s' does not contain any file" % streamer_folder)
0021 
0022 # Dedine and register options
0023 options = VarParsing.VarParsing("analysis")
0024 
0025 # Parameters for runType
0026 options.register('runkey',
0027                  'pp_run',
0028                  VarParsing.VarParsing.multiplicity.singleton,
0029                  VarParsing.VarParsing.varType.string,
0030                  "Run Keys of CMS")
0031 
0032 # Parameter for frontierKey
0033 options.register('runUniqueKey',
0034                  'InValid',
0035                  VarParsing.VarParsing.multiplicity.singleton,
0036                  VarParsing.VarParsing.varType.string,
0037                  "Unique run key from RCMS for Frontier")
0038 
0039 options.register('runNumber',
0040                  356383,
0041                  VarParsing.VarParsing.multiplicity.singleton,
0042                  VarParsing.VarParsing.varType.int,
0043                  "Run number. This run number has to be present in https://github.com/cms-data/DQM-Integration")
0044 
0045 options.register('datafnPosition',
0046                  3, # default value
0047                  VarParsing.VarParsing.multiplicity.singleton,
0048                  VarParsing.VarParsing.varType.int,
0049                  "Data filename position in the positional arguments array 'data' in json file.")
0050 
0051 options.register('streamLabel',
0052                  '',
0053                  VarParsing.VarParsing.multiplicity.singleton,
0054                  VarParsing.VarParsing.varType.string,
0055                  "Name of the stream")
0056 
0057 options.register('noDB',
0058                  True, # default value
0059                  VarParsing.VarParsing.multiplicity.singleton,
0060                  VarParsing.VarParsing.varType.bool,
0061                  "Don't upload the BeamSpot conditions to the DB")
0062 
0063 options.register('scanOnce',
0064                  True, # default value
0065                  VarParsing.VarParsing.multiplicity.singleton,
0066                  VarParsing.VarParsing.varType.bool,
0067                  "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'.")
0068 
0069 options.register('skipFirstLumis',
0070                  False, # default value
0071                  VarParsing.VarParsing.multiplicity.singleton,
0072                  VarParsing.VarParsing.varType.bool,
0073                  "Skip (and ignore the minEventsPerLumi parameter) for the files which have been available at the beginning of the processing.")
0074 
0075 options.register('BeamSplashRun',
0076                  False, # default value
0077                  VarParsing.VarParsing.multiplicity.singleton,
0078                  VarParsing.VarParsing.varType.bool,
0079                  "Set client source settings for beam SPLASH run")
0080 
0081 # This is used only by the online clients themselves. 
0082 # We need to register it here because otherwise an error occurs saying that there is an unidentified option.
0083 options.register('unitTest',
0084                  True,
0085                  VarParsing.VarParsing.multiplicity.singleton,
0086                  VarParsing.VarParsing.varType.bool,
0087                  "Required to avoid the error.")
0088 
0089 options.parseArguments()
0090 
0091 # Read streamer files from https://github.com/cms-data/DQM-Integration
0092 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]
0093 dqm_streamer_folder = os.path.join(dqm_integration_data,'run'+str(options.runNumber))
0094 print("Reading streamer files from:\n ",dqm_streamer_folder)
0095 checkInputFolder(dqm_streamer_folder)
0096 
0097 maxEvents = cms.untracked.PSet(
0098     input = cms.untracked.int32(-1)
0099 )
0100 
0101 runType = RunType()
0102 if not options.runkey.strip():
0103     options.runkey = "pp_run"
0104 
0105 runType.setRunType(options.runkey.strip())
0106 
0107 # stream label
0108 #  If streamLabel is empty, so not specified as a command-line argument,
0109 #  use the default value, i.e. "streamHIDQM" for runType==hi_run and "streamDQM" otherwise
0110 streamLabel = options.streamLabel
0111 if streamLabel == '':
0112     if runType.getRunType() == runType.hi_run:
0113         streamLabel = 'streamHIDQM'
0114     else:
0115         streamLabel = 'streamDQM'
0116 
0117 # Set the process source
0118 source = cms.Source("DQMStreamerReader",
0119     runNumber = cms.untracked.uint32(options.runNumber),
0120     runInputDir = cms.untracked.string(dqm_integration_data),
0121     SelectEvents = cms.untracked.vstring('*'),
0122     streamLabel = cms.untracked.string(streamLabel),
0123     scanOnce = cms.untracked.bool(options.scanOnce),
0124     datafnPosition = cms.untracked.uint32(options.datafnPosition),
0125     minEventsPerLumi = cms.untracked.int32(1000),
0126     delayMillis = cms.untracked.uint32(500),
0127     nextLumiTimeoutMillis = cms.untracked.int32(0),
0128     skipFirstLumis = cms.untracked.bool(options.skipFirstLumis),
0129     deleteDatFiles = cms.untracked.bool(False),
0130     endOfRunKills  = cms.untracked.bool(False),
0131     inputFileTransitionsEachEvent = cms.untracked.bool(False),
0132     unitTest = cms.untracked.bool(True) # stop processing if the input data cannot be deserialized
0133 )