~vpec/maus/tof_calib_read

« back to all changes in this revision

Viewing changes to src/go.py

  • 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
#!/bin/env python
 
2
# Author: Christopher Tunnell <tunnell@hep.uchicago.edu>
 
3
#
 
4
# March 04, 2009
 
5
#
 
6
import os, sys, gc
 
7
from src.region import *
 
8
from datetime import datetime
 
9
 
 
10
# This processes everything
 
11
class Go:
 
12
    def __init__(self, workers):
 
13
        print 'Welcome to TUCS (pid %d).  Building detector tree... ' % os.getpid(),
 
14
        startup = datetime.today()
 
15
        
 
16
        self.detector = constructTileCal()
 
17
        print 'done!'
 
18
        print
 
19
        print 'Entering worker loop:'
 
20
 
 
21
        if workers:
 
22
            for worker in workers:
 
23
                if worker:
 
24
                    print 'Running %s - %s' % (worker.__class__.__name__, worker.__class__.__doc__)
 
25
                    sys.stdout.flush()
 
26
                    self.detector = worker.HandleDetector(self.detector)
 
27
                    gc.collect()
 
28
                    if not isinstance(self.detector, Region):
 
29
                        print "The following worker returned non-sense:", worker
 
30
                        break
 
31
 
 
32
        # free up memory
 
33
        for region in self.detector.RegionGenerator():
 
34
            region.SetEvents(set())
 
35
            region.SetChildren(set())
 
36
        del self.detector
 
37
        gc.collect(2)
 
38
        print
 
39
        print 'TUCS finished in:', datetime.today() - startup