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

RawDaqDeadTimeBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawDaqDeadTimeBlock.cxx,v 1.3 2003/07/10 19:36:29 rhatcher Exp $
00003 // 
00004 // RawDaqDeadTimeBlock 
00005 // 
00006 // RawDaqDeadTimeBlock holds a range of dropped time frames
00007 //
00008 // Author:  R. Hatcher 2002.06.10
00009 //
00011 
00012 #include "RawData/RawDaqDeadTimeBlock.h"
00013 
00014 UInt_t RawDaqDeadTimeBlock::fgDebugFlags = 0;
00015 
00016 #include "MessageService/MsgService.h"
00017 //CVSID("$Id: RawDaqDeadTimeBlock.cxx,v 1.3 2003/07/10 19:36:29 rhatcher Exp $");
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    // Default constructor
00043 }
00044 
00045 //_____________________________________________________________________________
00046 RawDaqDeadTimeBlock::RawDaqDeadTimeBlock(const Int_t *block)
00047    : RawDataBlock(block)
00048 {
00049    //  stored block format is:
00050    //---------------------
00051    //  0   # words in block
00052    //  1   checksum
00053    //  2   Block Id
00054    //-----
00055    //  3   run #
00056    //  4   {subrun#| run type}
00057    //  5   start time (sec)
00058    //  6   start time (nsec)
00059    //  7   time frame begin
00060    //  8   time frame end
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    // Component ctor
00070 
00071    fSize = zzzz_last;
00072    if (fRawBlock) delete [] fRawBlock;
00073    fRawBlock = new Int_t [fSize];
00074 
00075    fRawBlock[0] = fSize;
00076 // fRawBlock[1] = checksum... see below
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    // fill checksum
00096    rdxsum_fill((long*)fRawBlock,0); 
00097 
00098 }
00099 
00100 //_____________________________________________________________________________
00101 RawDaqDeadTimeBlock::~RawDaqDeadTimeBlock()
00102 {
00103    // dtor
00104 }
00105 
00106 //_____________________________________________________________________________
00107 VldTimeStamp RawDaqDeadTimeBlock::GetTime() const
00108 {
00109    // get the trigger time
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    // get the run number
00120    if (fSize > indx_run) return fRawBlock[indx_run];
00121    return -1;
00122 }
00123 
00124 //_____________________________________________________________________________
00125 Short_t RawDaqDeadTimeBlock::GetSubRun() const
00126 {
00127    // get the subrun number
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    // get the run type
00136    if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00137    return -1;
00138 }
00139 
00140 //_____________________________________________________________________________
00141 Int_t RawDaqDeadTimeBlock::GetTimeFrameBegin() const
00142 {
00143    // get the time frame when dropping started
00144    if (fSize > indx_tfbegin) return fRawBlock[indx_tfbegin];
00145 
00146    return -1;
00147 }
00148 
00149 //_____________________________________________________________________________
00150 Int_t RawDaqDeadTimeBlock::GetTimeFrameEnd() const
00151 {
00152    // get the time frame when dropping started
00153    if (fSize > indx_tfbegin) return fRawBlock[indx_tfend];
00154 
00155    return -1;
00156 }
00157 
00158 //_____________________________________________________________________________
00159 VldContext RawDaqDeadTimeBlock::GetVldContext() const
00160 {
00161    // build validity context
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    // additional block specific formatted output is done here
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 //_____________________________________________________________________________

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