RawQieErrorStatsBlock Class Reference

#include <RawQieErrorStatsBlock.h>

Inheritance diagram for RawQieErrorStatsBlock:
RawDataBlock

List of all members.

Public Member Functions

 RawQieErrorStatsBlock ()
 RawQieErrorStatsBlock (const Int_t *block)
 RawQieErrorStatsBlock (const VldContext &vldc_start, const VldTimeStamp &time_end, Int_t run, Short_t subrun, Short_t runtype, Int_t nerrtypes)
virtual ~RawQieErrorStatsBlock ()
VldTimeStamp GetStartTime () const
VldTimeStamp GetEndTime () const
Int_t GetRun () const
Short_t GetSubRun () const
Short_t GetRunType () const
Int_t GetNumberOfErrTypes () const
Int_t GetTotalErrChannels () const
Int_t GetNumOfErrChannels (RawQieDigit::EQieErrorCode errcode) const
const std::map< RawChannelId,
UInt_t > & 
GetErrorList (RawQieDigit::EQieErrorCode errcode) const
VldContext GetVldContext () const
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
 RawQieErrorStatsBlock (const RawQieErrorStatsBlock &rhs)
RawQieErrorStatsBlockoperator= (const RawQieErrorStatsBlock &rhs)

Static Public Member Functions

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

Protected Member Functions

virtual void FillAllMaps () const
void ClearAllMaps () const
std::map< RawChannelId, UInt_t > & GetNonConstListRef (Int_t errcode) const

Protected Attributes

bool fUnpacked
std::map< RawChannelId, UInt_t > fParityErrorList
 not written out
std::map< RawChannelId, UInt_t > fCapIdErrorList
 unpacked data
std::map< RawChannelId, UInt_t > fMisCountErrorList
 unpacked data
std::map< RawChannelId, UInt_t > fUnknownErrorList
 unpacked data

Static Private Attributes

static UInt_t fgDebugFlags = 0
 unpacked data

Detailed Description

Definition at line 20 of file RawQieErrorStatsBlock.h.


Constructor & Destructor Documentation

RawQieErrorStatsBlock::RawQieErrorStatsBlock (  ) 

Definition at line 54 of file RawQieErrorStatsBlock.cxx.

00055   : RawDataBlock(), fUnpacked(false)
00056 {
00057    // Default constructor
00058 }

RawQieErrorStatsBlock::RawQieErrorStatsBlock ( const Int_t *  block  ) 

Definition at line 61 of file RawQieErrorStatsBlock.cxx.

00062   : RawDataBlock(block), fUnpacked(false)
00063 {
00064    //  stored block format is:
00065    //---------------------
00066    //  0   # words in block
00067    //  1   checksum
00068    //  2   Block Id
00069    //-----
00070    //  3   run #
00071    //  4   {subrun#| run type}
00072    //  5   start time (sec)
00073    //  6   start time (nsec)
00074    //  7   end time (sec)
00075    //  8   end time (nsec)
00076    //  9   # of error types
00077    // 10   NPE = # of errors of type: parity
00078    // 11   channel w/ parity error upper 16=chadd, lower 16=crate#
00079    // 12   # errors on this channel
00080    // ..   {channel / count}  pairs
00081    // 12+2*NPE:  NCE = # of error of type: cap id
00082    // ..
00083    // 12+2*NPE+1+2*NCE:  NWE = # of errors of type: word count
00084    // ..
00085 }

RawQieErrorStatsBlock::RawQieErrorStatsBlock ( const VldContext vldc_start,
const VldTimeStamp time_end,
Int_t  run,
Short_t  subrun,
Short_t  runtype,
Int_t  nerrtypes 
)

Definition at line 88 of file RawQieErrorStatsBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, VldContext::GetDetector(), RawBlockProxy::GetMajorId(), VldTimeStamp::GetNanoSec(), VldTimeStamp::GetSec(), VldContext::GetSimFlag(), VldContext::GetTimeStamp(), indx_endnsec, indx_endsec, indx_nerrtypes, indx_run, indx_startnsec, indx_startsec, indx_subrun, RawBlockRegistry::Instance(), RawBlockProxy::IsDCS(), RawBlockRegistry::LookUp(), rdxsum_fill(), and zzzz_last.

