Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:42

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_Run3_pp_on_PbPb_approxSiStripClusters', '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     if options.BeamSplashRun :
0075       set_BeamSplashRun_settings( process.source )
0076 
0077     m = re.search(r"\((\w+)\)", str(source.runNumber))
0078     runno = str(m.group(1))
0079     outDir= options.outputBaseDir+'/EvD/run'+runno+'/streamEvDOutput'
0080 else:
0081     runno = options.runNumber
0082     outDir = "./upload"
0083 
0084 #create output directory
0085 try:
0086     os.makedirs(outDir)
0087 except:
0088     pass
0089 
0090 process.options = cms.untracked.PSet(
0091         Rethrow = cms.untracked.vstring('ProductNotFound'),
0092         wantSummary = cms.untracked.bool(True),
0093         numberOfThreads = cms.untracked.uint32(8),
0094         numberOfStreams = cms.untracked.uint32(8)
0095     )
0096 
0097 process.maxEvents = cms.untracked.PSet(
0098         input = cms.untracked.int32(-1)
0099     )
0100 oldo = process._Process__outputmodules["FEVToutput"]
0101 del process._Process__outputmodules["FEVToutput"]
0102 
0103 process.FEVToutput = cms.OutputModule("JsonWritingTimeoutPoolOutputModule",
0104     splitLevel = oldo.splitLevel,
0105     outputCommands = oldo.outputCommands,
0106     fileName = oldo.fileName,
0107     dataset = oldo.dataset,
0108     runNumber = cms.untracked.uint32(int(runno)),
0109     streamLabel = cms.untracked.string("streamEvDOutput_dqmcluster"),
0110     # output path must exist!
0111     outputPath = cms.untracked.string(outDir),
0112 )
0113 
0114 process.DQMMonitoringService = cms.Service("DQMMonitoringService")
0115 
0116 dump = False
0117 if dump:
0118     psetFile = open("RunVisualizationProcessingCfg.py", "w")
0119     psetFile.write(process.dumpPython())
0120     psetFile.close()
0121     cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
0122     print("Now do:\n%s" % cmsRun)
0123 print("Final Source settings:", process.source)