00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "RawData/RawSubRunEndBlock.h"
00013
00014 UInt_t RawSubRunEndBlock::fgDebugFlags = 0;
00015 enum EDebugRunEndBlock {
00016 kdbg_ForceHexDump = 0x00000001
00017 };
00018
00019 #include "MessageService/MsgService.h"
00020
00021 #include "MessageService/MsgFormat.h"
00022
00023 #include "RawData/RawBlockRegistry.h"
00024 REGISTERRAWBLOCK(RawSubRunEndBlock,kMdBlockSubRunEnd,0);
00025
00026 ClassImp(RawSubRunEndBlock)
00027
00028 enum ERunEndBlkPos {
00029 indx_size = 0,
00030 indx_checksum = 1,
00031 indx_blockid = 2,
00032 indx_run = 3,
00033 indx_subrun = 4,
00034 indx_runtype = indx_subrun,
00035 indx_startsec = 5,
00036 indx_startnsec = 6,
00037 indx_endsec = 7,
00038 indx_endnsec = 8,
00039 indx_termcode = 9,
00040 indx_nsnarls = 10,
00041 indx_nnonsnarls = 11,
00042 indx_nerrors = 12,
00043 indx_ntimeframes = 13,
00044 indx_deadsec = indx_ntimeframes,
00045 indx_ndroppedtfs = 14,
00046 indx_deadnsec = indx_ndroppedtfs,
00047 zzzz_last = 15
00048 };
00049
00050
00051 RawSubRunEndBlock::RawSubRunEndBlock()
00052 {
00053
00054 }
00055
00056
00057 RawSubRunEndBlock::RawSubRunEndBlock(const Int_t *block)
00058 : RawDataBlock(block)
00059 {
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 }
00079
00080
00081 RawSubRunEndBlock::RawSubRunEndBlock(const VldContext& vldc_start,
00082 const VldTimeStamp& time_end, Int_t run,
00083 Short_t subrun, Short_t runtype)
00084 : RawDataBlock()
00085 {
00086
00087
00088 fSize = zzzz_last;
00089 fRawBlock = new Int_t [fSize];
00090
00091 fRawBlock[0] = fSize;
00092
00093
00094 RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00095 RawBlockProxy* rbp = rbr.LookUp("RawSubRunEndBlock");
00096
00097 Bool_t isDCS = rbp->IsDCS();
00098 Int_t majorId = rbp->GetMajorId();
00099 Int_t minorId = 1;
00100 RawBlockId rbid(majorId,minorId,isDCS,
00101 vldc_start.GetDetector(),vldc_start.GetSimFlag());
00102 fRawBlock[2] = rbid.GetEncoded();
00103
00104 fRawBlock[indx_run] = run;
00105 fRawBlock[indx_subrun] = (subrun&0xffff)<<16 | (runtype&0xffff);
00106 fRawBlock[indx_startsec] = vldc_start.GetTimeStamp().GetSec();
00107 fRawBlock[indx_startnsec] = vldc_start.GetTimeStamp().GetNanoSec();
00108 fRawBlock[indx_endsec] = time_end.GetSec();
00109 fRawBlock[indx_endnsec] = time_end.GetNanoSec();
00110 fRawBlock[indx_termcode] = 0;
00111 fRawBlock[indx_nsnarls] = -1;
00112 fRawBlock[indx_nnonsnarls] = -1;
00113 fRawBlock[indx_nerrors] = 0;
00114 fRawBlock[indx_ntimeframes] = -1;
00115 fRawBlock[indx_ndroppedtfs] = -1;
00116
00117
00118
00119
00120 rdxsum_fill((long*)fRawBlock,0);
00121 }
00122
00123
00124 RawSubRunEndBlock::~RawSubRunEndBlock()
00125 {
00126
00127 }
00128
00129
00130 VldTimeStamp RawSubRunEndBlock::GetStartTime() const
00131 {
00132
00133 if (fSize > indx_startnsec)
00134 return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00135
00136 return VldTimeStamp((time_t)0,(Int_t)0);
00137 }
00138
00139
00140 VldTimeStamp RawSubRunEndBlock::GetEndTime() const
00141 {
00142
00143 if (fSize > indx_endnsec)
00144 return VldTimeStamp(fRawBlock[indx_endsec],fRawBlock[indx_endnsec]);
00145
00146 return VldTimeStamp((time_t)0,(Int_t)0);
00147 }
00148
00149
00150 Int_t RawSubRunEndBlock::GetRun() const
00151 {
00152
00153 if (fSize > indx_run) return fRawBlock[indx_run];
00154 return -1;
00155 }
00156
00157
00158 Short_t RawSubRunEndBlock::GetSubRun() const
00159 {
00160
00161 if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00162 return -1;
00163 }
00164
00165
00166 Short_t RawSubRunEndBlock::GetRunType() const
00167 {
00168
00169 if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00170 return -1;
00171 }
00172
00173
00174 Int_t RawSubRunEndBlock::GetTerminationCode() const
00175 {
00176
00177 if (fSize > indx_termcode) return fRawBlock[indx_termcode];
00178 return -1;
00179 }
00180
00181
00182 Int_t RawSubRunEndBlock::GetNumberOfSnarls() const
00183 {
00184
00185 if (fSize > indx_nsnarls) return fRawBlock[indx_nsnarls];
00186 return -1;
00187 }
00188
00189
00190 Int_t RawSubRunEndBlock::GetNumberOfNonSnarls() const
00191 {
00192
00193 if (fSize > indx_nnonsnarls) return fRawBlock[indx_nnonsnarls];
00194 return -1;
00195 }
00196
00197
00198 Int_t RawSubRunEndBlock::GetNumberOfErrors() const
00199 {
00200
00201 if (fSize > indx_nerrors) return fRawBlock[indx_nerrors];
00202 return -1;
00203 }
00204
00205
00206 Int_t RawSubRunEndBlock::GetTotalTimeFrames() const
00207 {
00208
00209
00210 if (fSize > indx_ntimeframes && GetBlockId().GetMinor() >= 1 )
00211 return fRawBlock[indx_ntimeframes];
00212
00213 return -1;
00214 }
00215
00216
00217 Int_t RawSubRunEndBlock::GetDroppedTimeFrames() const
00218 {
00219
00220
00221 if (fSize > indx_ndroppedtfs && GetBlockId().GetMinor() >= 1 )
00222 return fRawBlock[indx_ndroppedtfs];
00223
00224 return -1;
00225 }
00226
00227
00228 VldTimeStamp RawSubRunEndBlock::GetDeadTime() const
00229 {
00230
00231
00232 if (fSize > indx_deadnsec && GetBlockId().GetMinor() < 1 )
00233 return VldTimeStamp(fRawBlock[indx_deadsec],fRawBlock[indx_deadnsec]);
00234
00235 return VldTimeStamp((time_t)0,(Int_t)0);
00236 }
00237
00238
00239 VldContext RawSubRunEndBlock::GetVldContext() const
00240 {
00241
00242 RawBlockId rbid = GetBlockId();
00243 return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetEndTime());
00244 }
00245
00246
00247 std::ostream& RawSubRunEndBlock::FormatToOStream(std::ostream& os,
00248 Option_t *option) const
00249 {
00250
00251 if (fgDebugFlags & kdbg_ForceHexDump) option = "x";
00252
00253 RawDataBlock::FormatToOStream(os,option);
00254 if (option[0] == 'X') return os;
00255
00256
00257
00258 os << " Run " << GetRun()
00259 << " SubRun " << GetSubRun()
00260 << " RunType " << GetRunType()
00261 << " : "
00262 << GetNumberOfSnarls() << " snarls, "
00263 << GetNumberOfNonSnarls() << " non-snarls"
00264 << endl;
00265 os << " Start " << GetStartTime().AsString("c") << endl;
00266 os << " End " << GetEndTime().AsString("c") << endl;
00267 if ( GetBlockId().GetMinor() >= 1 ) {
00268 os << " Dropped " << GetDroppedTimeFrames()
00269 << " timeframes out of " << GetTotalTimeFrames() << endl;
00270 }
00271 else {
00272 os << " Dead " << GetDeadTime().GetSec() << "."
00273 << setw(9) << setfill('0') << GetDeadTime().GetNanoSec()
00274 << setfill(' ') << endl;
00275 }
00276
00277 return os;
00278 }
00279
00280