9 from EventIndexProducer.EIPBof
import EIPBof
10 from EventIndexProducer.compressB64
import _fromB64
11 from EventIndexProducer.spbfile
import SpbFile
12 import EventIndexProducer.EIconstants
as eic
17 parser = argparse.ArgumentParser(description=
'Unpick Event Index File')
18 parser.add_argument(
'-e',
'--evtnumber',
21 help=
'event number to dump')
22 parser.add_argument(
'-r',
'--runnumber',
25 help=
'run number to dump')
26 parser.add_argument(
'-m',
'--evtmax',
29 help=
'Max number of events to dump')
30 parser.add_argument(
'--decodeL1trig',
32 help=
'decode L1 trigger')
33 parser.add_argument(
'--decodeL1trig0',
35 help=
'decode L1 trigger, remove redundancies')
36 parser.add_argument(
'--decodeL2trig',
38 help=
'decode L2 trigger')
39 parser.add_argument(
'--decodeEFtrig',
41 help=
'decode EF trigger')
42 parser.add_argument(
'--decodetrig',
44 help=
'decode ALL triggers')
45 parser.add_argument(
'eispbfile',
46 help=
"EventIndex SPB file")
48 return parser.parse_args()
56 for k
in range(0, len(s)):
83 if (pos >= 2*trigLen):
84 TAV.append(pos-2*trigLen)
85 elif (pos >= trigLen):
86 TAP.append(pos-trigLen)
90 l1tl = {
'TAV': TAV,
'TAP': TAP,
'TBP': TBP}
101 print(
'======================================================')
103 print(
'runNumber:', evt.runNumber)
104 print(
'eventNumber:', evt.eventNumber)
105 print(
'lumiBlock:', evt.lumiBlock)
106 print(
'timeStamp:', evt.timeStamp)
107 print(
'timeStampNSOffset:', evt.timeStampNSOffset)
108 print(
'bcid:', evt.bcid)
109 if evt.HasField(
"extendedLevel1ID"):
110 print(
'extendedLevel1ID:', evt.extendedLevel1ID)
111 print(
'isSimulation: {}'.
format(
'true' if evt.isSimulation
else 'false'))
112 print(
'isCalibration: {}'.
format(
'true' if evt.isCalibration
else 'false'))
113 print(
'isTestBeam: {}'.
format(
'true' if evt.isTestBeam
else 'false'))
114 if evt.HasField(
"L1PassedTrigMask"):
115 print(
'L1PassedTrigMask: "{}"'.
format(evt.L1PassedTrigMask))
116 if evt.HasField(
"L2PassedTrigMask"):
117 print(
'L2PassedTrigMask: "{}"'.
format(evt.L2PassedTrigMask))
118 if evt.HasField(
"EFPassedTrigMask"):
119 print(
'EFPassedTrigMask: "{}"'.
format(evt.EFPassedTrigMask))
120 if evt.HasField(
"SMK"):
121 print(
'SMK:', evt.SMK)
122 if evt.HasField(
"HLTPSK"):
123 print(
'HLTPSK:', evt.HLTPSK)
124 if evt.HasField(
"L1PSK"):
125 print(
'L1PSK:', evt.L1PSK)
126 if evt.HasField(
"mcEventWeight"):
127 print(
'mcEventWeight:', evt.mcEventWeight)
128 if evt.HasField(
"mcChannelNumber"):
129 print(
'mcChannelNumber:', evt.mcChannelNumber)
130 for tk
in evt.eitoken:
137 if opt.decodeL1trig
and evt.HasField(
"L1PassedTrigMask"):
138 L1mask = evt.L1PassedTrigMask
141 print(
'TBP: ', L1[
'TBP'])
142 print(
'TAP: ', L1[
'TAP'])
143 print(
'TAV: ', L1[
'TAV'])
145 if opt.decodeL1trig0
and evt.HasField(
"L1PassedTrigMask"):
146 L1mask = evt.L1PassedTrigMask
150 TAP2 = [k
for k
in L1[
'TAP']
if k
not in L1[
'TAV']]
151 TBP2 = [k
for k
in L1[
'TBP']
if k
not in L1[
'TAP']]
153 print(
'TBP*: ', TBP2)
154 print(
'TAP*: ', TAP2)
155 print(
'TAV*: ', TAV2)
157 if opt.decodeL2trig
and evt.HasField(
"L2PassedTrigMask"):
158 L2mask = evt.L2PassedTrigMask
160 L2mask = L2mask.split(
';')
166 print(
'L2_PH: ', L2[
'PH'])
167 print(
'L2_PT: ', L2[
'PT'])
168 print(
'L2_RS: ', L2[
'RS'])
173 if opt.decodeEFtrig
and evt.HasField(
"EFPassedTrigMask"):
174 EFmask = evt.EFPassedTrigMask
176 HLTmask = EFmask.split(
';')
182 print(
'PH: ', HLT[
'PH'])
183 print(
'PT: ', HLT[
'PT'])
184 print(
'RS: ', HLT[
'RS'])
195 opt.decodeL1trig =
True
196 opt.decodeL2trig =
True
197 opt.decodeEFtrig =
True
199 fname = opt.eispbfile
201 spbf = SpbFile(fname)
202 info = spbf.getInfo()
203 except Exception
as e:
204 print(
"Error reading SPB file. Please check file: " +
str(e))
208 print(
" version: ", info[
'version'])
209 print(
" #input files: ", info[
'nfiles'])
210 print(
" number of events: ", info[
'nevents'])
211 print(
" StartProcTime: ", info[
'startProcTime'])
212 print(
" EndProcTime: ", info[
'endProcTime'])
213 print(
" TaskID: ", info[
'taskID'])
214 print(
" JobID: ", info[
'jobID'])
215 print(
" InputDsName: ", info[
'inputDsName'])
216 print(
" Includes Provenance: ", info[
'provenanceRef'])
217 print(
" Includes Trigger: ", info[
'triggerInfo'])
219 for f
in info[
'guids']:
222 print(
" Events in this file: {:8d}".
format(f[
'nevents']))
223 print(
" Unique events in this file: {:8d}".
format(f[
'nuevents']))
225 f[
'fileStartProcTime']))
227 f[
'fileEndProcTime']))
231 print(
" RunEvtRanges: {}".
format(f[
'runevtRanges']))
234 eipbof = EIPBof(spbf.getVersion())
237 print(
"Summary: (info for {:d} events max)".
format(opt.evtmax))
242 (mtype_ver, mlen, msg) = spbf.getMsg()
243 mtype = (mtype_ver & 0x000fff00) >> 8
244 if mtype == eic.EI_PROTO_HEADER:
245 header = eipbof.Header()
246 header.ParseFromString(msg)
247 elif mtype == eic.EI_PROTO_BEGINGUID:
248 beginGUID = eipbof.BeginGUID()
249 beginGUID.ParseFromString(msg)
250 elif mtype == eic.EI_PROTO_ENDGUID:
251 endGUID = eipbof.EndGUID()
252 endGUID.ParseFromString(msg)
253 elif mtype == eic.EI_PROTO_EIEVENT:
254 eventPB = eipbof.EIEvent()
255 eventPB.ParseFromString(msg)
256 if nevt_shown < opt.evtmax:
257 if (opt.evtnumber != 0
and
258 opt.evtnumber != eventPB.eventNumber):
260 if (opt.runnumber != 0
and
261 opt.runnumber != eventPB.runNumber):
267 elif mtype == eic.EI_PROTO_TRIGGERMENU:
268 triggerMenu = eipbof.TriggerMenu()
269 triggerMenu.ParseFromString(msg)
270 elif mtype == eic.EI_PROTO_TRAILER:
271 trailer = eipbof.Trailer()
272 trailer.ParseFromString(msg)
281 if __name__ ==
'__main__':