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