Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python
# @file test_seeking_athena.py
# @purpose tests seeking within a POOL file
import os
import re
import difflib
## first, create an input POOL file
input_file_list = [ 'my1.data.pool', 'my2.data.pool', 'my3.data.pool' ]
output_file_name= 'reaccessed.my.data.pool'
## import PyUtils.AthFile as af
## af.server.flush_cache()
import os
import AthenaCommon.ChapPy as accp
num_evt = 0
run_num = 0
for input_file_name in input_file_list:
num_evt += 5
run_num += 1
app = accp.AthenaApp()
app << """
EVTMAX=%(num_evt)s
OUTPUT='%(input_file_name)s'
include('AthExThinning/AthExThinning_makeData.py')
svcMgr.EventSelector.RunNumber = %(run_num)s
""" % globals()
print "=== create an elephantino file..."
rc = app.run(stdout=os.devnull)
if rc:
raise RuntimeError(rc)
print "=== create an elephantino file... [ok]"
## now do the seeking within a new job.
app = accp.AthenaApp()
app << """
EVTMAX=-1
INPUT=%(input_file_list)s
OUTPUT='%(output_file_name)s'
include('AthExThinning/ReadNonThinnedData_jobOptions.py')
topSequence.ReadNonThinnedData.OutputLevel = Lvl.ERROR
import AthenaServices.PyAthenaEventLoopMgr as aspy
aspy.enable_seeking()
print '==test-seeking==: theApp.run(1)...'
theApp.run(1)
print '==test-seeking==: theApp.run(1)... [ok]'
theApp.seek(0)
theApp.nextEvent()
theApp.seek(2)
theApp.nextEvent()
theApp.seek(21)
theApp.nextEvent()
theApp.seek(6)
theApp.nextEvent()
theApp.seek(0)
theApp.nextEvent()
theApp.seekEvent(2)
theApp.seekEvent(21)
theApp.seekEvent(6)
theApp.seek(0)
theApp.nextEvent(-1)
theApp.finalize()
theApp.exit()
"""% globals()
read_logfile = open('seeking.elephantino.readback.logfile.txt', 'w+')
print "=== read the elephantino file back (with seeking)... (logfile=%s)" % (read_logfile.name,)
rc = app.run(stdout=read_logfile)
if rc:
raise RuntimeError(rc)
print "=== read the elephantino file back (with seeking)... [ok]"
read_logfile.seek(0)
out_for_diff = [
l.strip() for l in read_logfile
if re.match('^AthenaEventLoopMgr INFO ===>>> done processing event',
l)
]
ref_file = """\
AthenaEventLoopMgr INFO ===>>> done processing event #0, run #1 1 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #0, run #1 2 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #2, run #1 3 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #6, run #3 4 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #1, run #2 5 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #0, run #1 6 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #2, run #1 7 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #6, run #3 8 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #1, run #2 9 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #0, run #1 10 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #1, run #1 11 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #2, run #1 12 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #3, run #1 13 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #4, run #1 14 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #0, run #2 15 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #1, run #2 16 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #2, run #2 17 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #3, run #2 18 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #4, run #2 19 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #5, run #2 20 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #6, run #2 21 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #7, run #2 22 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #8, run #2 23 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #9, run #2 24 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #0, run #3 25 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #1, run #3 26 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #2, run #3 27 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #3, run #3 28 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #4, run #3 29 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #5, run #3 30 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #6, run #3 31 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #7, run #3 32 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #8, run #3 33 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #9, run #3 34 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #10, run #3 35 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #11, run #3 36 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #12, run #3 37 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #13, run #3 38 events processed so far <<<===
AthenaEventLoopMgr INFO ===>>> done processing event #14, run #3 39 events processed so far <<<===
""".splitlines()
diff = difflib.unified_diff(out_for_diff, ref_file)
diff = os.linesep.join( [d for d in diff] )
assert diff=='', diff
print "::: bye."
print ":"*80