00093   : RawDataBlock(), fUnpacked(false)
00094 {
00095    // Component ctor
00096 
00097    fSize = zzzz_last + nerrtypes;
00098    if (fRawBlock) delete [] fRawBlock;
00099    fRawBlock = new Int_t [fSize];
00100 
00101    fRawBlock[0] = fSize;
00102 // fRawBlock[1] = checksum... see below
00103 
00104    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00105    RawBlockProxy*    rbp = rbr.LookUp("RawQieErrorStatsBlock");
00106 
00107    Bool_t isDCS   = rbp->IsDCS();
00108    Int_t  majorId = rbp->GetMajorId();
00109    Int_t  minorId = 0;
00110    RawBlockId rbid(majorId,minorId,isDCS,
00111                    vldc_start.GetDetector(),vldc_start.GetSimFlag());
00112    fRawBlock[2] = rbid.GetEncoded();
00113 
00114    fRawBlock[indx_run]        = run;
00115    fRawBlock[indx_subrun]     = (subrun&0xffff)<<16 | (runtype&0xffff);
00116    fRawBlock[indx_startsec]   = vldc_start.GetTimeStamp().GetSec();
00117    fRawBlock[indx_startnsec]  = vldc_start.GetTimeStamp().GetNanoSec();
00118    fRawBlock[indx_endsec]     = time_end.GetSec();
00119    fRawBlock[indx_endnsec]    = time_end.GetNanoSec();
00120    fRawBlock[indx_nerrtypes]  = nerrtypes;
00121 
00122    for (Int_t i=0; i<nerrtypes; i++) {
00123       Int_t ioff = zzzz_last + i;
00124       fRawBlock[ioff+0] = 0;   // error counts for each type
00125    }
00126 
00127    // fill checksum
00128    rdxsum_fill((int32_t*)fRawBlock,0); 
00129 }

RawQieErrorStatsBlock::~RawQieErrorStatsBlock (  )  [virtual]

Definition at line 132 of file RawQieErrorStatsBlock.cxx.

00133 {
00134    // dtor
00135 }

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

Definition at line 53 of file RawQieErrorStatsBlock.h.

References ClearAllMaps().

00054      : RawDataBlock(rhs) { ClearAllMaps(); }


Member Function Documentation

void RawQieErrorStatsBlock::ClearAllMaps (  )  const [protected]

Definition at line 313 of file RawQieErrorStatsBlock.cxx.

References fCapIdErrorList, fMisCountErrorList, fParityErrorList, fUnknownErrorList, and fUnpacked.

Referenced by operator=(), and RawQieErrorStatsBlock().

00314 {
00315    // clear the unpacked data
00316 
00317    fUnpacked = false;
00318    fParityErrorList.clear();
00319    fCapIdErrorList.clear();
00320    fMisCountErrorList.clear();
00321    fUnknownErrorList.clear();
00322 
00323 }

void RawQieErrorStatsBlock::FillAllMaps (  )  const [protected, virtual]

Definition at line 251 of file RawQieErrorStatsBlock.cxx.

References count, det, RawDataBlock::fRawBlock, RawDataBlock::fSize, fUnpacked, RawDataBlock::GetBlockId(), RawBlockId::GetDetector(), GetNonConstListRef(), GetNumberOfErrTypes(), inlist, knownListOrder, ElecType::kQIE, Msg::kWarning, MSG, nknownLists, and zzzz_last.

Referenced by GetErrorList().

