RawVaTimingMonitorBlock Class Reference

#include <RawVaTimingMonitorBlock.h>

Inheritance diagram for RawVaTimingMonitorBlock:
RawDataBlock

List of all members.

Public Member Functions

 RawVaTimingMonitorBlock ()
 RawVaTimingMonitorBlock (const Int_t *block)
virtual ~RawVaTimingMonitorBlock ()
Int_t GetRun () const
Short_t GetSubRun () const
Short_t GetRunType () const
VldTimeStamp GetTimeStamp () const
VldContext GetVldContext () const
Int_t GetTimeFrameNum () const
const RawDigitCrateStatusGetCrateStatus () const
ElecType::Elec_t GetElecType () const
Int_t GetNumberOfDigits () const
const RawDigitAt (Int_t idx) const
virtual TIter GetDatumIter (Bool_t dir=kIterForward) const
Int_t IndexOf (RawDigit *rawdigit) const
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
 RawVaTimingMonitorBlock (const RawVaTimingMonitorBlock &rhs)
RawVaTimingMonitorBlockoperator= (const RawVaTimingMonitorBlock &rhs)

Static Public Member Functions

static void SetDebugFlags (const UInt_t dbgflgs)
static UInt_t GetDebugFlags ()

Protected Member Functions

virtual void FillRawDigits () const

Protected Attributes

RawDigitCrateStatusfRawCrateStatus
TObjArray * fRawDigits
 not written out

Static Private Attributes

static UInt_t fgDebugFlags = 0
 not written out

Detailed Description

Definition at line 24 of file RawVaTimingMonitorBlock.h.


Constructor & Destructor Documentation

RawVaTimingMonitorBlock::RawVaTimingMonitorBlock (  ) 

Definition at line 52 of file RawVaTimingMonitorBlock.cxx.

00053   : fRawCrateStatus(0), fRawDigits(0)
00054 {
00055    // Default constructor
00056 }

RawVaTimingMonitorBlock::RawVaTimingMonitorBlock ( const Int_t *  block  ) 

Definition at line 59 of file RawVaTimingMonitorBlock.cxx.

00060   : RawDataBlock(block), fRawCrateStatus(0), fRawDigits(0)
00061 {
00062    //  stored block format is:
00063    //---------------------
00064    //  0   # words in block
00065    //  1   checksum
00066    //  2   Block Id
00067    //-----
00068    //  3   Run Number
00069    //  4   SubRun | RunType
00070    //  5   Time (sec)
00071    //  6   Time (ns)
00072    //  7   CrateId (+ special bits)
00073    //  8   TimeFrame #
00074    //  8   # of digits to follow
00075    //  ... packed two 32-bit words per digit
00076 
00077 }

RawVaTimingMonitorBlock::~RawVaTimingMonitorBlock (  )  [virtual]

Definition at line 80 of file RawVaTimingMonitorBlock.cxx.

References fRawCrateStatus, and fRawDigits.

00081 {
00082    // dtor
00083    if ( fRawDigits ) {
00084      fRawDigits->Delete();
00085      delete fRawDigits;
00086      fRawDigits = 0;
00087    }
00088    if ( fRawCrateStatus ) {
00089      delete fRawCrateStatus;
00090      fRawCrateStatus = 0;
00091    }
00092 
00093 }

RawVaTimingMonitorBlock::RawVaTimingMonitorBlock ( const RawVaTimingMonitorBlock rhs  )  [inline]

Definition at line 58 of file RawVaTimingMonitorBlock.h.

00059      : RawDataBlock(rhs), fRawCrateStatus(0), fRawDigits(0) { ; }


Member Function Documentation

const RawDigit * RawVaTimingMonitorBlock::At ( Int_t  idx  )  const

Definition at line 211 of file RawVaTimingMonitorBlock.cxx.

References FillRawDigits(), and fRawDigits.

Referenced by GetFidModule::Ana().

00212 {
00213    // create/fill the TObjArray of RawDigits (if it doesn't exist)
00214    // return pointer to the i-th element
00215 
00216    if ( ! fRawDigits ) FillRawDigits();
00217    return (RawDigit*) fRawDigits->At(idx);
00218 }

void RawVaTimingMonitorBlock::FillRawDigits (  )  const [protected, virtual]

Definition at line 241 of file RawVaTimingMonitorBlock.cxx.

