7 import libpyevent_storage
as EventStorage
11 print(
" usage: %s [options] <filein> <fileout> <events1> [event2] ..." % sys.argv[0])
12 print(
" Writes out selected events from a bytestream file")
13 print(
" Events are specified as individual event number (counting from 0)")
14 print(
" or as ranges of event numbers (e.g. 3-10).")
15 print(
" Multiple ranges can be specified")
18 print(
" -1 - select on l1 id instead of event number")
19 print(
" -g - select on global id instead of event number")
20 print(
" -v - verbose")
25 opts, args = getopt.getopt(sys.argv[1:],
"1ghv")
27 raise getopt.GetoptError(
"not enough arguments provided")
28 except getopt.GetoptError
as err:
49 print(
"Opening file: %s" % ( input_file))
51 input = eformat.istream([input_file])
52 dr=EventStorage.pickDataReader(input_file)
53 output = eformat.ostream(core_name=output_file,
54 run_number=dr.runNumber(),
55 trigger_type=dr.triggerType(),
56 detector_mask=dr.detectorMask(),
57 beam_type=dr.beamType(),
58 beam_energy=dr.beamEnergy())
61 for range
in eventNums:
69 ranges.append( (
int(vals[0]),
int(vals[1])) )
75 print(
"Reading event %d with Lvl1 Id = %ld and global Id = %ld"% (cnt,event.lvl1_id(),event.global_id()))
82 if num>=range[0]
and num<=range[1]:
83 print(
" - Saving event %d with Lvl1 Id = %ld and global Id = %ld"% (cnt,event.lvl1_id(),event.global_id()))
89 print(numSaved,
'Events saved to',output.last_filename())