00252 {
00253    // unpack the data
00254 
00255    if ( fUnpacked ) return; // already unpacked
00256    fUnpacked = true;
00257 
00258    Detector::Detector_t det = GetBlockId().GetDetector();
00259    Int_t indx_cur = zzzz_last - 1; // just before first sublist
00260 
00261    for (int isublist = 0; isublist < GetNumberOfErrTypes(); ++isublist ) {
00262      Int_t listKey = unknownListCode;
00263      if ( isublist < nknownLists ) {
00264        listKey = knownListOrder[isublist];
00265      }
00266      else {
00267        MSG("RawData",Msg::kWarning)
00268          << "RawQieErrorStatsBlock has " << GetNumberOfErrTypes()
00269          << " sub-lists, but unpacker was expecting no more than "
00270          << knownListOrder << endl;
00271      }
00272      if ( fSize < indx_cur ) {
00273        MSG("RawData",Msg::kWarning)
00274          << "RawQieErrorStatsBlock  fSize=" << fSize
00275          << " but expected sub-list to start at index=" << indx_cur
00276          << endl;
00277        return;
00278      }
00279      Int_t nInList = fRawBlock[indx_cur++];
00280      std::map<RawChannelId,UInt_t>& curList = GetNonConstListRef(listKey);
00281      for (int inlist = 0; inlist < nInList; ++inlist) {
00282        if ( fSize < indx_cur ) {
00283          MSG("RawData",Msg::kWarning)
00284            << "RawQieErrorStatsBlock  fSize=" << fSize
00285            << " but saw end before processing inlist=" << inlist
00286            << " of sub-list=" << isublist
00287            << endl;
00288          return;
00289            
00290        }
00291        Int_t funky = fRawBlock[indx_cur++];
00292        Int_t count = fRawBlock[indx_cur++];
00293        // Geoff says these have no extraneous bits (error bits)
00294        UInt_t crate = funky & 0xFF;
00295        UInt_t chadd = funky >> 16;
00296        // only for QIE!
00297        RawChannelId rcid(det,ElecType::kQIE,crate,chadd);
00298        curList[rcid] = count;
00299      }
00300 
00301    }
00302 
00303    if ( indx_cur != fSize ) {
00304      MSG("RawData",Msg::kWarning)
00305        << "RawQieErrorStatsBlock  fSize=" << fSize
00306        << " but finished at index=" << indx_cur
00307        << endl;
00308    }
00309 
00310 }

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

Reimplemented from RawDataBlock.

Definition at line 326 of file RawQieErrorStatsBlock.cxx.

References bfld::AsString(), RawChannelId::AsString(), VldTimeStamp::AsString(), count, fgDebugFlags, GetEndTime(), GetErrorList(), GetNumberOfErrTypes(), GetRun(), GetRunType(), GetStartTime(), GetSubRun(), GetTotalErrChannels(), kdbg_ForceHexDump, knownListOrder, nentries, and nknownLists.

00328 {
00329 
00330    if (fgDebugFlags & kdbg_ForceHexDump) option = "x";
00331 
00332    RawDataBlock::FormatToOStream(os,option);
00333    if (option[0] == 'X') return os;
00334 
00335    os << " Start " << GetStartTime().AsString("c") << endl;
00336    os << " End   " << GetEndTime().AsString("c") << endl;
00337    os << " Run " << GetRun() 
00338       << " SubRun " << GetSubRun() 
00339       << " RunType " << GetRunType() << endl; 
00340    os << "   " << GetNumberOfErrTypes() << " error types, "
00341       << GetTotalErrChannels() << " total channels: " << endl;
00342 
00343    for (int iList = 0; iList<=nknownLists; iList++) {
00344      Int_t keyList = unknownListCode;
00345      if (iList<nknownLists) keyList = knownListOrder[iList];
00346 
00347      RawQieDigit::EQieErrorCode errcode = (RawQieDigit::EQieErrorCode)keyList;
00348 
00349      const std::map<RawChannelId,UInt_t>& listChannels = GetErrorList(errcode);
00350      size_t nentries = listChannels.size();
00351 
00352      // if the unknown error code list is empty don't print it
00353      if ( keyList == unknownListCode && nentries == 0 ) break;
00354 
00355      os << "   List of errors of type: "
00356         << RawQieDigit::AsString(errcode)
00357         << " (" << nentries << " entries)"
00358         << endl;
00359 
00360      std::map<RawChannelId,UInt_t>::const_iterator mapItr = 
00361        listChannels.begin(); 
00362      while ( mapItr != listChannels.end() ) {
00363        RawChannelId rcid = mapItr->first;
00364        UInt_t count      = mapItr->second;
00365        os << "     " << rcid.AsString("ec")
00366           << "     " << setw(8) << count
00367           << endl;
00368        mapItr++;  // move on
00369      }
00370    }
00371    return os;
00372 }

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

