Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-02 05:09:43

0001 
0002 # Use this as follows:
0003 #
0004 # cmsRun FWCore/Integration/test/testFrameworkExceptionHandling_cfg.py testNumber=1
0005 #
0006 # with the value assigned to testNumber having a value from 1 to 9.
0007 # That value specifies which transition to throw an exception in.
0008 # If the value is not specified, then no exception is thrown.
0009 
0010 import FWCore.ParameterSet.Config as cms
0011 
0012 nStreams = 4
0013 nRuns = 17
0014 nLumisPerRun = 1
0015 nEventsPerLumi = 6
0016 
0017 nEventsPerRun = nLumisPerRun*nEventsPerLumi
0018 nLumis = nRuns*nLumisPerRun
0019 nEvents = nRuns*nEventsPerRun
0020 
0021 process = cms.Process("TEST")
0022 
0023 from FWCore.ParameterSet.VarParsing import VarParsing
0024 
0025 process.TestServiceOne = cms.Service("TestServiceOne",
0026     verbose = cms.untracked.bool(False),
0027     printTimestamps = cms.untracked.bool(True)
0028 )
0029 
0030 process.TestServiceTwo = cms.Service("TestServiceTwo",
0031     verbose = cms.untracked.bool(False),
0032     printTimestamps = cms.untracked.bool(True)
0033 )
0034 
0035 options = VarParsing()
0036 
0037 options.register("testNumber", 0,
0038                  VarParsing.multiplicity.singleton,
0039                  VarParsing.varType.int,
0040                  "Test number")
0041 
0042 options.parseArguments()
0043 
0044 process.source = cms.Source("EmptySource",
0045     firstRun = cms.untracked.uint32(1),
0046     firstLuminosityBlock = cms.untracked.uint32(1),
0047     firstEvent = cms.untracked.uint32(1),
0048     numberEventsInLuminosityBlock = cms.untracked.uint32(nEventsPerLumi),
0049     numberEventsInRun = cms.untracked.uint32(nEventsPerRun)
0050 )
0051 
0052 process.maxEvents = cms.untracked.PSet(
0053     input = cms.untracked.int32(nEvents)
0054 )
0055 
0056 process.options = cms.untracked.PSet(
0057     numberOfThreads = cms.untracked.uint32(4),
0058     numberOfStreams = cms.untracked.uint32(nStreams),
0059     numberOfConcurrentRuns = cms.untracked.uint32(4),
0060     numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(4)
0061 )
0062 
0063 process.busy1 = cms.EDProducer("BusyWaitIntProducer",ivalue = cms.int32(1), iterations = cms.uint32(10*1000*1000))
0064 
0065 process.throwException = cms.EDProducer("ExceptionThrowingProducer")
0066 process.doNotThrowException = cms.EDProducer("ExceptionThrowingProducer")
0067 
0068 print('testNumber', options.testNumber)
0069 
0070 # Below, the EventID's are selected such that it is likely that in the process
0071 # configured by this file that more than 1 run, more than 1 lumi and more than 1 event
0072 # (stream) will be in flight when the exception is thrown.
0073 
0074 if options.testNumber == 1:
0075     process.throwException.eventIDThrowOnEvent = cms.untracked.EventID(3, 1, 5)
0076 elif options.testNumber == 2:
0077     process.throwException.eventIDThrowOnGlobalBeginRun = cms.untracked.EventID(4, 0, 0)
0078 elif options.testNumber == 3:
0079     process.throwException.eventIDThrowOnGlobalBeginLumi = cms.untracked.EventID(4, 1, 0)
0080     process.throwException.expectedGlobalBeginLumi = cms.untracked.uint32(4)
0081     process.throwException.expectedOffsetNoGlobalEndLumi = cms.untracked.uint32(1)
0082     process.throwException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0083     process.doNotThrowException.expectedOffsetNoGlobalEndLumi = cms.untracked.uint32(1)
0084     process.doNotThrowException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0085 elif options.testNumber == 4:
0086     process.throwException.eventIDThrowOnGlobalEndRun = cms.untracked.EventID(3, 0, 0)
0087 elif options.testNumber == 5:
0088     process.throwException.eventIDThrowOnGlobalEndLumi = cms.untracked.EventID(3, 1, 0)
0089     process.throwException.expectedGlobalBeginLumi = cms.untracked.uint32(3)
0090     process.throwException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0091     process.doNotThrowException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0092 elif options.testNumber == 6:
0093     process.throwException.eventIDThrowOnStreamBeginRun = cms.untracked.EventID(4, 0, 0)
0094 elif options.testNumber == 7:
0095     process.throwException.eventIDThrowOnStreamBeginLumi = cms.untracked.EventID(4, 1, 0)
0096     process.throwException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0097     process.throwException.expectedOffsetNoStreamEndLumi = cms.untracked.uint32(1)
0098     process.doNotThrowException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0099     process.doNotThrowException.expectedOffsetNoStreamEndLumi = cms.untracked.uint32(1)
0100 elif options.testNumber == 8:
0101     process.throwException.eventIDThrowOnStreamEndRun = cms.untracked.EventID(3, 0, 0)
0102 elif options.testNumber == 9:
0103     process.throwException.eventIDThrowOnStreamEndLumi = cms.untracked.EventID(3, 1, 0)
0104     process.throwException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0105     process.doNotThrowException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0106 else:
0107     print("The parameter named testNumber is out of range. An exception will not be thrown. Supported values range from 1 to 9.")
0108     print("The proper syntax for setting the parameter is:")
0109     print("")
0110     print ("    cmsRun FWCore/Integration/test/testFrameworkExceptionHandling_cfg.py testNumber=1")
0111     print("")
0112 process.path1 = cms.Path(
0113     process.busy1 *
0114     process.throwException
0115 )
0116 process.path2 = cms.Path(process.doNotThrowException)