Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:43

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                  "myTagName", # default value
0014                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0015                  VarParsing.VarParsing.varType.string, # string, int, or float
0016                  "output tag name")
0017 options.register('inputRecord',
0018                  "BeamSpotOnlineLegacyObjectsRcd", # default value
0019                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0020                  VarParsing.VarParsing.varType.string, # string, int, or float
0021                  "type of record")
0022 options.register('startRun',
0023                  306171, # default value
0024                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0025                  VarParsing.VarParsing.varType.int, # string, int, or float
0026                  "location of the input data")
0027 options.register('startLumi',
0028                  497, # default value
0029                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0030                  VarParsing.VarParsing.varType.int, # string, int, or float
0031                  "IOV Start Lumi")
0032 options.parseArguments()
0033 
0034 process.load("FWCore.MessageService.MessageLogger_cfi")
0035 process.MessageLogger.cerr.FwkReport.reportEvery = 100000                         # do not clog output with IO
0036 
0037 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1 if options.unitTest else 10000000) )   # large number of events is needed since we probe 5000LS for run (see below)
0038 
0039 ####################################################################
0040 # Empty source 
0041 ####################################################################
0042 
0043 process.source = cms.Source("EmptySource",
0044                             firstRun = cms.untracked.uint32(options.startRun),                  # Run in ../data/BeamFitResults_Run306171.txt
0045                             firstLuminosityBlock = cms.untracked.uint32(options.startLumi),         # Lumi in ../data/BeamFitResults_Run306171.txt
0046                             numberEventsInLuminosityBlock = cms.untracked.uint32(1),  # probe one event per LS
0047                             numberEventsInRun = cms.untracked.uint32(5000),           # a number of events > the number of LS possible in a real run (5000 s ~ 32 h)
0048                             )
0049 
0050 ####################################################################
0051 # Connect to conditions DB
0052 ####################################################################
0053 
0054 # either from Global Tag
0055 # process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cfi")
0056 # from Configuration.AlCa.GlobalTag import GlobalTag
0057 # process.GlobalTag = GlobalTag(process.GlobalTag,"auto:run2_data")
0058 
0059 # ...or specify database connection and tag:  
0060 #from CondCore.CondDB.CondDB_cfi import *
0061 #CondDBBeamSpotObjects = CondDB.clone(connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS'))
0062 #process.dbInput = cms.ESSource("PoolDBESSource",
0063 #                               CondDBBeamSpotObjects,
0064 #                               toGet = cms.VPSet(cms.PSet(record = cms.string('BeamSpotOnlineLegacyObjectsRcd'), # BeamSpotOnlineLegacy record
0065 #                                                          tag = cms.string('BSLegacy_tag')                       # choose your favourite tag
0066 #                                                          )
0067 #                                                 )
0068 #                               )
0069 # ...or from a local db file
0070 # input database (in this case the local sqlite file)
0071 
0072 if options.unitTest :
0073     if options.inputRecord ==  "BeamSpotOnlineLegacyObjectsRcd" : 
0074         tag_name = 'BSLegacy_tag'
0075     else:
0076         tag_name = 'BSHLT_tag'
0077 else:
0078     tag_name = options.inputTag
0079 
0080 from CondCore.CondDB.CondDB_cfi import *
0081 CondDBBeamSpotOnlineLegacy = CondDB.clone(connect = cms.string("sqlite_file:test_%s.db" % tag_name)) # customize with input db file
0082 process.PoolDBESSource = cms.ESSource("PoolDBESSource",
0083     CondDBBeamSpotOnlineLegacy,
0084     DumpStat=cms.untracked.bool(True),
0085     toGet = cms.VPSet(cms.PSet(
0086         record = cms.string(options.inputRecord),  # BeamSpotOnline record
0087         tag = cms.string(tag_name)                 # choose your favourite tag
0088     ))
0089 )
0090 
0091 print("isForHLT: ",(options.inputRecord ==  "BeamSpotOnlineHLTObjectsRcd"))
0092 
0093 ####################################################################
0094 # Load and configure analyzer
0095 ####################################################################
0096 process.beamspotonlinereader = cms.EDAnalyzer("BeamSpotOnlineRecordsReader",
0097                                               isHLT = cms.bool((options.inputRecord ==  "BeamSpotOnlineHLTObjectsRcd")),
0098                                               rawFileName = cms.untracked.string("test.txt") # choose an output name
0099                                               )
0100 
0101 ####################################################################
0102 # Output file
0103 ####################################################################
0104 process.TFileService = cms.Service("TFileService",
0105                                    fileName=cms.string("test.root") # choose an output name
0106                                    )
0107 
0108 # Put module in path:
0109 process.p = cms.Path(process.beamspotonlinereader)