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

RawTriggerStatsBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawTriggerStatsBlock.cxx,v 1.9 2003/07/10 19:36:30 rhatcher Exp $
00003 // 
00004 // RawTriggerStatsBlock 
00005 // 
00006 // RawTriggerStatsBlock holds the Trigger Statistics info
00007 //
00008 // Author:  R. Hatcher 2001.07.30
00009 //
00011 
00012 #include "RawData/RawTriggerStatsBlock.h"
00013 
00014 UInt_t RawTriggerStatsBlock::fgDebugFlags = 0;
00015 
00016 #include "MessageService/MsgService.h"
00017 //CVSID("$Id: RawTriggerStatsBlock.cxx,v 1.9 2003/07/10 19:36:30 rhatcher Exp $");
00018 #include "MessageService/MsgFormat.h"
00019 
00020 #include "RawData/RawBlockRegistry.h"
00021 REGISTERRAWBLOCK(RawTriggerStatsBlock,kMdBlockTriggerStats,0);
00022 
00023 ClassImp(RawTriggerStatsBlock)
00024 
00025 enum ETriggerStatsBlkPos {
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_endsec    =  7,
00035    indx_endnsec   =  8,
00036    indx_nsnarls   =  9,
00037    indx_nsrcs     = 10,
00038    zzzz_last      = 11
00039 };
00040 
00041 //_____________________________________________________________________________
00042 RawTriggerStatsBlock::RawTriggerStatsBlock() : RawDataBlock()
00043 {
00044    // Default constructor
00045 }
00046 
00047 //_____________________________________________________________________________
00048 RawTriggerStatsBlock::RawTriggerStatsBlock(const Int_t *block)
00049    : RawDataBlock(block)
00050 {
00051    //  stored block format is:
00052    //---------------------
00053    //  0   # words in block
00054    //  1   checksum
00055    //  2   Block Id
00056    //-----
00057    //  3   run #
00058    //  4   {subrun#| run type}
00059    //  5   start time (sec)
00060    //  6   start time (nsec)
00061    //  7   end time (sec)
00062    //  8   end time (nsec)
00063    //  9   total number of snarls
00064    // 10   number trigger sources
00065    // 11   src id (index 1)
00066    // 12   # snarls (index 1)
00067    // ..   {src id / # snarls}  pairs
00068 }
00069 
00070 //_____________________________________________________________________________
00071 RawTriggerStatsBlock::RawTriggerStatsBlock(const VldContext& vldc_start, 
00072                                            const VldTimeStamp& time_end, Int_t run,
00073                                            Short_t subrun, Short_t runtype,
00074                                            Int_t nsnarls, Int_t nsrcs,
00075                                            const Int_t* srcid, const Int_t *snarlcnt)
00076    : RawDataBlock()
00077 {
00078    // Component ctor
00079 
00080    fSize = zzzz_last + 2*nsrcs;
00081    if (fRawBlock) delete [] fRawBlock;
00082    fRawBlock = new Int_t [fSize];
00083 
00084    fRawBlock[0] = fSize;
00085 // fRawBlock[1] = checksum... see below
00086 
00087    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00088    RawBlockProxy*    rbp = rbr.LookUp("RawTriggerStatsBlock");
00089 
00090    Bool_t isDCS   = rbp->IsDCS();
00091    Int_t  majorId = rbp->GetMajorId();
00092    Int_t  minorId = 0;
00093    RawBlockId rbid(majorId,minorId,isDCS,
00094                    vldc_start.GetDetector(),vldc_start.GetSimFlag());
00095    fRawBlock[2] = rbid.GetEncoded();
00096 
00097    fRawBlock[indx_run]        = run;
00098    fRawBlock[indx_subrun]     = (subrun&0xffff)<<16 | (runtype&0xffff);
00099    fRawBlock[indx_startsec]   = vldc_start.GetTimeStamp().GetSec();
00100    fRawBlock[indx_startnsec]  = vldc_start.GetTimeStamp().GetNanoSec();
00101    fRawBlock[indx_endsec]     = time_end.GetSec();
00102    fRawBlock[indx_endnsec]    = time_end.GetNanoSec();
00103    fRawBlock[indx_nsnarls]    = nsnarls;
00104    fRawBlock[indx_nsrcs]      = nsrcs;
00105 
00106    for (Int_t i=0; i<nsrcs; i++) {
00107       Int_t ioff = zzzz_last + 2*i;
00108       fRawBlock[ioff+0] = srcid[i];
00109       fRawBlock[ioff+1] = snarlcnt[i];
00110    }
00111 
00112    // fill checksum
00113    rdxsum_fill((long*)fRawBlock,0); 
00114 }
00115 
00116 //_____________________________________________________________________________
00117 RawTriggerStatsBlock::~RawTriggerStatsBlock()
00118 {
00119    // dtor
00120 }
00121 
00122 //_____________________________________________________________________________
00123 VldTimeStamp RawTriggerStatsBlock::GetStartTime() const
00124 {
00125    // get the start time
00126    if (fSize >= zzzz_last) 
00127       return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00128 
00129    return VldTimeStamp((time_t)0,(Int_t)0);
00130 }
00131 
00132 //_____________________________________________________________________________
00133 VldTimeStamp RawTriggerStatsBlock::GetEndTime() const
00134 {
00135    // get the end time
00136    if (fSize >= zzzz_last) 
00137       return VldTimeStamp(fRawBlock[indx_endsec],fRawBlock[indx_endnsec]);
00138 
00139    return VldTimeStamp((time_t)0,(Int_t)0);
00140 }
00141 
00142 //_____________________________________________________________________________
00143 Int_t RawTriggerStatsBlock::GetRun() const
00144 {
00145    // get the run number
00146    if (fSize >= zzzz_last) return fRawBlock[indx_run];
00147    return -1;
00148 }
00149 
00150 //_____________________________________________________________________________
00151 Short_t RawTriggerStatsBlock::GetSubRun() const
00152 {
00153    // get the subrun number
00154    if (fSize >= zzzz_last) return (fRawBlock[indx_subrun]>>16)&0xffff;
00155    return -1;
00156 }
00157 
00158 //_____________________________________________________________________________
00159 Short_t RawTriggerStatsBlock::GetRunType() const
00160 {
00161    // get the run type
00162    if (fSize >= zzzz_last) return fRawBlock[indx_runtype]&0xffff;
00163    return -1;
00164 }
00165 
00166 //_____________________________________________________________________________
00167 Int_t RawTriggerStatsBlock::GetNumberOfSnarls() const
00168 {
00169    // get the total number of snarls
00170    if (fSize >= zzzz_last) return fRawBlock[indx_nsnarls];
00171    return -1;
00172 }
00173 
00174 //_____________________________________________________________________________
00175 Int_t RawTriggerStatsBlock::GetNumberOfSources() const
00176 {
00177    // get the number of sources in the list
00178    if (fSize >= zzzz_last) return fRawBlock[indx_nsrcs];
00179    return -1;
00180 }
00181 
00182 //_____________________________________________________________________________
00183 Int_t RawTriggerStatsBlock::GetSourceId(Int_t indx) const
00184 {
00185    // get the "indx"-th source from the list
00186    Int_t ioff = zzzz_last + 2*indx + 0;
00187    if (fSize >= ioff) return fRawBlock[ioff];
00188    return -1;
00189 }
00190 
00191 //_____________________________________________________________________________
00192 Int_t RawTriggerStatsBlock::GetSnarlCount(Int_t indx) const
00193 {
00194    // get the "indx"-th snarl count from the list
00195    Int_t ioff = zzzz_last + 2*indx + 1;
00196    if (fSize >= ioff) return fRawBlock[ioff];
00197    return -1;
00198 }
00199 
00200 //_____________________________________________________________________________
00201 VldContext RawTriggerStatsBlock::GetVldContext() const
00202 {
00203    // build validity context
00204    RawBlockId rbid = GetBlockId();
00205    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetEndTime());
00206 }
00207 
00208 //_____________________________________________________________________________
00209 std::ostream& RawTriggerStatsBlock::FormatToOStream(std::ostream& os, 
00210                                                     Option_t *option) const
00211 {
00212    RawDataBlock::FormatToOStream(os,option);
00213    if (option[0] == 'X') return os;
00214    
00215    // additional block specific formatted output is done here
00216 
00217    os << " Start " << GetStartTime().AsString("c") << endl;
00218    os << " End   " << GetEndTime().AsString("c") << endl;
00219    os << " Run " << GetRun() 
00220       << " SubRun " << GetSubRun() 
00221       << " RunType " << GetRunType() << endl; 
00222    os << "   " << GetNumberOfSnarls() << " snarls from "
00223       << GetNumberOfSources() << " sources: " << endl;
00224    for (int i = 0; i<GetNumberOfSources(); i++) {
00225       os << "   src 0x" << hex << GetSourceId(i) << dec
00226          << " gave " << GetSnarlCount(i) << " snarls" << endl;
00227    }
00228 
00229    return os;
00230 }
00231 
00232 //_____________________________________________________________________________

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