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 # example of how to add a filer IN FRONT of all the paths, eg for HLT selection
0059 #kwds['preFilter'] = 'DQM/Integration/config/visualizationPreFilter.hltfilter'
0060 
0061 # The following filter was used during 2018 high pile up (HPU) run.
0062 #kwds['preFilter'] = 'DQM/Integration/config/visualizationPreFilter.pixelClusterFilter'
0063 
0064 process = scenario.visualizationProcessing(writeTiers=['FEVT'], **kwds)
0065 
0066 if unitTest:
0067     process.__dict__['_Process__name'] = "RECONEW"
0068 
0069 process.source = source
0070 
0071 if not unitTest:
0072     process.source.inputFileTransitionsEachEvent = True
0073     process.source.skipFirstLumis                = True
0074     process.source.minEventsPerLumi              = 0
0075     process.source.nextLumiTimeoutMillis         = 10000
0076     process.source.streamLabel                   = 'streamDQMEventDisplay'
0077     if options.BeamSplashRun :
0078       set_BeamSplashRun_settings( process.source )
0079 
0080     m = re.search(r"\((\w+)\)", str(source.runNumber))
0081     runno = str(m.group(1))
0082     outDir= '/fff/BU0/output/EvD/run'+runno+'/streamEvDOutput2'
0083 else:
0084     runno = options.runNumber
0085     outDir = "./upload"
0086 
0087 #create output directory
0088 try:
0089     os.makedirs(outDir)
0090 except:
0091     pass
0092 
0093 process.options = cms.untracked.PSet(
0094         Rethrow = cms.untracked.vstring('ProductNotFound'),
0095         wantSummary = cms.untracked.bool(True),
0096         numberOfThreads = cms.untracked.uint32(8),
0097         numberOfStreams = cms.untracked.uint32(8)
0098     )
0099 
0100 process.maxEvents = cms.untracked.PSet(
0101         input = cms.untracked.int32(-1)
0102     )
0103 oldo = process._Process__outputmodules["FEVToutput"]
0104 del process._Process__outputmodules["FEVToutput"]
0105 
0106 process.FEVToutput = cms.OutputModule("JsonWritingTimeoutPoolOutputModule",
0107     splitLevel = oldo.splitLevel,
0108     outputCommands = oldo.outputCommands,
0109     fileName = oldo.fileName,
0110     dataset = oldo.dataset,
0111     runNumber = cms.untracked.uint32(int(runno)),
0112     streamLabel = cms.untracked.string("streamEvDOutput2_dqmcluster"),
0113     # output path must exist!
0114     outputPath = cms.untracked.string(outDir),
0115 )
0116 
0117 if hasattr(oldo, 'SelectEvents'):
0118     process.FEVToutput.SelectEvents = oldo.SelectEvents
0119 
0120 process.DQMMonitoringService = cms.Service("DQMMonitoringService")
0121 
0122 dump = False
0123 if dump:
0124     psetFile = open("RunVisualizationProcessingCfg.py", "w")
0125     psetFile.write(process.dumpPython())
0126     psetFile.close()
0127     cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
0128     print("Now do:\n%s" % cmsRun)
0129 print("Final Source settings:", process.source)