~vpec/maus/tof_calib_read

« back to all changes in this revision

Viewing changes to src/.svn/text-base/GenericWorker.py.svn-base

  • Committer: tunnell
  • Date: 2010-09-20 10:52:02 UTC
  • Revision ID: tunnell@itchy-20100920105202-ce4w9jm59zvgnsxq
moving stuff from tucs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Author: Christopher Tunnell <tunnell@hep.uchicago.edu>
 
2
#
 
3
# March 04, 2009
 
4
#
 
5
from src.region import *
 
6
from src.event import *
 
7
#import unittest
 
8
 
 
9
class GenericWorker(object):
 
10
    "Generic Worker Class"
 
11
 
 
12
    # one day we'll have test-suites
 
13
    #   testsuite = unittest.TestSuite() 
 
14
 
 
15
    # Constructor
 
16
    def __init__(self, verbose=False):
 
17
        if verbose:
 
18
            print "Print class set to verbose"
 
19
        self.verbose = verbose
 
20
 
 
21
    # The set of events are passed to processEvents, then processEvent
 
22
    # on each of the single events.  This allows classes to pick if they
 
23
    # want just events, or the whole set.  handleEvents mainly does checks
 
24
    # though.
 
25
    def HandleDetector(self, detector):
 
26
        if not isinstance(detector, Region):
 
27
            print 'The following worker was not passed a region', self
 
28
            return
 
29
 
 
30
        assert(isinstance(detector, Region))
 
31
 
 
32
        type = 'readout'
 
33
        if hasattr(self, 'type'):
 
34
            type = self.type
 
35
                            
 
36
        self.ProcessStart()
 
37
        
 
38
        for region in detector.RegionGenerator(type):
 
39
            self.ProcessRegion(region)
 
40
 
 
41
        self.ProcessStop()
 
42
            
 
43
        return detector
 
44
 
 
45
# Make sure people at least implement this
 
46
#    def ProcessRegion(self, region):
 
47
#        return region
 
48
 
 
49
    def ProcessStart(self):
 
50
        return
 
51
 
 
52
    def ProcessStop(self):
 
53
        return