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, sys
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 
10 unitTest = False
11 if 'unitTest=True' in sys.argv:
12  unitTest=True
13 
14 if unitTest:
15  from DQM.Integration.config.unittestinputsource_cfi import options, runType, source
16 else:
17  from DQM.Integration.config.inputsource_cfi import options, runType, source
18 
19 # 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
20 #scenarios = {'pp_run': 'ppEra_Run2_2016','cosmic_run':'cosmicsEra_Run2_2016','hi_run':'HeavyIons'}
21 #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'}
22 scenarios = {'pp_run': 'ppEra_Run3','cosmic_run':'cosmicsEra_Run3','hi_run':'ppEra_Run2_2016_pA'}
23 
24 if not runType.getRunTypeName() in scenarios.keys():
25  msg = "Error getting the scenario out of the 'runkey', no mapping for: %s\n"%runType.getRunTypeName()
26  raise RuntimeError(msg)
27 
28 scenarioName = scenarios[runType.getRunTypeName()]
29 
30 print("Using scenario:",scenarioName)
31 
32 try:
33  scenario = getScenario(scenarioName)
34 except Exception as ex:
35  msg = "Error getting Scenario implementation for %s\n" % (
36  scenarioName,)
37  msg += str(ex)
38  raise RuntimeError(msg)
39 
40 # A hack necessary to prevert scenario.visualizationProcessing
41 # from overriding the connect string
42 from DQM.Integration.config.FrontierCondition_GT_autoExpress_cfi import GlobalTag
43 kwds = {
44  'globalTag': GlobalTag.globaltag.value(),
45  'globalTagConnect': GlobalTag.connect.value()
46 }
47 
48 # explicitly select the input collection, since we get multiple in online
49 from EventFilter.RawDataCollector.rawDataMapperByLabel_cfi import rawDataMapperByLabel
50 rawDataMapperByLabel.rawCollectionList = [cms.InputTag("rawDataRepacker")]
51 
52 # example of how to add a filer IN FRONT of all the paths, eg for HLT selection
53 #kwds['preFilter'] = 'DQM/Integration/config/visualizationPreFilter.hltfilter'
54 
55 # The following filter was used during 2018 high pile up (HPU) run.
56 #kwds['preFilter'] = 'DQM/Integration/config/visualizationPreFilter.pixelClusterFilter'
57 
58 process = scenario.visualizationProcessing(writeTiers=['FEVT'], **kwds)
59 
60 if unitTest:
61  process.__dict__['_Process__name'] = "RECONEW"
62 
63 process.source = source
64 
65 if not unitTest:
66  process.source.inputFileTransitionsEachEvent = cms.untracked.bool(True)
67  process.source.skipFirstLumis = cms.untracked.bool(True)
68  process.source.minEventsPerLumi = cms.untracked.int32(0)
69  process.source.nextLumiTimeoutMillis = cms.untracked.int32(10000)
70  process.source.streamLabel = cms.untracked.string('streamDQMEventDisplay')
71 
72  m = re.search(r"\((\w+)\)", str(source.runNumber))
73  runno = str(m.group(1))
74  outDir= '/fff/BU0/output/EvD/run'+runno+'/streamEvDOutput2'
75 else:
76  runno = options.runNumber
77  outDir = "./upload"
78 
79 #create output directory
80 try:
81  os.makedirs(outDir)
82 except:
83  pass
84 
85 process.options = cms.untracked.PSet(
86  Rethrow = cms.untracked.vstring('ProductNotFound'),
87  wantSummary = cms.untracked.bool(True),
88  numberOfThreads = cms.untracked.uint32(8),
89  numberOfStreams = cms.untracked.uint32(8)
90  )
91 
92 process.maxEvents = cms.untracked.PSet(
93  input = cms.untracked.int32(-1)
94  )
95 oldo = process._Process__outputmodules["FEVToutput"]
96 del process._Process__outputmodules["FEVToutput"]
97 
98 process.FEVToutput = cms.OutputModule("JsonWritingTimeoutPoolOutputModule",
99  splitLevel = oldo.splitLevel,
100  outputCommands = oldo.outputCommands,
101  fileName = oldo.fileName,
102  dataset = oldo.dataset,
103  runNumber = cms.untracked.uint32(int(runno)),
104  streamLabel = cms.untracked.string("streamEvDOutput2_dqmcluster"),
105  # output path must exist!
106  outputPath = cms.untracked.string(outDir),
107 )
108 
109 if hasattr(oldo, 'SelectEvents'):
110  process.FEVToutput.SelectEvents = oldo.SelectEvents
111 
112 process.DQMMonitoringService = cms.Service("DQMMonitoringService")
113 
114 dump = False
115 if dump:
116  psetFile = open("RunVisualizationProcessingCfg.py", "w")
117  psetFile.write(process.dumpPython())
118  psetFile.close()
119  cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
120  print("Now do:\n%s" % cmsRun)
GetScenario.getScenario
def getScenario(scenarioName)
Definition: GetScenario.py:12
str
#define str(s)
Definition: TestProcessor.cc:52
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
createfilelist.int
int
Definition: createfilelist.py:10