RawTrcMonitorBlock Class Reference

#include <RawTrcMonitorBlock.h>

Inheritance diagram for RawTrcMonitorBlock:
RawDataBlock

List of all members.

Classes

class  RawTrcStatusReport

Public Types

enum  ETrcFlagCode {
  kXQTflag = BIT(0), kLowRate = BIT(1), kHighRate = BIT(2), kBitErrorRate = BIT(3),
  kLinkPoor = BIT(4), kHardFailure = BIT(5), kLinkSyncFail = BIT(6), kSetTo1 = BIT(7)
}

Public Member Functions

 RawTrcMonitorBlock ()
 RawTrcMonitorBlock (const Int_t *block)
virtual ~RawTrcMonitorBlock ()
Int_t GetRun () const
Short_t GetSubRun () const
Short_t GetRunType () const
Int_t GetCrateId () const
Int_t GetTimeFrameNum () const
Int_t GetNumTrcStatusReports () const
const RawTrcStatusReportGetTrcStatusReport (UInt_t indx) const
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
 RawTrcMonitorBlock (const RawTrcMonitorBlock &rhs)

Static Public Member Functions

static void SetDebugFlags (const UInt_t dbgflgs)
static UInt_t GetDebugFlags ()

Protected Member Functions

virtual void UnpackTrcStatusReports () const

Protected Attributes

std::vector< RawTrcStatusReportfTrcStatusReports

Static Private Attributes

static UInt_t fgDebugFlags = 0
 unpacked

Detailed Description

Definition at line 20 of file RawTrcMonitorBlock.h.


Member Enumeration Documentation

Enumerator:
kXQTflag 
kLowRate 
kHighRate 
kBitErrorRate 
kLinkPoor 
kHardFailure 
kLinkSyncFail 
kSetTo1 

Definition at line 38 of file RawTrcMonitorBlock.h.

00038                      {
00039      // interpretation of flags
00040      kXQTflag      = BIT(0),
00041      kLowRate      = BIT(1),
00042      kHighRate     = BIT(2),
00043      kBitErrorRate = BIT(3),
00044      kLinkPoor     = BIT(4),
00045      kHardFailure  = BIT(5),
00046      kLinkSyncFail = BIT(6),
00047      kSetTo1       = BIT(7)
00048    };


Constructor & Destructor Documentation

RawTrcMonitorBlock::RawTrcMonitorBlock (  ) 

Definition at line 44 of file RawTrcMonitorBlock.cxx.

00045 {
00046    // Default constructor
00047 }

RawTrcMonitorBlock::RawTrcMonitorBlock ( const Int_t *  block  ) 

Definition at line 50 of file RawTrcMonitorBlock.cxx.

00051    : RawDataBlock(block)
00052 {
00053    //  stored block format is:
00054    //---------------------
00055    //  0   # words in block
00056    //  1   checksum
00057    //  2   Block Id
00058    //-----
00059    //  3   run #
00060    //  4   {subrun#| run type}
00061    //  5   crate identifier
00062    //  6   timeframe #
00063    //  7   # of Trc status report blocks
00064    //  ..  { Trc status report sub-blocks }
00065 }

RawTrcMonitorBlock::~RawTrcMonitorBlock (  )  [virtual]

Definition at line 68 of file RawTrcMonitorBlock.cxx.

00069 {
00070    // dtor
00071 }

RawTrcMonitorBlock::RawTrcMonitorBlock ( const RawTrcMonitorBlock rhs  )  [inline]

Definition at line 72 of file RawTrcMonitorBlock.h.

00073      : RawDataBlock(rhs) { ; }


Member Function Documentation

std::ostream & RawTrcMonitorBlock::FormatToOStream ( std::ostream &  os,
Option_t *  option = "" 
) const [virtual]

Reimplemented from RawDataBlock.

Definition at line 140 of file RawTrcMonitorBlock.cxx.

