CMS 3D CMS Logo

CmsRun.py
Go to the documentation of this file.
1 import libFWCorePythonFramework as _pf
2 import libFWCorePythonParameterSet as _pp
3 
4 class CmsRun(object):
5  def __init__(self,process):
6  """Uses a cms.Process to setup an edm::EventProcessor
7  """
8  procDesc = _pp.ProcessDesc()
9  process.fillProcessDesc(procDesc.pset())
10  self._cppProcessor = _pf.PythonEventProcessor(procDesc)
11  def run(self):
12  """Process all the events
13  """
14  self._cppProcessor.run()
15 
16  def totalEvents(self):
17  return self._cppProcessor.totalEvents()
18  def totalEventsPassed(self):
19  return self._cppProcessor.totalEventsPassed()
20  def totalEventsFailed(self):
21  return self._cppProcessor.totalEventsFailed()
22 
23 if __name__ == "__main__":
24 
25  import unittest
26  class testCmsRun(unittest.TestCase):
27  def testFiltering(self):
28  import FWCore.ParameterSet.Config as cms
29  process = cms.Process("Test")
30  process.source = cms.Source("EmptySource")
31  nEvents=10
32  process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(nEvents))
33  process.scale = cms.EDFilter("Prescaler",prescaleFactor = cms.int32(1), prescaleOffset = cms.int32(0))
34  process.p = cms.Path(process.scale)
35  filterResults = ((10,0),(5,5),(3,7))
36  for x in [1,2,3]:
37  process.scale.prescaleFactor = x
38  e = CmsRun(process)
39  e.run()
40  self.assertEqual(e.totalEvents(),nEvents)
41  self.assertEqual(e.totalEventsPassed(),filterResults[x-1][0])
42  self.assertEqual(e.totalEventsFailed(),filterResults[x-1][1])
43  del e
44 
45  unittest.main()
def totalEventsPassed(self)
Definition: CmsRun.py:18
def testFiltering(self)
Definition: CmsRun.py:27
def totalEvents(self)
Definition: CmsRun.py:16
def __init__(self, process)
Definition: CmsRun.py:5
def totalEventsFailed(self)
Definition: CmsRun.py:20
def run(self)
Definition: CmsRun.py:11