From adbae7eecd6030aa0c76088c2203b80f9aed6a20 Mon Sep 17 00:00:00 2001 From: Ole Hansen Date: Wed, 30 Aug 2023 12:47:39 -0400 Subject: [PATCH] CodaDecoder: Print info about CODA banks discovered in data --- hana_decode/CodaDecoder.cxx | 42 +++++++++++++++++++++++++++++++++++++ hana_decode/CodaDecoder.h | 1 + 2 files changed, 43 insertions(+) diff --git a/hana_decode/CodaDecoder.cxx b/hana_decode/CodaDecoder.cxx index 2f5159fc..b95936af 100644 --- a/hana_decode/CodaDecoder.cxx +++ b/hana_decode/CodaDecoder.cxx @@ -21,6 +21,7 @@ #include #include #include +#include using namespace std; @@ -286,6 +287,16 @@ Int_t CodaDecoder::physics_decode( const UInt_t* evbuffer ) return status; } } + // Print summary of discovered banks + constexpr UInt_t bankinfo_bit = 65; + if( !fMsgPrinted.TestBitNumber(bankinfo_bit) ) { + if( !bankdat.empty() ) { + PrintBankInfo(); + // Unless we are debugging, print just once at start of run + if( fDebug < 2 ) + fMsgPrinted.SetBitNumber(bankinfo_bit); + } + } return HED_OK; } @@ -516,6 +527,37 @@ void CodaDecoder::debug_print( const UInt_t* evbuffer ) const } } +//_____________________________________________________________________________ +void CodaDecoder::PrintBankInfo() const +{ + // Pretty-print bank info in 'bankdat'. + + // Sort banks by ROC, then position in buffer + auto banks = bankdat; + std::sort(ALL(banks), []( const BankDat_t& a, const BankDat_t& b ) -> bool { + if( (a.key >> 16) < (b.key >> 16) ) + return true; + else if( (a.key >> 16) > (b.key >> 16) ) + return false; + return a.pos < b.pos; + }); + + UInt_t sum = 0; + cout << "Banks found (event " << event_num << "):" << endl; + cout << " roc bank pos len" << endl; + for( const auto& b : banks ) { + UInt_t bank = b.key & 0xFFFF; + UInt_t roc = b.key >> 16; + cout << dec << setw(4) << roc + << setw(6) << bank + << setw(8) << b.pos + << setw(8) << b.len + << endl; + sum += b.len; + } + cout << "Sum" << setw(23) << sum << endl; +} + //_____________________________________________________________________________ uint32_t CodaDecoder::TBOBJ::Fill( const uint32_t* evbuffer, uint32_t blkSize, uint32_t tsroc ) diff --git a/hana_decode/CodaDecoder.h b/hana_decode/CodaDecoder.h index 32487a61..5da68b04 100644 --- a/hana_decode/CodaDecoder.h +++ b/hana_decode/CodaDecoder.h @@ -78,6 +78,7 @@ class CodaDecoder : public THaEvData { Int_t prescale_decode_coda3( const UInt_t* evbuffer ); void dump( const UInt_t* evbuffer ) const; void debug_print( const UInt_t* evbuffer ) const; + void PrintBankInfo() const; // Data UInt_t nroc;