00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "RawData/RawDaqDeadTimeBlock.h"
00013
00014 UInt_t RawDaqDeadTimeBlock::fgDebugFlags = 0;
00015
00016 #include "MessageService/MsgService.h"
00017
00018 #include "MessageService/MsgFormat.h"
00019
00020 #include "RawData/RawBlockRegistry.h"
00021 REGISTERRAWBLOCK(RawDaqDeadTimeBlock,kMdBlockDaqDeadTime,0);
00022
00023 ClassImp(RawDaqDeadTimeBlock)
00024
00025 enum ERunStartBlkPos {
00026 indx_size = 0,
00027 indx_checksum = 1,
00028 indx_blockid = 2,
00029 indx_run = 3,
00030 indx_subrun = 4,
00031 indx_runtype = indx_subrun,
00032 indx_startsec = 5,
00033 indx_startnsec = 6,
00034 indx_tfbegin = 7,
00035 indx_tfend = 8,
00036 zzzz_last = 9
00037 };
00038
00039
00040 RawDaqDeadTimeBlock::RawDaqDeadTimeBlock() : RawDataBlock()
00041 {
00042
00043 }
00044
00045
00046 RawDaqDeadTimeBlock::RawDaqDeadTimeBlock(const Int_t *block)
00047 : RawDataBlock(block)
00048 {
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 }
00062
00063
00064 RawDaqDeadTimeBlock::RawDaqDeadTimeBlock(const VldContext& vldc, Int_t run,
00065 Short_t subrun, Short_t runtype,
00066 Int_t tfBegin, Int_t tfEnd)
00067 : RawDataBlock()
00068 {
00069
00070
00071 fSize = zzzz_last;
00072 if (fRawBlock) delete [] fRawBlock;
00073 fRawBlock = new Int_t [fSize];
00074
00075 fRawBlock[0] = fSize;
00076
00077
00078 RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00079 RawBlockProxy* rbp = rbr.LookUp("RawDaqDeadTimeBlock");
00080
00081 Bool_t isDCS = rbp->IsDCS();
00082 Int_t majorId = rbp->GetMajorId();
00083 Int_t minorId = 0;
00084 RawBlockId rbid(majorId,minorId,isDCS,
00085 vldc.GetDetector(),vldc.GetSimFlag());
00086 fRawBlock[2] = rbid.GetEncoded();
00087
00088 fRawBlock[indx_run] = run;
00089 fRawBlock[indx_subrun] = (subrun&0xffff)<<16 | (runtype&0xffff);
00090 fRawBlock[indx_startsec] = vldc.GetTimeStamp().GetSec();
00091 fRawBlock[indx_startnsec] = vldc.GetTimeStamp().GetNanoSec();
00092 fRawBlock[indx_tfbegin] = tfBegin;
00093 fRawBlock[indx_tfend] = tfEnd;
00094
00095
00096 rdxsum_fill((long*)fRawBlock,0);
00097
00098 }
00099
00100
00101 RawDaqDeadTimeBlock::~RawDaqDeadTimeBlock()
00102 {
00103
00104 }
00105
00106
00107 VldTimeStamp RawDaqDeadTimeBlock::GetTime() const
00108 {
00109
00110 if (fSize > indx_startnsec)
00111 return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00112
00113 return VldTimeStamp((time_t)0,(Int_t)0);
00114 }
00115
00116
00117 Int_t RawDaqDeadTimeBlock::GetRun() const
00118 {
00119
00120 if (fSize > indx_run) return fRawBlock[indx_run];
00121 return -1;
00122 }
00123
00124
00125 Short_t RawDaqDeadTimeBlock::GetSubRun() const
00126 {
00127
00128 if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00129 return -1;
00130 }
00131
00132
00133 Short_t RawDaqDeadTimeBlock::GetRunType() const
00134 {
00135
00136 if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00137 return -1;
00138 }
00139
00140
00141 Int_t RawDaqDeadTimeBlock::GetTimeFrameBegin() const
00142 {
00143
00144 if (fSize > indx_tfbegin) return fRawBlock[indx_tfbegin];
00145
00146 return -1;
00147 }
00148
00149
00150 Int_t RawDaqDeadTimeBlock::GetTimeFrameEnd() const
00151 {
00152
00153 if (fSize > indx_tfbegin) return fRawBlock[indx_tfend];
00154
00155 return -1;
00156 }
00157
00158
00159 VldContext RawDaqDeadTimeBlock::GetVldContext() const
00160 {
00161
00162 RawBlockId rbid = GetBlockId();
00163 return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTime());
00164 }
00165
00166
00167 std::ostream& RawDaqDeadTimeBlock::FormatToOStream(std::ostream& os,
00168 Option_t *option) const
00169 {
00170 RawDataBlock::FormatToOStream(os,option);
00171 if (option[0] == 'X') return os;
00172
00173
00174
00175 os << " DaqDeadTime " << GetTime().AsString("c") << endl;
00176 os << " Run " << GetRun()
00177 << " SubRun " << GetSubRun()
00178 << " RunType " << GetRunType()
00179 << endl
00180 << " Dropped TimeFrames in range ["
00181 << GetTimeFrameBegin() << "," << GetTimeFrameEnd() << "]"
00182 << endl;
00183
00184 return os;
00185 }
00186
00187