ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigTools
TrigByteStreamTools
bin
trigbs_mixBSevents.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
4
5
import
eformat
6
import
libpyevent_storage
as
EventStorage
7
import
sys
8
import
getopt
9
10
eventsPerFile=500
11
verbose=
False
12
13
def
usage
():
14
print
(
" usage: %s [options] <outbasename> <file1> <file2> <file3>"
% sys.argv[0])
15
print
(
" Rewrites events with event ids numbered consequtively from 1"
)
16
print
(
" This is mainly used for preparing events from playback partition"
)
17
print
()
18
print
(
" Options:"
)
19
print
(
" -n <number of events per file> : defaults to 500"
)
20
print
(
" -v : verbose output"
)
21
sys.exit(1)
22
23
try
:
24
opts, args = getopt.getopt(sys.argv[1:],
"vn:"
)
25
if
len(args)<2:
26
usage
()
27
except
getopt:
28
usage
()
29
30
for
opt,arg
in
opts:
31
if
opt ==
'-n'
:
32
eventsPerFile=int(arg)
33
if
opt ==
'-v'
:
34
verbose=
True
35
36
basename=args[0]
37
files = args[1:]
38
39
ifile = 0
40
id = 1
41
outnum=1
42
dr=EventStorage.pickDataReader(files[0])
43
numFiles=0
44
output = eformat.ostream(core_name=basename,
45
run_number=dr.runNumber(),
46
trigger_type=dr.triggerType(),
47
detector_mask=dr.detectorMask(),
48
beam_type=dr.beamType(),
49
beam_energy=dr.beamEnergy())
50
output.max_events_per_file(eventsPerFile)
51
52
for
input_file
in
files:
53
ifile += 1
54
print
(
"Opening file %d: %s"
% (ifile, input_file))
55
56
input = eformat.istream([input_file])
57
58
for
event
in
input:
59
if
verbose:
60
print
(
"Reading event with Lvl1 Id = %ld and rewritting with %ld"
% (event.lvl1_id(),id))
61
new_event = eformat.write.FullEventFragment(event)
62
new_event.lvl1_id(id)
63
new_event.global_id(id)
64
for
rob
in
new_event.children():
65
rob.rod_lvl1_id(id)
66
rob.checksum_type(0)
#remove checksum
67
rob.rod_lvl1_trigger_type(event.lvl1_trigger_type())
68
69
output.write(new_event)
70
71
id+=1
72
73
print
(
'Wrote %d events to %d files'
% ( id-1, 1+((id-1)//eventsPerFile) ))
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
trigbs_mixBSevents.usage
usage()
Definition
trigbs_mixBSevents.py:13
Generated on
for ATLAS Offline Software by
1.17.0