Definition at line 50 of file RawQieErrorStatsBlock.h.

References fgDebugFlags.

00050 { return fgDebugFlags; }

VldTimeStamp RawQieErrorStatsBlock::GetEndTime (  )  const

Definition at line 161 of file RawQieErrorStatsBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_endnsec, indx_endsec, and zzzz_last.

Referenced by FormatToOStream(), and GetVldContext().

00162 {
00163    // get the end time
00164    if (fSize >= zzzz_last) 
00165       return VldTimeStamp(fRawBlock[indx_endsec],fRawBlock[indx_endnsec]);
00166 
00167    return VldTimeStamp((time_t)0,(Int_t)0);
00168 }

const std::map< RawChannelId, UInt_t > & RawQieErrorStatsBlock::GetErrorList ( RawQieDigit::EQieErrorCode  errcode  )  const

Definition at line 222 of file RawQieErrorStatsBlock.cxx.

References FillAllMaps(), and GetNonConstListRef().

Referenced by FormatToOStream(), and GetNumOfErrChannels().

00223 {
00224    // get the unpacked list
00225    FillAllMaps();  // unpack the data
00226    return GetNonConstListRef(errcode);  // const-ness when returned!
00227 }

std::map< RawChannelId, UInt_t > & RawQieErrorStatsBlock::GetNonConstListRef ( Int_t  errcode  )  const [protected]

Definition at line 231 of file RawQieErrorStatsBlock.cxx.

References fCapIdErrorList, fMisCountErrorList, fParityErrorList, fUnknownErrorList, RawQieDigit::kCapIdError, RawQieDigit::kMisCountError, and RawQieDigit::kParityError.

Referenced by FillAllMaps(), and GetErrorList().

00232 {
00233 
00234    switch ( errcode ) {
00235    case RawQieDigit::kParityError:   return fParityErrorList;
00236    case RawQieDigit::kCapIdError:    return fCapIdErrorList;
00237    case RawQieDigit::kMisCountError: return fMisCountErrorList;
00238    default:                          return fUnknownErrorList;
00239    }
00240 }

Int_t RawQieErrorStatsBlock::GetNumberOfErrTypes (  )  const

Definition at line 195 of file RawQieErrorStatsBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_nerrtypes, and zzzz_last.

Referenced by FillAllMaps(), FormatToOStream(), and GetTotalErrChannels().

00196 {
00197    // get the number of error types reported by block
00198    if (fSize >= zzzz_last) return fRawBlock[indx_nerrtypes];
00199    return -1;
00200 }

Int_t RawQieErrorStatsBlock::GetNumOfErrChannels ( RawQieDigit::EQieErrorCode  errcode  )  const

Definition at line 214 of file RawQieErrorStatsBlock.cxx.

References GetErrorList().

00215 {
00216    // get the number of channels with errors of a particular type
00217    return GetErrorList(errcode).size();
00218 }

Int_t RawQieErrorStatsBlock::GetRun ( void   )  const

Definition at line 171 of file RawQieErrorStatsBlock.cxx.

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

Referenced by FormatToOStream().

00172 {
00173    // get the run number
00174    if (fSize >= zzzz_last) return fRawBlock[indx_run];
00175    return -1;
00176 }

Short_t RawQieErrorStatsBlock::GetRunType (  )  const

Definition at line 187 of file RawQieErrorStatsBlock.cxx.

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

Referenced by FormatToOStream().

