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