References ElecType::AsString(), bfld::AsString(), RawBlockId::AsString(), dbg_DumpCrateOnUnpack, dbg_DumpDigitOnUnpack, dbg_DumpHeaderOnUnpack, fgDebugFlags, RawDataBlock::fRawBlock, fRawCrateStatus, fRawDigits, RawDataBlock::fSize, RawDataBlock::GetBlockId(), RawBlockId::GetDetector(), RawCrateStatus::GetElecType(), RawCrateStatus::GetEntries(), RawBlockId::GetSimFlag(), GetTimeStamp(), indx_crateid, SimFlag::kDaqFakeData, SimFlag::kData, Msg::kError, Msg::kInfo, SimFlag::kMC, Detector::kNear, ElecType::kQIE, ElecType::kReroot, SimFlag::kReroot, SimFlag::kUnknown, ElecType::kVA, Msg::kWarning, MSG, RawCrateStatus::Print(), and RawDigit::Print().

Referenced by At(), GetCrateStatus(), GetDatumIter(), GetNumberOfDigits(), and IndexOf().

00242 {
00243    // create the TObjArray of RawDigit (if it doesn't exist)
00244    
00245    if ( fRawDigits ) return;   // already filled
00246    if ( fSize <= 0 || fRawBlock == 0) {
00247       MSG("RawData",Msg::kWarning)
00248          << "RawVaTimingMonitorBlock::FillRawDigits empty block? "
00249          << fSize << " " << fRawBlock << endl;
00250       return;
00251    }
00252 
00253    fRawDigits          = new TObjArray();
00254    RawDigit  *rawdigit = 0;
00255    const Int_t    *p   = fRawBlock;
00256    const Int_t    *end = fRawBlock + fSize; // 1 beyond end
00257 
00258    RawBlockId rbid = GetBlockId();
00259    p += indx_crateid; // skip #words, blockid and checksum, etc
00260 
00261    if (fgDebugFlags&dbg_DumpHeaderOnUnpack) {
00262       MSG("RawData",Msg::kInfo) 
00263          << "RawVaTimingMonitorBlock::FillRawDigits "
00264          << " fSize " << fSize 
00265          << " id " << rbid.AsString()
00266          << endl;
00267    }
00268 
00269    // unpack crate info
00270    // all version have TF word between crateId and # of entries
00271    fRawCrateStatus = new RawDigitCrateStatus(rbid,p,GetTimeStamp(),true);
00272    Int_t npairs = fRawCrateStatus->GetEntries(); 
00273 
00274    if (fgDebugFlags&dbg_DumpCrateOnUnpack) fRawCrateStatus->Print();
00275 
00276    while (p<end) {
00277 
00278       for (Int_t ipair = 0; ipair < npairs; ipair++) {
00279          // assume that the readout type is consistent for whole crate
00280          // and that the status block knows what it is
00281          ElecType::Elec_t etype = fRawCrateStatus->GetElecType();
00282 
00283          // pointer is advanced by RawDigit ctor
00284          // knowing how many words it needed to eat
00285          switch (rbid.GetSimFlag()) {
00286          case SimFlag::kData:
00287          case SimFlag::kDaqFakeData:
00288             switch (etype) {
00289             case ElecType::kVA:
00290                rawdigit = new RawVaDigit(p,fRawCrateStatus);
00291                break;
00292             case ElecType::kQIE:
00293                rawdigit = new RawQieDigit(p,fRawCrateStatus);
00294                break;
00295             default:
00296                rawdigit = new RawDigit(p,fRawCrateStatus);
00297                break;
00298             }
00299             break;
00300          case SimFlag::kMC:
00301          case SimFlag::kReroot:
00302             switch (etype) {
00303             case ElecType::kVA:
00304                rawdigit = new RawVaMCDigit(p,fRawCrateStatus);
00305                break;
00306             case ElecType::kQIE:
00307                rawdigit = new RawQieMCDigit(p,fRawCrateStatus);
00308                break;
00309             case ElecType::kReroot:
00310               {
00311                 if (rbid.GetDetector() == Detector::kNear) {
00312                   static int nmsg = 10;
00313                   if (nmsg) {
00314                     MSG("RawData",Msg::kWarning)
00315                       << "RawVaTimingMonitorBlock::FillRawDigits SimFlag "
00316                       << SimFlag::AsString(rbid.GetSimFlag())
00317                       << " ElecType " << ElecType::AsString(etype)
00318                       << " in Detector " 
00319                       << Detector::AsString(rbid.GetDetector())
00320                       << endl
00321                       << " treat as kQIE for RawQieMCDigit creation"
00322                       << endl;
00323                     if (nmsg) {
00324                       if (--nmsg == 0)
00325                         MSG("RawData",Msg::kWarning)
00326                           << " ... last warning of this type" << endl;
00327                     }
00328                   }
00329                   rawdigit = new RawQieMCDigit(p,fRawCrateStatus);
00330                   break;
00331                 }
00332                 else 
00333                   MSG("RawData",Msg::kError) 
00334                     << "RawVaTimingMonitorBlock::FillRawDigits SimFlag "
00335                     << SimFlag::AsString(rbid.GetSimFlag())
00336                     << " ElecType " << ElecType::AsString(etype)
00337                     << endl << "  attempt to move past problem " << endl;
00338                 p += 3;
00339                 break;
00340               }
00341             default:
00342                MSG("RawData",Msg::kError) 
00343                   << "RawVaTimingMonitorBlock::FillRawDigits SimFlag "
00344                   << SimFlag::AsString(rbid.GetSimFlag())
00345                   << " ElecType " << ElecType::AsString(etype)
00346                   << endl << "  attempt to move past problem " << endl;
00347                p += 3;
00348                break;
00349             }
00350             break;
00351          case SimFlag::kUnknown:
00352                MSG("RawData",Msg::kError) 
00353                   << "RawVaTimingMonitorBlock::FillRawDigits SimFlag "
00354                   << SimFlag::AsString(rbid.GetSimFlag())
00355                   << endl << "  attempt to move past problem " << endl;
00356                p += 2;
00357                break;
00358          }
00359 
00360          fRawDigits->Add(rawdigit);
00361 
00362          if (fgDebugFlags&dbg_DumpDigitOnUnpack) {
00363            rawdigit->Print(); cout << endl;
00364          }
00365          if (p>end) {
00366             MSG("RawData",Msg::kWarning)
00367                << "RawVaTimingMonitorBlock::FillRawDigits crate info seems trashed"
00368                << endl << " SimFlag " << SimFlag::AsString(rbid.GetSimFlag())
00369                << " ElecType " << ElecType::AsString(etype)
00370                << endl;
00371             break;
00372          }
00373       }
00374    }
00375 
00376 }

