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

RawRunStartBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawRunStartBlock.cxx,v 1.11 2003/07/10 19:36:30 rhatcher Exp $
00003 // 
00004 // RawRunStartBlock 
00005 // 
00006 // RawRunStartBlock holds the Run Start info
00007 //
00008 // Author:  R. Hatcher 2001.06.01
00009 //
00011 
00012 #include "RawData/RawRunStartBlock.h"
00013 
00014 UInt_t RawRunStartBlock::fgDebugFlags = 0;
00015 
00016 #include "MessageService/MsgService.h"
00017 //CVSID("$Id: RawRunStartBlock.cxx,v 1.11 2003/07/10 19:36:30 rhatcher Exp $");
00018 #include "MessageService/MsgFormat.h"
00019 
00020 #include "RawData/RawBlockRegistry.h"
00021 REGISTERRAWBLOCK(RawRunStartBlock,kMdBlockRunStart,0);
00022 
00023 ClassImp(RawRunStartBlock)
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    zzzz_last      = 7
00035 };
00036 
00037 //_____________________________________________________________________________
00038 RawRunStartBlock::RawRunStartBlock()
00039 {
00040    // Default constructor
00041 }
00042 
00043 //_____________________________________________________________________________
00044 RawRunStartBlock::RawRunStartBlock(const Int_t *block)
00045    : RawDataBlock(block)
00046 {
00047    //  stored block format is:
00048    //---------------------
00049    //  0   # words in block
00050    //  1   checksum
00051    //  2   Block Id
00052    //-----
00053    //  3   run #
00054    //  4   {subrun#| run type}
00055    //  5   start time (sec)
00056    //  6   start time (nsec)
00057 }
00058 
00059 //_____________________________________________________________________________
00060 RawRunStartBlock::RawRunStartBlock(const VldContext& vldc, Int_t run,
00061                                    Short_t subrun, Short_t runtype)
00062    : RawDataBlock()
00063 {
00064    // Component ctor
00065 
00066    fSize = zzzz_last;
00067    fRawBlock = new Int_t [fSize];
00068 
00069    fRawBlock[0] = fSize;
00070 // fRawBlock[1] = checksum... see below
00071 
00072    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00073    RawBlockProxy*    rbp = rbr.LookUp("RawRunStartBlock");
00074 
00075    Bool_t isDCS   = rbp->IsDCS();
00076    Int_t  majorId = rbp->GetMajorId();
00077    Int_t  minorId = 0;
00078    RawBlockId rbid(majorId,minorId,isDCS,
00079                    vldc.GetDetector(),vldc.GetSimFlag());
00080    fRawBlock[2] = rbid.GetEncoded();
00081 
00082    fRawBlock[indx_run]     = run;
00083    fRawBlock[indx_subrun]  = (subrun&0xffff)<<16 | (runtype&0xffff);
00084    fRawBlock[indx_startsec]     = vldc.GetTimeStamp().GetSec();
00085    fRawBlock[indx_startnsec]    = vldc.GetTimeStamp().GetNanoSec();
00086 
00087    // fill checksum
00088    rdxsum_fill((long*)fRawBlock,0); 
00089 
00090 }
00091 
00092 //_____________________________________________________________________________
00093 RawRunStartBlock::~RawRunStartBlock()
00094 {
00095    // dtor
00096 }
00097 
00098 //_____________________________________________________________________________
00099 VldTimeStamp RawRunStartBlock::GetStartTime() const
00100 {
00101    // get the trigger time
00102    if (fSize >= zzzz_last) 
00103       return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00104 
00105    return VldTimeStamp((time_t)0,(Int_t)0);
00106 }
00107 
00108 //_____________________________________________________________________________
00109 Int_t RawRunStartBlock::GetRun() const
00110 {
00111    // get the run number
00112    if (fSize >= zzzz_last) return fRawBlock[indx_run];
00113    return -1;
00114 }
00115 
00116 //_____________________________________________________________________________
00117 Short_t RawRunStartBlock::GetSubRun() const
00118 {
00119    // get the subrun number
00120    if (fSize >= zzzz_last) return (fRawBlock[indx_subrun]>>16)&0xffff;
00121    return -1;
00122 }
00123 
00124 //_____________________________________________________________________________
00125 Short_t RawRunStartBlock::GetRunType() const
00126 {
00127    // get the run type
00128    if (fSize >= zzzz_last) return fRawBlock[indx_runtype]&0xffff;
00129    return -1;
00130 }
00131 
00132 //_____________________________________________________________________________
00133 VldContext RawRunStartBlock::GetVldContext() const
00134 {
00135    // build validity context
00136    RawBlockId rbid = GetBlockId();
00137    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetStartTime());
00138 }
00139 
00140 //_____________________________________________________________________________
00141 std::ostream& RawRunStartBlock::FormatToOStream(std::ostream& os, 
00142                                                 Option_t *option) const
00143 {
00144    RawDataBlock::FormatToOStream(os,option);
00145    if (option[0] == 'X') return os;
00146    
00147    // additional block specific formatted output is done here
00148 
00149    os << " StartTime " << GetStartTime().AsString("c") << endl;
00150    os << " Run " << GetRun() 
00151       << " SubRun " << GetSubRun() 
00152       << " RunType " << GetRunType() << endl; 
00153 
00154    return os;
00155 }
00156 
00157 //_____________________________________________________________________________

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