1 from __future__
import print_function
11 import FWCore.ParameterSet.Config
as cms
12 import FWCore.ParameterSet.VarParsing
as VarParsing
13 from xml.etree.ElementTree
import parse
21 print(
"Usage: cmsRun loadConditions.py file=FILENAME record=RECORD db=CONNECTSTRING")
23 print(
" specify xml file to load to DB")
25 print(
" record=RECORD")
26 print(
" specify record to be loaded (EcalChannelStatus, etc)")
28 print(
" db=CONNECTSTRING")
29 print(
" specify connection string, e.g. sqlite_file=file.db")
37 options.register (
'file',
39 VarParsing.VarParsing.multiplicity.singleton,
40 VarParsing.VarParsing.varType.string,
43 options.register (
'record',
45 VarParsing.VarParsing.multiplicity.singleton,
46 VarParsing.VarParsing.varType.string,
47 "record type to load")
49 options.register (
'db',
51 VarParsing.VarParsing.multiplicity.singleton,
52 VarParsing.VarParsing.varType.string,
53 "db connection string")
55 options.parseArguments()
59 '''Read tag and since from EcalCondHeader in XML file ''' 60 root =
parse(filename).getroot()
61 header = root.find(headertag)
62 since = header.findtext(
'since')
63 tag = header.findtext(
'tag')
71 analyzer_ = {
'EcalGainRatios':
'EcalGainRatiosAnalyzer', \
72 'EcalADCToGeVConstant':
'EcalADCToGeVConstantAnalyzer', \
73 'EcalWeightXtalGroups':
'EcalWeightGroupAnalyzer', \
74 'EcalChannelStatus':
'EcalChannelStatusHandler', \
75 'EcalChannelStatus':
'EcalChannelStatusAnalyzer', \
76 'EcalTBWeights':
'EcalTBWeightsAnalyzer', \
77 'EcalIntercalibConstants':
'EcalIntercalibConstantsAnalyzer', \
78 'EcalIntercalibConstantsMC':
'EcalIntercalibConstantsMCAnalyzer', \
79 'EcalIntercalibErrors':
'EcalIntercalibErrorsAnalyzer' 84 process = cms.Process(
"LoadEcalConditions")
86 process.source = cms.Source(
"EmptyIOVSource",
87 timetype = cms.string(
'runnumber'),
88 firstValue = cms.uint64(1),
89 lastValue = cms.uint64(1),
90 interval = cms.uint64(1)
94 process.load(
"CondCore.DBCommon.CondDBCommon_cfi")
95 process.CondDBCommon.connect = cms.string(options.db)
96 process.CondDBCommon.DBParameters.authenticationPath = cms.untracked.string(
'/afs/cern.ch/cms/DB/conddb')
98 process.PoolDBOutputService = cms.Service(
"PoolDBOutputService",
100 timetype = cms.untracked.string(
'runnumber'),
101 toPut = cms.VPSet(cms.PSet(
102 record = cms.string(options.record+
'Rcd'),
103 tag = cms.string(tag_)
105 logconnect= cms.untracked.string(
'sqlite_file:log.db')
109 process.popconAnalyzer = cms.EDAnalyzer(analyzer_[options.record],
110 record = cms.string(options.record+
'Rcd'),
111 loggingOn= cms.untracked.bool(
True),
112 SinceAppendMode=cms.bool(
True),
114 xmlFile = cms.untracked.string(options.file),
115 since = cms.untracked.int64(
int(since_))
121 process.p = cms.Path(process.popconAnalyzer)
vector< string > parse(string line, const string &delimiter)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def readTagAndSince(filename, headertag='EcalCondHeader')