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

RawDaqHeaderBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawDaqHeaderBlock.cxx,v 1.18 2004/08/13 16:42:46 rhatcher Exp $
00003 // 
00004 // RawDaqHeaderBlock 
00005 // 
00006 // RawDaqHeaderBlock holds the basic Daq Record Header info
00007 //    in all cases except the DaqSnarl, which has additional
00008 //    information tagging it
00009 //
00010 // Author:  R. Hatcher 2001.05.24
00011 //
00013 
00014 #include "RawData/RawDaqHeaderBlock.h"
00015 
00016 UInt_t RawDaqHeaderBlock::fgDebugFlags = 0;
00017 
00018 #include "MessageService/MsgService.h"
00019 //CVSID("$Id: RawDaqHeaderBlock.cxx,v 1.18 2004/08/13 16:42:46 rhatcher Exp $");
00020 //#include "MessageService/MsgStream.h"
00021 
00022 #include "RawData/RawBlockRegistry.h"
00023 REGISTERRAWBLOCK(RawDaqHeaderBlock,kMdBlockMonitorHeader,0);
00024 
00025 ClassImp(RawDaqHeaderBlock)
00026 
00027 enum EDaqHeaderBlkPos {
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_start_sec  =  5,
00035    indx_start_nsec =  6,
00036    indx_tf         =  7,
00037    indx_end_sec    =  8,
00038    indx_end_nsec   =  9,
00039    zzzz_last       = 10
00040 };
00041 
00042 //_____________________________________________________________________________
00043 RawDaqHeaderBlock::RawDaqHeaderBlock() : RawDataBlock()
00044 {
00045    // Default constructor
00046 }
00047 
00048 //_____________________________________________________________________________
00049 RawDaqHeaderBlock::RawDaqHeaderBlock(const Int_t *block)
00050    : RawDataBlock(block)
00051 {
00052    //  stored block format is:
00053    //---------------------
00054    //  0   # words in block
00055    //  1   checksum
00056    //  2   Block Id
00057    //-----
00058    //  3   run #
00059    //  4   {subrun #| run type}
00060    //  5   start timestamp (sec)
00061    //  6   start timestamp (nsec)
00062    //  7   timeframe #   [version 1+]
00063    //  8   end timestamp (sec)  [version 2+]
00064    //  9   end timestamp (nsec) [version 2+]
00065 }
00066 //_____________________________________________________________________________
00067 RawDaqHeaderBlock::RawDaqHeaderBlock(const VldContext& vldc, Int_t run, 
00068                                      Short_t subrun, Short_t runtype,
00069                                      Int_t timeframe)
00070    : RawDataBlock()
00071 {
00072    // Component ctor
00073 
00074    fSize = zzzz_last;
00075    if (fRawBlock) delete [] fRawBlock;
00076    fRawBlock = new Int_t [fSize];
00077 
00078    fRawBlock[0] = fSize;
00079 // fRawBlock[1] = checksum... see below
00080 
00081    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00082    RawBlockProxy*    rbp = rbr.LookUp("RawDaqHeaderBlock");
00083 
00084    Bool_t isDCS   = rbp->IsDCS();
00085    Int_t  majorId = rbp->GetMajorId();
00086    Int_t  minorId = 2;  // latest and greatest minor version #
00087    RawBlockId rbid(majorId,minorId,isDCS,
00088                    vldc.GetDetector(),vldc.GetSimFlag());
00089    fRawBlock[2] = rbid.GetEncoded();
00090 
00091    fRawBlock[indx_run]         = run;
00092    fRawBlock[indx_subrun]      = (subrun&0xffff)<<16 | (runtype&0xffff);
00093    fRawBlock[indx_start_sec]   = vldc.GetTimeStamp().GetSec();
00094    fRawBlock[indx_start_nsec]  = vldc.GetTimeStamp().GetNanoSec();
00095    fRawBlock[indx_tf]          = timeframe;
00096    fRawBlock[indx_end_sec]     = fRawBlock[indx_start_sec] + 1;
00097    fRawBlock[indx_end_nsec]    = fRawBlock[indx_start_nsec];
00098 
00099    // fill checksum
00100    rdxsum_fill((long*)fRawBlock,0); 
00101 
00102 }
00103 
00104 //_____________________________________________________________________________
00105 RawDaqHeaderBlock::~RawDaqHeaderBlock()
00106 {
00107    // dtor
00108 }
00109 
00110 //_____________________________________________________________________________
00111 VldTimeStamp RawDaqHeaderBlock::GetFrameStartTime() const
00112 {
00113    // get the timestamp for the start of the timeframe
00114    if (fSize > indx_start_nsec) 
00115       return VldTimeStamp(fRawBlock[indx_start_sec],
00116                           fRawBlock[indx_start_nsec]);
00117 
00118    return VldTimeStamp((time_t)0,(Int_t)0);
00119 }
00120 
00121 //_____________________________________________________________________________
00122 VldTimeStamp RawDaqHeaderBlock::GetFrameEndTime() const
00123 {
00124    // get the timestamp for the end of the timeframe
00125 
00126    if (fSize > indx_end_nsec) 
00127       return VldTimeStamp(fRawBlock[indx_end_sec],
00128                           fRawBlock[indx_end_nsec]);
00129 
00130    // prior to v2 this didn't exist, so fake it w/ the assumption of 1sec
00131    if (fSize > indx_start_nsec) 
00132       return VldTimeStamp(fRawBlock[indx_start_sec]+1,
00133                           fRawBlock[indx_start_nsec]);
00134 
00135    return VldTimeStamp((time_t)0,(Int_t)0);
00136 }
00137 
00138 //_____________________________________________________________________________
00139 Int_t RawDaqHeaderBlock::GetRun() const
00140 {
00141    // get the run number
00142    if (fSize > indx_run) return fRawBlock[indx_run];
00143    return -1;
00144 }
00145 
00146 //_____________________________________________________________________________
00147 Short_t RawDaqHeaderBlock::GetSubRun() const
00148 {
00149    // get the subrun number
00150    if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00151    return -1;
00152 }
00153 
00154 //_____________________________________________________________________________
00155 Short_t RawDaqHeaderBlock::GetRunType() const
00156 {
00157    // get the run type
00158    if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00159    return -1;
00160 }
00161 
00162 //_____________________________________________________________________________
00163 Int_t RawDaqHeaderBlock::GetTimeFrameNum() const
00164 {
00165    // get the timeframe number
00166    if (fSize > indx_tf) return fRawBlock[indx_tf];
00167    return -1;
00168 }
00169 
00170 //_____________________________________________________________________________
00171 VldContext RawDaqHeaderBlock::GetVldContext() const
00172 {
00173    // build validity context
00174    RawBlockId rbid = GetBlockId();
00175    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTimeStamp());
00176 }
00177 
00178 //_____________________________________________________________________________
00179 std::ostream& RawDaqHeaderBlock::FormatToOStream(ostream& os, 
00180                                                  Option_t *option) const
00181 {
00182    RawDataBlock::FormatToOStream(os,option);
00183    if (option[0] == 'X') return os;
00184 
00185    Int_t minor = GetMinorId();
00186 
00187    if (minor > 1) {
00188      os << " [ " 
00189         << GetFrameStartTime().AsString("c") 
00190         << " : "
00191         << GetFrameEndTime().AsString("c") 
00192         << " ]"
00193         << endl;
00194    }
00195    else {
00196      // prior to v2 there was only one timestamp
00197      // current code with give something (time stamp + 1sec)
00198      // so we could actually just go with the above code
00199      os << " TimeStamp " 
00200         << GetTimeStamp().AsString("c") 
00201         << endl;
00202    }
00203    os << " Run " << GetRun()
00204       << " SubRun " << GetSubRun() 
00205       << " RunType " << GetRunType();
00206    if (minor > 0) {
00207       os << " TimeFrame " << GetTimeFrameNum();
00208    }
00209    os << endl; 
00210 
00211    return os;
00212 }
00213 
00214 //_____________________________________________________________________________

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