Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-26 02:34:08

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