Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-16 23:25:23

0001 
0002 from __future__ import print_function
0003 import time
0004 
0005 import FWCore.ParameterSet.Config as cms
0006 import FWCore.ParameterSet.VarParsing as VarParsing
0007 from Configuration.AlCa.autoCond import autoCond
0008 
0009 options = VarParsing.VarParsing()
0010 options.register('processId',
0011                  '0',
0012                  VarParsing.VarParsing.multiplicity.singleton,
0013                  VarParsing.VarParsing.varType.string,
0014                  "Process Id")
0015 options.register('connectionString',
0016                  #'sqlite_file:cms_conditions.db', #default value
0017                  #'frontier://FrontierProd/CMS_CONDITIONS', #default value
0018                  'frontier://FrontierPrep/CMS_CONDITIONS',
0019                  #'oracle://cms_orcon_prod/CMS_CONDITIONS',
0020                  VarParsing.VarParsing.multiplicity.singleton,
0021                  VarParsing.VarParsing.varType.string,
0022                  "CondDB Connection string")
0023 options.register('tag',
0024                  #'BeamSpot_test_updateByLumi_00',
0025                  'BeamSpot_test_updateByTime_01',
0026                  VarParsing.VarParsing.multiplicity.singleton,
0027                  VarParsing.VarParsing.varType.string,
0028                  "tag for record BeamSpotObjectsRcd")
0029 options.register('snapshotTime',
0030                  '', #default value
0031                  VarParsing.VarParsing.multiplicity.singleton,
0032                  VarParsing.VarParsing.varType.string,
0033                  "GlobalTag snapshot time")
0034 options.register('refresh',
0035                  0, #default value
0036                  VarParsing.VarParsing.multiplicity.singleton,
0037                  VarParsing.VarParsing.varType.int,
0038                  "Refresh type: default no refresh")
0039 options.register('runNumber',
0040                  120013, #default value, int limit -3
0041                  VarParsing.VarParsing.multiplicity.singleton,
0042                  VarParsing.VarParsing.varType.int,
0043                  "Run number; default gives latest IOV")
0044 options.register('eventsPerLumi',
0045                  20, #default value
0046                  VarParsing.VarParsing.multiplicity.singleton,
0047                  VarParsing.VarParsing.varType.int,
0048                  "number of events per lumi")
0049 options.register('numberOfLumis',
0050                  20, #default value
0051                  VarParsing.VarParsing.multiplicity.singleton,
0052                  VarParsing.VarParsing.varType.int,
0053                  "number of lumisections per run")
0054 options.register('numberOfRuns',
0055                  1, #default value
0056                  VarParsing.VarParsing.multiplicity.singleton,
0057                  VarParsing.VarParsing.varType.int,
0058                  "number of runs in the job")
0059 options.register('messageLevel',
0060                  0, #default value
0061                  VarParsing.VarParsing.multiplicity.singleton,
0062                  VarParsing.VarParsing.varType.int,
0063                  "Message level; default to 0")
0064 options.register('security',
0065                  '', #default value
0066                  VarParsing.VarParsing.multiplicity.singleton,
0067                  VarParsing.VarParsing.varType.string,
0068                  "FroNTier connection security: activate it with 'sig'")
0069 
0070 options.parseArguments()
0071 
0072 process = cms.Process("TEST")
0073 
0074 process.MessageLogger = cms.Service("MessageLogger",
0075                                     cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')),
0076                                     destinations = cms.untracked.vstring('cout')
0077                                     )
0078 #process.MessageLogger = cms.Service( "MessageLogger",
0079 #                                     destinations = cms.untracked.vstring( 'detailedInfo' ),
0080 #                                     detailedInfo = cms.untracked.PSet( threshold = cms.untracked.string( 'INFO' ) ),
0081 #                                     )
0082 
0083 CondDBParameters = cms.PSet( authenticationPath = cms.untracked.string( '/build/gg/' ),
0084                              authenticationSystem = cms.untracked.int32( 0 ),
0085                              messageLevel = cms.untracked.int32( 3 ),
0086                              security = cms.untracked.string( options.security ),
0087                              )
0088 
0089 refreshAlways, refreshOpenIOVs, refreshEachRun, reconnectEachRun = False, False, False, False
0090 if options.refresh == 0:
0091     refreshAlways, refreshOpenIOVs, refreshEachRun, reconnectEachRun = False, False, False, False
0092 elif options.refresh == 1:
0093     refreshAlways = True
0094     refreshOpenIOVs, refreshEachRun, reconnectEachRun = False, False, False
0095 elif options.refresh == 2:
0096     refreshAlways = False
0097     refreshOpenIOVs = True
0098     refreshEachRun, reconnectEachRun = False, False
0099 elif options.refresh == 3:
0100     refreshAlways, refreshOpenIOVs = False, False
0101     refreshEachRun = True
0102     reconnectEachRun = False
0103 elif options.refresh == 4:
0104     refreshAlways, refreshOpenIOVs, refreshEachRun = False, False, False
0105     reconnectEachRun = True
0106 
0107 process.GlobalTag = cms.ESSource( "PoolDBESSource",
0108                                   DBParameters = CondDBParameters,
0109                                   connect = cms.string( options.connectionString ),
0110                                   snapshotTime = cms.string( options.snapshotTime ),
0111                                   frontierKey = cms.untracked.string('abcdefghijklmnopqrstuvwxyz0123456789'),
0112                                   toGet = cms.VPSet(cms.PSet(
0113                                       record = cms.string('BeamSpotObjectsRcd'),
0114                                       tag = cms.string( options.tag ),
0115                                       refreshTime = cms.uint64( 0 )
0116                                   )),
0117                                   RefreshAlways = cms.untracked.bool( refreshAlways ),
0118                                   RefreshOpenIOVs = cms.untracked.bool( refreshOpenIOVs ),
0119                                   RefreshEachRun = cms.untracked.bool( refreshEachRun ),
0120                                   ReconnectEachRun = cms.untracked.bool( reconnectEachRun ),
0121                                   DumpStat = cms.untracked.bool( True ),
0122                                   )
0123 
0124 
0125 #TODO: add VarParsing support for adding custom conditions
0126 #process.GlobalTag.toGet.append( cms.PSet( record = cms.string( "BeamSpotObjectsRcd" ),
0127 #                                          tag = cms.string( "firstcollisions" ),
0128 #                                          connect = cms.string( "frontier://FrontierProd/CMS_CONDITIONS" ),
0129 #                                          snapshotTime = cms.string('2014-01-01 00:00:00.000'),
0130 #                                          )
0131 #      
0132 
0133 process.source = cms.Source( "EmptySource",
0134                              #firstRun = cms.untracked.uint32( options.runNumber ),
0135                              #firstLuminosityBlock = cms.untracked.uint32( 1 ),
0136                              #firstTime = cms.untracked.uint64( 5401426372679696384 ), 
0137                              firstTime = cms.untracked.uint64( 5771327162577584128 ), 
0138                              timeBetweenEvents = cms.untracked.uint64( 429496729600 ),
0139                              numberEventsInRun = cms.untracked.uint32( 1000 ), # options.numberOfLumis lumi sections per run
0140 #                             numberEventsInRun = cms.untracked.uint32( options.eventsPerLumi *  options.numberOfLumis ), # options.numberOfLumis lumi sections per run
0141                              numberEventsInLuminosityBlock = cms.untracked.uint32( options.eventsPerLumi )
0142                              )
0143 
0144 #process.source = cms.Source( "FileBasedEmptySource",
0145 #                             interval = cms.uint32( 5 ),
0146 #                             maxEvents = cms.uint32( 2 ),
0147 #                             pathForLastLumiFile = cms.string('/build/gg/last_lumi.txt'),
0148 #                             firstLuminosityBlock = cms.untracked.uint32(1),
0149 #                             firstRun = cms.untracked.uint32( options.runNumber ),
0150 #                             firstTime = cms.untracked.uint64( ( int( time.time() ) - 24 * 3600 ) << 32 ), #24 hours ago in nanoseconds
0151 #                             numberEventsInRun = cms.untracked.uint32( 1000 ), # options.numberOfLumis lumi sections per run
0152 #                             numberEventsInLuminosityBlock = cms.untracked.uint32( options.eventsPerLumi )
0153 #                             )
0154 
0155 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100))
0156 
0157 #process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32( options.eventsPerLumi *  options.numberOfLumis * options.numberOfRuns ) ) #options.numberOfRuns runs per job
0158 
0159 process.prod = cms.EDAnalyzer("LumiTestReadAnalyzer",
0160                               processId = cms.untracked.string( options.processId ),
0161                               pathForLastLumiFile = cms.untracked.string("/build/gg/last_lumi.txt"),
0162                               pathForAllLumiFile = cms.untracked.string("./all_time.txt" ),
0163                               pathForErrorFile = cms.untracked.string("./lumi_read_errors")
0164 )
0165 
0166 #process.get = cms.EDAnalyzer( "EventSetupRecordDataGetter",
0167 #                              toGet =  cms.VPSet(),
0168 #                              verbose = cms.untracked.bool( True )
0169 #                              )
0170 
0171 #process.escontent = cms.EDAnalyzer( "PrintEventSetupContent",
0172 #                                    compact = cms.untracked.bool( True ),
0173 #                                    printProviders = cms.untracked.bool( True )
0174 #                                    )
0175 
0176 #process.esretrieval = cms.EDAnalyzer( "PrintEventSetupDataRetrieval",
0177 #                                      printProviders = cms.untracked.bool( True )
0178 #                                      )
0179 
0180 process.p = cms.Path( process.prod )
0181 #process.esout = cms.EndPath( process.escontent + process.esretrieval )
0182 #if process.schedule_() is not None:
0183 #    process.schedule_().append( process.esout )
0184 
0185 for name, module in process.es_sources_().items():
0186     print("ESModules> provider:%s '%s'" % ( name, module.type_() ))
0187 for name, module in process.es_producers_().items():
0188     print("ESModules> provider:%s '%s'" % ( name, module.type_() ))