Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:00

0001 import libFWCorePythonFramework as _pf
0002 import libFWCorePythonParameterSet as _pp
0003 
0004 class CmsRun(object):
0005   def __init__(self,process):
0006     """Uses a cms.Process to setup an edm::EventProcessor
0007     """
0008     procDesc = _pp.ProcessDesc()
0009     process.fillProcessDesc(procDesc.pset())
0010     self._cppProcessor = _pf.PythonEventProcessor(procDesc)
0011 
0012   def run(self):
0013     """Process all the events
0014     """
0015     self._cppProcessor.run()
0016 
0017   def totalEvents(self):
0018     return self._cppProcessor.totalEvents()
0019   def totalEventsPassed(self):
0020     return self._cppProcessor.totalEventsPassed()    
0021   def totalEventsFailed(self):
0022     return self._cppProcessor.totalEventsFailed()
0023 
0024 if __name__ == "__main__":
0025   
0026   import unittest
0027   class testCmsRun(unittest.TestCase):
0028     def testFiltering(self):
0029       import FWCore.ParameterSet.Config as cms
0030       process = cms.Process("Test")
0031       process.source = cms.Source("EmptySource")
0032       nEvents=10
0033       process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(nEvents))
0034       process.scale = cms.EDFilter("Prescaler",prescaleFactor = cms.int32(1), prescaleOffset = cms.int32(0))
0035       process.p = cms.Path(process.scale)
0036       filterResults = ((10,0),(5,5),(3,7))
0037       for x in [1,2,3]:
0038         process.scale.prescaleFactor = x
0039         e = CmsRun(process)
0040         e.run()
0041         self.assertEqual(e.totalEvents(),nEvents)
0042         self.assertEqual(e.totalEventsPassed(),filterResults[x-1][0])
0043         self.assertEqual(e.totalEventsFailed(),filterResults[x-1][1])
0044         del e
0045 
0046   unittest.main()