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

RawBeamMonHeaderBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawBeamMonHeaderBlock.cxx,v 1.4 2004/09/22 17:26:26 bv Exp $
00003 // 
00004 // RawBeamMonHeaderBlock 
00005 // 
00006 // RawBeamMonHeaderBlock holds the basic BeamMon Record Header info.
00007 //
00008 // Author:  R. Hatcher 2003.01.22
00009 //
00011 
00012 #include "RawData/RawBeamMonHeaderBlock.h"
00013 #include <OnlineUtil/rawBeamDataBlockLayout.h>
00014 
00015 UInt_t RawBeamMonHeaderBlock::fgDebugFlags = 0;
00016 
00017 #include "MessageService/MsgService.h"
00018 //CVSID("$Id: RawBeamMonHeaderBlock.cxx,v 1.4 2004/09/22 17:26:26 bv Exp $");
00019 //#include "MessageService/MsgStream.h"
00020 
00021 #include "RawData/RawBlockRegistry.h"
00022 REGISTERRAWBLOCK(RawBeamMonHeaderBlock,kMdBlockBeamMonHeader,1);
00023 
00024 ClassImp(RawBeamMonHeaderBlock)
00025 
00026 //_____________________________________________________________________________
00027 RawBeamMonHeaderBlock::RawBeamMonHeaderBlock() : RawDataBlock()
00028 {
00029    // Default constructor
00030 }
00031 
00032 //_____________________________________________________________________________
00033 RawBeamMonHeaderBlock::RawBeamMonHeaderBlock(const Int_t *block)
00034    : RawDataBlock(block)
00035 {
00036    //  stored block format is:
00037    //---------------------
00038    //  0   # words in block
00039    //  1   checksum
00040    //  2   Block Id
00041    //-----
00042    //  3   timestamp (sec)
00043    //  4   timestamp (nsec)
00044    //  5   spill count
00045 }
00046 //_____________________________________________________________________________
00047 RawBeamMonHeaderBlock::RawBeamMonHeaderBlock(const VldContext& vldc,
00048                                              UInt_t spillcnt)
00049    : RawDataBlock()
00050 {
00051    // Component ctor
00052 
00053    fSize = zzzz_last;
00054    if (fRawBlock) delete [] fRawBlock;
00055    fRawBlock = new Int_t [fSize];
00056 
00057    fRawBlock[0] = fSize;
00058 // fRawBlock[1] = checksum... see below
00059 
00060    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00061    RawBlockProxy*    rbp = rbr.LookUp("RawBeamMonHeaderBlock");
00062 
00063    Bool_t isDCS   = rbp->IsDCS();
00064    Int_t  majorId = rbp->GetMajorId();
00065    Int_t  minorId = 1;  // latest and greatest minor version #
00066    RawBlockId rbid(majorId,minorId,isDCS,
00067                    vldc.GetDetector(),vldc.GetSimFlag());
00068    fRawBlock[2] = rbid.GetEncoded();
00069 
00070    fRawBlock[hdr_indx_sec]      = vldc.GetTimeStamp().GetSec();
00071    fRawBlock[hdr_indx_nsec]     = vldc.GetTimeStamp().GetNanoSec();
00072    fRawBlock[hdr_indx_spillcnt] = spillcnt;
00073 
00074    // fill checksum
00075    rdxsum_fill((long*)fRawBlock,0); 
00076 
00077 }
00078 
00079 //_____________________________________________________________________________
00080 RawBeamMonHeaderBlock::~RawBeamMonHeaderBlock()
00081 {
00082    // dtor
00083 }
00084 
00085 //_____________________________________________________________________________
00086 VldTimeStamp RawBeamMonHeaderBlock::GetTimeStamp() const
00087 {
00088    // get the timestamp
00089    if (fSize > hdr_indx_nsec) 
00090       return VldTimeStamp(fRawBlock[hdr_indx_sec],fRawBlock[hdr_indx_nsec]);
00091 
00092    return VldTimeStamp((time_t)0,(Int_t)0);
00093 }
00094 
00095 //_____________________________________________________________________________
00096 Int_t RawBeamMonHeaderBlock::GetSpillCountNum() const
00097 {
00098    // get the timeframe number
00099    if (fSize > hdr_indx_spillcnt) return fRawBlock[hdr_indx_spillcnt];
00100    return -1;
00101 }
00102 
00103 //_____________________________________________________________________________
00104 VldContext RawBeamMonHeaderBlock::GetVldContext() const
00105 {
00106    // build validity context
00107    RawBlockId rbid = GetBlockId();
00108    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTimeStamp());
00109 }
00110 
00111 //_____________________________________________________________________________
00112 std::ostream& RawBeamMonHeaderBlock::FormatToOStream(ostream& os, 
00113                                                      Option_t *option) const
00114 {
00115    RawDataBlock::FormatToOStream(os,option);
00116    if (option[0] == 'X') return os;
00117 
00118    os << " TimeStamp " << GetTimeStamp().AsString("c")
00119       << " SpillCount " << GetSpillCountNum() << endl;
00120 
00121    return os;
00122 }
00123 
00124 //_____________________________________________________________________________

Generated on Sat Nov 7 01:27:16 2009 for loon by  doxygen 1.3.9.1