CMS 3D CMS Logo

visualization-live-secondInstance_cfg.py
Go to the documentation of this file.
1 import re,os
2 import FWCore.ParameterSet.Config as cms
3 from Configuration.DataProcessing.GetScenario import getScenario
4 
5 """
6 Example configuration for online reconstruction meant for visualization clients.
7 """
8 from DQM.Integration.config.inputsource_cfi import options,runType,source
9 
10 # this is needed to map the names of the run-types chosen by DQM to the scenarios, ideally we could converge to the same names
11 #scenarios = {'pp_run': 'ppEra_Run2_2016','cosmic_run':'cosmicsEra_Run2_2016','hi_run':'HeavyIons'}
12 #scenarios = {'pp_run': 'ppEra_Run2_2016','pp_run_stage1': 'ppEra_Run2_2016','cosmic_run':'cosmicsEra_Run2_2016','cosmic_run_stage1':'cosmicsEra_Run2_2016','hi_run':'HeavyIonsEra_Run2_HI'}
13 scenarios = {'pp_run': 'ppEra_Run2_2018','cosmic_run':'cosmicsEra_Run2_2018','hi_run':'HeavyIonsEra_Run2_HI'}
14 
15 if not runType.getRunTypeName() in scenarios.keys():
16  msg = "Error getting the scenario out of the 'runkey', no mapping for: %s\n"%runType.getRunTypeName()
17  raise RuntimeError(msg)
18 
19 scenarioName = scenarios[runType.getRunTypeName()]
20 
21 print "Using scenario:",scenarioName
22 
23 
24 try:
25  scenario = getScenario(scenarioName)
26 except Exception as ex:
27  msg = "Error getting Scenario implementation for %s\n" % (
28  scenarioName,)
29  msg += str(ex)
30  raise RuntimeError(msg)
31 
32 # A hack necessary to prevert scenario.visualizationProcessing
33 # from overriding the connect string
34 from DQM.Integration.config.FrontierCondition_GT_autoExpress_cfi import GlobalTag
35 kwds = {
36  'globalTag': GlobalTag.globaltag.value(),
37  'globalTagConnect': GlobalTag.connect.value()
38 }
39 
40 # example of how to add a filer IN FRONT of all the paths, eg for HLT selection
41 #kwds['preFilter'] = 'DQM/Integration/python/config/visualizationPreFilter.hltfilter'
42 
43 process = scenario.visualizationProcessing(writeTiers=['FEVT'], **kwds)
44 
45 process.source = source
46 process.source.inputFileTransitionsEachEvent = cms.untracked.bool(True)
47 process.source.skipFirstLumis = cms.untracked.bool(True)
48 process.source.minEventsPerLumi = cms.untracked.int32(0)
49 process.source.nextLumiTimeoutMillis = cms.untracked.int32(10000)
50 process.source.streamLabel = cms.untracked.string('streamDQMEventDisplay')
51 
52 m = re.search(r"\((\w+)\)", str(source.runNumber))
53 runno = str(m.group(1))
54 outDir= '/fff/BU0/output/EvD/run'+runno+'/streamEvDOutput2'
55 
56 #create output directory
57 try:
58  os.makedirs(outDir)
59 except:
60  pass
61 
62 process.options = cms.untracked.PSet(
63  Rethrow = cms.untracked.vstring('ProductNotFound'),
64  wantSummary = cms.untracked.bool(True),
65  numberOfThreads = cms.untracked.uint32(8),
66  numberOfStreams = cms.untracked.uint32(8)
67  )
68 
69 process.maxEvents = cms.untracked.PSet(
70  input = cms.untracked.int32(-1)
71  )
72 oldo = process._Process__outputmodules["FEVToutput"]
73 del process._Process__outputmodules["FEVToutput"]
74 
75 process.FEVToutput = cms.OutputModule("JsonWritingTimeoutPoolOutputModule",
76  splitLevel = oldo.splitLevel,
77  eventAutoFlushCompressedSize = oldo.eventAutoFlushCompressedSize,
78  outputCommands = oldo.outputCommands,
79  fileName = oldo.fileName,
80  dataset = oldo.dataset,
81  runNumber = cms.untracked.uint32(int(runno)),
82  streamLabel = cms.untracked.string("streamEvDOutput2_dqmcluster"),
83  # output path must exist!
84  outputPath = cms.untracked.string(outDir),
85 )
86 
87 process.DQMMonitoringService = cms.Service("DQMMonitoringService")
88 
89 dump = False
90 if dump:
91  psetFile = open("RunVisualizationProcessingCfg.py", "w")
92  psetFile.write(process.dumpPython())
93  psetFile.close()
94  cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
95  print "Now do:\n%s" % cmsRun
def getScenario(scenarioName)
Definition: GetScenario.py:12