Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:19

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 #process.load("CondCore.DBCommon.CondDBCommon_cfi")
0007 #process.CondDBCommon.connect = 'sqlite_file:lhcinfoperls_pop_test.db'
0008 #process.CondDBCommon.DBParameters.authenticationPath = '.'
0009 #process.CondDBCommon.DBParameters.messageLevel=cms.untracked.int32(1)
0010 
0011 sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R'
0012 if socket.getfqdn().find('.cms') != -1:
0013     sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R'
0014 
0015 options = VarParsing.VarParsing()
0016 options.register( 'mode'
0017                 , None # Required parameter
0018                 , VarParsing.VarParsing.multiplicity.singleton
0019                 , VarParsing.VarParsing.varType.string
0020                 , "The mode the fills are going to be process and the data gathered. Accepted values: duringFill endFill"
0021                   )
0022 options.register( 'destinationConnection'
0023                 , 'sqlite_file:lhcinfo_pop_test.db' #default value
0024                 , VarParsing.VarParsing.multiplicity.singleton
0025                 , VarParsing.VarParsing.varType.string
0026                 , "Connection string to the DB where payloads will be possibly written."
0027                   )
0028 options.register( 'targetConnection'
0029                 , '' #default value
0030                 , VarParsing.VarParsing.multiplicity.singleton
0031                 , VarParsing.VarParsing.varType.string
0032                 , """Connection string to the target DB:
0033                      if not empty (default), this provides the latest IOV and payloads to compare;
0034                      it is the DB where payloads should be finally uploaded."""
0035                   )
0036 options.register( 'tag'
0037                 , 'LHCInfoPerFill_PopCon_test'
0038                 , VarParsing.VarParsing.multiplicity.singleton
0039                 , VarParsing.VarParsing.varType.string
0040                 , "Tag written in destinationConnection and finally appended in targetConnection."
0041                   )
0042 options.register( 'messageLevel'
0043                 , 0 #default value
0044                 , VarParsing.VarParsing.multiplicity.singleton
0045                 , VarParsing.VarParsing.varType.int
0046                 , "Message level; default to 0"
0047                   )
0048 options.register( 'startTime'
0049                 , '2021-09-10 03:10:18.000'
0050                 , VarParsing.VarParsing.multiplicity.singleton
0051                 , VarParsing.VarParsing.varType.string
0052                 , """Date and time of the start of processing:
0053                      processes only fills starting at startTime or later"""
0054                   )
0055 options.register( 'endTime'
0056                 , ''
0057                 , VarParsing.VarParsing.multiplicity.singleton
0058                 , VarParsing.VarParsing.varType.string
0059                 , """Date and time of the start of processing:
0060                      processes only fills starting before endTime;
0061                      default to empty string which sets no restriction"""
0062                   )
0063 options.parseArguments()
0064 if options.mode is None:
0065   raise ValueError("mode argument not provided. Supported modes are: duringFill endFill")
0066 if options.mode not in ("duringFill", "endFill"):
0067   raise ValueError("Wrong mode argument. Supported modes are: duringFill endFill")
0068 
0069 CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
0070 CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
0071 
0072 process.MessageLogger = cms.Service("MessageLogger",
0073                                     cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')),
0074                                     destinations = cms.untracked.vstring('cout')
0075                                     )
0076 
0077 process.source = cms.Source("EmptyIOVSource",
0078                             lastValue = cms.uint64(1),
0079                             timetype = cms.string('runnumber'),
0080                             firstValue = cms.uint64(1),
0081                             interval = cms.uint64(1)
0082                             )
0083 
0084 # Write different time-types tags depending on the O2O mode
0085 if options.mode == 'endFill':
0086   timetype = 'timestamp'
0087 else:
0088   timetype = 'lumiid'
0089 
0090 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0091                                           CondDBConnection,
0092                                           timetype = cms.untracked.string(timetype),
0093                                           toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerFillRcd'),
0094                                                                      tag = cms.string( options.tag )
0095                                                                      )
0096                                                             )
0097                                           )
0098 
0099 process.Test1 = cms.EDAnalyzer("LHCInfoPerFillPopConAnalyzer",
0100                                SinceAppendMode = cms.bool(True),
0101                                record = cms.string('LHCInfoPerFillRcd'),
0102                                name = cms.untracked.string('LHCInfo'),
0103                                Source = cms.PSet(fill = cms.untracked.uint32(6417),
0104                                    startTime = cms.untracked.string(options.startTime),
0105                                    endTime = cms.untracked.string(options.endTime),
0106                                    endFill = cms.untracked.bool(True if options.mode == "endFill" else False),
0107                                    name = cms.untracked.string("LHCInfoPerFillPopConSourceHandler"),
0108                                    connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"),
0109                                    ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"),
0110                                    omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"),
0111                                    authenticationPath = cms.untracked.string(""),
0112                                    debug=cms.untracked.bool(False)
0113                                                  ),
0114                                loggingOn = cms.untracked.bool(True),
0115                                IsDestDbCheckedInQueryLog = cms.untracked.bool(False)
0116                                )
0117 
0118 process.p = cms.Path(process.Test1)