29 """Fills in the L1R from the most appropriate source (L1/ROS or Dummy)."""
31 map=[[eformat.helper.SubDetector.TDAQ_CTP,0,1],
32 [eformat.helper.SubDetector.TDAQ_MUON_CTP_INTERFACE,0,1],
33 [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,136,168],
34 [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,137,169],
35 [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,138,170],
36 [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,139,171],
37 [eformat.helper.SubDetector.TDAQ_CALO_JET_PROC_ROI,140,172],
38 [eformat.helper.SubDetector.TDAQ_CALO_JET_PROC_ROI,141,173]]
40 DaqRobs=[
None]*len(map)
41 L2Robs=[
None]*len(map)
47 if rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[1]):
49 elif rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[2]):
54 if (
not DaqRobs[0])
and (
not L2Robs[0]):
55 logging.warning(
' Plugin "addL1": No DAQ CTP fragment. Event can not be recovered. Event will be skipped. L1 id = %d, Global id = %d ', event.lvl1_id(), event.global_id())
59 new_event=eformat.write.FullEventFragment()
60 new_event.copy_header(event)
62 new_event.append_unchecked(rob)
64 for idx
in range(len(map)):
69 rob=eformat.write.ROBFragment(DaqRobs[idx])
70 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
72 daq_data = [r
for r
in rob.rod_data()]
76 offset = CTPdataformat.NumberTimeWords + CTPfragment.lvl1AcceptBunch(rob)*CTPdataformat.DAQwordsPerBunch
78 data = daq_data[:CTPdataformat.NumberTimeWords]
80 data += daq_data[offset : offset+CTPdataformat.DAQwordsPerBunch]
82 data += daq_data[-CTPfragment.numberExtraPayloadWords(rob):]
87 if len(DaqRobs[idx].rod_data()) > 0:
88 muctpBC=(DaqRobs[idx].rod_data()[0]>>18)&7
89 for word
in DaqRobs[idx].rod_data()[1:]:
90 if (word>>14)&7==muctpBC
and (word>>26)&1:
91 data+=[(word&0x3fff)|(((word>>17)&0x1ff)<<14)]
94 rob=eformat.write.ROBFragment()
95 rob.copy_header(DaqRobs[idx])
96 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
100 new_event.append(rob)
102 rob=eformat.write.ROBFragment()
103 rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
104 new_event.append(rob)
106 return new_event.readonly()