Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-28 02:56:42

0001 from __future__ import print_function
0002 import sys
0003 import FWCore.ParameterSet.Config as cms
0004 from FWCore.ParameterSet.VarParsing import VarParsing
0005 
0006 options = VarParsing()
0007 options.register ("dumplist", '', VarParsing.multiplicity.list, VarParsing.varType.string)
0008 options.register ("globaltag", '', VarParsing.multiplicity.singleton, VarParsing.varType.string)
0009 options.register ("geometry", '', VarParsing.multiplicity.singleton, VarParsing.varType.string)
0010 options.register ("era", '', VarParsing.multiplicity.singleton, VarParsing.varType.string)
0011 options.register ("run", 1, VarParsing.multiplicity.singleton, VarParsing.varType.int)
0012 options.register ("dbfile", '', VarParsing.multiplicity.singleton, VarParsing.varType.string) # 'sqlite_file:testExample.db'
0013 options.register ("dblist", '', VarParsing.multiplicity.list, VarParsing.varType.string)
0014 options.register ("frontierloc", 'frontier://FrontierProd/CMS_CONDITIONS', VarParsing.multiplicity.singleton, VarParsing.varType.string) # 'frontier://FrontierDev/CMS_COND_HCAL'
0015 options.register ("frontierlist", '', VarParsing.multiplicity.list, VarParsing.varType.string)
0016 options.register ("usehardcode", '', VarParsing.multiplicity.singleton, VarParsing.varType.bool)
0017 options.register ("asciilist", '', VarParsing.multiplicity.list, VarParsing.varType.string)
0018 options.register ("prefix", 'DumpCond', VarParsing.multiplicity.singleton, VarParsing.varType.string)
0019 options.register ("command", '', VarParsing.multiplicity.singleton, VarParsing.varType.string)
0020 options.register ("info", '', VarParsing.multiplicity.singleton, VarParsing.varType.bool)
0021 options.register ("dump", '', VarParsing.multiplicity.singleton, VarParsing.varType.bool)
0022 options.parseArguments()
0023 
0024 allconds = [
0025     'Pedestals',
0026     'PedestalWidths',
0027     'EffectivePedestals',
0028     'EffectivePedestalWidths',
0029     'Gains',
0030     'QIEData',
0031     'QIETypes',
0032     'ElectronicsMap',
0033     'ChannelQuality',
0034     'GainWidths',
0035     'RespCorrs',
0036     'TimeCorrs',
0037     'LUTCorrs',
0038     'PFCorrs',
0039     'L1TriggerObjects',
0040     'ZSThresholds',
0041     'ValidationCorrs',
0042     'LutMetadata',
0043     'DcsValues',
0044     'DcsMap',
0045     'TimingParams',
0046     'RecoParams',
0047     'LongRecoParams',
0048     'MCParams',
0049     'FlagHFDigiTimeParams',
0050     'SiPMParameters',
0051     'SiPMCharacteristics',
0052     'TPParameters',
0053     'TPChannelParameters',
0054     'FrontEndMap',
0055     'CalibrationsSet',
0056     'CalibrationWidthsSet',
0057 ]
0058 
0059 #custom help message
0060 if options.info:
0061     print("dumplist possibilities:")
0062     print(allconds)
0063     print("dbfile format: sqlite_file:foo.db")
0064     print("frontierloc possibilities: frontier://FrontierProd/CMS_CONDITIONS (default), frontier://FrontierDev/CMS_COND_HCAL, etc.")
0065     print("dblist/frontierlist entry format: HcalPedestalsRcd:hcal_pedestals_fC_v6_mc or HcalPedestalsRcd:effective:HcalPedestals_2018_v2.0_mc_effective for labeled records")
0066     print("asciilist entry format: Pedestals:CondFormats/HcalObjects/data/hcal_pedestals_fC_v5.txt")
0067     print("command can be used to execute extra settings, newline separated, e.g.: process.es_hardcode.useHEUpgrade=cms.bool(True)\\nprocess.es_hardcode.useHFUpgrade=cms.bool(True)")
0068     print("dump will do the equivalent of edmConfigDump: use with python instead of cmsRun")
0069     print("specifying globaltag without the proper geometry may cause errors")
0070     
0071     sys.exit(0)
0072 
0073 if not options.dumplist:
0074     print("Nothing to do!")
0075     sys.exit(0)
0076     
0077 process = cms.Process("DUMP")
0078 if options.era:
0079     from Configuration.StandardSequences.Eras import eras
0080     process = cms.Process("DUMP",getattr(eras,options.era))
0081 
0082 process.load("CondCore.CondDB.CondDB_cfi")
0083 process.load('Configuration.StandardSequences.Services_cff')
0084 
0085 if options.globaltag:
0086     process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0087     from Configuration.AlCa.GlobalTag import GlobalTag
0088     process.GlobalTag = GlobalTag(process.GlobalTag, options.globaltag, '')
0089 
0090 # extracted from Configuration/Applications/python/ConfigBuilder.py
0091 if options.geometry:
0092     SimGeometryCFF=''
0093     GeometryCFF='Configuration/StandardSequences/GeometryRecoDB_cff'
0094     geometryDBLabel=None
0095     simGeometry=''
0096     def inGeometryKeys(opt):
0097         from Configuration.StandardSequences.GeometryConf import GeometryConf
0098         if opt in GeometryConf:
0099             return GeometryConf[opt]
0100         else:
0101             return opt
0102 
0103     geoms=options.geometry.split(',')
0104     if len(geoms)==1: geoms=inGeometryKeys(geoms[0]).split(',')
0105     if len(geoms)==2:
0106         #may specify the reco geometry
0107         if '/' in geoms[1] or '_cff' in geoms[1]:
0108             GeometryCFF=geoms[1]
0109         else:
0110             GeometryCFF='Configuration/Geometry/Geometry'+geoms[1]+'_cff'
0111 
0112     if (geoms[0].startswith('DB:')):
0113         SimGeometryCFF='Configuration/StandardSequences/GeometrySimDB_cff'
0114         geometryDBLabel=geoms[0][3:]
0115     else:
0116         if '/' in geoms[0] or '_cff' in geoms[0]:
0117             SimGeometryCFF=geoms[0]
0118         else:
0119             simGeometry=geoms[0]
0120             SimGeometryCFF='Configuration/Geometry/Geometry'+geoms[0]+'_cff'
0121 
0122     if SimGeometryCFF: process.load(SimGeometryCFF)
0123     process.load(GeometryCFF)
0124     if geometryDBLabel:
0125         process.XMLFromDBSource.label = cms.string(geometryDBLabel)
0126 
0127 process.prod = cms.EDAnalyzer("HcalDumpConditions",
0128     dump = cms.untracked.vstring(options.dumplist),
0129     outFilePrefix = cms.untracked.string(options.prefix)
0130 )
0131 
0132 # specify for which run you would like to get the conditions in the "firstRun"
0133 process.source = cms.Source("EmptySource",
0134     numberEventsInRun = cms.untracked.uint32(1),
0135     firstRun = cms.untracked.uint32(options.run)
0136 )
0137 
0138 if options.dbfile and options.dblist:
0139     process.es_dbfile = cms.ESSource("PoolDBESSource",
0140         timetype = cms.string('runnumber'),
0141         connect = cms.string(options.dbfile),
0142         authenticationMethod = cms.untracked.uint32(0),
0143         toGet = cms.VPSet()
0144     )
0145     for rcd in options.dblist:
0146         rcds = rcd.split(':')
0147         if len(rcds) == 2: process.es_dbfile.toGet.append(cms.PSet(record = cms.string(rcds[0]), tag = cms.string(rcds[1])))
0148         elif len(rcds) == 3: process.es_dbfile.toGet.append(cms.PSet(record = cms.string(rcds[0]), label = cms.untracked.string(rcds[1]), tag = cms.string(rcds[2])))
0149     process.es_prefer_dbfile = cms.ESPrefer('PoolDBESSource','es_dbfile')
0150 
0151 if options.frontierloc and options.frontierlist:
0152     process.es_frontier = cms.ESSource("PoolDBESSource",
0153         timetype = cms.string('runnumber'),
0154         connect = cms.string(options.frontierloc),
0155         authenticationMethod = cms.untracked.uint32(0),
0156         toGet = cms.VPSet()
0157     )
0158     for rcd in options.frontierlist:
0159         rcds = rcd.split(':')
0160         if len(rcds) == 2: process.es_frontier.toGet.append(cms.PSet(record = cms.string(rcds[0]), tag = cms.string(rcds[1])))
0161         elif len(rcds) == 3: process.es_frontier.toGet.append(cms.PSet(record = cms.string(rcds[0]), label = cms.untracked.string(rcds[1]), tag = cms.string(rcds[2])))
0162     process.es_prefer_frontier = cms.ESPrefer('PoolDBESSource','es_frontier')
0163 
0164 if options.asciilist:
0165     process.es_ascii = cms.ESSource("HcalTextCalibrations",
0166         input = cms.VPSet()
0167     )
0168     for obj in options.asciilist:
0169         objs = obj.split(':')
0170         if len(objs) != 2: continue
0171         process.es_ascii.input.append(cms.PSet(object = cms.string(objs[0]), file = cms.FileInPath(objs[1])))
0172     process.es_prefer_ascii = cms.ESPrefer('HcalTextCalibrations','es_ascii')
0173 
0174 if options.usehardcode:
0175     # loads params and es_prefer
0176     process.load("CalibCalorimetry.HcalPlugins.Hcal_Conditions_forGlobalTag_cff")
0177     process.es_hardcode.toGet = cms.untracked.vstring(options.dumplist)
0178     process.es_hardcode.toGet.append('GainWidths')
0179 
0180 if options.command:
0181     cmds = options.command.split('\\n')
0182     for cmd in cmds:
0183         exec(cmd)
0184 
0185 process.maxEvents = cms.untracked.PSet(
0186     input = cms.untracked.int32(1)
0187 )
0188 
0189 if options.dump:
0190     print(process.dumpPython())
0191     sys.exit(0)
0192 else:
0193     process.p = cms.Path(process.prod)