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("LHCInfoPerLSPopulator")
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
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'
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 , ''
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 , 'LHCInfoPerLS_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
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 It's the source of crossing angle and beta * data"""
0066 )
0067 options.register( 'oms'
0068 , "http://vocms0184.cern.ch/agg/api/v1"
0069 , VarParsing.VarParsing.multiplicity.singleton
0070 , VarParsing.VarParsing.varType.string
0071 , """OMS base URL"""
0072 )
0073
0074
0075 options.register( 'lastLumiFile'
0076 , ''
0077 , VarParsing.VarParsing.multiplicity.singleton
0078 , VarParsing.VarParsing.varType.string
0079 , """duringFill only: path to file with lumiid to override the last lumisection processed by HLT.
0080 Used for testing. Leave empty for production behaviour (getting this info from OMS)"""
0081 )
0082 options.register( 'frontierKey'
0083 , ''
0084 , VarParsing.VarParsing.multiplicity.singleton
0085 , VarParsing.VarParsing.varType.string
0086 , """duringFill only: run-unique key for writing with OnlinePopCon
0087 (used for confirming proper upload)"""
0088 )
0089 options.register('offsetLS'
0090 , 2
0091 , VarParsing.VarParsing.multiplicity.singleton
0092 , VarParsing.VarParsing.varType.int
0093 , """duringFill only: offset between lastLumi (last LS processed by HLT or overriden by lastLumiFile)
0094 and the IOV of the payload to be uploaded"""
0095 )
0096 options.register( 'debugLogic'
0097 , False
0098 , VarParsing.VarParsing.multiplicity.singleton
0099 , VarParsing.VarParsing.varType.bool
0100 , """duringFill only: Enables debug logic, meant to be used only for tests"""
0101 )
0102 options.register( 'defaultXangleX'
0103 , 160.0
0104 , VarParsing.VarParsing.multiplicity.singleton
0105 , VarParsing.VarParsing.varType.float
0106 , """duringFill only: crossingAngleX value (in urad) for the default payload.
0107 The default payload is inserted after the last processed fill has ended
0108 and there's no ongoing stable beam yet. """
0109 )
0110 options.register( 'defaultXangleY'
0111 , 0.0
0112 , VarParsing.VarParsing.multiplicity.singleton
0113 , VarParsing.VarParsing.varType.float
0114 , """duringFill only: crossingAngleY value (in urad) for the default payload.
0115 The default payload is inserted after the last processed fill has ended
0116 and there's no ongoing stable beam yet. """
0117 )
0118 options.register( 'defaultBetaX'
0119 , 0.3
0120 , VarParsing.VarParsing.multiplicity.singleton
0121 , VarParsing.VarParsing.varType.float
0122 , """duringFill only: betaStarX value (in meters) for the default payload.
0123 The default payload is inserted after the last processed fill has ended
0124 and there's no ongoing stable beam yet. """
0125 )
0126 options.register( 'defaultBetaY'
0127 , 0.3
0128 , VarParsing.VarParsing.multiplicity.singleton
0129 , VarParsing.VarParsing.varType.float
0130 , """duringFill only: betaStarY value (in meters) for the default payload.
0131 The default payload is inserted after the last processed fill has ended
0132 and there's no ongoing stable beam yet. """
0133 )
0134
0135
0136
0137 options.register('minBetaStar', 0.1
0138 , VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
0139 , """duringFill only: [meters] min value of the range of valid values.
0140 If the value is outside of this range the payload is not uploaded""")
0141 options.register('maxBetaStar', 100.
0142 , VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
0143 , """duringFill only: [meters] min value of the range of valid values.
0144 If the value is outside of this range the payload is not uploaded""")
0145 options.register('minCrossingAngle', 10.
0146 , VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
0147 , """duringFill only: [urad] min value of the range of valid values.
0148 If the value is outside of this range the payload is not uploaded""")
0149 options.register('maxCrossingAngle', 500.
0150 , VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
0151 , """duringFill only: [urad] min value of the range of valid values.
0152 If the value is outside of this range the payload is not uploaded""")
0153
0154
0155 options.register( 'authenticationPath'
0156 , ""
0157 , VarParsing.VarParsing.multiplicity.singleton
0158 , VarParsing.VarParsing.varType.string
0159 , """for now this option was always left empty"""
0160 )
0161
0162 options.parseArguments()
0163 if options.mode is None:
0164 raise ValueError("mode argument not provided. Supported modes are: duringFill endFill")
0165 if options.mode not in ("duringFill", "endFill"):
0166 raise ValueError("Wrong mode argument. Supported modes are: duringFill endFill")
0167
0168 CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
0169 CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
0170 CondDBConnection.DBParameters.authenticationPath = cms.untracked.string(options.authenticationPath)
0171
0172 process.MessageLogger = cms.Service("MessageLogger",
0173 cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')),
0174 destinations = cms.untracked.vstring('cout')
0175 )
0176
0177 process.source = cms.Source("EmptyIOVSource",
0178 lastValue = cms.uint64(1),
0179 timetype = cms.string('runnumber'),
0180 firstValue = cms.uint64(1),
0181 interval = cms.uint64(1)
0182 )
0183
0184
0185 if options.mode == 'endFill':
0186 timetype = 'timestamp'
0187 else:
0188 timetype = 'lumiid'
0189
0190 if options.mode == "endFill":
0191 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0192 CondDBConnection,
0193 timetype = cms.untracked.string(timetype),
0194 toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerLSRcd'),
0195 tag = cms.string( options.tag )
0196 )
0197 )
0198 )
0199 else:
0200 process.OnlineDBOutputService = cms.Service("OnlineDBOutputService",
0201 CondDBConnection,
0202 preLoadConnectionString = cms.untracked.string('frontier://FrontierProd/CMS_CONDITIONS'
0203 if not options.destinationConnection.startswith('sqlite')
0204 else options.destinationConnection ),
0205 lastLumiFile = cms.untracked.string(options.lastLumiFile),
0206 omsServiceUrl = cms.untracked.string('http://cmsoms-eventing.cms:9949/urn:xdaq-application:lid=100/getRunAndLumiSection'
0207 if not options.lastLumiFile else "" ),
0208
0209
0210 latency = cms.untracked.uint32(options.offsetLS),
0211 timetype = cms.untracked.string(timetype),
0212 toPut = cms.VPSet(cms.PSet(
0213 record = cms.string('LHCInfoPerLSRcd'),
0214 tag = cms.string( options.tag ),
0215 onlyAppendUpdatePolicy = cms.untracked.bool(True)
0216 )),
0217 frontierKey = cms.untracked.string(options.frontierKey)
0218 )
0219
0220
0221 process.Test1 = cms.EDAnalyzer(("LHCInfoPerLSPopConAnalyzer" if options.mode == "endFill"
0222 else "LHCInfoPerLSOnlinePopConAnalyzer"),
0223 SinceAppendMode = cms.bool(True),
0224 record = cms.string('LHCInfoPerLSRcd'),
0225 name = cms.untracked.string('LHCInfo'),
0226 Source = cms.PSet(
0227 startTime = cms.untracked.string(options.startTime),
0228 endTime = cms.untracked.string(options.endTime),
0229 endFill = cms.untracked.bool(options.mode == "endFill"),
0230 name = cms.untracked.string("LHCInfoPerLSPopConSourceHandler"),
0231 connectionString = cms.untracked.string(options.sourceConnection),
0232 omsBaseUrl = cms.untracked.string(options.oms),
0233 authenticationPath = cms.untracked.string(options.authenticationPath),
0234 debug=cms.untracked.bool(False),
0235 debugLogic=cms.untracked.bool(options.debugLogic),
0236 defaultCrossingAngleX = cms.untracked.double(options.defaultXangleX),
0237 defaultCrossingAngleY = cms.untracked.double(options.defaultXangleY),
0238 defaultBetaStarX = cms.untracked.double(options.defaultBetaX),
0239 defaultBetaStarY = cms.untracked.double(options.defaultBetaY),
0240 minBetaStar = cms.untracked.double(options.minBetaStar),
0241 maxBetaStar = cms.untracked.double(options.maxBetaStar),
0242 minCrossingAngle = cms.untracked.double(options.minCrossingAngle),
0243 maxCrossingAngle = cms.untracked.double(options.maxCrossingAngle),
0244 ),
0245 loggingOn = cms.untracked.bool(True),
0246 IsDestDbCheckedInQueryLog = cms.untracked.bool(False)
0247 )
0248
0249 process.p = cms.Path(process.Test1)