5 Module for creating the MUCTPi fragment normally send through the RoIB
6 using the information readout from the ROS.
7 It can be used either standalone or as a "-Z" plugin to athenaMT/PT.
9 Note that a bunch of information is hardcoded and could change if
10 the data format of the CTP/MUCTPI/L1Calo ROIB fragments change.
17 import libpyevent_storage
as EventStorage
20 """Fills in the MUCTPi ROB)."""
22 map=[[eformat.helper.SubDetector.TDAQ_MUON_CTP_INTERFACE,0,1]]
24 DaqRobs=[
None]*len(map)
29 if rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[1]):
36 new_event=eformat.write.FullEventFragment()
37 new_event.copy_header(event)
41 if rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[2]):
45 new_event.append_unchecked(rob)
46 for idx
in range(len(map)):
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
53 ctpSkip=(rob.rod_minor_version()>>8)&0x3f
55 ctpSkip=(rob.rod_detev_type()>>16)&0x3f
56 data=[DaqRobs[idx].rod_data()[0],DaqRobs[idx].rod_data()[1]]
58 data+=[DaqRobs[idx].rod_data()[2+ctpSkip*30+ii]]
60 if map[idx][0]==eformat.helper.SubDetector.TDAQ_MUON_CTP_INTERFACE:
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)]
68 rob=eformat.write.ROBFragment()
69 rob.copy_header(DaqRobs[idx])
70 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
75 rob=eformat.write.ROBFragment()
76 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
78 return new_event.readonly()
82 input = eformat.istream([input_file])
83 dr=EventStorage.pickDataReader(input_file)
84 output = eformat.ostream(core_name=
"subset",
85 run_number=dr.runNumber(),
86 trigger_type=dr.triggerType(),
87 detector_mask=dr.detectorMask(),
88 beam_type=dr.beamType(),
89 beam_energy=dr.beamEnergy())
91 output.write(
modify(event))
92 tmp_file_name = output.last_filename()
94 os.rename(tmp_file_name,output_file)
98 if __name__ ==
"__main__":
100 print(
'usage: %s <infile> <outfile>' % sys.argv[0])
102 input_file = sys.argv[1]
103 output_file = sys.argv[2]