Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RawErrorStatsBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawErrorStatsBlock.cxx,v 1.10 2003/07/10 19:36:29 rhatcher Exp $
00003 // 
00004 // RawErrorStatsBlock 
00005 // 
00006 // RawErrorStatsBlock holds the TriggerStatistics info
00007 //
00008 // Author:  R. Hatcher 2001.07.30
00009 //
00011 
00012 #include "RawData/RawErrorStatsBlock.h"
00013 
00014 UInt_t RawErrorStatsBlock::fgDebugFlags = 0;
00015 
00016 #include "MessageService/MsgStream.h"
00017 #include "MessageService/MsgFormat.h"
00018 
00019 #include "MessageService/MsgService.h"
00020 //CVSID("$Id: RawErrorStatsBlock.cxx,v 1.10 2003/07/10 19:36:29 rhatcher Exp $");
00021 
00022 #include "RawData/RawBlockRegistry.h"
00023 REGISTERRAWBLOCK(RawErrorStatsBlock,kMdBlockErrorStats,0);
00024 
00025 ClassImp(RawErrorStatsBlock)
00026 
00027 enum EErrorStatsBlkPos {
00028    indx_size      =  0,
00029    indx_checksum  =  1,
00030    indx_blockid   =  2,
00031    indx_run       =  3,
00032    indx_subrun    =  4,
00033    indx_runtype   = indx_subrun,
00034    indx_startsec  =  5,
00035    indx_startnsec =  6,
00036    indx_endsec    =  7,
00037    indx_endnsec   =  8,
00038    indx_nerrors   =  9,
00039    indx_nsrcs     = 10,
00040    zzzz_last      = 11
00041 };
00042 
00043 //_____________________________________________________________________________
00044 RawErrorStatsBlock::RawErrorStatsBlock() : RawDataBlock()
00045 {
00046    // Default constructor
00047 }
00048 
00049 //_____________________________________________________________________________
00050 RawErrorStatsBlock::RawErrorStatsBlock(const Int_t *block)
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   start time (sec)
00062    //  6   start time (nsec)
00063    //  7   end time (sec)
00064    //  8   end time (nsec)
00065    //  9   total number of errors
00066    // 10   number error sources
00067    // 11   src id (index 1)
00068    // 12   # errors (index 1)
00069    // ..   {src id / # snarls}  pairs
00070 }
00071 
00072 //_____________________________________________________________________________
00073 RawErrorStatsBlock::RawErrorStatsBlock(const VldContext& vldc_start, 
00074                                            const VldTimeStamp& time_end, Int_t run,
00075                                            Short_t subrun, Short_t runtype,
00076                                            Int_t nsnarls, Int_t nsrcs,
00077                                            const Int_t* srcid, const Int_t *errorcnt)
00078    : RawDataBlock()
00079 {
00080    // Component ctor
00081 
00082    fSize = zzzz_last + 2*nsrcs;
00083    if (fRawBlock) delete [] fRawBlock;
00084    fRawBlock = new Int_t [fSize];
00085 
00086    fRawBlock[0] = fSize;
00087 // fRawBlock[1] = checksum... see below
00088 
00089    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00090    RawBlockProxy*    rbp = rbr.LookUp("RawErrorStatsBlock");
00091 
00092    Bool_t isDCS   = rbp->IsDCS();
00093    Int_t  majorId = rbp->GetMajorId();
00094    Int_t  minorId = 0;
00095    RawBlockId rbid(majorId,minorId,isDCS,
00096                    vldc_start.GetDetector(),vldc_start.GetSimFlag());
00097    fRawBlock[2] = rbid.GetEncoded();
00098 
00099    fRawBlock[indx_run]        = run;
00100    fRawBlock[indx_subrun]     = (subrun&0xffff)<<16 | (runtype&0xffff);
00101    fRawBlock[indx_startsec]   = vldc_start.GetTimeStamp().GetSec();
00102    fRawBlock[indx_startnsec]  = vldc_start.GetTimeStamp().GetNanoSec();
00103    fRawBlock[indx_endsec]     = time_end.GetSec();
00104    fRawBlock[indx_endnsec]    = time_end.GetNanoSec();
00105    fRawBlock[indx_nerrors]    = nsnarls;
00106    fRawBlock[indx_nsrcs]      = nsrcs;
00107 
00108    for (Int_t i=0; i<nsrcs; i++) {
00109       Int_t ioff = zzzz_last + 2*i;
00110       fRawBlock[ioff+0] = srcid[i];
00111       fRawBlock[ioff+1] = errorcnt[i];
00112    }
00113 
00114    // fill checksum
00115    rdxsum_fill((long*)fRawBlock,0); 
00116 }
00117 
00118 //_____________________________________________________________________________
00119 RawErrorStatsBlock::~RawErrorStatsBlock()
00120 {
00121    // dtor
00122 }
00123 
00124 //_____________________________________________________________________________
00125 VldTimeStamp RawErrorStatsBlock::GetStartTime() const
00126 {
00127    // get the start time
00128    if (fSize >= zzzz_last) 
00129       return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00130 
00131    return VldTimeStamp((time_t)0,(Int_t)0);
00132 }
00133 
00134 //_____________________________________________________________________________
00135 VldTimeStamp RawErrorStatsBlock::GetEndTime() const
00136 {
00137    // get the end time
00138    if (fSize >= zzzz_last) 
00139       return VldTimeStamp(fRawBlock[indx_endsec],fRawBlock[indx_endnsec]);
00140 
00141    return VldTimeStamp((time_t)0,(Int_t)0);
00142 }
00143 
00144 //_____________________________________________________________________________
00145 Int_t RawErrorStatsBlock::GetRun() const
00146 {
00147    // get the run number
00148    if (fSize >= zzzz_last) return fRawBlock[indx_run];
00149    return -1;
00150 }
00151 
00152 //_____________________________________________________________________________
00153 Short_t RawErrorStatsBlock::GetSubRun() const
00154 {
00155    // get the subrun number
00156    if (fSize >= zzzz_last) return (fRawBlock[indx_subrun]>>16)&0xffff;
00157    return -1;
00158 }
00159 
00160 //_____________________________________________________________________________
00161 Short_t RawErrorStatsBlock::GetRunType() const
00162 {
00163    // get the run type
00164    if (fSize >= zzzz_last) return fRawBlock[indx_runtype]&0xffff;
00165    return -1;
00166 }
00167 
00168 //_____________________________________________________________________________
00169 Int_t RawErrorStatsBlock::GetNumberOfErrors() const
00170 {
00171    // get the total number of snarls
00172    if (fSize >= zzzz_last) return fRawBlock[indx_nerrors];
00173    return -1;
00174 }
00175 
00176 //_____________________________________________________________________________
00177 Int_t RawErrorStatsBlock::GetNumberOfSources() const
00178 {
00179    // get the number of sources in the list
00180    if (fSize >= zzzz_last) return fRawBlock[indx_nsrcs];
00181    return -1;
00182 }
00183 
00184 //_____________________________________________________________________________
00185 Int_t RawErrorStatsBlock::GetSourceId(Int_t indx) const
00186 {
00187    // get the "indx"-th source from the list
00188    Int_t ioff = zzzz_last + 2*indx + 0;
00189    if (fSize >= ioff) return fRawBlock[ioff];
00190    return -1;
00191 }
00192 
00193 //_____________________________________________________________________________
00194 Int_t RawErrorStatsBlock::GetErrorCount(Int_t indx) const
00195 {
00196    // get the "indx"-th snarl count from the list
00197    Int_t ioff = zzzz_last + 2*indx + 1;
00198    if (fSize >= ioff) return fRawBlock[ioff];
00199    return -1;
00200 }
00201 
00202 //_____________________________________________________________________________
00203 VldContext RawErrorStatsBlock::GetVldContext() const
00204 {
00205    // build validity context
00206    RawBlockId rbid = GetBlockId();
00207    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetEndTime());
00208 }
00209 
00210 //_____________________________________________________________________________
00211 std::ostream& RawErrorStatsBlock::FormatToOStream(std::ostream& os, 
00212                                                   Option_t *option) const
00213 {
00214    RawDataBlock::FormatToOStream(os,option);
00215    if (option[0] == 'X') return os;
00216 
00217    os << " Start " << GetStartTime().AsString("c") << endl;
00218    os << " End   " << GetEndTime().AsString("c") << endl;
00219    os << " Run " << GetRun() 
00220       << " SubRun " << GetSubRun() 
00221       << " RunType " << GetRunType() << endl; 
00222    os << "   " << GetNumberOfErrors() << " errors from "
00223       << GetNumberOfSources() << " sources: " << endl;
00224    for (int i = 0; i<GetNumberOfSources(); i++) {
00225       os << "   src 0x" << hex << GetSourceId(i) << dec
00226          << " gave " << GetErrorCount(i) << " errors" << endl;
00227    }
00228    return os;
00229 }
00230 
00231 //_____________________________________________________________________________

Generated on Sat Nov 21 22:47:30 2009 for loon by  doxygen 1.3.9.1