Skip to content

Commit

Permalink
CodaDecoder: Print info about CODA banks discovered in data
Browse files Browse the repository at this point in the history
  • Loading branch information
hansenjo committed Aug 30, 2023
1 parent 1a43595 commit adbae7e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions hana_decode/CodaDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <utility>
#include <cstring>
#include <sstream>
#include <iomanip>

using namespace std;

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions hana_decode/CodaDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit adbae7e

Please sign in to comment.