File indexing completed on 2024-11-07 06:12:38
0001 import FWCore.ParameterSet.Config as cms
0002 import FWCore.ParameterSet.VarParsing as VarParsing
0003
0004 process = cms.Process("READ")
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 "myInputTagName",
0014 VarParsing.VarParsing.multiplicity.singleton,
0015 VarParsing.VarParsing.varType.string,
0016 "input tag name")
0017 options.register('inputFile',
0018 "",
0019 VarParsing.VarParsing.multiplicity.singleton,
0020 VarParsing.VarParsing.varType.string,
0021 "input sqlite (.db) file")
0022 options.register('outputTag',
0023 "myOutputTagName",
0024 VarParsing.VarParsing.multiplicity.singleton,
0025 VarParsing.VarParsing.varType.string,
0026 "output tag name")
0027 options.register('outputRecord',
0028 "BeamSpotOnlineLegacyObjectsRcd",
0029 VarParsing.VarParsing.multiplicity.singleton,
0030 VarParsing.VarParsing.varType.string,
0031 "type of output record")
0032 options.register('startRun',
0033 1,
0034 VarParsing.VarParsing.multiplicity.singleton,
0035 VarParsing.VarParsing.varType.int,
0036 "location of the input data")
0037 options.register('startLumi',
0038 1,
0039 VarParsing.VarParsing.multiplicity.singleton,
0040 VarParsing.VarParsing.varType.int,
0041 "IOV Start Lumi")
0042 options.register('maxIOVtoProcess',
0043 999,
0044 VarParsing.VarParsing.multiplicity.singleton,
0045 VarParsing.VarParsing.varType.int,
0046 "max number of IOVs (events) to process")
0047 options.parseArguments()
0048
0049 process.load("FWCore.MessageService.MessageLogger_cfi")
0050 process.MessageLogger.cerr.FwkReport.reportEvery = 100000
0051
0052 process.maxEvents = cms.untracked.PSet(
0053 input = cms.untracked.int32(options.maxIOVtoProcess)
0054 )
0055
0056
0057
0058
0059 process.source = cms.Source("EmptySource",
0060 firstRun = cms.untracked.uint32(options.startRun),
0061 firstLuminosityBlock = cms.untracked.uint32(options.startLumi),
0062 numberEventsInLuminosityBlock = cms.untracked.uint32(1),
0063 numberEventsInRun = cms.untracked.uint32(options.maxIOVtoProcess))
0064
0065
0066
0067
0068 if options.inputFile != "":
0069 from CondCore.CondDB.CondDB_cfi import *
0070
0071 CondDBBeamSpotObjects = CondDB.clone(connect = cms.string('sqlite_file:'+options.inputFile))
0072
0073
0074
0075
0076 process.dbInput = cms.ESSource("PoolDBESSource",
0077 CondDBBeamSpotObjects,
0078 toGet = cms.VPSet(cms.PSet(record = cms.string('BeamSpotObjectsRcd'),
0079 tag = cms.string(options.inputTag)
0080 )
0081 )
0082 )
0083 else:
0084
0085 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0086 from Configuration.AlCa.GlobalTag import GlobalTag
0087 process.GlobalTag = GlobalTag(process.GlobalTag,"auto:run2_data")
0088
0089
0090
0091
0092 if options.unitTest :
0093 if options.outputRecord == "BeamSpotOnlineLegacyObjectsRcd" :
0094 tag_name = 'BSLegacy_tag'
0095 else:
0096 tag_name = 'BSHLT_tag'
0097 else:
0098 tag_name = options.outputTag
0099
0100 from CondCore.CondDB.CondDB_cfi import *
0101 CondDBBeamSpotObjects = CondDB.clone(connect = cms.string('sqlite_file:test_%s.db' % tag_name))
0102 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0103 CondDBBeamSpotObjects,
0104 timetype = cms.untracked.string('lumiid'),
0105 toPut = cms.VPSet(cms.PSet(record = cms.string(options.outputRecord),
0106 tag = cms.string(tag_name))),
0107 loadBlobStreamer = cms.untracked.bool(False)
0108 )
0109
0110 isForHLT = (options.outputRecord == "BeamSpotOnlineHLTObjectsRcd")
0111 print("isForHLT: ",isForHLT)
0112
0113
0114
0115
0116 from CondTools.BeamSpot.beamSpotOnlineFromOfflineConverter_cfi import beamSpotOnlineFromOfflineConverter
0117 process.BeamSpotOnlineFromOfflineConverter = beamSpotOnlineFromOfflineConverter.clone(isHLT = isForHLT)
0118 process.BeamSpotOnlineFromOfflineConverter.IOVStartRun = options.startRun
0119 process.BeamSpotOnlineFromOfflineConverter.IOVStartLumi = options.startLumi
0120
0121
0122 process.p = cms.Path(process.BeamSpotOnlineFromOfflineConverter)