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

RawSubRunEndBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawSubRunEndBlock.cxx,v 1.2 2003/10/20 23:03:42 rhatcher Exp $
00003 // 
00004 // RawSubRunEndBlock 
00005 // 
00006 // RawSubRunEndBlock holds the Sub Run End info
00007 //
00008 // Author:  R. Hatcher 2003.09.08
00009 //
00011 
00012 #include "RawData/RawSubRunEndBlock.h"
00013 
00014 UInt_t RawSubRunEndBlock::fgDebugFlags = 0;
00015 enum EDebugRunEndBlock {
00016   kdbg_ForceHexDump = 0x00000001
00017 };
00018 
00019 #include "MessageService/MsgService.h"
00020 //CVSID("$Id: RawSubRunEndBlock.cxx,v 1.2 2003/10/20 23:03:42 rhatcher Exp $");
00021 #include "MessageService/MsgFormat.h"
00022 
00023 #include "RawData/RawBlockRegistry.h"
00024 REGISTERRAWBLOCK(RawSubRunEndBlock,kMdBlockSubRunEnd,0);
00025 
00026 ClassImp(RawSubRunEndBlock)
00027 
00028 enum ERunEndBlkPos {
00029    indx_size        =  0,
00030    indx_checksum    =  1,
00031    indx_blockid     =  2,
00032    indx_run         =  3,
00033    indx_subrun      =  4,
00034    indx_runtype     = indx_subrun,
00035    indx_startsec    =  5,
00036    indx_startnsec   =  6,
00037    indx_endsec      =  7,
00038    indx_endnsec     =  8,
00039    indx_termcode    =  9,
00040    indx_nsnarls     = 10,
00041    indx_nnonsnarls  = 11,
00042    indx_nerrors     = 12,
00043    indx_ntimeframes = 13,
00044    indx_deadsec     = indx_ntimeframes,
00045    indx_ndroppedtfs = 14,
00046    indx_deadnsec    = indx_ndroppedtfs,
00047    zzzz_last        = 15
00048 };
00049 
00050 //_____________________________________________________________________________
00051 RawSubRunEndBlock::RawSubRunEndBlock()
00052 {
00053    // Default constructor
00054 }
00055 
00056 //_____________________________________________________________________________
00057 RawSubRunEndBlock::RawSubRunEndBlock(const Int_t *block)
00058    : RawDataBlock(block)
00059 {
00060    //  stored block format is:
00061    //---------------------
00062    //  0   # words in block
00063    //  1   checksum
00064    //  2   Block Id
00065    //-----
00066    //  3   run #
00067    //  4   {subrun#| run type}
00068    //  5   start time (sec)
00069    //  6   start time (nsec)
00070    //  7   end time (sec)
00071    //  8   end time (nsec)
00072    //  9   termination code (reason for run stop)
00073    // 10   number of snarls
00074    // 11   number of non-snarls
00075    // 12   number of errors
00076    // 13   total # of time frames     // v1: deadtime (sec)
00077    // 14   # of dropped time frames   // v1: deadtime (nsec)
00078 }
00079 
00080 //_____________________________________________________________________________
00081 RawSubRunEndBlock::RawSubRunEndBlock(const VldContext& vldc_start, 
00082                                      const VldTimeStamp& time_end, Int_t run,
00083                                      Short_t subrun, Short_t runtype)
00084    : RawDataBlock()
00085 {
00086    // Component ctor
00087 
00088    fSize = zzzz_last;
00089    fRawBlock = new Int_t [fSize];
00090 
00091    fRawBlock[0] = fSize;
00092 // fRawBlock[1] = checksum... see below
00093 
00094    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00095    RawBlockProxy*    rbp = rbr.LookUp("RawSubRunEndBlock");
00096 
00097    Bool_t isDCS   = rbp->IsDCS();
00098    Int_t  majorId = rbp->GetMajorId();
00099    Int_t  minorId = 1;
00100    RawBlockId rbid(majorId,minorId,isDCS,
00101                    vldc_start.GetDetector(),vldc_start.GetSimFlag());
00102    fRawBlock[2] = rbid.GetEncoded();
00103 
00104    fRawBlock[indx_run]        = run;
00105    fRawBlock[indx_subrun]     = (subrun&0xffff)<<16 | (runtype&0xffff);
00106    fRawBlock[indx_startsec]   = vldc_start.GetTimeStamp().GetSec();
00107    fRawBlock[indx_startnsec]  = vldc_start.GetTimeStamp().GetNanoSec();
00108    fRawBlock[indx_endsec]     = time_end.GetSec();
00109    fRawBlock[indx_endnsec]    = time_end.GetNanoSec();
00110    fRawBlock[indx_termcode]   = 0;
00111    fRawBlock[indx_nsnarls]    = -1;
00112    fRawBlock[indx_nnonsnarls] = -1;
00113    fRawBlock[indx_nerrors]    = 0;
00114    fRawBlock[indx_ntimeframes] = -1;
00115    fRawBlock[indx_ndroppedtfs] = -1;
00116 
00117 
00118 
00119    // fill checksum
00120    rdxsum_fill((long*)fRawBlock,0); 
00121 }
00122 
00123 //_____________________________________________________________________________
00124 RawSubRunEndBlock::~RawSubRunEndBlock()
00125 {
00126    // dtor
00127 }
00128 
00129 //_____________________________________________________________________________
00130 VldTimeStamp RawSubRunEndBlock::GetStartTime() const
00131 {
00132    // get the start time
00133    if (fSize > indx_startnsec) 
00134       return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00135 
00136    return VldTimeStamp((time_t)0,(Int_t)0);
00137 }
00138 
00139 //_____________________________________________________________________________
00140 VldTimeStamp RawSubRunEndBlock::GetEndTime() const
00141 {
00142    // get the end time
00143    if (fSize > indx_endnsec) 
00144       return VldTimeStamp(fRawBlock[indx_endsec],fRawBlock[indx_endnsec]);
00145 
00146    return VldTimeStamp((time_t)0,(Int_t)0);
00147 }
00148 
00149 //_____________________________________________________________________________
00150 Int_t RawSubRunEndBlock::GetRun() const
00151 {
00152    // get the run number
00153    if (fSize > indx_run) return fRawBlock[indx_run];
00154    return -1;
00155 }
00156 
00157 //_____________________________________________________________________________
00158 Short_t RawSubRunEndBlock::GetSubRun() const
00159 {
00160    // get the subrun number
00161    if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00162    return -1;
00163 }
00164 
00165 //_____________________________________________________________________________
00166 Short_t RawSubRunEndBlock::GetRunType() const
00167 {
00168    // get the run type
00169    if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00170    return -1;
00171 }
00172 
00173 //_____________________________________________________________________________
00174 Int_t RawSubRunEndBlock::GetTerminationCode() const
00175 {
00176    // get the termination code
00177    if (fSize > indx_termcode) return fRawBlock[indx_termcode];
00178    return -1;
00179 }
00180 
00181 //_____________________________________________________________________________
00182 Int_t RawSubRunEndBlock::GetNumberOfSnarls() const
00183 {
00184    // get the number of snarls
00185    if (fSize > indx_nsnarls) return fRawBlock[indx_nsnarls];
00186    return -1;
00187 }
00188 
00189 //_____________________________________________________________________________
00190 Int_t RawSubRunEndBlock::GetNumberOfNonSnarls() const
00191 {
00192    // get the number of non-snarls
00193    if (fSize > indx_nnonsnarls) return fRawBlock[indx_nnonsnarls];
00194    return -1;
00195 }
00196 
00197 //_____________________________________________________________________________
00198 Int_t RawSubRunEndBlock::GetNumberOfErrors() const
00199 {
00200    // get the number of errors
00201    if (fSize > indx_nerrors) return fRawBlock[indx_nerrors];
00202    return -1;
00203 }
00204 
00205 //_____________________________________________________________________________
00206 Int_t RawSubRunEndBlock::GetTotalTimeFrames() const
00207 {
00208    // get the total number of time frames in the run
00209 
00210    if (fSize > indx_ntimeframes && GetBlockId().GetMinor() >= 1 )
00211       return fRawBlock[indx_ntimeframes];
00212 
00213    return -1;
00214 }
00215 
00216 //_____________________________________________________________________________
00217 Int_t RawSubRunEndBlock::GetDroppedTimeFrames() const
00218 {
00219    // get the number of time frames dropped during the run
00220 
00221    if (fSize > indx_ndroppedtfs && GetBlockId().GetMinor() >= 1 ) 
00222       return fRawBlock[indx_ndroppedtfs];
00223 
00224    return -1;
00225 }
00226 
00227 //_____________________________________________________________________________
00228 VldTimeStamp RawSubRunEndBlock::GetDeadTime() const
00229 {
00230    // get the deadtime (only for minor version <1; never was filled by DAQ)
00231 
00232    if (fSize > indx_deadnsec && GetBlockId().GetMinor() < 1 ) 
00233       return VldTimeStamp(fRawBlock[indx_deadsec],fRawBlock[indx_deadnsec]);
00234 
00235    return VldTimeStamp((time_t)0,(Int_t)0);
00236 }
00237 
00238 //_____________________________________________________________________________
00239 VldContext RawSubRunEndBlock::GetVldContext() const
00240 {
00241    // build validity context
00242    RawBlockId rbid = GetBlockId();
00243    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetEndTime());
00244 }
00245 
00246 //_____________________________________________________________________________
00247 std::ostream& RawSubRunEndBlock::FormatToOStream(std::ostream& os, 
00248                                                  Option_t *option) const
00249 {
00250 
00251    if (fgDebugFlags & kdbg_ForceHexDump) option = "x";
00252 
00253    RawDataBlock::FormatToOStream(os,option);
00254    if (option[0] == 'X') return os;
00255    
00256    // additional block specific formatted output is done here
00257 
00258    os << " Run " << GetRun() 
00259       << " SubRun " << GetSubRun() 
00260       << " RunType " << GetRunType() 
00261       << " : " 
00262       << GetNumberOfSnarls() << " snarls, " 
00263       << GetNumberOfNonSnarls() << " non-snarls" 
00264       << endl; 
00265    os << " Start " << GetStartTime().AsString("c") << endl;
00266    os << " End   " << GetEndTime().AsString("c") << endl;
00267    if ( GetBlockId().GetMinor() >= 1 ) {
00268       os << " Dropped " << GetDroppedTimeFrames()
00269          << " timeframes out of " << GetTotalTimeFrames() << endl;
00270    }
00271    else {
00272       os << " Dead  " << GetDeadTime().GetSec() << "."
00273          << setw(9) << setfill('0') << GetDeadTime().GetNanoSec()
00274          << setfill(' ') << endl;
00275    }
00276    
00277    return os;
00278 }
00279 
00280 //_____________________________________________________________________________

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