Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-07 06:12:39

0001 import socket
0002 import FWCore.ParameterSet.Config as cms
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 process = cms.Process("LHCInfoPerFillPopulator")
0005 from CondCore.CondDB.CondDB_cfi import *
0006 
0007 sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R'
0008 if socket.getfqdn().find('.cms') != -1:
0009     sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R'
0010 
0011 options = VarParsing.VarParsing()
0012 options.register( 'mode'
0013                 , None # Required parameter
0014                 , VarParsing.VarParsing.multiplicity.singleton
0015                 , VarParsing.VarParsing.varType.string
0016                 , "The mode the fills are going to be process and the data gathered. Accepted values: duringFill endFill"
0017                   )
0018 options.register( 'destinationConnection'
0019                 , 'sqlite_file:lhcinfo_pop_test.db' #default value
0020                 , VarParsing.VarParsing.multiplicity.singleton
0021                 , VarParsing.VarParsing.varType.string
0022                 , "Connection string to the DB where payloads will be possibly written."
0023                   )
0024 options.register( 'targetConnection'
0025                 , '' #default value
0026                 , VarParsing.VarParsing.multiplicity.singleton
0027                 , VarParsing.VarParsing.varType.string
0028                 , """Connection string to the target DB:
0029                      if not empty (default), this provides the latest IOV and payloads to compare;
0030                      it is the DB where payloads should be finally uploaded."""
0031                   )
0032 options.register( 'tag'
0033                 , 'LHCInfoPerFill_PopCon_test'
0034                 , VarParsing.VarParsing.multiplicity.singleton
0035                 , VarParsing.VarParsing.varType.string
0036                 , "Tag written in destinationConnection and finally appended in targetConnection."
0037                   )
0038 options.register( 'messageLevel'
0039                 , 0 #default value
0040                 , VarParsing.VarParsing.multiplicity.singleton
0041                 , VarParsing.VarParsing.varType.int
0042                 , "Message level; default to 0"
0043                   )
0044 options.register( 'startTime'
0045                 , '2021-09-10 03:10:18.000'
0046                 , VarParsing.VarParsing.multiplicity.singleton
0047                 , VarParsing.VarParsing.varType.string
0048                 , """Date and time of the start of processing:
0049                      processes only fills starting at startTime or later"""
0050                   )
0051 options.register( 'endTime'
0052                 , ''
0053                 , VarParsing.VarParsing.multiplicity.singleton
0054                 , VarParsing.VarParsing.varType.string
0055                 , """Date and time of the start of processing:
0056                      processes only fills starting before endTime;
0057                      default to empty string which sets no restriction"""
0058                   )
0059 
0060 options.register( 'sourceConnection'
0061                 , "oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"
0062                 , VarParsing.VarParsing.multiplicity.singleton
0063                 , VarParsing.VarParsing.varType.string
0064                 , """beam data source connection string (aka PPS db)"""
0065                   )
0066 options.register( 'ecalConnection'
0067                 , "oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"
0068                 , VarParsing.VarParsing.multiplicity.singleton
0069                 , VarParsing.VarParsing.varType.string
0070                 , """ecal data source connection string"""
0071                   )
0072 options.register( 'oms'
0073                 , "http://vocms0184.cern.ch/agg/api/v1"
0074                 , VarParsing.VarParsing.multiplicity.singleton
0075                 , VarParsing.VarParsing.varType.string
0076                 , """OMS base URL"""
0077                   )
0078 
0079 #duringFill mode specific:
0080 options.register( 'lastLumiFile'
0081                 , ''
0082                 , VarParsing.VarParsing.multiplicity.singleton
0083                 , VarParsing.VarParsing.varType.string
0084                 , """duringFill only: path to file with lumiid to override the last lumisection processed by HLT.
0085                      Used for testing. Leave empty for production behaviour (getting this info from OMS)"""
0086                   )
0087 options.register( 'frontierKey'
0088                 , ''
0089                 , VarParsing.VarParsing.multiplicity.singleton
0090                 , VarParsing.VarParsing.varType.string
0091                 , """duringFill only: run-unique key for writing with OnlinePopCon
0092                      (used for confirming proper upload)"""
0093                   )
0094 
0095 
0096 # so far there was no need to use option, added just in case
0097 options.register( 'authenticationPath'
0098                 , ""
0099                 , VarParsing.VarParsing.multiplicity.singleton
0100                 , VarParsing.VarParsing.varType.string
0101                 , """for now this option was always left empty"""
0102                   )
0103 
0104 options.parseArguments()
0105 if options.mode is None:
0106   raise ValueError("mode argument not provided. Supported modes are: duringFill endFill")
0107 if options.mode not in ("duringFill", "endFill"):
0108   raise ValueError("Wrong mode argument. Supported modes are: duringFill endFill")
0109 
0110 CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
0111 CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
0112 CondDBConnection.DBParameters.authenticationPath = cms.untracked.string(options.authenticationPath)
0113 
0114 process.MessageLogger = cms.Service("MessageLogger",
0115                                     cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')),
0116                                     destinations = cms.untracked.vstring('cout')
0117                                     )
0118 
0119 process.source = cms.Source("EmptyIOVSource",
0120                             lastValue = cms.uint64(1),
0121                             timetype = cms.string('runnumber'),
0122                             firstValue = cms.uint64(1),
0123                             interval = cms.uint64(1)
0124                             )
0125 
0126 # Write different time-types tags depending on the O2O mode
0127 if options.mode == 'endFill':
0128   timetype = 'timestamp'
0129 else:
0130   timetype = 'lumiid'
0131 
0132 if options.mode == "endFill":
0133   process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0134                                             CondDBConnection,
0135                                             timetype = cms.untracked.string(timetype),
0136                                             toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerFillRcd'),
0137                                                                       tag = cms.string( options.tag )
0138                                                                       )
0139                                                               )
0140                                             )
0141 else:
0142   process.OnlineDBOutputService = cms.Service("OnlineDBOutputService",
0143     CondDBConnection,
0144     preLoadConnectionString = cms.untracked.string('frontier://FrontierProd/CMS_CONDITIONS' 
0145                                                 if not options.destinationConnection.startswith('sqlite') 
0146                                                 else options.destinationConnection ), 
0147     lastLumiFile = cms.untracked.string(options.lastLumiFile),
0148     omsServiceUrl = cms.untracked.string('http://cmsoms-eventing.cms:9949/urn:xdaq-application:lid=100/getRunAndLumiSection'
0149                                          if not options.lastLumiFile else "" ),
0150     # runNumber = cms.untracked.uint64(384468), #not used in production, the last LS processed is set as the 1st LS of this
0151                                             #run if the omsServiceUrl is empty and file specified in lastLumiFile is empty
0152     latency = cms.untracked.uint32(2),
0153     timetype = cms.untracked.string(timetype),
0154     toPut = cms.VPSet(cms.PSet(
0155         record = cms.string('LHCInfoPerFillRcd'),
0156         tag = cms.string( options.tag ),
0157         onlyAppendUpdatePolicy = cms.untracked.bool(True)
0158     )),
0159     frontierKey = cms.untracked.string(options.frontierKey)
0160 )
0161 
0162 
0163 process.Test1 = cms.EDAnalyzer("LHCInfoPerFillPopConAnalyzer" if options.mode == "endFill" else "LHCInfoPerFillOnlinePopConAnalyzer",
0164                                SinceAppendMode = cms.bool(True),
0165                                record = cms.string('LHCInfoPerFillRcd'),
0166                                name = cms.untracked.string('LHCInfo'),
0167                                Source = cms.PSet(
0168                                    startTime = cms.untracked.string(options.startTime),
0169                                    endTime = cms.untracked.string(options.endTime),
0170                                    endFill = cms.untracked.bool(options.mode == "endFill"),
0171                                    name = cms.untracked.string("LHCInfoPerFillPopConSourceHandler"),
0172                                    connectionString = cms.untracked.string(options.sourceConnection),
0173                                    ecalConnectionString = cms.untracked.string(options.ecalConnection),
0174                                    omsBaseUrl = cms.untracked.string(options.oms),
0175                                    authenticationPath = cms.untracked.string(options.authenticationPath),
0176                                    debug=cms.untracked.bool(False)
0177                                ),
0178                                loggingOn = cms.untracked.bool(True),
0179                                IsDestDbCheckedInQueryLog = cms.untracked.bool(False)
0180                                )
0181 
0182 process.p = cms.Path(process.Test1)