File indexing completed on 2024-04-06 12:02:42
0001 import FWCore.ParameterSet.Config as cms
0002 import FWCore.ParameterSet.VarParsing as VarParsing
0003
0004 process = cms.Process("writeBeamProfile2DB")
0005
0006 options = VarParsing.VarParsing()
0007 options.register('unitTest',
0008 False,
0009 VarParsing.VarParsing.multiplicity.singleton,
0010 VarParsing.VarParsing.varType.bool,
0011 "are we running the unit test?")
0012 options.register('inputTag',
0013 "myTagName",
0014 VarParsing.VarParsing.multiplicity.singleton,
0015 VarParsing.VarParsing.varType.string,
0016 "output tag name")
0017 options.parseArguments()
0018
0019
0020 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0021 from CondCore.CondDB.CondDB_cfi import *
0022
0023 if options.unitTest :
0024 tag_name = 'simBS_tag'
0025 else:
0026 tag_name = options.inputTag
0027
0028 process.source = cms.Source("EmptySource")
0029 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
0030
0031 from CondTools.BeamSpot.beamProfile2DBWriter_cfi import beamProfile2DBWriter
0032 process.load("IOMC.EventVertexGenerators.VtxSmearedParameters_cfi")
0033
0034
0035 psets_SimBeamSpotObjects = []
0036 psets_names = []
0037 for psetName in process.__dict__:
0038 pset = getattr(process, psetName)
0039 if isinstance(pset, cms.PSet) and ("BetaStar" in pset.parameterNames_() or "SigmaX" in pset.parameterNames_()):
0040 print(psetName)
0041 psets_names.append(psetName)
0042 psets_SimBeamSpotObjects.append(pset)
0043
0044
0045 myVPSet = cms.VPSet()
0046
0047 for i, pset in enumerate(psets_SimBeamSpotObjects):
0048 cloneName = 'BeamProfile2DBWriter_' + str(i+1)
0049 setattr(process, cloneName, beamProfile2DBWriter.clone(pset,
0050 recordName = cms.string(psets_names[i])))
0051
0052
0053 pathName = 'Path_' + str(i+1)
0054 setattr(process, pathName, cms.Path(getattr(process, cloneName)))
0055
0056 myPSet = cms.PSet(
0057 record = cms.string(psets_names[i]),
0058 tag = cms.string(psets_names[i])
0059 )
0060
0061 myVPSet.append(myPSet)
0062
0063
0064
0065
0066 CondDBSimBeamSpotObjects = CondDB.clone(connect = cms.string('sqlite_file:test_%s.db' % tag_name))
0067 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0068 CondDBSimBeamSpotObjects,
0069 timetype = cms.untracked.string('runnumber'),
0070 toPut = myVPSet,
0071 loadBlobStreamer = cms.untracked.bool(False))
0072
0073
0074 process.end = cms.EndPath()
0075
0076 process.schedule = cms.Schedule()
0077 for i, pset in enumerate(psets_SimBeamSpotObjects):
0078 pathName = 'Path_' + str(i+1)
0079 process.schedule.append(getattr(process, pathName))
0080 process.schedule.append(process.end)
0081
0082