00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "RawData/RawSnarlHeaderBlock.h"
00013
00014 UInt_t RawSnarlHeaderBlock::fgDebugFlags = 0;
00015 enum DDebugRawSnarlHeaderBlock {
00016 kdbg_ForceHexDump = 0x00000001
00017 };
00018
00019 #include "MessageService/MsgService.h"
00020
00021
00022 #include "RawData/RawBlockRegistry.h"
00023 REGISTERRAWBLOCK(RawSnarlHeaderBlock,kMdBlockSnarlHeader,0);
00024
00025 ClassImp(RawSnarlHeaderBlock)
00026
00027 enum ESnarlHeaderBlkPos {
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_sec = 5,
00035 indx_nsec = 6,
00036 indx_tf = 7,
00037 indx_snarl = 8,
00038 indx_trigsrc = 9,
00039 indx_errcode = 10,
00040 indx_nrdigit = 11,
00041 indx_spilltype = 12,
00042 zzzz_last = 13
00043 };
00044
00045
00046 RawSnarlHeaderBlock::RawSnarlHeaderBlock()
00047 {
00048
00049 }
00050
00051
00052 RawSnarlHeaderBlock::RawSnarlHeaderBlock(const Int_t *block)
00053 : RawDataBlock(block)
00054 {
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 }
00073
00074 RawSnarlHeaderBlock::RawSnarlHeaderBlock(const VldContext& vldc,
00075 Int_t run, Short_t subrun, Short_t runtype,
00076 Int_t timeframe, Int_t snarl, Int_t trigsrc,
00077 Int_t err, Int_t nrawdigits, Int_t spilltype)
00078 : RawDataBlock()
00079 {
00080
00081
00082 fSize = zzzz_last;
00083 fRawBlock = new Int_t [fSize];
00084
00085 fRawBlock[0] = fSize;
00086
00087
00088 RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00089 RawBlockProxy* rbp = rbr.LookUp("RawSnarlHeaderBlock");
00090
00091 Bool_t isDCS = rbp->IsDCS();
00092 Int_t majorId = rbp->GetMajorId();
00093 Int_t minorId = 3;
00094 RawBlockId rbid(majorId,minorId,isDCS,
00095 vldc.GetDetector(),vldc.GetSimFlag());
00096 fRawBlock[2] = rbid.GetEncoded();
00097
00098 fRawBlock[indx_run] = run;
00099 fRawBlock[indx_subrun] = (subrun&0xffff)<<16 | (runtype&0xffff);
00100 fRawBlock[indx_sec] = vldc.GetTimeStamp().GetSec();
00101 fRawBlock[indx_nsec] = vldc.GetTimeStamp().GetNanoSec();
00102 fRawBlock[indx_tf] = timeframe;
00103
00104 fRawBlock[indx_snarl] = snarl;
00105 fRawBlock[indx_trigsrc] = trigsrc;
00106 fRawBlock[indx_errcode] = err;
00107 fRawBlock[indx_nrdigit] = nrawdigits;
00108 fRawBlock[indx_spilltype] = spilltype;
00109
00110
00111 rdxsum_fill((long*)fRawBlock,0);
00112 }
00113
00114
00115 RawSnarlHeaderBlock::~RawSnarlHeaderBlock()
00116 {
00117
00118 }
00119
00120
00121 VldTimeStamp RawSnarlHeaderBlock::GetTriggerTime() const
00122 {
00123
00124 if (fSize > indx_nsec)
00125 return VldTimeStamp(fRawBlock[indx_sec],fRawBlock[indx_nsec]);
00126
00127 return VldTimeStamp((time_t)0,(Int_t)0);
00128 }
00129
00130
00131 Int_t RawSnarlHeaderBlock::GetRun() const
00132 {
00133
00134 if (fSize > indx_run) return fRawBlock[indx_run];
00135 return -1;
00136 }
00137
00138
00139 Short_t RawSnarlHeaderBlock::GetSubRun() const
00140 {
00141
00142 if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00143 return -1;
00144 }
00145
00146
00147 Short_t RawSnarlHeaderBlock::GetRunType() const
00148 {
00149
00150 if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00151 return -1;
00152 }
00153
00154
00155 Int_t RawSnarlHeaderBlock::GetTimeFrameNum() const
00156 {
00157
00158 if (GetMinorId() <= 0) return -1;
00159 if (fSize > indx_tf) return fRawBlock[indx_tf];
00160 return -1;
00161 }
00162
00163
00164 Int_t RawSnarlHeaderBlock::GetSnarl() const
00165 {
00166
00167
00168 int indx_snarl_v = indx_snarl;
00169 if (GetMinorId() <= 0) indx_snarl_v--;
00170 if (fSize > indx_snarl_v) return fRawBlock[indx_snarl_v];
00171 return -1;
00172 }
00173
00174
00175 Int_t RawSnarlHeaderBlock::GetTriggerSource() const
00176 {
00177
00178
00179 int indx_trigsrc_v = indx_trigsrc;
00180 if (GetMinorId() <= 0) indx_trigsrc_v--;
00181 if (fSize > indx_trigsrc_v) return fRawBlock[indx_trigsrc_v];
00182 return -1;
00183 }
00184
00185
00186 Int_t RawSnarlHeaderBlock::GetErrorCode() const
00187 {
00188
00189
00190 int indx_errcode_v = indx_errcode;
00191 if (GetMinorId() <= 0) indx_errcode_v--;
00192 if (fSize > indx_errcode_v) return fRawBlock[indx_errcode_v];
00193 return -1;
00194 }
00195
00196
00197 Int_t RawSnarlHeaderBlock::GetNumRawDigits() const
00198 {
00199
00200
00201 if (fSize > indx_nrdigit) return fRawBlock[indx_nrdigit];
00202 return -1;
00203 }
00204
00205
00206 Int_t RawSnarlHeaderBlock::GetRemoteSpillType() const
00207 {
00208
00209
00210 if (fSize > indx_spilltype) return fRawBlock[indx_spilltype];
00211 return -1;
00212 }
00213
00214
00215 VldContext RawSnarlHeaderBlock::GetVldContext() const
00216 {
00217
00218 RawBlockId rbid = GetBlockId();
00219 return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTriggerTime());
00220 }
00221
00222
00223 std::ostream& RawSnarlHeaderBlock::FormatToOStream(std::ostream& os,
00224 Option_t *option) const
00225 {
00226
00227 if (fgDebugFlags & kdbg_ForceHexDump) option = "x";
00228
00229 RawDataBlock::FormatToOStream(os,option);
00230 if (option[0] == 'X') return os;
00231
00232
00233 int minorid = GetMinorId();
00234
00235 os << " TriggerTime " << GetTriggerTime().AsString("c") << endl;
00236 os << " Run " << GetRun()
00237 << " SubRun " << GetSubRun()
00238 << " RunType " << GetRunType();
00239 if (minorid > 0) {
00240 os << " TimeFrame " << GetTimeFrameNo();
00241 }
00242 os << endl;
00243 os << " Snarl " << GetSnarl()
00244 << " TrigSource " << GetTriggerSource()
00245 << " ErrorCode " << GetErrorCode();
00246 if (minorid > 1) {
00247 os << " # RawDigits " << GetNumRawDigits();
00248 }
00249 if (minorid > 2) {
00250 os << " RemoteSpillType " << GetRemoteSpillType();
00251 }
00252 os << endl;
00253
00254 return os;
00255 }
00256
00257
00258