CMS 3D CMS Logo

visualization-live-secondInstance_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 
25 try:
26  scenario = getScenario(scenarioName)
27 except Exception as ex:
28  msg = "Error getting Scenario implementation for %s\n" % (
29  scenarioName,)
30  msg += str(ex)
31  raise RuntimeError(msg)
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 # example of how to add a filer IN FRONT of all the paths, eg for HLT selection
46 #kwds['preFilter'] = 'DQM/Integration/config/visualizationPreFilter.hltfilter'
47 
48 # The following filter was used during 2018 high pile up (HPU) run.
49 #kwds['preFilter'] = 'DQM/Integration/config/visualizationPreFilter.pixelClusterFilter'
50 
51 process = scenario.visualizationProcessing(writeTiers=['FEVT'], **kwds)
52 
53 process.source = source
54 process.source.inputFileTransitionsEachEvent = cms.untracked.bool(True)
55 process.source.skipFirstLumis = cms.untracked.bool(True)
56 process.source.minEventsPerLumi = cms.untracked.int32(0)
57 process.source.nextLumiTimeoutMillis = cms.untracked.int32(10000)
58 process.source.streamLabel = cms.untracked.string('streamDQMEventDisplay')
59 
60 m = re.search(r"\((\w+)\)", str(source.runNumber))
61 runno = str(m.group(1))
62 outDir= '/fff/BU0/output/EvD/run'+runno+'/streamEvDOutput2'
63 
64 #create output directory
65 try:
66  os.makedirs(outDir)
67 except:
68  pass
69 
70 process.options = cms.untracked.PSet(
71  Rethrow = cms.untracked.vstring('ProductNotFound'),
72  wantSummary = cms.untracked.bool(True),
73  numberOfThreads = cms.untracked.uint32(8),
74  numberOfStreams = cms.untracked.uint32(8)
75  )
76 
77 process.maxEvents = cms.untracked.PSet(
78  input = cms.untracked.int32(-1)
79  )
80 oldo = process._Process__outputmodules["FEVToutput"]
81 del process._Process__outputmodules["FEVToutput"]
82 
83 process.FEVToutput = cms.OutputModule("JsonWritingTimeoutPoolOutputModule",
84  splitLevel = oldo.splitLevel,
85  outputCommands = oldo.outputCommands,
86  fileName = oldo.fileName,
87  dataset = oldo.dataset,
88  runNumber = cms.untracked.uint32(int(runno)),
89  streamLabel = cms.untracked.string("streamEvDOutput2_dqmcluster"),
90  # output path must exist!
91  outputPath = cms.untracked.string(outDir),
92 )
93 
94 if hasattr(oldo, 'SelectEvents'):
95  process.FEVToutput.SelectEvents = oldo.SelectEvents
96 
97 process.DQMMonitoringService = cms.Service("DQMMonitoringService")
98 
99 dump = False
100 if dump:
101  psetFile = open("RunVisualizationProcessingCfg.py", "w")
102  psetFile.write(process.dumpPython())
103  psetFile.close()
104  cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
105  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)