File indexing completed on 2024-11-25 02:29:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 import FWCore.ParameterSet.Config as cms
0011 import FWCore.ParameterSet.VarParsing as VarParsing
0012 from xml.etree.ElementTree import parse
0013 import sys,os
0014
0015
0016
0017
0018 def usage():
0019
0020 print("Usage: cmsRun loadConditions.py file=FILENAME record=RECORD db=CONNECTSTRING")
0021 print(" file=FILE")
0022 print(" specify xml file to load to DB")
0023 print()
0024 print(" record=RECORD")
0025 print(" specify record to be loaded (EcalChannelStatus, etc)")
0026 print()
0027 print(" db=CONNECTSTRING")
0028 print(" specify connection string, e.g. sqlite_file=file.db")
0029 print()
0030
0031
0032 usage()
0033
0034
0035 options = VarParsing.VarParsing ()
0036 options.register ('file',
0037 "",
0038 VarParsing.VarParsing.multiplicity.singleton,
0039 VarParsing.VarParsing.varType.string,
0040 "xml file to load")
0041
0042 options.register ('record',
0043 "",
0044 VarParsing.VarParsing.multiplicity.singleton,
0045 VarParsing.VarParsing.varType.string,
0046 "record type to load")
0047
0048 options.register ('db',
0049 "",
0050 VarParsing.VarParsing.multiplicity.singleton,
0051 VarParsing.VarParsing.varType.string,
0052 "db connection string")
0053
0054 options.parseArguments()
0055
0056
0057 def readTagAndSince(filename, headertag='EcalCondHeader'):
0058 '''Read tag and since from EcalCondHeader in XML file '''
0059 root = parse(filename).getroot()
0060 header = root.find(headertag)
0061 since = header.findtext('since')
0062 tag = header.findtext('tag')
0063
0064 return tag,since
0065
0066
0067 tag_ , since_ = readTagAndSince(options.file)
0068
0069
0070 analyzer_ = {'EcalGainRatios':'EcalGainRatiosAnalyzer', \
0071 'EcalADCToGeVConstant':'EcalADCToGeVConstantAnalyzer', \
0072 'EcalWeightXtalGroups':'EcalWeightGroupAnalyzer', \
0073 'EcalChannelStatus':'EcalChannelStatusHandler', \
0074 'EcalChannelStatus':'EcalChannelStatusAnalyzer', \
0075 'EcalTBWeights':'EcalTBWeightsAnalyzer', \
0076 'EcalIntercalibConstants':'EcalIntercalibConstantsAnalyzer', \
0077 'EcalIntercalibConstantsMC':'EcalIntercalibConstantsMCAnalyzer', \
0078 'EcalIntercalibErrors':'EcalIntercalibErrorsAnalyzer'
0079 }
0080
0081
0082
0083 process = cms.Process("LoadEcalConditions")
0084
0085 process.source = cms.Source("EmptyIOVSource",
0086 timetype = cms.string('runnumber'),
0087 firstValue = cms.uint64(1),
0088 lastValue = cms.uint64(1),
0089 interval = cms.uint64(1)
0090 )
0091
0092
0093 process.load("CondCore.DBCommon.CondDBCommon_cfi")
0094 process.CondDBCommon.connect = cms.string(options.db)
0095 process.CondDBCommon.DBParameters.authenticationPath = cms.untracked.string('/afs/cern.ch/cms/DB/conddb')
0096
0097 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0098 process.CondDBCommon,
0099 timetype = cms.untracked.string('runnumber'),
0100 toPut = cms.VPSet(cms.PSet(
0101 record = cms.string(options.record+'Rcd'),
0102 tag = cms.string(tag_)
0103 )),
0104 logconnect= cms.untracked.string('sqlite_file:log.db')
0105 )
0106
0107
0108 process.popconAnalyzer = cms.EDAnalyzer(analyzer_[options.record],
0109 record = cms.string(options.record+'Rcd'),
0110 loggingOn= cms.untracked.bool(True),
0111 SinceAppendMode=cms.bool(True),
0112 Source=cms.PSet(
0113 xmlFile = cms.untracked.string(options.file),
0114 since = cms.untracked.int64(int(since_))
0115
0116 )
0117 )
0118
0119
0120 process.p = cms.Path(process.popconAnalyzer)
0121
0122