Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-27 23:38:14

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 process = cms.Process("L1ConfigWritePayloadOnline")
0004 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0005 process.MessageLogger.cout.enable = cms.untracked.bool(True)
0006 process.MessageLogger.cout.threshold = cms.untracked.string('DEBUG')
0007 process.MessageLogger.debugModules = cms.untracked.vstring('*')
0008 process.MessageLogger.suppressInfo = cms.untracked.vstring('L1TMuonBarrelParamsOnlineProd') # suppressDebug, suppressWarning
0009 
0010 import FWCore.ParameterSet.VarParsing as VarParsing
0011 options = VarParsing.VarParsing()
0012 options.register('tscKey',
0013                  '', #default value
0014                  VarParsing.VarParsing.multiplicity.singleton,
0015                  VarParsing.VarParsing.varType.string,
0016                  "TSC key")
0017 options.register('rsKey',
0018                  '', #default value
0019                  VarParsing.VarParsing.multiplicity.singleton,
0020                  VarParsing.VarParsing.varType.string,
0021                  "RS key")
0022 options.register('onlineDBConnect',
0023                  'oracle://CMS_OMDS_LB/CMS_TRG_R', #default value
0024                  VarParsing.VarParsing.multiplicity.singleton,
0025                  VarParsing.VarParsing.varType.string,
0026                  "Connection string for online DB")
0027 options.register('onlineDBAuth',
0028                  '.', #default value
0029                  VarParsing.VarParsing.multiplicity.singleton,
0030                  VarParsing.VarParsing.varType.string,
0031                  "Authentication path for online DB")
0032 options.register('protoDBConnect',
0033                  'oracle://cms_orcon_prod/CMS_CONDITIONS', #default value
0034                  VarParsing.VarParsing.multiplicity.singleton,
0035                  VarParsing.VarParsing.varType.string,
0036                  "Connection string for prototypes' DB")
0037 options.register('protoDBAuth',
0038                  '.', #default value
0039                  VarParsing.VarParsing.multiplicity.singleton,
0040                  VarParsing.VarParsing.varType.string,
0041                  "Authentication path for prototypes' DB")
0042 options.register('outputDBConnect',
0043                  'sqlite_file:l1config.db', #default value
0044                  VarParsing.VarParsing.multiplicity.singleton,
0045                  VarParsing.VarParsing.varType.string,
0046                  "Connection string for output DB")
0047 options.register('outputDBAuth',
0048                  '.', #default value
0049                  VarParsing.VarParsing.multiplicity.singleton,
0050                  VarParsing.VarParsing.varType.string,
0051                  "Authentication path for output DB")
0052 options.register('overwriteKeys',
0053                  0, #default value
0054                  VarParsing.VarParsing.multiplicity.singleton,
0055                  VarParsing.VarParsing.varType.int,
0056                  "Overwrite existing keys")
0057 options.register('logTransactions',
0058                  1, #default value
0059                  VarParsing.VarParsing.multiplicity.singleton,
0060                  VarParsing.VarParsing.varType.int,
0061                  "Record transactions in log DB")
0062 options.register('copyNonO2OPayloads',
0063                  0, #default value
0064                  VarParsing.VarParsing.multiplicity.singleton,
0065                  VarParsing.VarParsing.varType.int,
0066                  "Copy DTTF TSC payloads from ORCON")
0067 options.register('copyDBConnect',
0068                  'sqlite_file:l1config.db', #default value
0069                  VarParsing.VarParsing.multiplicity.singleton,
0070                  VarParsing.VarParsing.varType.string,
0071                  "Connection string for copy DB")
0072 options.register('copyDBAuth',
0073                  '.', #default value
0074                  VarParsing.VarParsing.multiplicity.singleton,
0075                  VarParsing.VarParsing.varType.string,
0076                  "Authentication path for copy DB")
0077 options.register('subsystemLabels',
0078                  'uGT,uGTrs,uGMT,CALO,BMTF,OMTF,EMTF', #default value
0079                  VarParsing.VarParsing.multiplicity.singleton,
0080                  VarParsing.VarParsing.varType.string,
0081                  "Comma-separated list of specific payloads to be processed")
0082 options.register('tagUpdate',
0083                  '', #default value
0084                  VarParsing.VarParsing.multiplicity.singleton,
0085                  VarParsing.VarParsing.varType.string,
0086                  "Comma-separated list of column-separated pairs relating type to a new tagBase")
0087 options.register('unsafe',
0088                  '', #default value
0089                  VarParsing.VarParsing.multiplicity.singleton,
0090                  VarParsing.VarParsing.varType.string,
0091                  "Comma-separated list of systems that we do not care about anymore")
0092 options.register('dropFromJob',
0093                  '', #default value
0094                  VarParsing.VarParsing.multiplicity.singleton,
0095                  VarParsing.VarParsing.varType.string,
0096                  "Comma-separated list of systems for which we must not create WriterProxy")
0097 
0098 options.parseArguments()
0099 
0100 # Generate L1TriggerKeyExt from OMDS
0101 process.load("CondTools.L1TriggerExt.L1SubsystemKeysOnlineExt_cfi")
0102 process.L1SubsystemKeysOnlineExt.tscKey = cms.string( options.tscKey )
0103 process.L1SubsystemKeysOnlineExt.rsKey  = cms.string( options.rsKey )
0104 process.L1SubsystemKeysOnlineExt.onlineDB = cms.string( options.onlineDBConnect )
0105 process.L1SubsystemKeysOnlineExt.onlineAuthentication = cms.string( options.onlineDBAuth )
0106 
0107 process.load("CondTools.L1TriggerExt.L1ConfigTSCKeysExt_cff")
0108 from CondTools.L1TriggerExt.L1ConfigTSCKeysExt_cff import setTSCKeysDB, liftKeySafetyFor
0109 setTSCKeysDB( process, options.onlineDBConnect, options.onlineDBAuth )
0110 liftKeySafetyFor( process, options.unsafe.split(',') )
0111 
0112 process.load("CondTools.L1TriggerExt.L1TriggerKeyOnlineExt_cfi")
0113 process.L1TriggerKeyOnlineExt.subsystemLabels = cms.vstring( options.subsystemLabels.split(',') )
0114 
0115 # Generate configuration data from OMDS
0116 process.load("CondTools.L1TriggerExt.L1ConfigTSCPayloadsExt_cff")
0117 from CondTools.L1TriggerExt.L1ConfigTSCPayloadsExt_cff import setTSCPayloadsDB, liftPayloadSafetyFor
0118 setTSCPayloadsDB( process, options.onlineDBConnect, options.onlineDBAuth, options.protoDBConnect, options.protoDBAuth )
0119 liftPayloadSafetyFor( process, options.unsafe.split(',') )
0120 print( "Lifted transaction safe for:", options.unsafe.split(',') )
0121 
0122 # Define CondDB tags
0123 from CondTools.L1TriggerExt.L1CondEnumExt_cfi import L1CondEnumExt
0124 from CondTools.L1TriggerExt.L1O2OTagsExt_cfi import initL1O2OTagsExt
0125 initL1O2OTagsExt()
0126 
0127 # Override the tag bases if instructed to do so
0128 if options.tagUpdate :
0129     for type2tagBase in options.tagUpdate.split(',') :
0130         (t,tagBase) = type2tagBase.split(':')
0131         index = L1CondEnumExt.__dict__[t]
0132         initL1O2OTagsExt.tagBaseVec[index] = tagBase
0133 
0134 # writer modules
0135 from CondTools.L1TriggerExt.L1CondDBPayloadWriterExt_cff import initPayloadWriterExt
0136 initPayloadWriterExt( process,
0137                    outputDBConnect = options.outputDBConnect,
0138                    outputDBAuth = options.outputDBAuth,
0139                    tagBaseVec = initL1O2OTagsExt.tagBaseVec )
0140 
0141 if options.logTransactions == 1:
0142 #    initPayloadWriterExt.outputDB.logconnect = cms.untracked.string('oracle://cms_orcon_prod/CMS_COND_31X_POPCONLOG')
0143     initPayloadWriterExt.outputDB.logconnect = cms.untracked.string('sqlite_file:l1o2o-log.db')
0144     process.L1CondDBPayloadWriterExt.logTransactions = True
0145 
0146 if options.overwriteKeys == 0:
0147     process.L1CondDBPayloadWriterExt.overwriteKeys = False
0148 else:
0149     process.L1CondDBPayloadWriterExt.overwriteKeys = True
0150                 
0151 process.maxEvents = cms.untracked.PSet(
0152     input = cms.untracked.int32(1)
0153 )
0154 
0155 process.load("CondCore.CondDB.CondDB_cfi")
0156 process.CondDB.connect = options.outputDBConnect if options.copyNonO2OPayloads == 0 else options.copyDBConnect
0157 
0158 # Suppress warnings, not actually used, except for copyNonO2OPayloads
0159 process.outputDB = cms.ESSource("PoolDBESSource",
0160                                 process.CondDB,
0161                                 toGet = cms.VPSet(cms.PSet(
0162     record = cms.string('L1TriggerKeyListExtRcd'),
0163     tag = cms.string( "L1TriggerKeyListExt_" + initL1O2OTagsExt.tagBaseVec[ L1CondEnumExt.L1TriggerKeyListExt ] )
0164     )),
0165                                 RefreshEachRun=cms.untracked.bool(True)
0166                                 )
0167 
0168 if options.copyNonO2OPayloads == 0:
0169     process.outputDB.DBParameters.authenticationPath = options.outputDBAuth
0170     process.source = cms.Source("EmptySource")
0171 else:
0172     process.outputDB.DBParameters.authenticationPath = options.copyDBAuth
0173     process.source = cms.Source("EmptyIOVSource",
0174                                 timetype = cms.string('runnumber'),
0175                                 firstValue = cms.uint64(4294967295),
0176                                 lastValue = cms.uint64(4294967295),
0177                                 interval = cms.uint64(1) )
0178                             
0179 systems = process.L1CondDBPayloadWriterExt.sysWriters
0180 ## still need a method to handle exceptions for existing payloads in the CondDB
0181 systems.remove("L1TMuonEndCapForestO2ORcd@L1TMuonEndCapForest")
0182 systems.remove("L1TMuonOverlapParamsO2ORcd@L1TMuonOverlapParams")
0183 if "uGMT" in options.dropFromJob:
0184     systems.remove("L1TMuonGlobalParamsO2ORcd@L1TMuonGlobalParams")
0185 if "EMTF" in options.dropFromJob:
0186     systems.remove("L1TMuonEndCapParamsO2ORcd@L1TMuonEndCapParams")
0187     ## still need a method to handle exceptions for existing payloads in the CondDB
0188 if "OMTF" in options.dropFromJob:
0189     systems.remove("L1TMuonOverlapFwVersionO2ORcd@L1TMuonOverlapFwVersion")
0190     ## still need a method to handle exceptions for existing payloads in the CondDB
0191 if "BMTF" in options.dropFromJob:
0192     systems.remove("L1TMuonBarrelParamsO2ORcd@L1TMuonBarrelParams")
0193 if "CALO" in options.dropFromJob:
0194     systems.remove("L1TCaloParamsO2ORcd@CaloParams")
0195 if "uGT" in options.dropFromJob:
0196     systems.remove("L1TUtmTriggerMenuO2ORcd@L1TUtmTriggerMenu")
0197 if "uGTrs" in options.dropFromJob:
0198     systems.remove("L1TGlobalPrescalesVetosFractO2ORcd@L1TGlobalPrescalesVetosFract")
0199 print( "Will create only the following writers:", process.L1CondDBPayloadWriterExt.sysWriters )
0200 
0201 process.p = cms.Path(process.L1CondDBPayloadWriterExt)