85 std::vector<o2::InteractionRecord> irList;
86 std::vector<std::array<short, 56>> cellTRURanges;
87 for (
int iddl = 14; iddl--;) {
88 mTmpCells[iddl].clear();
89 mTmpTRU[iddl].clear();
91 mOutputHWErrors.clear();
93 mOutputFitChi.clear();
98 static size_t contDeadBeef = 0;
101 const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
103 if (payloadSize == 0) {
105 if (++contDeadBeef <= maxWarn) {
106 LOGP(warning,
"Found input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : assuming no payload for all links in this TF{}",
107 dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, payloadSize,
108 contDeadBeef == maxWarn ? fmt::format(
". {} such inputs in row received, stopping reporting", contDeadBeef) :
"");
110 mOutputCells.clear();
112 mOutputTriggerRecords.clear();
114 mOutputHWErrors.clear();
117 mOutputFitChi.clear();
125 if (mInitSimParams) {
127 mInitSimParams =
false;
133 const gsl::span<const char>& rawmemory = o2::framework::DataRefUtils::as<const char>(rawData);
134 if (rawmemory.size() == 0) {
147 mOutputHWErrors.emplace_back(14, (
int)e, 1);
158 auto triggerBC = o2::raw::RDHUtils::getTriggerBC(header);
159 auto triggerOrbit = o2::raw::RDHUtils::getTriggerOrbit(header);
160 auto ddl = o2::raw::RDHUtils::getFEEID(header);
163 LOG(error) <<
"DDL=" << ddl;
164 mOutputHWErrors.emplace_back(14, 16,
char(ddl));
172 if (currentIR.
differenceInBC({0, tfOrbitFirst}) >= ctpOffsets.LM_L0) {
173 currentIR -= ctpOffsets.LM_L0;
178 auto irIter = irList.rbegin();
179 auto rangeIter = cellTRURanges.rbegin();
180 while (irIter != irList.rend() && *irIter != currentIR) {
184 if (irIter != irList.rend()) {
185 (*rangeIter)[2 * ddl] = mTmpCells[ddl].size();
186 (*rangeIter)[28 + 2 * ddl] = mTmpTRU[ddl].size();
188 irList.push_back(currentIR);
189 cellTRURanges.emplace_back();
190 cellTRURanges.back().fill(0);
191 cellTRURanges.back()[2 * ddl] = mTmpCells[ddl].size();
192 cellTRURanges.back()[28 + 2 * ddl] = mTmpTRU[ddl].size();
193 rangeIter = cellTRURanges.rbegin();
195 std::vector<Cell>& currentCellContainer = mTmpCells[ddl];
196 std::vector<Cell>& currentTRUContainer = mTmpTRU[ddl];
199 mDecoder->decode(rawreader, mRawFitter.get(), currentCellContainer, currentTRUContainer);
200 const std::vector<o2::phos::RawReaderError>& errs = mDecoder->hwerrors();
201 for (
auto a : errs) {
202 mOutputHWErrors.emplace_back(
a);
205 const std::vector<short>& chi2list = mDecoder->chi2list();
206 for (
auto a : chi2list) {
207 mOutputFitChi.emplace_back(
a);
212 (*rangeIter)[2 * ddl + 1] = currentCellContainer.size();
213 auto itBegin = currentCellContainer.begin() + (*rangeIter)[2 * ddl];
214 std::sort(itBegin, currentCellContainer.end(), [](
o2::phos::Cell& lhs,
o2::phos::Cell& rhs) { return lhs.getAbsId() < rhs.getAbsId(); });
215 auto itTrBegin = currentTRUContainer.begin() + (*rangeIter)[28 + 2 * ddl];
216 (*rangeIter)[28 + 2 * ddl + 1] = currentTRUContainer.size();
217 std::sort(itTrBegin, currentTRUContainer.end(), [](
o2::phos::Cell& lhs,
o2::phos::Cell& rhs) { return lhs.getTRUId() < rhs.getTRUId(); });
222 mOutputCells.clear();
224 mOutputCells.reserve(mLastSize);
226 mOutputTriggerRecords.clear();
227 auto rangeIter = cellTRURanges.begin();
228 for (
auto irIter = irList.begin(); irIter != irList.end(); ++irIter, ++rangeIter) {
231 int prevCellSize = mOutputCells.size();
232 for (
int iddl = 0; iddl < 14; iddl++) {
233 auto cbegin = mTmpCells[iddl].begin() + (*rangeIter)[2 * iddl];
234 auto cend = mTmpCells[iddl].begin() + (*rangeIter)[2 * iddl + 1];
236 if (mCombineGHLG && !mPedestalRun) {
242 while (it1 != cend) {
244 if ((*it1).getAbsId() == (*it2).getAbsId()) {
246 if ((*it1).getEnergy() < 1023) {
247 mOutputCells.push_back(*it1);
249 mOutputCells.push_back(*it2);
252 if ((*it2).getEnergy() < 1023) {
253 mOutputCells.push_back(*it2);
255 mOutputCells.push_back(*it1);
264 mOutputCells.push_back(*it1);
268 mOutputCells.push_back(*it1);
273 mOutputCells.insert(mOutputCells.end(), cbegin, cend);
276 for (
int iddl = 0; iddl < 14; iddl++) {
277 auto trbegin = mTmpTRU[iddl].begin() + (*rangeIter)[28 + 2 * iddl];
278 auto trend = mTmpTRU[iddl].begin() + (*rangeIter)[28 + 2 * iddl + 1];
280 for (
auto tri = trbegin; tri != trend; tri++) {
281 if (tri->getEnergy() > 0 || mKeepTrigNoise) {
282 mOutputCells.emplace_back(tri->getTRUId(), tri->getEnergy(), tri->getTime(), tri->getType());
287 mOutputTriggerRecords.emplace_back(*irIter, prevCellSize, mOutputCells.size() - prevCellSize);
290 mLastSize = 1.1 * mOutputCells.size();
292 LOG(
debug) <<
"[PHOSRawToCellConverter - run] Writing " << mOutputCells.size() <<
" cells ...";
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.