CMS 3D CMS Logo

unitteststreamerinputsource_cfi.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from __future__ import absolute_import
3 from builtins import range
4 import os, sys
5 import FWCore.ParameterSet.Config as cms
6 
7 # Parameters for runType
8 import FWCore.ParameterSet.VarParsing as VarParsing
9 from .dqmPythonTypes import *
10 
11 '''
12 check that the input directory exists and there are files in it
13 '''
14 def checkInputFolder(streamer_folder):
15  if not (os.path.exists(streamer_folder) and os.path.isdir(os.path.join(streamer_folder))):
16  raise IOError("Input folder '%s' does not exist in CMSSW_SEARCH_PATH" % streamer_folder)
17 
18  items = os.listdir(dqm_streamer_folder)
19  if not items:
20  raise IOError("Input folder '%s' does not contain any file" % streamer_folder)
21 
22 # Dedine and register options
23 options = VarParsing.VarParsing("analysis")
24 
25 # Parameters for runType
26 options.register('runkey',
27  'pp_run',
28  VarParsing.VarParsing.multiplicity.singleton,
29  VarParsing.VarParsing.varType.string,
30  "Run Keys of CMS")
31 
32 # Parameter for frontierKey
33 options.register('runUniqueKey',
34  'InValid',
35  VarParsing.VarParsing.multiplicity.singleton,
36  VarParsing.VarParsing.varType.string,
37  "Unique run key from RCMS for Frontier")
38 
39 options.register('runNumber',
40  356383,
41  VarParsing.VarParsing.multiplicity.singleton,
42  VarParsing.VarParsing.varType.int,
43  "Run number. This run number has to be present in https://github.com/cms-data/DQM-Integration")
44 
45 options.register('datafnPosition',
46  3, # default value
47  VarParsing.VarParsing.multiplicity.singleton,
48  VarParsing.VarParsing.varType.int,
49  "Data filename position in the positional arguments array 'data' in json file.")
50 
51 options.register('streamLabel',
52  '',
53  VarParsing.VarParsing.multiplicity.singleton,
54  VarParsing.VarParsing.varType.string,
55  "Name of the stream")
56 
57 options.register('noDB',
58  True, # default value
59  VarParsing.VarParsing.multiplicity.singleton,
60  VarParsing.VarParsing.varType.bool,
61  "Don't upload the BeamSpot conditions to the DB")
62 
63 options.register('scanOnce',
64  True, # default value
65  VarParsing.VarParsing.multiplicity.singleton,
66  VarParsing.VarParsing.varType.bool,
67  "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'.")
68 
69 options.register('skipFirstLumis',
70  False, # default value
71  VarParsing.VarParsing.multiplicity.singleton,
72  VarParsing.VarParsing.varType.bool,
73  "Skip (and ignore the minEventsPerLumi parameter) for the files which have been available at the beginning of the processing.")
74 
75 options.register('BeamSplashRun',
76  False, # default value
77  VarParsing.VarParsing.multiplicity.singleton,
78  VarParsing.VarParsing.varType.bool,
79  "Set client source settings for beam SPLASH run")
80 
81 # This is used only by the online clients themselves.
82 # We need to register it here because otherwise an error occurs saying that there is an unidentified option.
83 options.register('unitTest',
84  True,
85  VarParsing.VarParsing.multiplicity.singleton,
86  VarParsing.VarParsing.varType.bool,
87  "Required to avoid the error.")
88 
89 options.parseArguments()
90 
91 # Read streamer files from https://github.com/cms-data/DQM-Integration
92 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]
93 dqm_streamer_folder = os.path.join(dqm_integration_data,'run'+str(options.runNumber))
94 print("Reading streamer files from:\n ",dqm_streamer_folder)
95 checkInputFolder(dqm_streamer_folder)
96 
97 maxEvents = cms.untracked.PSet(
98  input = cms.untracked.int32(-1)
99 )
100 
101 runType = RunType()
102 if not options.runkey.strip():
103  options.runkey = "pp_run"
104 
105 runType.setRunType(options.runkey.strip())
106 
107 # stream label
108 # If streamLabel is empty, so not specified as a command-line argument,
109 # use the default value, i.e. "streamHIDQM" for runType==hi_run and "streamDQM" otherwise
110 streamLabel = options.streamLabel
111 if streamLabel == '':
112  if runType.getRunType() == runType.hi_run:
113  streamLabel = 'streamHIDQM'
114  else:
115  streamLabel = 'streamDQM'
116 
117 # Set the process source
118 source = cms.Source("DQMStreamerReader",
119  runNumber = cms.untracked.uint32(options.runNumber),
120  runInputDir = cms.untracked.string(dqm_integration_data),
121  SelectEvents = cms.untracked.vstring('*'),
122  streamLabel = cms.untracked.string(streamLabel),
123  scanOnce = cms.untracked.bool(options.scanOnce),
124  datafnPosition = cms.untracked.uint32(options.datafnPosition),
125  minEventsPerLumi = cms.untracked.int32(1000),
126  delayMillis = cms.untracked.uint32(500),
127  nextLumiTimeoutMillis = cms.untracked.int32(0),
128  skipFirstLumis = cms.untracked.bool(options.skipFirstLumis),
129  deleteDatFiles = cms.untracked.bool(False),
130  endOfRunKills = cms.untracked.bool(False),
131  inputFileTransitionsEachEvent = cms.untracked.bool(False),
132  unitTest = cms.untracked.bool(True) # stop processing if the input data cannot be deserialized
133 )
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)