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  'streamDQM', # default DQM stream value
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 # Set the process source
98 source = cms.Source("DQMStreamerReader",
99  runNumber = cms.untracked.uint32(options.runNumber),
100  runInputDir = cms.untracked.string(dqm_integration_data),
101  SelectEvents = cms.untracked.vstring('*'),
102  streamLabel = cms.untracked.string(options.streamLabel),
103  scanOnce = cms.untracked.bool(options.scanOnce),
104  datafnPosition = cms.untracked.uint32(options.datafnPosition),
105  minEventsPerLumi = cms.untracked.int32(1000),
106  delayMillis = cms.untracked.uint32(500),
107  nextLumiTimeoutMillis = cms.untracked.int32(0),
108  skipFirstLumis = cms.untracked.bool(options.skipFirstLumis),
109  deleteDatFiles = cms.untracked.bool(False),
110  endOfRunKills = cms.untracked.bool(False),
111  inputFileTransitionsEachEvent = cms.untracked.bool(False)
112 )
113 
114 maxEvents = cms.untracked.PSet(
115  input = cms.untracked.int32(-1)
116 )
117 
118 runType = RunType()
119 if not options.runkey.strip():
120  options.runkey = "pp_run"
121 
122 runType.setRunType(options.runkey.strip())
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)