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 
12  def run(self):
13  """Process all the events
14  """
15  self._cppProcessor.run()
16 
17  def totalEvents(self):
18  return self._cppProcessor.totalEvents()
19  def totalEventsPassed(self):
20  return self._cppProcessor.totalEventsPassed()
21  def totalEventsFailed(self):
22  return self._cppProcessor.totalEventsFailed()
23 
24 if __name__ == "__main__":
25 
26  import unittest
27  class testCmsRun(unittest.TestCase):
28  def testFiltering(self):
29  import FWCore.ParameterSet.Config as cms
30  process = cms.Process("Test")
31  process.source = cms.Source("EmptySource")
32  nEvents=10
33  process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(nEvents))
34  process.scale = cms.EDFilter("Prescaler",prescaleFactor = cms.int32(1), prescaleOffset = cms.int32(0))
35  process.p = cms.Path(process.scale)
36  filterResults = ((10,0),(5,5),(3,7))
37  for x in [1,2,3]:
38  process.scale.prescaleFactor = x
39  e = CmsRun(process)
40  e.run()
41  self.assertEqual(e.totalEvents(),nEvents)
42  self.assertEqual(e.totalEventsPassed(),filterResults[x-1][0])
43  self.assertEqual(e.totalEventsFailed(),filterResults[x-1][1])
44  del e
45 
46  unittest.main()
def totalEventsPassed(self)
Definition: CmsRun.py:19
def testFiltering(self)
Definition: CmsRun.py:28
def totalEvents(self)
Definition: CmsRun.py:17
def __init__(self, process)
Definition: CmsRun.py:5
def totalEventsFailed(self)
Definition: CmsRun.py:21
def run(self)
Definition: CmsRun.py:12