00188 {
00189    // get the run type
00190    if (fSize >= zzzz_last) return fRawBlock[indx_runtype]&0xffff;
00191    return -1;
00192 }

VldTimeStamp RawQieErrorStatsBlock::GetStartTime (  )  const

Definition at line 151 of file RawQieErrorStatsBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_startnsec, indx_startsec, and zzzz_last.

Referenced by FormatToOStream().

00152 {
00153    // get the start time
00154    if (fSize >= zzzz_last) 
00155       return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00156 
00157    return VldTimeStamp((time_t)0,(Int_t)0);
00158 }

Short_t RawQieErrorStatsBlock::GetSubRun (  )  const

Definition at line 179 of file RawQieErrorStatsBlock.cxx.

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

Referenced by FormatToOStream().

00180 {
00181    // get the subrun number
00182    if (fSize >= zzzz_last) return (fRawBlock[indx_subrun]>>16)&0xffff;
00183    return -1;
00184 }

Int_t RawQieErrorStatsBlock::GetTotalErrChannels (  )  const

Definition at line 203 of file RawQieErrorStatsBlock.cxx.

References RawDataBlock::fSize, GetNumberOfErrTypes(), and zzzz_last.

Referenced by FormatToOStream().

00204 {
00205    // get the total number of channels with error
00206    if (fSize >= zzzz_last) {
00207      Int_t pairs =  fSize - (zzzz_last-1) - GetNumberOfErrTypes();
00208      return pairs >> 1;
00209    }
00210    return -1;
00211 }

VldContext RawQieErrorStatsBlock::GetVldContext (  )  const

Definition at line 243 of file RawQieErrorStatsBlock.cxx.

References RawDataBlock::GetBlockId(), RawBlockId::GetDetector(), GetEndTime(), and RawBlockId::GetSimFlag().

00244 {
00245    // build validity context
00246    RawBlockId rbid = GetBlockId();
00247    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetEndTime());
00248 }

RawQieErrorStatsBlock & RawQieErrorStatsBlock::operator= ( const RawQieErrorStatsBlock rhs  ) 

Reimplemented from RawDataBlock.

Definition at line 139 of file RawQieErrorStatsBlock.cxx.

References ClearAllMaps().

00140 {
00141    // deep copy assignment
00142    if (this != &rhs) {
00143      RawDataBlock::operator=(rhs);
00144      // clear the unpacked info to allow it to be re-filled
00145      ClearAllMaps();
00146    }
00147    return *this;
00148 }

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

Definition at line 49 of file RawQieErrorStatsBlock.h.

References fgDebugFlags.

00049 {fgDebugFlags=dbgflgs;}


Member Data Documentation

std::map<RawChannelId,UInt_t> RawQieErrorStatsBlock::fCapIdErrorList [mutable, protected]

unpacked data

Definition at line 69 of file RawQieErrorStatsBlock.h.

Referenced by ClearAllMaps(), and GetNonConstListRef().

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

unpacked data

Definition at line 76 of file RawQieErrorStatsBlock.h.

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

std::map<RawChannelId,UInt_t> RawQieErrorStatsBlock::fMisCountErrorList [mutable, protected]

unpacked data

Definition at line 70 of file RawQieErrorStatsBlock.h.

Referenced by ClearAllMaps(), and GetNonConstListRef().

std::map<RawChannelId,UInt_t> RawQieErrorStatsBlock::fParityErrorList [mutable, protected]

not written out

Definition at line 68 of file RawQieErrorStatsBlock.h.

Referenced by ClearAllMaps(), and GetNonConstListRef().

std::map<RawChannelId,UInt_t> RawQieErrorStatsBlock::fUnknownErrorList [mutable, protected]

unpacked data

Definition at line 71 of file RawQieErrorStatsBlock.h.

Referenced by ClearAllMaps(), and GetNonConstListRef().

bool RawQieErrorStatsBlock::fUnpacked [mutable, protected]

Definition at line 67 of file RawQieErrorStatsBlock.h.

Referenced by ClearAllMaps(), and FillAllMaps().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1