Back to home page

Project CMSSW displayed by LXR

 
 

    


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, # default value
0009                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0010                  VarParsing.VarParsing.varType.bool, # string, int, or float
0011                  "are we running the unit test?")
0012 options.register('inputTag',
0013                  "myInputTagName", # default value
0014                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0015                  VarParsing.VarParsing.varType.string, # string, int, or float
0016                  "input tag name")
0017 options.register('inputFile',
0018                  "", # default value
0019                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0020                  VarParsing.VarParsing.varType.string, # string, int, or float
0021                  "input sqlite (.db) file")
0022 options.register('outputTag',
0023                  "myOutputTagName", # default value
0024                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0025                  VarParsing.VarParsing.varType.string, # string, int, or float
0026                  "output tag name")
0027 options.register('outputRecord',
0028                  "BeamSpotOnlineLegacyObjectsRcd", # default value
0029                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0030                  VarParsing.VarParsing.varType.string, # string, int, or float
0031                  "type of output record")
0032 options.register('startRun',
0033                  1, # default value
0034                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0035                  VarParsing.VarParsing.varType.int, # string, int, or float
0036                  "location of the input data")
0037 options.register('startLumi',
0038                  1, # default value
0039                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0040                  VarParsing.VarParsing.varType.int, # string, int, or float
0041                  "IOV Start Lumi")
0042 options.register('maxIOVtoProcess',
0043                  999, # default value
0044                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0045                  VarParsing.VarParsing.varType.int, # string, int, or float
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 # do not clog output with IO
0051 
0052 process.maxEvents = cms.untracked.PSet(
0053     input = cms.untracked.int32(options.maxIOVtoProcess)
0054 )
0055 
0056 ####################################################################
0057 # Empty source 
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 # Connect to conditions DB
0067 ####################################################################
0068 if options.inputFile != "":
0069     from CondCore.CondDB.CondDB_cfi import *
0070     # Load from a local db file
0071     CondDBBeamSpotObjects = CondDB.clone(connect = cms.string('sqlite_file:'+options.inputFile))
0072     #To connect directly to a database replace the above line with:
0073     #CondDBBeamSpotObjects = CondDB.clone(connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS'))
0074 
0075     # Specifying the tag name:
0076     process.dbInput = cms.ESSource("PoolDBESSource",
0077                                    CondDBBeamSpotObjects,
0078                                    toGet = cms.VPSet(cms.PSet(record = cms.string('BeamSpotObjectsRcd'),
0079                                                               tag = cms.string(options.inputTag) # choose your input tag
0080                                                              )
0081                                                     )
0082                                   )
0083 else:
0084     # Load from Global Tag
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 # Load and configure outputservice
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)) # choose an output name
0102 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0103                                           CondDBBeamSpotObjects,
0104                                           timetype = cms.untracked.string('lumiid'), #('lumiid'), #('runnumber')
0105                                           toPut = cms.VPSet(cms.PSet(record = cms.string(options.outputRecord), # BeamSpotOnline record
0106                                                                      tag = cms.string(tag_name))),              # choose your favourite tag
0107                                           loadBlobStreamer = cms.untracked.bool(False)
0108                                           )
0109 
0110 isForHLT = (options.outputRecord == "BeamSpotOnlineHLTObjectsRcd")
0111 print("isForHLT: ",isForHLT)
0112 
0113 ####################################################################
0114 # Load and configure analyzer
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 # Put module in path:
0122 process.p = cms.Path(process.BeamSpotOnlineFromOfflineConverter)