References VldTimeStamp::AsString(), fgDebugFlags, RawTrcMonitorBlock::RawTrcStatusReport::flags, GetCrateId(), GetNumTrcStatusReports(), GetRun(), GetRunType(), GetSubRun(), GetTrcStatusReport(), kdbg_ForceHexDump, RawTrcMonitorBlock::RawTrcStatusReport::numBufferSwaps, and RawTrcMonitorBlock::RawTrcStatusReport::timestamp.

00142 {
00143 
00144    if (fgDebugFlags & kdbg_ForceHexDump) option = "x";
00145 
00146    RawDataBlock::FormatToOStream(os,option);
00147    if (option[0] == 'X') return os;
00148 
00149    // additional block specific formatted output is done here
00150 
00151    os << " Run " << GetRun() 
00152       << " SubRun " << GetSubRun() 
00153       << " RunType " << GetRunType() << endl; 
00154    int crateid = GetCrateId();
00155    os << " Crate " << (crateid&0x3f)
00156       << " (0x" << hex << crateid << dec << ") had "
00157       << GetNumTrcStatusReports() << " reports: " << endl;
00158    for (int i = 0; i<GetNumTrcStatusReports(); i++) {
00159      const RawTrcStatusReport status = GetTrcStatusReport(i);
00160      os << "   report [" << setw(2) << i << "] " 
00161         << status.timestamp.AsString("c")
00162         << " swaps=" << int(status.numBufferSwaps)
00163         << " flags=0x" << hex << setfill('0') << int(status.flags&0xFF)
00164         << setfill(' ') << dec
00165         << endl;
00166    }
00167    return os;
00168 }

Int_t RawTrcMonitorBlock::GetCrateId (  )  const

Definition at line 98 of file RawTrcMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_crateid.

Referenced by FormatToOStream().

00099 {
00100    // get the crate id
00101    if (fSize > indx_crateid) return fRawBlock[indx_crateid];
00102    return -1;
00103 }

static UInt_t RawTrcMonitorBlock::GetDebugFlags (  )  [inline, static]

Definition at line 69 of file RawTrcMonitorBlock.h.

References fgDebugFlags.

00069 { return fgDebugFlags; }

Int_t RawTrcMonitorBlock::GetNumTrcStatusReports (  )  const

Definition at line 114 of file RawTrcMonitorBlock.cxx.

References fTrcStatusReports, and UnpackTrcStatusReports().

Referenced by FormatToOStream(), and GetTrcStatusReport().

00115 {
00116    // get the number of status report sub-blocks
00117 
00118    //if (fSize > indx_nreports) return fRawBlock[indx_nreports];
00119    //return -1;
00120   UnpackTrcStatusReports();
00121   return fTrcStatusReports.size();
00122 }

Int_t RawTrcMonitorBlock::GetRun ( void   )  const

Definition at line 74 of file RawTrcMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_run.

Referenced by FormatToOStream().

00075 {
00076    // get the run number
00077    if (fSize > indx_run) return fRawBlock[indx_run];
00078    return -1;
00079 }

Short_t RawTrcMonitorBlock::GetRunType (  )  const

Definition at line 90 of file RawTrcMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_runtype.

Referenced by FormatToOStream().

00091 {
00092    // get the run type
00093    if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00094    return -1;
00095 }

Short_t RawTrcMonitorBlock::GetSubRun (  )  const

Definition at line 82 of file RawTrcMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_subrun.

Referenced by FormatToOStream().

00083 {
00084    // get the subrun number
00085    if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00086    return -1;
00087 }

Int_t RawTrcMonitorBlock::GetTimeFrameNum (  )  const

Definition at line 106 of file RawTrcMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_timeframe.

00107 {
00108    // get the time frame #
00109    if (fSize > indx_timeframe) return fRawBlock[indx_timeframe];
00110    return -1;
00111 }

const RawTrcMonitorBlock::RawTrcStatusReport & RawTrcMonitorBlock::GetTrcStatusReport ( UInt_t  indx  )  const

Definition at line 126 of file RawTrcMonitorBlock.cxx.