std::ostream & RawVaTimingMonitorBlock::FormatToOStream ( std::ostream &  os,
Option_t *  option = "" 
) const [virtual]

Reimplemented from RawDataBlock.

Definition at line 112 of file RawVaTimingMonitorBlock.cxx.

References VldTimeStamp::AsString(), GetCrateStatus(), GetDatumIter(), GetNumberOfDigits(), GetRun(), GetRunType(), GetSubRun(), GetTimeFrameNum(), and GetTimeStamp().

00114 {
00115    RawDataBlock::FormatToOStream(os,option);
00116    if (option[0] == 'X') return os;
00117    
00118    // additional block specific formatted output is done here
00119 
00120    os << " TimeStamp " << GetTimeStamp().AsString("c") << endl;
00121    os << " Run " << GetRun() 
00122       << " SubRun " << GetSubRun() 
00123       << " RunType " << GetRunType() 
00124       << " TimeFrame " << GetTimeFrameNum()
00125       << " with " << GetNumberOfDigits() << " digits "
00126       << endl; 
00127    os << " " << *GetCrateStatus() << endl;
00128 
00129    if (strchr(option,'q') != 0) return os;
00130 
00131    TIter iter = GetDatumIter();
00132    TObject *tobj;
00133    RawDigit *udigit;
00134    while ( ( tobj = iter.Next() ) ) {
00135      udigit = dynamic_cast<RawDigit *>(tobj);
00136      if (udigit) os << " " << (*udigit) << endl;
00137    }
00138    os << endl;
00139    return os;
00140 }

const RawDigitCrateStatus * RawVaTimingMonitorBlock::GetCrateStatus (  )  const

Definition at line 194 of file RawVaTimingMonitorBlock.cxx.

References FillRawDigits(), fRawCrateStatus, and fRawDigits.

Referenced by FormatToOStream(), and GetElecType().

00195 {
00196    // get the crate id --> status
00197    if ( ! fRawDigits ) FillRawDigits();
00198    return fRawCrateStatus;
00199 
00200 }

TIter RawVaTimingMonitorBlock::GetDatumIter ( Bool_t  dir = kIterForward  )  const [virtual]

Definition at line 221 of file RawVaTimingMonitorBlock.cxx.

References FillRawDigits(), and fRawDigits.

Referenced by FormatToOStream().

00222 {
00223    // create/fill the TObjArray of RawDigits (if it doesn't exist)
00224    // return an iterator to look over them
00225 
00226    if ( ! fRawDigits ) FillRawDigits();
00227    return TIter(fRawDigits,dir);
00228 }

static UInt_t RawVaTimingMonitorBlock::GetDebugFlags (  )  [inline, static]

Definition at line 55 of file RawVaTimingMonitorBlock.h.

References fgDebugFlags.

00055 { return fgDebugFlags; }

ElecType::Elec_t RawVaTimingMonitorBlock::GetElecType (  )  const [inline]

Definition at line 40 of file RawVaTimingMonitorBlock.h.

References GetCrateStatus(), and RawCrateStatus::GetElecType().

