19def modify(event):
20 """Fills in the MUCTPi ROB)."""
21
22 map=[[eformat.helper.SubDetector.TDAQ_MUON_CTP_INTERFACE,0,1]]
23
24 DaqRobs=[None]*len(map)
25
26 for rob in event:
27 cnt=0
28 for match in map:
29 if rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[1]):
30 DaqRobs[cnt]=rob
31 cnt+=1
32
33
34
35
36 new_event=eformat.write.FullEventFragment()
37 new_event.copy_header(event)
38 for rob in event:
39 keep=True
40 for match in map:
41 if rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[2]):
42 keep=False
43 break
44 if keep:
45 new_event.append_unchecked(rob)
46 for idx in range(len(map)):
47 if DaqRobs[idx]:
48 rob=eformat.write.ROBFragment(DaqRobs[idx])
49 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
50 if map[idx][0]==eformat.helper.SubDetector.TDAQ_CTP:
51 version=rob.rod_minor_version()&0x1f
52 if version:
53 ctpSkip=(rob.rod_minor_version()>>8)&0x3f
54 else:
55 ctpSkip=(rob.rod_detev_type()>>16)&0x3f
56 data=[DaqRobs[idx].rod_data()[0],DaqRobs[idx].rod_data()[1]]
57 for ii in range(30):
58 data+=[DaqRobs[idx].rod_data()[2+ctpSkip*30+ii]]
59 rob.rod_data(data)
60 if map[idx][0]==eformat.helper.SubDetector.TDAQ_MUON_CTP_INTERFACE:
61 data=[]
62 if len(DaqRobs[idx].rod_data()):
63 muctpBC=(DaqRobs[idx].rod_data()[0]>>18)&7
64 for word in DaqRobs[idx].rod_data()[1:]:
65 if (word>>14)&7==muctpBC and (word>>26)&1:
66 data+=[(word&0x3fff)|(((word>>17)&0x1ff)<<14)]
67 if len(data)==0:
68 rob=eformat.write.ROBFragment()
69 rob.copy_header(DaqRobs[idx])
70 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
71 else:
72 rob.rod_data(data)
73 new_event.append(rob)
74 else:
75 rob=eformat.write.ROBFragment()
76 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
77 new_event.append(rob)
78 return new_event.readonly()
79
80