Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 from __future__ import print_function
0002 import time
0003 
0004 import FWCore.ParameterSet.Config as cms
0005 import FWCore.ParameterSet.VarParsing as VarParsing
0006 from Configuration.AlCa.autoCond import autoCond
0007 
0008 options = VarParsing.VarParsing()
0009 options.register('connectionString',
0010                  'frontier://FrontierProd/CMS_CONDITIONS', #default value
0011                  VarParsing.VarParsing.multiplicity.singleton,
0012                  VarParsing.VarParsing.varType.string,
0013                  "GlobalTag Connection string")
0014 options.register('globalTag',
0015                  autoCond['run2_data'], #default value
0016                  VarParsing.VarParsing.multiplicity.singleton,
0017                  VarParsing.VarParsing.varType.string,
0018                  "GlobalTag")
0019 options.register('snapshotTime',
0020                  '', #default value
0021                  VarParsing.VarParsing.multiplicity.singleton,
0022                  VarParsing.VarParsing.varType.string,
0023                  "GlobalTag snapshot time")
0024 options.register('refresh',
0025                  0, #default value
0026                  VarParsing.VarParsing.multiplicity.singleton,
0027                  VarParsing.VarParsing.varType.int,
0028                  "Refresh type: default no refresh")
0029 options.register('pfnPostfix',
0030                  '', #default value
0031                  VarParsing.VarParsing.multiplicity.singleton,
0032                  VarParsing.VarParsing.varType.string,
0033                  "PFN postfix in GlobalTag connection strings")
0034 options.register('pfnPrefix',
0035                  '', #default value
0036                  VarParsing.VarParsing.multiplicity.singleton,
0037                  VarParsing.VarParsing.varType.string,
0038                  "PFN prefix in GlobalTag connection strings")
0039 options.register('runNumber',
0040                  4294967292, #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                  3, #default value
0046                  VarParsing.VarParsing.multiplicity.singleton,
0047                  VarParsing.VarParsing.varType.int,
0048                  "number of events per lumi")
0049 options.register('numberOfLumis',
0050                  3, #default value
0051                  VarParsing.VarParsing.multiplicity.singleton,
0052                  VarParsing.VarParsing.varType.int,
0053                  "number of lumisections per run")
0054 options.register('numberOfRuns',
0055                  3, #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                                      destinations = cms.untracked.vstring( 'detailedInfo' ),
0076                                      detailedInfo = cms.untracked.PSet( threshold = cms.untracked.string( 'INFO' ) ),
0077                                      )
0078 
0079 CondDBParameters = cms.PSet( authenticationPath = cms.untracked.string( '' ),
0080                              authenticationSystem = cms.untracked.int32( 0 ),
0081                              messageLevel = cms.untracked.int32( options.messageLevel ),
0082                              security = cms.untracked.string( options.security ),
0083                              )
0084 
0085 refreshAlways, refreshOpenIOVs, refreshEachRun, reconnectEachRun = False, False, False, False
0086 if options.refresh == 0:
0087     refreshAlways, refreshOpenIOVs, refreshEachRun, reconnectEachRun = False, False, False, False
0088 elif options.refresh == 1:
0089     refreshAlways = True
0090     refreshOpenIOVs, refreshEachRun, reconnectEachRun = False, False, False
0091 elif options.refresh == 2:
0092     refreshAlways = False
0093     refreshOpenIOVs = True
0094     refreshEachRun, reconnectEachRun = False, False
0095 elif options.refresh == 3:
0096     refreshAlways, refreshOpenIOVs = False, False
0097     refreshEachRun = True
0098     reconnectEachRun = False
0099 elif options.refresh == 4:
0100     refreshAlways, refreshOpenIOVs, refreshEachRun = False, False, False
0101     reconnectEachRun = True
0102 
0103 process.GlobalTag = cms.ESSource( "PoolDBESSource",
0104                                   DBParameters = CondDBParameters,
0105                                   connect = cms.string( options.connectionString ),
0106                                   globaltag = cms.string( options.globalTag ),
0107                                   snapshotTime = cms.string( options.snapshotTime ),
0108                                   toGet = cms.VPSet(),
0109                                   RefreshAlways = cms.untracked.bool( refreshAlways ),
0110                                   RefreshOpenIOVs = cms.untracked.bool( refreshOpenIOVs ),
0111                                   RefreshEachRun = cms.untracked.bool( refreshEachRun ),
0112                                   ReconnectEachRun = cms.untracked.bool( reconnectEachRun ),
0113                                   DumpStat = cms.untracked.bool( True ),
0114                                   pfnPrefix = cms.untracked.string( '' ),   
0115                                   pfnPostfix = cms.untracked.string( '' )
0116                                   )
0117 
0118 if options.pfnPrefix:
0119     process.GlobalTag.pfnPrefix = options.pfnPrefix
0120 if options.pfnPostfix:
0121     process.GlobalTag.pfnPostfix = options.pfnPostfix
0122 
0123 #TODO: add VarParsing support for adding custom conditions
0124 #process.GlobalTag.toGet.append( cms.PSet( record = cms.string( "BeamSpotObjectsRcd" ),
0125 #                                          tag = cms.string( "firstcollisions" ),
0126 #                                          connect = cms.string( "frontier://FrontierProd/CMS_CONDITIONS" ),
0127 #                                          snapshotTime = cms.string('2014-01-01 00:00:00.000'),
0128 #                                          )
0129 #                                )
0130 
0131 process.source = cms.Source( "EmptySource",
0132                              firstRun = cms.untracked.uint32( options.runNumber ),
0133                              firstTime = cms.untracked.uint64( ( int( time.time() ) - 24 * 3600 ) << 32 ), #24 hours ago in nanoseconds
0134                              numberEventsInRun = cms.untracked.uint32( options.eventsPerLumi *  options.numberOfLumis ), # options.numberOfLumis lumi sections per run
0135                              numberEventsInLuminosityBlock = cms.untracked.uint32( options.eventsPerLumi )
0136                              )
0137 
0138 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32( options.eventsPerLumi *  options.numberOfLumis * options.numberOfRuns ) ) #options.numberOfRuns runs per job
0139 
0140 process.get = cms.EDAnalyzer( "EventSetupRecordDataGetter",
0141                               toGet =  cms.VPSet(),
0142                               verbose = cms.untracked.bool( True )
0143                               )
0144 
0145 process.escontent = cms.EDAnalyzer( "PrintEventSetupContent",
0146                                     compact = cms.untracked.bool( True ),
0147                                     printProviders = cms.untracked.bool( True )
0148                                     )
0149 
0150 process.esretrieval = cms.EDAnalyzer( "PrintEventSetupDataRetrieval",
0151                                       printProviders = cms.untracked.bool( True )
0152                                       )
0153 
0154 process.p = cms.Path( process.get )
0155 process.esout = cms.EndPath( process.escontent + process.esretrieval )
0156 if process.schedule_() is not None:
0157     process.schedule_().append( process.esout )
0158 
0159 for name, module in process.es_sources_().items():
0160     print("ESModules> provider:%s '%s'" % ( name, module.type_() ))
0161 for name, module in process.es_producers_().items():
0162     print("ESModules> provider:%s '%s'" % ( name, module.type_() ))