source: trunk/examples/advanced/Tiara/source/py_modules/runSequence.py@ 1241

Last change on this file since 1241 was 807, checked in by garnier, 17 years ago

update

File size: 3.4 KB
Line 
1# $Id: runSequence.py,v 1.4 2004/06/09 15:04:36 daquinog Exp $
2# -------------------------------------------------------------------
3# GEANT4 tag $Name: $
4# -------------------------------------------------------------------
5#
6import Tiara
7import myUtils
8import shelve
9import os
10import string
11
12class RunConfig(object):
13 def __init__(self):
14 self.basePath = ""
15 self.tApp = ""
16 self.tiaraSpecs = ""
17 self.impGeo = ""
18 self.impScorer = ""
19 self.totalTime = ""
20 self.comment = ""
21 def getConfInfo(self):
22 return myUtils.\
23 getConfigurationInfo(self.impGeo,
24 self.tiaraSpecs.experiment,
25 self.tApp.physicsList,
26 self.totalTime,
27 self.comment)
28
29
30
31
32class RunSequence(object):
33 # methods to be used public
34 def __init__(self, runConfig, usePI = True):
35 self.rc = runConfig
36 self.usePI = usePI
37 self.runNum = -1
38 self.confInfo = self.rc.getConfInfo()
39 self.storeName = myUtils.getStoreName()
40 self.xmlStore = ""
41 self.pathXMLName = ""
42 self.shelveName = ""
43 self.pathShelveName = ""
44 self.randomNumberFileName = ""
45 self.path = self.mkPath()
46
47 def runNevents(self, events):
48 self.runNum += 1
49 self.mkNames()
50 self.mkShelve()
51 self.report()
52 self.rc.tApp.tiaraSim.BeamOn (events)
53 Tiara.saveRandomStatus(self.randomNumberFileName)
54 myUtils.saveResults(self.rc.tApp,
55 self.path,
56 self.shelveName,
57 self.rc.impScorer,
58 self.rc.impGeo)
59
60 def runLoop(self):
61 while ( not \
62 (self.rc.tApp.eventAction.\
63 GetTotalProcessedTime() > self.rc.totalTime)):
64 self.runNevents(10000000) # dummy num. events
65
66
67
68
69
70
71
72 # methods used privately
73
74 def report(self):
75 print "\n\nRunSequence.report:"
76 print self.confInfo
77 if self.usePI:
78 print "the xml store will be named: "
79 print " ", self.pathXMLName
80 print "the shelve name: "
81 print " ", self.pathShelveName
82 print "\n\n"
83
84
85
86 def mkPath(self):
87 if not os.path.exists(self.rc.basePath):
88 os.mkdir(self.rc.basePath)
89 path = self.rc.basePath + "/" + self.storeName
90 if not os.path.exists(path):
91 os.mkdir(path)
92 return path
93
94 def mkNames(self):
95 rn = self.runNum
96 rns = "%(rn)d" % vars()
97 rns = string.rjust(rns, 5)
98 rns = string.replace(rns,' ','0')
99 rId = "_run" + rns
100 if self.usePI:
101 self.xmlStore = self.storeName + rId + ".xml"
102 self.pathXMLName = self.path + "/" + self.xmlStore
103
104 self.shelveName = self.storeName + rId + ".shelve"
105 self.pathShelveName = self.path + "/" + self.shelveName
106 self.randomNumberFileName = self.path + "/randomNumberFile" + rId
107
108
109 def mkShelve(self):
110 myShelve = shelve.open(self.pathShelveName)
111 if self.usePI:
112 myShelve["xmlStoreName"] = self.xmlStore
113 for info in self.confInfo:
114 myShelve[info] = self.confInfo[info]
115 myShelve.close()
116
117
118# end of RunSeuence
119
Note: See TracBrowser for help on using the repository browser.