Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:50:19

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 
0004 # Define once the BeamSpotOnline record name,
0005 # will be used both in BeamMonitor setup and in payload creation/upload
0006 BSOnlineRecordName = 'BeamSpotOnlineHLTObjectsRcd'
0007 BSOnlineTag = 'BeamSpotOnlineHLT'
0008 BSOnlineJobName = 'BeamSpotOnlineHLT'
0009 BSOnlineOmsServiceUrl = 'http://cmsoms-services.cms:9949/urn:xdaq-application:lid=100/getRunAndLumiSection'
0010 useLockRecords = True
0011 
0012 import sys
0013 from Configuration.Eras.Era_Run3_cff import Run3
0014 process = cms.Process("BeamMonitor", Run3)
0015 
0016 # Message logger
0017 #process.load("FWCore.MessageLogger.MessageLogger_cfi")
0018 #process.MessageLogger = cms.Service("MessageLogger",
0019 #    debugModules = cms.untracked.vstring('*'),
0020 #    cerr = cms.untracked.PSet(
0021 #        FwkReport = cms.untracked.PSet(
0022 #            optionalPSet = cms.untracked.bool(True),
0023 #            reportEvery = cms.untracked.int32(1000),
0024 #            limit = cms.untracked.int32(999999)
0025 #        )
0026 #    ),
0027 #    destinations = cms.untracked.vstring('cerr'),
0028 #)
0029 
0030 # switch
0031 live = True # FIXME
0032 unitTest = False
0033 
0034 if 'unitTest=True' in sys.argv:
0035   live=False
0036   unitTest=True
0037   useLockRecords = False
0038 
0039 # Common part for PP and H.I Running
0040 #-----------------------------
0041 if unitTest:
0042   process.load("DQM.Integration.config.unittestinputsource_cfi")
0043   from DQM.Integration.config.unittestinputsource_cfi import options
0044 
0045   # Overwrite source of the unitTest to use a streamer file instead of the DAS query output
0046   print("[beamhlt_dqm_sourceclient-live_cfg]:: Overriding DAS input to use a streamer file")
0047 
0048   # Read streamer files from https://github.com/cms-data/DQM-Integration
0049   import os
0050   dqm_integration_data = [os.path.join(dir,'DQM/Integration/data') for dir in os.getenv('CMSSW_SEARCH_PATH','').split(":") if os.path.exists(os.path.join(dir,'DQM/Integration/data'))][0]
0051 
0052   # Set the process source
0053   process.source = cms.Source("DQMStreamerReader",
0054       runNumber = cms.untracked.uint32(346373),
0055       runInputDir = cms.untracked.string(dqm_integration_data),
0056       SelectEvents = cms.untracked.vstring('*'),
0057       streamLabel = cms.untracked.string('streamDQMOnlineBeamspot'),
0058       scanOnce = cms.untracked.bool(True),
0059       minEventsPerLumi = cms.untracked.int32(1000),
0060       delayMillis = cms.untracked.uint32(500),
0061       nextLumiTimeoutMillis = cms.untracked.int32(0),
0062       skipFirstLumis = cms.untracked.bool(False),
0063       deleteDatFiles = cms.untracked.bool(False),
0064       endOfRunKills  = cms.untracked.bool(False),
0065       inputFileTransitionsEachEvent = cms.untracked.bool(False)
0066   )
0067 
0068 elif live:
0069   # for live online DQM in P5
0070   process.load("DQM.Integration.config.inputsource_cfi")
0071   from DQM.Integration.config.inputsource_cfi import options
0072   # new stream label
0073   process.source.streamLabel = cms.untracked.string('streamDQMOnlineBeamspot')
0074 else:
0075   process.load("DQM.Integration.config.fileinputsource_cfi")
0076   from DQM.Integration.config.fileinputsource_cfi import options
0077 
0078 # for testing in lxplus
0079 #process.load("DQM.Integration.config.fileinputsource_cfi")
0080 #from DQM.Integration.config.fileinputsource_cfi import options
0081 
0082 #--------------------------
0083 # HLT Filter
0084 # 0=random, 1=physics, 2=calibration, 3=technical
0085 #--------------------------
0086 process.hltTriggerTypeFilter = cms.EDFilter("HLTTriggerTypeFilter",
0087     SelectedTriggerType = cms.int32(1)
0088 )
0089 
0090 #-----------------------------
0091 # DQM Live Environment
0092 #-----------------------------
0093 process.load("DQM.Integration.config.environment_cfi")
0094 process.dqmEnv.subSystemFolder = 'BeamMonitorHLT'
0095 process.dqmSaver.tag           = 'BeamMonitorHLT'
0096 process.dqmSaver.runNumber     = options.runNumber
0097 process.dqmSaverPB.tag         = 'BeamMonitorHLT'
0098 process.dqmSaverPB.runNumber   = options.runNumber
0099 
0100 # Configure tag and jobName if running Playback system
0101 if process.isDqmPlayback.value :
0102   BSOnlineTag = BSOnlineTag + 'Playback'
0103   BSOnlineJobName = BSOnlineJobName + 'Playback'
0104   BSOnlineOmsServiceUrl = ''
0105   useLockRecords = False
0106 
0107 #-----------------------------
0108 # BeamMonitor
0109 #-----------------------------
0110 process.load("DQM.BeamMonitor.BeamMonitor_cff")
0111 
0112 #---------------
0113 # Calibration
0114 #---------------
0115 # Condition for P5 cluster
0116 process.load("DQM.Integration.config.FrontierCondition_GT_cfi")
0117 process.GlobalTag.DBParameters.authenticationPath = cms.untracked.string('.')
0118 # Condition for lxplus: change and possibly customise the GT
0119 #from Configuration.AlCa.GlobalTag import GlobalTag as gtCustomise
0120 #process.GlobalTag = gtCustomise(process.GlobalTag, 'auto:run2_data', '')
0121 
0122 # Change Beam Monitor variables
0123 process.dqmBeamMonitor.useLockRecords = cms.untracked.bool(useLockRecords)
0124 if process.dqmRunConfig.type.value() == "production":
0125   process.dqmBeamMonitor.BeamFitter.WriteAscii = True
0126   process.dqmBeamMonitor.BeamFitter.AsciiFileName = '/nfshome0/yumiceva/BeamMonitorDQM/BeamFitResults.txt'
0127   process.dqmBeamMonitor.BeamFitter.WriteDIPAscii = True
0128   process.dqmBeamMonitor.BeamFitter.DIPFileName = '/nfshome0/dqmpro/BeamMonitorDQM/BeamFitResults.txt'
0129 else:
0130   process.dqmBeamMonitor.BeamFitter.WriteAscii = False
0131   process.dqmBeamMonitor.BeamFitter.AsciiFileName = '/nfshome0/yumiceva/BeamMonitorDQM/BeamFitResults.txt'
0132   process.dqmBeamMonitor.BeamFitter.WriteDIPAscii = True
0133   process.dqmBeamMonitor.BeamFitter.DIPFileName = '/nfshome0/dqmdev/BeamMonitorDQM/BeamFitResults.txt'
0134 
0135 process.dqmcommon = cms.Sequence(process.dqmEnv
0136                                * process.dqmSaver*process.dqmSaverPB)
0137 
0138 process.monitor = cms.Sequence(process.dqmBeamMonitor)
0139 
0140 #-----------------------------------------------------------
0141 # process customizations included here
0142 from DQM.Integration.config.online_customizations_cfi import *
0143 process = customise(process)
0144 
0145 # Digitisation: produce the TCDS digis containing BST record
0146 from EventFilter.OnlineMetaDataRawToDigi.tcdsRawToDigi_cfi import *
0147 process.tcdsDigis = tcdsRawToDigi.clone()
0148 
0149 #------------------------
0150 # Set rawDataRepacker (HI and live) or rawDataCollector (for all the rest)
0151 if (process.runType.getRunType() == process.runType.hi_run and live):
0152     rawDataInputTag = "rawDataRepacker"
0153 elif unitTest:
0154     # This is needed until we update the streamer files used for the unitTest
0155     rawDataInputTag = "rawDataCollector"
0156 else:
0157     # Use raw data from selected TCDS FEDs (1024, 1025)
0158     rawDataInputTag = "hltFEDSelectorTCDS"
0159 
0160 process.tcdsDigis.InputLabel = rawDataInputTag
0161 
0162 #-----------------------------------------------------------
0163 # Swap offline <-> online BeamSpot as in Express and HLT
0164 import RecoVertex.BeamSpotProducer.onlineBeamSpotESProducer_cfi as _mod
0165 process.BeamSpotESProducer = _mod.onlineBeamSpotESProducer.clone()
0166 import RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi
0167 process.offlineBeamSpot = RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi.onlineBeamSpotProducer.clone()
0168 
0169 #--------------------------
0170 # Proton-Proton Stuff
0171 #--------------------------
0172 
0173 if (process.runType.getRunType() == process.runType.pp_run or
0174     process.runType.getRunType() == process.runType.pp_run_stage1 or
0175     process.runType.getRunType() == process.runType.hpu_run or
0176     process.runType.getRunType() == process.runType.hi_run or
0177     process.runType.getRunType() == process.runType.commissioning_run):
0178 
0179     print("[beamhlt_dqm_sourceclient-live_cfg]:: Running pp")
0180 
0181     process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi")
0182 
0183     process.dqmBeamMonitor.monitorName = 'BeamMonitorHLT'
0184 
0185     process.dqmBeamMonitor.OnlineMode = True              
0186     process.dqmBeamMonitor.recordName = BSOnlineRecordName
0187 
0188     process.dqmBeamMonitor.resetEveryNLumi   = 5
0189     process.dqmBeamMonitor.resetPVEveryNLumi = 5
0190 
0191     process.dqmBeamMonitor.PVFitter.minNrVerticesForFit = 20
0192     process.dqmBeamMonitor.PVFitter.minVertexNdf        = 10
0193   
0194     # some inputs to BeamMonitor
0195     if(process.runType.getRunType() == process.runType.hi_run):
0196       process.dqmBeamMonitor.BeamFitter.TrackCollection = 'hltPFMuonMergingPPOnAA'
0197       process.dqmBeamMonitor.primaryVertex              = 'hltVerticesPFFilterPPOnAA'
0198       process.dqmBeamMonitor.PVFitter.VertexCollection  = 'hltVerticesPFFilterPPOnAA'
0199     else:
0200       process.dqmBeamMonitor.BeamFitter.TrackCollection = 'hltPFMuonMerging'
0201       process.dqmBeamMonitor.primaryVertex              = 'hltVerticesPFFilter'
0202       process.dqmBeamMonitor.PVFitter.VertexCollection  = 'hltVerticesPFFilter'
0203 
0204     # keep checking this with new release expected close to 1
0205     process.dqmBeamMonitor.PVFitter.errorScale = 0.95
0206 
0207     #TriggerName for selecting pv for DIP publication, NO wildcard needed here
0208     #it will pick all triggers which have these strings in their name
0209     process.dqmBeamMonitor.jetTrigger = cms.untracked.vstring(
0210         "HLT_HT300_Beamspot", "HLT_HT300_Beamspot",
0211         "HLT_PAZeroBias_v", "HLT_ZeroBias_", "HLT_QuadJet",
0212         "HLT_HI",
0213         "HLT_PixelClusters")
0214 
0215     process.dqmBeamMonitor.hltResults = "TriggerResults::HLT"
0216 
0217     #---------
0218     # Upload BeamSpotOnlineObject (HLTRcd) to CondDB
0219     if unitTest == False:
0220       process.OnlineDBOutputService = cms.Service("OnlineDBOutputService",
0221         DBParameters = cms.PSet(
0222                                 messageLevel = cms.untracked.int32(0),
0223                                 authenticationPath = cms.untracked.string('.')
0224                                ),
0225 
0226         # Upload to CondDB
0227         connect = cms.string('oracle://cms_orcon_prod/CMS_CONDITIONS'),
0228         preLoadConnectionString = cms.untracked.string('frontier://FrontierProd/CMS_CONDITIONS'),
0229         runNumber = cms.untracked.uint64(options.runNumber),
0230         omsServiceUrl = cms.untracked.string(BSOnlineOmsServiceUrl),
0231         latency = cms.untracked.uint32(2),
0232         autoCommit = cms.untracked.bool(True),
0233         saveLogsOnDB = cms.untracked.bool(True),
0234         jobName = cms.untracked.string(BSOnlineJobName), # name of the DB log record
0235         toPut = cms.VPSet(cms.PSet(
0236             record = cms.string(BSOnlineRecordName),
0237             tag = cms.string(BSOnlineTag),
0238             timetype = cms.untracked.string('Lumi'),
0239             onlyAppendUpdatePolicy = cms.untracked.bool(True)
0240         )),
0241         frontierKey = cms.untracked.string(options.runUniqueKey)
0242       )
0243 
0244     else:
0245       process.OnlineDBOutputService = cms.Service("OnlineDBOutputService",
0246         DBParameters = cms.PSet(
0247                                 messageLevel = cms.untracked.int32(0),
0248                                 authenticationPath = cms.untracked.string('.')
0249                                 ),
0250 
0251         # Upload to CondDB
0252         connect = cms.string('sqlite_file:BeamSpotOnlineHLT.db'),
0253         preLoadConnectionString = cms.untracked.string('sqlite_file:BeamSpotOnlineHLT.db'),
0254         runNumber = cms.untracked.uint64(options.runNumber),
0255         lastLumiFile = cms.untracked.string('src/DQM/Integration/python/clients/last_lumi.txt'),
0256         latency = cms.untracked.uint32(2),
0257         autoCommit = cms.untracked.bool(True),
0258         toPut = cms.VPSet(cms.PSet(
0259             record = cms.string(BSOnlineRecordName),
0260             tag = cms.string(BSOnlineTag),
0261             timetype = cms.untracked.string('Lumi'),
0262             onlyAppendUpdatePolicy = cms.untracked.bool(True)
0263         )),
0264         frontierKey = cms.untracked.string(options.runUniqueKey)
0265       )
0266 
0267     print("Configured frontierKey", options.runUniqueKey)
0268 
0269     process.p = cms.Path( process.hltTriggerTypeFilter
0270                         * process.tcdsDigis
0271                         * process.dqmcommon
0272                         * process.offlineBeamSpot
0273                         * process.monitor )
0274 
0275 print("Final Source settings:", process.source)
0276