File indexing completed on 2023-03-17 10:42:26
0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 import os
0005
0006 options = VarParsing.VarParsing()
0007
0008 options.register('dbformat',
0009 'Legacy',
0010 VarParsing.VarParsing.multiplicity.singleton,
0011 VarParsing.VarParsing.varType.string,
0012 "DB format to use: 'Legacy' or 'DTRecoConditions'")
0013
0014 options.register('type',
0015 'TTrigDB',
0016 VarParsing.VarParsing.multiplicity.singleton,
0017 VarParsing.VarParsing.varType.string,
0018 "Database to read: 'TZeroDB', 'TTrigDB', 'VDriftDB', or 'UncertDB'")
0019
0020 options.register('inputfile',
0021 '',
0022 VarParsing.VarParsing.multiplicity.singleton,
0023 VarParsing.VarParsing.varType.string,
0024 "Input text file to be converted")
0025
0026
0027 options.parseArguments()
0028
0029 DBFORMAT = options.dbformat
0030 TYPE = options.type
0031 INPUTFILE = options.inputfile
0032
0033
0034
0035 if DBFORMAT not in ['Legacy', 'DTRecoConditions'] :
0036 print('\nERROR: invalid value for dbformat: ', DBFORMAT,'\n')
0037 exit()
0038
0039 if TYPE not in ['TZeroDB', 'TTrigDB', 'VDriftDB', 'UncertDB'] :
0040 print('\nERROR: invalid value for type: ', TYPE,'\n')
0041 exit()
0042
0043 if INPUTFILE == '' :
0044 print('\nERROR: must specify inputfile\n')
0045 exit()
0046
0047
0048
0049 process = cms.Process("DumpFileToDB")
0050 process.load("CondCore.DBCommon.CondDBSetup_cfi")
0051
0052
0053 process.source = cms.Source("EmptySource",
0054 numberEventsInRun = cms.untracked.uint32(1),
0055 firstRun = cms.untracked.uint32(1)
0056 )
0057
0058 process.maxEvents = cms.untracked.PSet(
0059 input = cms.untracked.int32(1)
0060 )
0061
0062
0063
0064 OUTPUTFILE = INPUTFILE.replace('.txt','')+"_"+DBFORMAT+".db"
0065
0066
0067 RECORD=""
0068 GRANULARITY = "bySL"
0069
0070 if TYPE=="TZeroDB" :
0071 RECORD = "DTT0Rcd"
0072 GRANULARITY = "byWire"
0073 if DBFORMAT=="Legacy" :
0074 if TYPE=="TTrigDB" : RECORD = "DTTtrigRcd"
0075 if TYPE=="VDriftDB" : RECORD = "DTMtimeRcd"
0076 if TYPE=="UncertDB" :
0077 RECORD = ""
0078 print('\nERROR, Legacy RecoUncertDB is no longer supported')
0079 elif DBFORMAT=="DTRecoConditions" :
0080 if TYPE=="TTrigDB" : RECORD = "DTRecoConditionsTtrigRcd"
0081 if TYPE=="VDriftDB" : RECORD = "DTRecoConditionsVdriftRcd"
0082 if TYPE=="UncertDB" :
0083 RECORD = "DTRecoConditionsUncertRcd"
0084 TYPE='RecoUncertDB'
0085 try:
0086 os.remove(OUTPUTFILE)
0087 except OSError:
0088 pass
0089
0090
0091 print('\n Reading ', TYPE, ' from ', INPUTFILE)
0092 print(' Record : ', RECORD)
0093 print('writing db file : ', OUTPUTFILE, '\n')
0094
0095
0096 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0097 process.CondDBSetup,
0098 connect = cms.string("sqlite_file:"+OUTPUTFILE),
0099 toPut = cms.VPSet(cms.PSet(record = cms.string(RECORD),
0100 tag = cms.string(TYPE)))
0101 )
0102
0103
0104
0105
0106 process.dumpToDB = cms.EDAnalyzer("DumpFileToDB",
0107 calibFileConfig = cms.untracked.PSet(
0108 calibConstFileName = cms.untracked.string(INPUTFILE),
0109 calibConstGranularity = cms.untracked.string(GRANULARITY),
0110 ),
0111 dbFormat = cms.untracked.string(DBFORMAT),
0112 dbToDump = cms.untracked.string(TYPE),
0113 )
0114
0115
0116
0117
0118 process.p = cms.Path(process.dumpToDB)
0119
0120