Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-10 22:24:31

0001 from __future__ import print_function
0002 import re, os, sys
0003 import FWCore.ParameterSet.Config as cms
0004 from Configuration.DataProcessing.GetScenario import getScenario
0005 
0006 """
0007 Example configuration for online reconstruction meant for visualization clients.
0008 """
0009 
0010 unitTest = False
0011 if 'unitTest=True' in sys.argv:
0012     unitTest=True
0013 
0014 if unitTest:
0015     from DQM.Integration.config.unittestinputsource_cfi import options, runType, source
0016 else:
0017     from DQM.Integration.config.inputsource_cfi import options, runType, source, set_BeamSplashRun_settings
0018 
0019 # 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
0020 #scenarios = {'pp_run': 'ppEra_Run2_2016','cosmic_run':'cosmicsEra_Run2_2016','hi_run':'HeavyIons'}
0021 #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'}
0022 scenarios = {'pp_run': 'ppEra_Run3','cosmic_run':'cosmicsEra_Run3','hi_run':'ppEra_Run2_2016_pA', 'commissioning_run':'cosmicsEra_Run3'}
0023 
0024 if not runType.getRunTypeName() in scenarios.keys():
0025     msg = "Error getting the scenario out of the 'runkey', no mapping for: %s\n"%runType.getRunTypeName()
0026     raise RuntimeError(msg)
0027 
0028 scenarioName = scenarios[runType.getRunTypeName()]
0029 
0030 if not unitTest :
0031   if options.BeamSplashRun :
0032     scenarioName = 'ppEra_Run3'
0033     pass
0034 
0035 print("Using scenario:",scenarioName)
0036 
0037 try:
0038     scenario = getScenario(scenarioName)
0039 except Exception as ex:
0040     msg = "Error getting Scenario implementation for %s\n" % (
0041         scenarioName,)
0042     msg += str(ex)
0043     raise RuntimeError(msg)
0044 
0045 # A hack necessary to prevert scenario.visualizationProcessing
0046 # from overriding the connect string
0047 from DQM.Integration.config.FrontierCondition_GT_autoExpress_cfi import GlobalTag
0048 kwds = {
0049    'globalTag': GlobalTag.globaltag.value(),
0050    'globalTagConnect': GlobalTag.connect.value(),
0051    'beamSplashRun' : ":localreco+hcalOnlyGlobalRecoSequence+caloTowersRec" if options.BeamSplashRun else "",
0052 }
0053 
0054 # explicitly select the input collection, since we get multiple in online
0055 from EventFilter.RawDataCollector.rawDataMapperByLabel_cfi import rawDataMapperByLabel
0056 rawDataMapperByLabel.rawCollectionList = ["rawDataRepacker"]
0057 
0058 
0059 # example of how to add a filer IN FRONT of all the paths, eg for HLT selection
0060 #kwds['preFilter'] = 'DQM/Integration/python/config/visualizationPreFilter.hltfilter'
0061 
0062 process = scenario.visualizationProcessing(writeTiers=['FEVT'], **kwds)
0063 
0064 if unitTest:
0065     process.__dict__['_Process__name'] = "RECONEW"
0066 
0067 process.source = source
0068 
0069 if not unitTest:
0070     process.source.inputFileTransitionsEachEvent = True
0071     process.source.skipFirstLumis                = True
0072     process.source.minEventsPerLumi              = 0
0073     process.source.nextLumiTimeoutMillis         = 10000
0074     process.source.streamLabel                   = 'streamDQM'
0075     if options.BeamSplashRun :
0076       set_BeamSplashRun_settings( process.source )
0077 
0078     m = re.search(r"\((\w+)\)", str(source.runNumber))
0079     runno = str(m.group(1))
0080     outDir= '/fff/BU0/output/EvD/run'+runno+'/streamEvDOutput'
0081 else:
0082     runno = options.runNumber
0083     outDir = "./upload"
0084 
0085 #create output directory
0086 try:
0087     os.makedirs(outDir)
0088 except:
0089     pass
0090 
0091 process.options = cms.untracked.PSet(
0092         Rethrow = cms.untracked.vstring('ProductNotFound'),
0093         wantSummary = cms.untracked.bool(True),
0094         numberOfThreads = cms.untracked.uint32(8),
0095         numberOfStreams = cms.untracked.uint32(8)
0096     )
0097 
0098 process.maxEvents = cms.untracked.PSet(
0099         input = cms.untracked.int32(-1)
0100     )
0101 oldo = process._Process__outputmodules["FEVToutput"]
0102 del process._Process__outputmodules["FEVToutput"]
0103 
0104 process.FEVToutput = cms.OutputModule("JsonWritingTimeoutPoolOutputModule",
0105     splitLevel = oldo.splitLevel,
0106     outputCommands = oldo.outputCommands,
0107     fileName = oldo.fileName,
0108     dataset = oldo.dataset,
0109     runNumber = cms.untracked.uint32(int(runno)),
0110     streamLabel = cms.untracked.string("streamEvDOutput_dqmcluster"),
0111     # output path must exist!
0112     outputPath = cms.untracked.string(outDir),
0113 )
0114 
0115 process.DQMMonitoringService = cms.Service("DQMMonitoringService")
0116 
0117 dump = False
0118 if dump:
0119     psetFile = open("RunVisualizationProcessingCfg.py", "w")
0120     psetFile.write(process.dumpPython())
0121     psetFile.close()
0122     cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
0123     print("Now do:\n%s" % cmsRun)
0124 print("Final Source settings:", process.source)