18 : \
"" <<
type <<
"\".",
20 )
21
22std::vector<uint32_t>
24 const uint32_t* input,
25 eformat::Compression comp,
26 unsigned int comp_level) {
27 ERS_DEBUG(5, "Create read fullevent");
28 eformat::read::FullEventFragment fullevent(input);
29 ERS_DEBUG(5, "Create write hltresult");
30 eformat::write::FullEventFragment newEvent(hltresult);
31
32
33 auto nstream_tag = newEvent.nstream_tag();
34 auto stream_tag = newEvent.stream_tag();
35 ERS_DEBUG(4, nstream_tag << " stream tag words, stream_tag[0]= " << stream_tag[0]);
36 std::vector<eformat::helper::StreamTag> vstream_tag;
37 eformat::helper::decode(nstream_tag, stream_tag, vstream_tag);
38
39
40 newEvent.compression_type(comp);
41 newEvent.compression_level(comp_level);
42 newEvent.lvl2_trigger_info(0, nullptr);
43
44 std::vector<eformat::read::ROBFragment> currRobs;
45 fullevent.robs(currRobs);
46 ERS_DEBUG(4, currRobs.size() << " robs in input event");
47
48
49 eformat::read::FullEventFragment tempEvent(hltresult);
50 std::vector<eformat::read::ROBFragment> tempRobs;
51 tempEvent.robs(tempRobs);
52 std::set<uint32_t> hltResultRobIds;
53 for (
auto &
r : tempRobs) {
54 hltResultRobIds.emplace(
r.rob_source_id());
55 }
56
57 std::set<uint32_t> robset;
58 std::set<eformat::SubDetector> detset;
59 for (const auto &t : vstream_tag) {
60 if (
t.robs.empty()&&
t.dets.empty()) {
61 robset.clear();
62 detset.clear();
63 break;
64 } else {
65 std::copy(std::begin(
t.robs), std::end(
t.robs),
66 std::inserter(robset, std::begin(robset)));
67 std::copy(std::begin(
t.dets), std::end(
t.dets),
68 std::inserter(detset, std::begin(detset)));
69 }
70 }
71
72 std::vector<eformat::write::ROBFragment> robs2write;
73 robs2write.reserve(currRobs.size());
74
75
76 auto toCopy = [&](const auto & rob){
77 auto sId = rob.rob_source_id();
78 auto subId = eformat::helper::SourceIdentifier{sId}.subdetector_id();
79
80 bool build_full_event = robset.empty() && detset.empty();
81 bool HLT_rob = (subId == eformat::TDAQ_HLT);
82 bool already_in_HLTResult = (hltResultRobIds.find(sId) != hltResultRobIds.end());
83 bool suitable_for_copy = (!HLT_rob && !already_in_HLTResult);
84
85 if (build_full_event && suitable_for_copy) {
86 return true;
87 } else {
88 bool requested_by_streamtag = (robset.find(sId) != robset.end()|| detset.find(subId) != detset.end());
89 if (requested_by_streamtag && suitable_for_copy) {
90 return true;
91 }
92 }
93 return false;
94 };
95
96 for (
const auto&
r : currRobs) {
98 robs2write.push_back(
r.start());
99 }
100 }
101
102 ERS_DEBUG(4, robs2write.size() << " ROBs will be written to write event");
103
104 for (
size_t t = 0;
t < robs2write.size();
t++) {
105 newEvent.append(&robs2write[t]);
106 }
107
108 const eformat::write::node_t*
top = newEvent.bind();
109 auto finalSize = newEvent.size_word();
110 auto finalEvent = std::make_unique<uint32_t[]>(finalSize);
111 ERS_DEBUG(4, finalSize << " words will be copied to final event");
112 auto res = eformat::write::copy(*
top, finalEvent.get(), finalSize);
113 if (
res != finalSize) {
114 std::string errMsg("ERROR, event serialization failed - ");
115 errMsg += std::string("Serialized event size: ") + std::to_string(finalSize);
116 errMsg += std::string(
", Written size: ") + std::to_string(
res);
117 auto issue = HLTMPPUIssue::EformatIssue(ERS_HERE,errMsg.c_str());
118 ers::warning(issue);
119 throw issue;
120 }
121 std::vector<uint32_t>
result;
122 result.assign(finalEvent.get(), finalEvent.get() + finalSize);
124}
std::pair< std::vector< unsigned int >, bool > res
std::vector< uint32_t > merge_hltresult_with_input_event(const uint32_t *hltresult, const uint32_t *input, eformat::Compression comp, unsigned int comp_level)
Merge two events: Take header and robs from hltresult event, add all res of the ROBS from input event...