12#include <fairlogger/Logger.h> 
   29  bool physicsTrigger = 
false;
 
   31  std::shared_ptr<PixelLaneHandler> currenttrigger;
 
   32  for (
const auto& word : payload) {
 
   33    if (word.isDataHeader()) {
 
   36    if (word.isDataTrailer()) {
 
   39    if (word.isDiagnosticWord()) {
 
   42    if (word.isTriggerWord()) {
 
   43      auto lastIR = currentIR;
 
   44      currentIR.
orbit = word.orbit;
 
   45      currentIR.
bc = word.bc;
 
   47        physicsTrigger = 
true;
 
   49      if (lastIR != currentIR || !currenttrigger) {
 
   50        auto found = mPixelData.find(currentIR);
 
   51        if (found == mPixelData.end()) {
 
   52          currenttrigger = std::make_shared<PixelLaneHandler>();
 
   53          mPixelData[currentIR] = currenttrigger;
 
   55          currenttrigger = found->second;
 
   61      auto payload = gsl::span<const uint8_t>(
reinterpret_cast<const uint8_t*
>(word.getW8()), 9);
 
   63      if (word.isDataIB()) {
 
   64        lane = dataword->getLaneIB();
 
   65      } 
else if (word.isDataOB()) {
 
   68        lane = dataword->getLaneIB();
 
   74      currenttrigger->getLane(lane).append(payload);
 
   81  LOG(
debug) << 
"Found " << mPixelData.size() << 
" triggers";
 
   82  for (
auto& [trigger, 
data] : mPixelData) {
 
   84    LOG(
debug) << 
"Found trigger " << trigger.asString();
 
   85    std::vector<PixelChip> combinedChips;
 
   88      const auto& lane = 
data->getLane(ilane);
 
   89      if (lane.getPayload().size()) {
 
   91        LOG(
debug) << 
"[Lane " << ilane << 
"] " << lane;
 
   92        auto laneChips = decodeLane(ilane, lane.getPayload());
 
   93        auto chipsBefore = combinedChips.size();
 
   94        std::copy(laneChips.begin(), laneChips.end(), std::back_inserter(combinedChips));
 
   96        LOG(
debug) << 
"Merging combined chips, before " << chipsBefore << 
", after " << combinedChips.size();
 
  101    LOG(
debug) << 
"Trigger has " << combinedChips.size() << 
" chips from " << foundLanes << 
" lanes ";
 
  102    std::sort(combinedChips.begin(), combinedChips.end(), std::less<>());
 
  103    for (
auto& chip : combinedChips) {
 
  105      LOG(
debug) << 
"Chip " << 
static_cast<int>(chip.mChipID) << 
" [lane " << 
static_cast<int>(chip.mLaneID) << 
"], with " << chip.mHits.size() << 
" hit(s) ... ";
 
  107    mChipData[trigger] = combinedChips;
 
 
  114  if (payloadword == 0xff) {
 
  116  } 
else if (payloadword == 0xf1) {
 
  118  } 
else if (payloadword == 0xf0) {
 
  120  } 
else if ((payloadword & 0xf0) == 0xa0) {
 
  122  } 
else if ((payloadword & 0xf0) == 0xb0) {
 
  124  } 
else if ((payloadword & 0xf0) == 0xe0) {
 
  126  } 
else if ((payloadword & 0xe0) == 0xc0) {
 
  128  } 
else if ((payloadword & 0xc0) == 0x40) {
 
  130  } 
else if ((payloadword & 0xc0) == 0x00) {
 
  136uint16_t PixelDecoder::AlpideY(uint16_t 
address)
 
  141uint16_t PixelDecoder::AlpideX(uint8_t region, uint8_t encoder, uint16_t 
address)
 
  143  int x = region * 32 + encoder * 2;
 
  153std::vector<PixelChip> PixelDecoder::decodeLane(uint8_t laneID, gsl::span<const uint8_t> laneWords)
 
  156  auto currentptr = laneWords.data();
 
  160  uint16_t currentChipStatus;
 
  161  std::vector<PixelHit> hits;
 
  162  std::vector<PixelChip> decodedChips;
 
  163  bool activeChip = 
false;
 
  165    if (!activeChip && (*currentptr == 0)) {
 
  168      if (currentptr - laneWords.data() >= laneWords.size()) {
 
  173    auto wordtype = getWordType(*currentptr);
 
  174    std::size_t wordsize;
 
  180        auto chipID = emptyword->
mChipID;
 
  182        LOG(
debug) << 
"Empty chip (" << std::bitset<4>(emptyword->mIdentifier) << 
") " << 
int(emptyword->mChipID) << 
", BC (" << 
int(emptyword->mBunchCrossing) << 
"), empty " << (emptyword->isEmptyFrame() ? 
"yes" : 
"no");
 
  183        if (std::find_if(decodedChips.begin(), decodedChips.end(), [chipID, laneID](
const PixelChip& chip) { return chip.mChipID == chipID && chip.mLaneID == laneID; }) == decodedChips.end()) {
 
  186          LOG(
debug) << 
"Creating new empty frame";
 
  187          currentChipStatus = (emptyword->mIdentifier) << 8;
 
  188          decodedChips.push_back({0, laneID, 
static_cast<uint8_t>(chipID), currentChipStatus, hits});
 
  191          LOG(
debug) << 
"Skipping existing empty frame";
 
  199        currentChipID = chipheader->
mChipID;
 
  201        currentChipStatus = (chipheader->mIdentifier) << 8;
 
  203        LOG(
debug) << 
"New chip (" << std::bitset<4>(chipheader->mIdentifier) << 
") " << 
int(chipheader->mChipID) << 
", BC (" << 
int(chipheader->mBunchCrossing) << 
"), empty " << (chipheader->isEmptyFrame() ? 
"yes" : 
"no");
 
  213        LOG(
debug) << 
"Finished chip (" << std::bitset<4>(trailer->mIdentifier) << 
") " << 
int(currentChipID) << 
" with " << hits.size() << 
" hits .. (Readout flags " << std::bitset<4>(trailer->mReadoutFlags) << 
")";
 
  214        auto found = std::find_if(decodedChips.begin(), decodedChips.end(), [currentChipID, laneID](
const PixelChip& chip) { return chip.mChipID == currentChipID && chip.mLaneID == laneID; });
 
  215        if (found != decodedChips.end()) {
 
  216          auto hitsbefore = found->mHits.size();
 
  217          std::copy(hits.begin(), hits.end(), std::back_inserter(found->mHits));
 
  218          found->mStatusCode = currentChipStatus;
 
  219          found->removeEmptyframe();
 
  221          LOG(
debug) << 
"Merging data with existing chip, Hits before: " << hitsbefore << 
", after: " << found->mHits.size();
 
  225          decodedChips.push_back({0, laneID, currentChipID, currentChipStatus, hits});
 
  233        currentRegion = regionheader->
mRegion;
 
  235        LOG(
debug) << 
"New region (" << std::bitset<3>(regionheader->mIdentifier) << 
") " << 
int(regionheader->mRegion);
 
  241        LOG(
debug) << 
"Found DataShort [" << std::bitset<16>(datashort.mData) << 
"] word (" << std::bitset<2>(datashort.mIdentifier) << 
") with encoder " << std::bitset<4>(datashort.mEncoderID) << 
" and address " << std::bitset<10>(datashort.mAddress);
 
  243        hits.push_back({AlpideX(currentRegion, datashort.mEncoderID, datashort.mAddress), AlpideY(datashort.mAddress)});
 
  251        LOG(
debug) << 
"Found DataLong [" << std::bitset<16>(datapart.mData) << 
"] word (" << std::bitset<2>(datapart.mIdentifier) << 
") with encoder " << std::bitset<4>(datapart.mEncoderID) << 
" and address " << std::bitset<10>(datapart.mAddress);
 
  253        auto hitmap = hitmappart->getHitmap();
 
  254        for (
int bitID = 0; bitID < hitmap.size(); bitID++) {
 
  255          if (hitmap.test(bitID)) {
 
  256            auto address = datapart.mAddress + bitID + 1;
 
  257            hits.push_back({AlpideX(currentRegion, datapart.mEncoderID, 
address), AlpideY(
address)});
 
  276    currentptr += wordsize;
 
  277    if (currentptr - laneWords.data() >= laneWords.size()) {
 
  282  LOG(
debug) << 
"Lane " << laneID << 
": Found " << decodedChips.size() << 
" chips ... ";
 
Definition of the 32 Central Trigger System (CTS) Trigger Types defined in https://twiki....
 
void decodeEvent(gsl::span< const o2::itsmft::GBTWord > payload)
 
static constexpr std::size_t NLANES
 
GLuint GLuint64EXT address
 
uint8_t itsSharedClusterMap uint8_t
 
uint16_t bc
bunch crossing ID of interaction
 
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"