00041      { return GetCrateStatus()->GetElecType(); }

Int_t RawVaTimingMonitorBlock::GetNumberOfDigits ( void   )  const

Definition at line 203 of file RawVaTimingMonitorBlock.cxx.

References FillRawDigits(), and fRawDigits.

Referenced by GetFidModule::Ana(), and FormatToOStream().

00204 {
00205    // get the number of digits
00206    if ( ! fRawDigits ) FillRawDigits();
00207    return fRawDigits->GetEntriesFast();  // known not to have gaps
00208 }

Int_t RawVaTimingMonitorBlock::GetRun ( void   )  const

Definition at line 143 of file RawVaTimingMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_run.

Referenced by GetFidModule::Ana(), and FormatToOStream().

00144 {
00145    // get the run number
00146    if (fSize > indx_run) return fRawBlock[indx_run];
00147    return -1;
00148 }

Short_t RawVaTimingMonitorBlock::GetRunType (  )  const

Definition at line 159 of file RawVaTimingMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_runtype.

Referenced by FormatToOStream().

00160 {
00161    // get the run type
00162    if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00163    return -1;
00164 }

Short_t RawVaTimingMonitorBlock::GetSubRun (  )  const

Definition at line 151 of file RawVaTimingMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, and indx_subrun.

Referenced by FormatToOStream().

00152 {
00153    // get the subrun number
00154    if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00155    return -1;
00156 }

Int_t RawVaTimingMonitorBlock::GetTimeFrameNum (  )  const

Definition at line 186 of file RawVaTimingMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_tf, and zzzz_last.

Referenced by FormatToOStream().

00187 {
00188    // get the time frame #
00189    if (fSize >= zzzz_last) return fRawBlock[indx_tf];
00190    return -1;
00191 }

VldTimeStamp RawVaTimingMonitorBlock::GetTimeStamp (  )  const

Definition at line 167 of file RawVaTimingMonitorBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_loadnsec, indx_loadsec, and zzzz_last.

Referenced by GetFidModule::Ana(), FillRawDigits(), FormatToOStream(), and GetVldContext().

00168 {
00169    // get the start time
00170    if (fSize >= zzzz_last) 
00171       return VldTimeStamp(fRawBlock[indx_loadsec],fRawBlock[indx_loadnsec]);
00172 
00173    return VldTimeStamp((time_t)0,(Int_t)0);
00174 }

VldContext RawVaTimingMonitorBlock::GetVldContext (  )  const

Definition at line 177 of file RawVaTimingMonitorBlock.cxx.

References RawDataBlock::GetBlockId(), RawBlockId::GetDetector(), RawBlockId::GetSimFlag(), and GetTimeStamp().

00178 {
00179    // get a VldContext
00180 
00181    RawBlockId rbid = GetBlockId();
00182    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTimeStamp());
00183 }

Int_t RawVaTimingMonitorBlock::IndexOf ( RawDigit rawdigit  )  const

Definition at line 231 of file RawVaTimingMonitorBlock.cxx.

References FillRawDigits(), and fRawDigits.

00232 {
00233    // create/fill the TObjArray of RawDigits (if it doesn't exist)
00234    // return the index for this object (if contained in the list)
00235 
00236    if ( ! fRawDigits ) FillRawDigits();
00237    return fRawDigits->IndexOf(rawdigit);
00238 }

RawVaTimingMonitorBlock & RawVaTimingMonitorBlock::operator= ( const RawVaTimingMonitorBlock rhs  ) 

Reimplemented from RawDataBlock.

Definition at line 96 of file RawVaTimingMonitorBlock.cxx.

References fRawCrateStatus, and fRawDigits.

00097 {
00098    // deep copy assignment 
00099   if (this != &rhs) {
00100     RawDataBlock::operator=(rhs);
00101     if (fRawCrateStatus) { delete fRawCrateStatus; fRawCrateStatus = 0; }
00102     if (fRawDigits) { 
00103       fRawDigits->Delete(); 
00104       delete fRawDigits; 
00105       fRawDigits = 0;
00106     }
00107   }
00108   return *this;
00109 }

static void RawVaTimingMonitorBlock::SetDebugFlags ( const UInt_t  dbgflgs  )  [inline, static]

Definition at line 54 of file RawVaTimingMonitorBlock.h.

References fgDebugFlags.

00054 {fgDebugFlags=dbgflgs;}


Member Data Documentation

UInt_t RawVaTimingMonitorBlock::fgDebugFlags = 0 [static, private]

not written out

Definition at line 75 of file RawVaTimingMonitorBlock.h.

Referenced by FillRawDigits(), GetDebugFlags(), and SetDebugFlags().

TObjArray* RawVaTimingMonitorBlock::fRawDigits [mutable, protected]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1