Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-18 02:24:41

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 
0005 options = VarParsing.VarParsing()
0006 
0007 options.register('dbformat',
0008                  'Legacy', #default value
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', #default value
0015                  VarParsing.VarParsing.multiplicity.singleton,
0016                  VarParsing.VarParsing.varType.string,
0017                  "Database to read: 'TZeroDB', 'TTrigDB',  'VDriftDB', 'UncertDB', 'NoiseDB', 'DeadDB', 'ChannelsDB'")
0018 
0019 options.register('GT',
0020                  'auto:run2_data', #default value
0021                  VarParsing.VarParsing.multiplicity.singleton,
0022                  VarParsing.VarParsing.varType.string,
0023                  "Global tag to read, default is auto:run2_data")
0024 
0025 options.register('inputfile',
0026                  '', #default value
0027                  VarParsing.VarParsing.multiplicity.singleton,
0028                  VarParsing.VarParsing.varType.string,
0029                  "Read payload from db file instead than GT")
0030 
0031 options.register('inputtag',
0032                  '', #default value
0033                  VarParsing.VarParsing.multiplicity.singleton,
0034                  VarParsing.VarParsing.varType.string,
0035                  "Read payload from tag in frontier instead than GT")
0036 
0037 options.register('run',
0038                  999999, #default value
0039                  VarParsing.VarParsing.multiplicity.singleton,
0040                  VarParsing.VarParsing.varType.int,
0041                  "Run number (determines IOV to be read)")
0042 
0043 
0044 options.parseArguments()
0045 
0046 DBFORMAT  = options.dbformat
0047 TYPE      = options.type
0048 INPUTFILE = options.inputfile
0049 INPUTTAG  = options.inputtag
0050 GLOBALTAG = options.GT
0051 RUN       = options.run
0052 
0053 
0054 
0055 #Input sanification
0056 
0057 if DBFORMAT not in ['Legacy', 'DTRecoConditions'] :
0058     print('\nERROR: invalid value for dbformat: ',  DBFORMAT,'\n')
0059     exit()
0060     
0061 if TYPE not in ['TZeroDB', 'TTrigDB',  'VDriftDB', 'UncertDB', 'NoiseDB', 'DeadDB', 'ChannelsDB'] :
0062     print('\nERROR: invalid value for type: ',  TYPE,'\n')
0063     exit()
0064 
0065 
0066 if INPUTTAG!="" and INPUTFILE!="" :
0067     print('\nERROR: specify either inputtag or inputfile\n')
0068     exit()
0069 
0070 
0071 
0072 
0073 ofExt = {'TZeroDB'  : '_t0.txt',
0074          'TTrigDB'  : '_ttrig.txt',
0075          'VDriftDB' : '_vdrift.txt',
0076          'UncertDB' : '_uncert.txt',
0077          'NoiseDB'  : '_noise.txt',
0078          'DeadDB'   : '_dead.txt',
0079          'ChannelsDB' : '_channels.txt'}
0080 
0081 
0082 if INPUTFILE!="":
0083     OUTPUTFILE=INPUTFILE
0084 elif INPUTTAG!="" :
0085     OUTPUTFILE=INPUTTAG
0086 else :
0087     OUTPUTFILE=GLOBALTAG+"_"+str(RUN)
0088     if OUTPUTFILE[0:5] == 'auto:' : OUTPUTFILE=OUTPUTFILE[5:]
0089 OUTPUTFILE+=ofExt[TYPE]
0090 
0091 
0092 ###########
0093 
0094 RECORD=""
0095 if TYPE=="TZeroDB" : RECORD = "DTT0Rcd"
0096 elif DBFORMAT=="Legacy" :
0097     if TYPE=="TTrigDB" : RECORD = "DTTtrigRcd"
0098     if TYPE=="VDriftDB" : RECORD = "DTMtimeRcd"
0099     if TYPE=="UncertDB" :
0100         RECORD = ""
0101         print('\nERROR, Legacy RecoUncertDB is no longer supported')
0102 elif DBFORMAT=="DTRecoConditions" :
0103     if TYPE=="TTrigDB" : RECORD = "DTRecoConditionsTtrigRcd"
0104     if TYPE=="VDriftDB" : RECORD = "DTRecoConditionsVdriftRcd"
0105     if TYPE=="UncertDB" : RECORD = "DTRecoConditionsUncertRcd"
0106 
0107 
0108 if TYPE == 'NoiseDB' : RECORD = 'DTStatusFlagRcd'
0109 elif TYPE == 'DeadDB' : RECORD = 'DTDeadFlagRcd'
0110 elif TYPE == 'ChannelsDB' : RECORD = 'DTReadOutMappingRcd'
0111 
0112 process = cms.Process("DumpDBToFile")
0113 process.load("CondCore.CondDB.CondDB_cfi")
0114 
0115 process.source = cms.Source("EmptySource",
0116     numberEventsInRun = cms.untracked.uint32(1),
0117     firstRun = cms.untracked.uint32(RUN)
0118 )
0119 
0120 process.maxEvents = cms.untracked.PSet(
0121     input = cms.untracked.int32(1)
0122 )
0123 
0124 
0125 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0126 from Configuration.AlCa.GlobalTag import GlobalTag
0127 process.GlobalTag = GlobalTag(process.GlobalTag, GLOBALTAG, '')
0128 
0129 # Read from local db file
0130 if INPUTFILE!="" :
0131     print("\nDumpDBToFile: Read from: ", INPUTFILE)
0132     print("              Record:    ", RECORD)
0133     print("              Type:      ", TYPE)
0134 
0135 
0136     process.GlobalTag.toGet = cms.VPSet(
0137         cms.PSet(record = cms.string(RECORD),
0138                  tag = cms.string(TYPE), # NOTE: commonly used tags for db files are 'ttrig', 't0','T0DB', etc.
0139                  connect = cms.string("sqlite_file:"+INPUTFILE)
0140                  )
0141         )
0142 
0143 
0144 # Read payload with the specified tag from frontier
0145 if INPUTTAG!="" :
0146     print("\nDumpDBToFile: Read from Frontier, tag:    ", INPUTTAG)
0147     print("                               Record: ", RECORD)
0148     print("                                 Type:   ", TYPE)
0149 
0150     process.GlobalTag.toGet = cms.VPSet(
0151         cms.PSet(record = cms.string(RECORD),
0152                  tag = cms.string(INPUTTAG),
0153                  connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS'),
0154 #                 connect = cms.string('frontier://FrontierProd/CMS_COND_DT_000')
0155                  )
0156         )
0157 
0158 # Read payload specified in the GT
0159 else :
0160     print("\nDumpDBToFile: Read from GT:", GLOBALTAG)
0161     print("                      Type:", TYPE)
0162 
0163 print('Writing to file: ', OUTPUTFILE, '\n')
0164 
0165 
0166 
0167 
0168 process.dumpT0ToFile = cms.EDAnalyzer("DumpDBToFile",
0169     dbToDump = cms.untracked.string('TZeroDB'),
0170     dbLabel = cms.untracked.string(''),
0171     calibFileConfig = cms.untracked.PSet(
0172         nFields = cms.untracked.int32(8),
0173         calibConstGranularity = cms.untracked.string('byWire')
0174     ),
0175     outputFileName = cms.untracked.string(OUTPUTFILE)
0176 )
0177 
0178 process.dumpTTrigToFile = cms.EDAnalyzer("DumpDBToFile",
0179     dbToDump = cms.untracked.string('TTrigDB'),
0180     dbLabel = cms.untracked.string(''),
0181     dbFormat = cms.untracked.string(DBFORMAT),
0182     calibFileConfig = cms.untracked.PSet(
0183         nFields = cms.untracked.int32(8),
0184         calibConstGranularity = cms.untracked.string('bySL')
0185     ),
0186     outputFileName = cms.untracked.string(OUTPUTFILE)
0187 )
0188 
0189 
0190 process.dumpVdToFile = cms.EDAnalyzer("DumpDBToFile",
0191     dbToDump = cms.untracked.string('VDriftDB'),
0192     dbLabel = cms.untracked.string(''),
0193     dbFormat = cms.untracked.string(DBFORMAT),
0194     calibFileConfig = cms.untracked.PSet(
0195         nFields = cms.untracked.int32(8),
0196         calibConstGranularity = cms.untracked.string('bySL')
0197     ),
0198     outputFileName = cms.untracked.string(OUTPUTFILE)
0199 )
0200 
0201 
0202 process.dumpUncertToFile = cms.EDAnalyzer("DumpDBToFile",
0203     dbToDump = cms.untracked.string('RecoUncertDB'),
0204     dbLabel = cms.untracked.string(''),
0205     dbFormat = cms.untracked.string(DBFORMAT),
0206     calibFileConfig = cms.untracked.PSet(
0207         nFields = cms.untracked.int32(8),
0208         calibConstGranularity = cms.untracked.string('bySL')
0209     ),
0210     outputFileName = cms.untracked.string(OUTPUTFILE)
0211 )
0212 
0213 process.dumpNoiseToFile = cms.EDAnalyzer("DumpDBToFile",
0214     dbToDump = cms.untracked.string('NoiseDB'),
0215     dbLabel = cms.untracked.string(''),
0216     dbFormat = cms.untracked.string(DBFORMAT),
0217     calibFileConfig = cms.untracked.PSet(
0218         nFields = cms.untracked.int32(8),
0219         calibConstGranularity = cms.untracked.string('byWire')
0220     ),
0221     outputFileName = cms.untracked.string(OUTPUTFILE)
0222 )
0223 
0224 process.dumpDeadToFile = cms.EDAnalyzer("DumpDBToFile",
0225     dbToDump = cms.untracked.string('DeadDB'),
0226     dbLabel = cms.untracked.string(''),
0227     dbFormat = cms.untracked.string(DBFORMAT),
0228     calibFileConfig = cms.untracked.PSet(
0229         nFields = cms.untracked.int32(8),
0230         calibConstGranularity = cms.untracked.string('byWire')
0231     ),
0232     outputFileName = cms.untracked.string(OUTPUTFILE)
0233 )
0234 
0235 process.dumpChannelsToFile = cms.EDAnalyzer("DumpDBToFile",
0236     dbToDump = cms.untracked.string('ChannelsDB'),
0237     dbLabel = cms.untracked.string(''),
0238     dbFormat = cms.untracked.string(DBFORMAT),
0239     calibFileConfig = cms.untracked.PSet(
0240         nFields = cms.untracked.int32(8),
0241         calibConstGranularity = cms.untracked.string('byWire')
0242     ),
0243     outputFileName = cms.untracked.string(OUTPUTFILE)
0244 )
0245 
0246 
0247 
0248 if   TYPE=="TZeroDB" :     process.p2 = cms.Path(process.dumpT0ToFile)
0249 elif TYPE=="TTrigDB" :     process.p2 = cms.Path(process.dumpTTrigToFile)
0250 elif TYPE=="VDriftDB" :    process.p2 = cms.Path(process.dumpVdToFile)
0251 elif TYPE=="UncertDB":     process.p2 = cms.Path(process.dumpUncertToFile)
0252 elif TYPE=='NoiseDB' :     process.p2 = cms.Path(process.dumpNoiseToFile)
0253 elif TYPE=='DeadDB' :      process.p2 = cms.Path(process.dumpDeadToFile)
0254 elif TYPE=='ChannelsDB' :  process.p2 = cms.Path(process.dumpChannelsToFile)
0255 
0256