00001
00002
00003
00004
00005
00006
00007
00008
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
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
00047 }
00048
00049
00050 RawErrorStatsBlock::RawErrorStatsBlock(const Int_t *block)
00051 : RawDataBlock(block)
00052 {
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
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
00081
00082 fSize = zzzz_last + 2*nsrcs;
00083 if (fRawBlock) delete [] fRawBlock;
00084 fRawBlock = new Int_t [fSize];
00085
00086 fRawBlock[0] = fSize;
00087
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
00115 rdxsum_fill((long*)fRawBlock,0);
00116 }
00117
00118
00119 RawErrorStatsBlock::~RawErrorStatsBlock()
00120 {
00121
00122 }
00123
00124
00125 VldTimeStamp RawErrorStatsBlock::GetStartTime() const
00126 {
00127
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
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
00148 if (fSize >= zzzz_last) return fRawBlock[indx_run];
00149 return -1;
00150 }
00151
00152
00153 Short_t RawErrorStatsBlock::GetSubRun() const
00154 {
00155
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
00164 if (fSize >= zzzz_last) return fRawBlock[indx_runtype]&0xffff;
00165 return -1;
00166 }
00167
00168
00169 Int_t RawErrorStatsBlock::GetNumberOfErrors() const
00170 {
00171
00172 if (fSize >= zzzz_last) return fRawBlock[indx_nerrors];
00173 return -1;
00174 }
00175
00176
00177 Int_t RawErrorStatsBlock::GetNumberOfSources() const
00178 {
00179
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
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
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
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