Back to home page

Project CMSSW displayed by LXR

 
 

    


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