CMS 3D CMS Logo

visualization-live_cfg.py
Go to the documentation of this file.
1 from __future__ import print_function
2 import re,os
3 import FWCore.ParameterSet.Config as cms
4 from Configuration.DataProcessing.GetScenario import getScenario
5 
6 """
7 Example configuration for online reconstruction meant for visualization clients.
8 """
9 from DQM.Integration.config.inputsource_cfi import options,runType,source
10 
11 # 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
12 #scenarios = {'pp_run': 'ppEra_Run2_2016','cosmic_run':'cosmicsEra_Run2_2016','hi_run':'HeavyIons'}
13 #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'}
14 scenarios = {'pp_run': 'ppEra_Run2_2018','cosmic_run':'cosmicsEra_Run2_2018','hi_run':'ppEra_Run2_2018_pp_on_AA'}
15 
16 if not runType.getRunTypeName() in scenarios.keys():
17  msg = "Error getting the scenario out of the 'runkey', no mapping for: %s\n"%runType.getRunTypeName()
18  raise RuntimeError(msg)
19 
20 scenarioName = scenarios[runType.getRunTypeName()]
21 
22 print("Using scenario:",scenarioName)
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 
33 # A hack necessary to prevert scenario.visualizationProcessing
34 # from overriding the connect string
35 from DQM.Integration.config.FrontierCondition_GT_autoExpress_cfi import GlobalTag
36 kwds = {
37  'globalTag': GlobalTag.globaltag.value(),
38  'globalTagConnect': GlobalTag.connect.value()
39 }
40 
41 # explicitly select the input collection, since we get multiple in online
42 from EventFilter.RawDataCollector.rawDataMapperByLabel_cfi import rawDataMapperByLabel
43 rawDataMapperByLabel.rawCollectionList = [cms.InputTag("rawDataRepacker")]
44 
45 
46 # example of how to add a filer IN FRONT of all the paths, eg for HLT selection
47 #kwds['preFilter'] = 'DQM/Integration/python/config/visualizationPreFilter.hltfilter'
48 
49 process = scenario.visualizationProcessing(writeTiers=['FEVT'], **kwds)
50 
51 process.source = source
52 process.source.inputFileTransitionsEachEvent = cms.untracked.bool(True)
53 process.source.skipFirstLumis = cms.untracked.bool(True)
54 process.source.minEventsPerLumi = cms.untracked.int32(0)
55 process.source.nextLumiTimeoutMillis = cms.untracked.int32(10000)
56 process.source.streamLabel = cms.untracked.string('streamDQM')
57 
58 m = re.search(r"\((\w+)\)", str(source.runNumber))
59 runno = str(m.group(1))
60 outDir= '/fff/BU0/output/EvD/run'+runno+'/streamEvDOutput'
61 
62 #create output directory
63 try:
64  os.makedirs(outDir)
65 except:
66  pass
67 
68 process.options = cms.untracked.PSet(
69  Rethrow = cms.untracked.vstring('ProductNotFound'),
70  wantSummary = cms.untracked.bool(True),
71  numberOfThreads = cms.untracked.uint32(8),
72  numberOfStreams = cms.untracked.uint32(8)
73  )
74 
75 process.maxEvents = cms.untracked.PSet(
76  input = cms.untracked.int32(-1)
77  )
78 oldo = process._Process__outputmodules["FEVToutput"]
79 del process._Process__outputmodules["FEVToutput"]
80 
81 process.FEVToutput = cms.OutputModule("JsonWritingTimeoutPoolOutputModule",
82  splitLevel = oldo.splitLevel,
83  outputCommands = oldo.outputCommands,
84  fileName = oldo.fileName,
85  dataset = oldo.dataset,
86  runNumber = cms.untracked.uint32(int(runno)),
87  streamLabel = cms.untracked.string("streamEvDOutput_dqmcluster"),
88  # output path must exist!
89  outputPath = cms.untracked.string(outDir),
90 )
91 
92 process.DQMMonitoringService = cms.Service("DQMMonitoringService")
93 
94 dump = False
95 if dump:
96  psetFile = open("RunVisualizationProcessingCfg.py", "w")
97  psetFile.write(process.dumpPython())
98  psetFile.close()
99  cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
100  print("Now do:\n%s" % cmsRun)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def getScenario(scenarioName)
Definition: GetScenario.py:12
#define str(s)