Skip to content

Commit

Permalink
Adjust tdc printing
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed May 23, 2024
1 parent 6e3db4b commit 14dd833
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion plugins/dogma/dogmaprint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ uint32_t ref_addr = 0;

void print_tu(dogma::DogmaTu *tu, const char *prefix = "")
{
printf("%stu addr:%04x type:%02x trignum:%06x time:%08x local:%08x err:%02x frame:%02x paylod:%04x size:%u\n", prefix,
printf("%sTu addr:%04x type:%02x trignum:%06x time:%08x local:%08x err:%02x frame:%02x paylod:%04x size:%u\n", prefix,
(unsigned)tu->GetAddr(), (unsigned)tu->GetTrigType(), (unsigned)tu->GetTrigNumber(),
(unsigned)tu->GetTrigTime(), (unsigned)tu->GetLocalTrigTime(),
(unsigned)tu->GetErrorBits(), (unsigned)tu->GetFrameBits(), (unsigned)tu->GetPayloadLen(), (unsigned) tu->GetSize());
Expand Down
25 changes: 3 additions & 22 deletions plugins/hadaq/hldprint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,7 @@ struct SubevStat {

};


void PrintTdc4Data(hadaq::RawSubevent* sub, unsigned ix, unsigned len, unsigned prefix)
{
if (len == 0) return;

unsigned sz = ((sub->GetSize() - sizeof(hadaq::RawSubevent)) / sub->Alignment());

if (ix >= sz) return;
// here when len was 0 - rest of subevent was printed
if ((len == 0) || (ix + len > sz)) len = sz - ix;

std::vector<uint32_t> data(len, 0);
for (unsigned i = 0; i < len; ++i)
data[i] = sub->Data(i + ix);

PrintTdc4DataPlain(ix, data, prefix);
}


void PrintTdcData(hadaq::RawSubevent* sub, unsigned ix, unsigned len, unsigned prefix, unsigned& errmask, SubevStat *substat = nullptr)
void PrintTdcData(hadaq::RawSubevent* sub, unsigned ix, unsigned len, unsigned prefix, unsigned& errmask, SubevStat *substat = nullptr, bool as_ver4 = false)
{
if (len == 0) return;

Expand All @@ -143,7 +124,7 @@ void PrintTdcData(hadaq::RawSubevent* sub, unsigned ix, unsigned len, unsigned p
for (unsigned i = 0; i < len; ++i)
data[i] = sub->Data(i + ix);

unsigned maxch = PrintTdcDataPlain(ix, data, prefix, errmask);
unsigned maxch = PrintTdcDataPlain(ix, data, prefix, errmask, as_ver4);

if (substat) {
if (substat->maxch < maxch)
Expand Down Expand Up @@ -747,7 +728,7 @@ int main(int argc, char* argv[])
if (as_tdc)
PrintTdcData(sub, ix, datalen, prefix, errmask);
else if (as_new)
PrintTdc4Data(sub, ix, datalen, prefix);
PrintTdcData(sub, ix, datalen, prefix, errmask, nullptr, true);
else if (as_adc)
PrintAdcData(sub, ix, datalen, prefix);
else if (as_cts)
Expand Down
20 changes: 15 additions & 5 deletions plugins/hadaq/tdc_print_code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ void PrintBubble(unsigned* bubble, unsigned len = 0)
}
}

unsigned BubbleCheck(unsigned* bubble, int &p1, int &p2) {
unsigned BubbleCheck(unsigned* bubble, int &p1, int &p2)
{
p1 = 0; p2 = 0;

unsigned pos = 0, last = 1, nflip = 0;
Expand Down Expand Up @@ -275,7 +276,8 @@ unsigned BubbleCheck(unsigned* bubble, int &p1, int &p2) {
return 0x22; // mark both as errors, should analyze better
}

void PrintBubbleBinary(unsigned* bubble, int p1 = -1, int p2 = -1) {
void PrintBubbleBinary(unsigned* bubble, int p1 = -1, int p2 = -1)
{
if (p1<0) p1 = 0;
if (p2<=p1) p2 = BUBBLE_SIZE*16;

Expand Down Expand Up @@ -557,18 +559,26 @@ const char* debug_name[32] = {
};


unsigned PrintTdcDataPlain(unsigned ix, const std::vector<uint32_t> &data, unsigned prefix, unsigned &errmask)
unsigned PrintTdcDataPlain(unsigned ix, const std::vector<uint32_t> &data, unsigned prefix, unsigned &errmask, bool as_ver4 = false)
{
unsigned len = data.size();
errmask = 0;

if (len == 0)
return 0;

if (bubble_mode) {
PrintBubbleData(ix, data, prefix);
return 0;
}

unsigned msg0 = data[0];
if (((msg0 & tdckind_Mask) == tdckind_Header) && (((msg0 >> 24) & 0xF) == 0x4))
if (!as_ver4) {
unsigned msg0 = data[0];
if (((msg0 & tdckind_Mask) == tdckind_Header) && (((msg0 >> 24) & 0xF) == 0x4))
as_ver4 = true;
}

if (as_ver4)
return PrintTdc4DataPlain(ix, data, prefix);

unsigned wlen = len > 999 ? 4 : (len > 99 ? 3 : 2);
Expand Down

0 comments on commit 14dd833

Please sign in to comment.