33 std::vector<o2::phos::Cell> outputCells;
34 std::vector<o2::phos::TriggerRecord> outputTriggers;
38 int posTriggerRecords = ctx.
inputs().
getPos(
"inputtriggers");
42 std::vector<SubspecSet> subspecs;
45 for (
int islot = 0; islot < numSlotsTriggerRecords; islot++) {
46 auto trgrecorddata = ctx.
inputs().
getByPos(posTriggerRecords, islot);
47 auto subspecification = framework::DataRefUtils::getHeader<header::DataHeader*>(trgrecorddata)->subSpecification;
49 if (subspecification == 0xDEADBEEF) {
55 if (framework::DataRefUtils::getHeader<header::DataHeader*>(celldata)->subSpecification != subspecification) {
56 for (
int islotCell = 0; islotCell < numSlotsCells; islotCell++) {
58 if (framework::DataRefUtils::getHeader<header::DataHeader*>(celldata)->subSpecification == subspecification) {
63 if (framework::DataRefUtils::getHeader<header::DataHeader*>(celldata)->subSpecification != subspecification) {
64 LOG(error) <<
"Can not find cells for TrigRecords with subspecification " << subspecification;
68 subspecs.emplace_back(ctx.
inputs().
get<gsl::span<o2::phos::TriggerRecord>>(trgrecorddata),
69 ctx.
inputs().
get<gsl::span<o2::phos::Cell>>(celldata));
74 if (subspecs.size() == 1) {
75 for (
const Cell&
c : subspecs[0].cellSpan) {
76 outputCells.emplace_back(
c);
79 outputTriggers.emplace_back(
r);
83 if (subspecs.size() > 2) {
84 LOG(error) <<
" Too many subspecs for event building:" << subspecs.size();
86 auto tr1 = subspecs[0].trSpan.begin();
87 auto tr2 = subspecs[1].trSpan.begin();
88 while (tr1 != subspecs[0].trSpan.end() && tr2 != subspecs[1].trSpan.end()) {
89 if (tr1->getBCData() == tr2->getBCData()) {
91 if (subspecs[0].cellSpan.size() > 0) {
92 short absId = subspecs[0].cellSpan[0].getAbsId();
94 first1 = 1 + (absId - 1) / (2 * 64 * 56);
96 first1 = 1 + (subspecs[0].cellSpan[0].getTRUId() - 1) / (8 * 28 * 7);
99 if (subspecs[1].cellSpan.size() > 0) {
100 short absId = subspecs[1].cellSpan[0].getAbsId();
102 first1 = 2 - (absId - 1) / (2 * 64 * 56);
104 first1 = 2 - (subspecs[1].cellSpan[0].getTRUId() - 1) / (8 * 28 * 7);
111 gsl::details::span_iterator<const o2::phos::Cell> itC1, end1, itC2, end2;
113 itC1 = subspecs[0].cellSpan.begin() + tr1->getFirstEntry();
114 end1 = subspecs[0].cellSpan.begin() + tr1->getFirstEntry() + tr1->getNumberOfObjects();
115 itC2 = subspecs[1].cellSpan.begin() + tr2->getFirstEntry();
116 end2 = subspecs[1].cellSpan.begin() + tr2->getFirstEntry() + tr2->getNumberOfObjects();
118 itC1 = subspecs[1].cellSpan.begin() + tr2->getFirstEntry();
119 end1 = subspecs[1].cellSpan.begin() + tr2->getFirstEntry() + tr2->getNumberOfObjects();
120 itC2 = subspecs[0].cellSpan.begin() + tr1->getFirstEntry();
121 end2 = subspecs[0].cellSpan.begin() + tr1->getFirstEntry() + tr1->getNumberOfObjects();
124 while (itC1 != end1) {
125 if (itC1->getAbsId() == 0) {
128 outputCells.emplace_back(*itC1);
131 while (itC2 != end2) {
132 if (itC2->getAbsId() == 0) {
135 outputCells.emplace_back(*itC2);
139 while (itC1 != end1) {
140 outputCells.emplace_back(*itC1);
143 while (itC2 != end2) {
144 outputCells.emplace_back(*itC2);
148 outputTriggers.emplace_back(tr1->getBCData(), nOutCells, outputCells.size() - nOutCells);
149 nOutCells = outputCells.size();
154 if (tr1->getBCData() < tr2->getBCData()) {
155 auto itC1 = subspecs[0].cellSpan.begin() + tr1->getFirstEntry();
156 auto end1 = subspecs[0].cellSpan.begin() + tr1->getFirstEntry() + tr1->getNumberOfObjects();
157 while (itC1 != end1) {
158 outputCells.emplace_back(*itC1);
160 outputTriggers.emplace_back(tr1->getBCData(), nOutCells, outputCells.size() - nOutCells);
161 nOutCells = outputCells.size();
164 auto itC1 = subspecs[1].cellSpan.begin() + tr2->getFirstEntry();
165 auto end1 = subspecs[1].cellSpan.begin() + tr2->getFirstEntry() + tr2->getNumberOfObjects();
166 while (itC1 != end1) {
167 outputCells.emplace_back(*itC1);
169 outputTriggers.emplace_back(tr2->getBCData(), nOutCells, outputCells.size() - nOutCells);
170 nOutCells = outputCells.size();
175 if (tr1 != subspecs[0].trSpan.end() || tr2 != subspecs[1].trSpan.end()) {
176 LOG(error) <<
"Inconsistent number of TriggerRecords in subsec 1 and 2: " << subspecs[0].trSpan.size() <<
" and " << subspecs[1].trSpan.size();
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.