References fTrcStatusReports, GetNumTrcStatusReports(), Msg::kWarning, and MSG.

Referenced by FormatToOStream().

00127 {
00128    // get the i-th status report sub-block
00129   size_t nreports = GetNumTrcStatusReports();
00130   if (indx >= nreports) {
00131     MSG("Raw",Msg::kWarning)
00132       << "GetStatusReport() can't get index " << indx
00133       << " as there are only " << nreports << endl;
00134     return dummyTrcStatusReport;
00135   }
00136   return fTrcStatusReports[indx];
00137 }

static void RawTrcMonitorBlock::SetDebugFlags ( const UInt_t  dbgflgs  )  [inline, static]

Definition at line 68 of file RawTrcMonitorBlock.h.

References fgDebugFlags.

00068 {fgDebugFlags=dbgflgs;}

void RawTrcMonitorBlock::UnpackTrcStatusReports (  )  const [protected, virtual]

Definition at line 171 of file RawTrcMonitorBlock.cxx.

References RawTrcMonitorBlock::RawTrcStatusReport::flags, RawDataBlock::fRawBlock, RawDataBlock::fSize, fTrcStatusReports, indx_nreports, Msg::kWarning, MSG, Munits::ns, RawTrcMonitorBlock::RawTrcStatusReport::numBufferSwaps, and RawTrcMonitorBlock::RawTrcStatusReport::timestamp.

Referenced by GetNumTrcStatusReports().

00172 {
00173    // unpack the Trc status sub-blocks
00174    if (!fTrcStatusReports.empty()) return;  // early exit if already unpacked
00175 
00176    UInt_t nexpected = 0, nseen = 0;
00177    if (fSize > indx_nreports) nexpected = fRawBlock[indx_nreports];
00178 
00179    Int_t *report_start = fRawBlock + indx_nreports + 1;
00180    Int_t *toofar       = fRawBlock + fSize;
00181 
00182    const size_t sizeTrcReportSubBlk = 3;
00183 
00184    while (report_start < toofar) {
00185      time_t sec    = report_start[0];
00186      Int_t  ns     = report_start[1];
00187      Int_t  packed = report_start[2]; 
00188      // packed is the two char flags and numBufferSwaps + 2 padding chars
00189      // structure mappings of chars to memory is tricky!
00190      // for gcc Linux on x86 architecture first char maps to *lowest* byte.
00191      // but despite documentation (and structure in mdBlockDefinitions.h
00192      // it appears to be filled via the following) the flags data 
00193      // appears to be in the top most byte, not the lowest.
00194      // but that assumes that the structure is filled on the same
00195      // a platform with the endian-ness and a byte swapping doesn't
00196      // occur somewhere in the game.
00197      char flags = (packed>>24) & 0xff;
00198      char nswap = (packed>>16) & 0xff;
00199 
00200      RawTrcStatusReport report;
00201      report.timestamp      = VldTimeStamp(sec,ns);
00202      report.flags          = flags;
00203      report.numBufferSwaps = nswap;
00204      fTrcStatusReports.push_back(report);
00205 
00206      ++nseen;
00207      report_start += sizeTrcReportSubBlk;
00208    }
00209 
00210    if (nseen != nexpected || report_start != toofar)
00211      MSG("Raw",Msg::kWarning)
00212        << "Unpacking reached end in an inconsistent manner"
00213        << " ptr @ " << report_start << " should be " << toofar
00214        << " saw " << nseen << " of " << nexpected << " expected"
00215        << " TrcStatusReports." << endl;
00216 
00217 }


Member Data Documentation

UInt_t RawTrcMonitorBlock::fgDebugFlags = 0 [static, private]

unpacked

Definition at line 86 of file RawTrcMonitorBlock.h.

Referenced by FormatToOStream(), GetDebugFlags(), and SetDebugFlags().

std::vector<RawTrcStatusReport> RawTrcMonitorBlock::fTrcStatusReports [mutable, protected]

The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1