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