RawSparsifierTableBlock Class Reference

#include <RawSparsifierTableBlock.h>

Inheritance diagram for RawSparsifierTableBlock:
RawDataBlock

List of all members.

Public Member Functions

 RawSparsifierTableBlock ()
 RawSparsifierTableBlock (const Int_t *block)
virtual ~RawSparsifierTableBlock ()
Int_t GetRun () const
Short_t GetSubRun () const
Short_t GetRunType () const
VldTimeStamp GetLoadTime () const
const RawCrateStatusGetCrateStatus () const
ElecType::Elec_t GetElecType () const
Int_t GetNumberOfValues () const
void GetThresholdValue (Int_t indx, RawChannelId &rcid, Int_t &value) const
Int_t GetThresholdValue (const RawChannelId &rcid) const
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
 RawSparsifierTableBlock (const RawSparsifierTableBlock &rhs)
RawSparsifierTableBlockoperator= (const RawSparsifierTableBlock &rhs)

Static Public Member Functions

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

Protected Attributes

RawCrateStatusfRawCrateStatus

Static Private Attributes

static UInt_t fgDebugFlags = 0
 not written out

Detailed Description

Definition at line 21 of file RawSparsifierTableBlock.h.


Constructor & Destructor Documentation

RawSparsifierTableBlock::RawSparsifierTableBlock (  ) 

Definition at line 47 of file RawSparsifierTableBlock.cxx.

00048    : fRawCrateStatus(0)
00049 {
00050    // Default constructor
00051 }

RawSparsifierTableBlock::RawSparsifierTableBlock ( const Int_t *  block  ) 

Definition at line 54 of file RawSparsifierTableBlock.cxx.

00055    : RawDataBlock(block), fRawCrateStatus(0)
00056 {
00057    //  stored block format is:
00058    //---------------------
00059    //  0   # words in block
00060    //  1   checksum
00061    //  2   Block Id
00062    //-----
00063    //  3   Run Number
00064    //  4   SubRun | RunType
00065    //  5   Load Time (sec)
00066    //  6   Load Time (ns)
00067    //  7   CrateId (+ special bits)
00068    //  8   # of pedestals to follow
00069    //  ... packed two entries per 32-bit word
00070    //      varc [0..2] vmm [0..5] adcsel [0..1] chip [0..2] channel [0..21]
00071 }

RawSparsifierTableBlock::~RawSparsifierTableBlock (  )  [virtual]

Definition at line 74 of file RawSparsifierTableBlock.cxx.

References fRawCrateStatus.

00075 {
00076    // dtor
00077    if (fRawCrateStatus) delete fRawCrateStatus;
00078    fRawCrateStatus = 0;
00079 }

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

Definition at line 55 of file RawSparsifierTableBlock.h.

00056      : RawDataBlock(rhs), fRawCrateStatus(0) { ; }


Member Function Documentation

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

Reimplemented from RawDataBlock.

Definition at line 93 of file RawSparsifierTableBlock.cxx.

References bfld::AsString(), RawChannelId::AsString(), VldTimeStamp::AsString(), fgDebugFlags, GetCrateStatus(), GetElecType(), GetLoadTime(), GetNumberOfValues(), GetRun(), GetRunType(), GetSubRun(), GetThresholdValue(), kdbg_ForceHexDump, ElecType::kQIE, ElecType::kVA, Msg::kWarning, and MSG.

00095 {
00096 
00097    if (fgDebugFlags & kdbg_ForceHexDump) option = "x";
00098 
00099    RawDataBlock::FormatToOStream(os,option);
00100    if (option[0] == 'X') return os;
00101    
00102    // additional block specific formatted output is done here
00103 
00104    os << " Loaded " << GetLoadTime().AsString("c") << endl;
00105    os << " Run " << GetRun() 
00106       << " SubRun " << GetSubRun() 
00107       << " RunType " << GetRunType() << endl; 
00108    os << " " << *GetCrateStatus();
00109    os << " " << GetNumberOfValues() << " pedestal values" << endl;
00110 
00111    if (strchr(option,'q') != 0) return os;
00112 
00113    Int_t  indx, value;
00114    RawChannelId rcid;
00115 
00116    switch (GetElecType()) {
00117    case (ElecType::kVA): {
00118       for (indx=0; indx<GetNumberOfValues(); indx++) {
00119          GetThresholdValue(indx,rcid,value);
00120 //test alternative lookup method
00121 //         Int_t value2 = GetThresholdValue(rcid);
00122          os << "   [" << setw(4) << indx << "] " 
00123             << rcid.AsString("e") << " := " << setw(5) << value 
00124 //test alternative lookup method
00125 //              << ((value != value2) ? " bad indexind " : " lookup ok")
00126             << endl;
00127       }
00128       break;
00129    }
00130    case (ElecType::kQIE):
00131       // not yet implemented ... fall through
00132    default:
00133       MSG("RawData",Msg::kWarning)
00134          << "Print not implemented for electronics type "
00135          << ElecType::AsString(GetElecType()) << endl;
00136    }
00137 
00138    return os;
00139 }

const RawCrateStatus * RawSparsifierTableBlock::GetCrateStatus (  )  const

Definition at line 176 of file RawSparsifierTableBlock.cxx.

References RawDataBlock::fRawBlock, fRawCrateStatus, RawDataBlock::fSize, RawDataBlock::GetBlockId(), and indx_crateid.

Referenced by FormatToOStream(), GetElecType(), and DbuDaqMonitorModule::WriteVaChipSparsEntry().

00177 {
00178    // get the crate id --> status
00179    if (fRawCrateStatus) return fRawCrateStatus;
00180 
00181    if (fSize > indx_crateid) {
00182       const Int_t* crateid_ptr = fRawBlock+indx_crateid;
00183       fRawCrateStatus = new RawCrateStatus(GetBlockId(),crateid_ptr);
00184                                            
00185       return fRawCrateStatus;
00186    }
00187    return 0;
00188 }

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

Definition at line 52 of file RawSparsifierTableBlock.h.

References fgDebugFlags.

00052 { return fgDebugFlags; }

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

Definition at line 35 of file RawSparsifierTableBlock.h.

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

Referenced by FormatToOStream(), and GetThresholdValue().

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

VldTimeStamp RawSparsifierTableBlock::GetLoadTime (  )  const

Definition at line 166 of file RawSparsifierTableBlock.cxx.

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

Referenced by FormatToOStream(), and DbuDaqMonitorModule::WriteVaChipSparsEntry().

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

Int_t RawSparsifierTableBlock::GetNumberOfValues (  )  const

Definition at line 191 of file RawSparsifierTableBlock.cxx.

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

Referenced by FormatToOStream(), GetThresholdValue(), and DbuDaqMonitorModule::WriteVaChipSparsEntry().

00192 {
00193    // get the number of pedestals
00194    if (fSize > indx_nvalues) return fRawBlock[indx_nvalues];
00195    return -1;
00196 }

Int_t RawSparsifierTableBlock::GetRun ( void   )  const

Definition at line 142 of file RawSparsifierTableBlock.cxx.

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

Referenced by FormatToOStream().

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

Short_t RawSparsifierTableBlock::GetRunType (  )  const

Definition at line 158 of file RawSparsifierTableBlock.cxx.

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

Referenced by FormatToOStream().

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

Short_t RawSparsifierTableBlock::GetSubRun (  )  const

Definition at line 150 of file RawSparsifierTableBlock.cxx.

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

Referenced by FormatToOStream().

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

Int_t RawSparsifierTableBlock::GetThresholdValue ( const RawChannelId rcid  )  const

Definition at line 250 of file RawSparsifierTableBlock.cxx.

References bfld::AsString(), RawDataBlock::fRawBlock, fRawCrateStatus, RawDataBlock::GetBlockId(), RawChannelId::GetCrate(), RawCrateStatus::GetCrate(), GetElecType(), RawChannelId::GetElecType(), RawCrateStatus::GetElecType(), GetNumberOfValues(), RawChannelId::GetVaAdcSel(), RawChannelId::GetVaChannel(), RawChannelId::GetVaChip(), RawChannelId::GetVarcId(), RawChannelId::GetVmm(), ElecType::kQIE, ElecType::kVA, Msg::kWarning, MSG, and zzzz_last.

00251 {
00252    Int_t indx = -1;
00253 
00254    RawBlockId rbid = GetBlockId();
00255 
00256    const Int_t kBadValue = -1;
00257 
00258    if (GetElecType() != rcid.GetElecType()) {
00259       MSG("RawData",Msg::kWarning)
00260          << "RawChannelId " << rcid 
00261          << " does not match ElecType of crate "
00262          << ElecType::AsString(fRawCrateStatus->GetElecType())
00263          << endl;
00264       return kBadValue;
00265    }
00266 
00267    if (fRawCrateStatus->GetCrate() != rcid.GetCrate()) {
00268       MSG("RawData",Msg::kWarning)
00269          << "RawChannelId " << rcid 
00270          << " does not match of crate # of table "
00271          << fRawCrateStatus->GetCrate()
00272          << endl;
00273       return kBadValue;
00274    }
00275 
00276    switch (GetElecType()) {
00277    case (ElecType::kVA): {
00278       // VA electronics
00279       // packed varc[0..2] XYZZY[0..12] chip[0..2] chann[0..21]
00280       Int_t vachan = rcid.GetVaChannel();
00281       Int_t vachip = rcid.GetVaChip();
00282       Int_t adcsel = rcid.GetVaAdcSel();
00283       Int_t vmm    = rcid.GetVmm();
00284       Int_t varc   = rcid.GetVarcId();
00285       Int_t xyzzy    = (vmm<<1) + adcsel;
00286       indx = (((varc)*12 + xyzzy)*3 + vachip)*22 + vachan;
00287 
00288       if (indx<0 || indx> GetNumberOfValues()) {
00289          MSG("RawData",Msg::kWarning)
00290             << "calulated index out of range "
00291             << indx << " (max " << GetNumberOfValues() << ")" << endl;
00292             return kBadValue;
00293       }
00294       
00295       Int_t offset = indx/2;
00296       if (indx&1) {
00297          // odd indices == lower half of word
00298          return fRawBlock[zzzz_last+offset] & 0xffff;
00299       }
00300       else {
00301          // even indices == upper half of word
00302          return (fRawBlock[zzzz_last+offset] >> 16) & 0xffff;
00303       }
00304     
00305       return kBadValue;
00306       break;
00307    }
00308    case (ElecType::kQIE):
00309       // not yet implemented ... fall through
00310    default:
00311       MSG("RawData",Msg::kWarning)
00312          << "GetThresholdValue not implemented for electronics type "
00313          << ElecType::AsString(GetElecType()) << endl;
00314       return kBadValue;
00315       break;
00316    }
00317 
00318    return kBadValue;
00319 
00320 }

void RawSparsifierTableBlock::GetThresholdValue ( Int_t  indx,
RawChannelId rcid,
Int_t &  value 
) const

Definition at line 199 of file RawSparsifierTableBlock.cxx.

References bfld::AsString(), RawDataBlock::fRawBlock, fRawCrateStatus, RawDataBlock::GetBlockId(), RawCrateStatus::GetCommonMode(), RawCrateStatus::GetCrate(), RawBlockId::GetDetector(), GetElecType(), RawCrateStatus::GetElecType(), GetNumberOfValues(), RawCrateStatus::GetPedMode(), RawCrateStatus::GetSparsMode(), ElecType::kQIE, ElecType::kVA, Msg::kWarning, MSG, RawChannelId::SetModeBits(), and zzzz_last.

Referenced by FormatToOStream(), and DbuDaqMonitorModule::WriteVaChipSparsEntry().

00201 {
00202    if (indx >= GetNumberOfValues()) {
00203       rcid  = RawChannelId();
00204       value = -1;
00205       return;
00206    }
00207 
00208    RawBlockId rbid = GetBlockId();
00209 
00210    switch (GetElecType()) {
00211    case (ElecType::kVA): {
00212       // VA electronics
00213       // packed varc[0..2] XYZZY[0..12] chip[0..2] chann[0..21]
00214       Int_t tmp = indx;
00215       Int_t vachan = tmp%22;  tmp /= 22;
00216       Int_t vachip = tmp%3;   tmp /= 3;
00217       Int_t xyzzy  = tmp%12;  tmp /= 12;  
00218       Int_t adcsel = xyzzy&1;
00219       Int_t vmm    = xyzzy>>1;
00220       Int_t varc   = tmp%3;   tmp /= 3;
00221 
00222       rcid = RawChannelId(rbid.GetDetector(),
00223                           fRawCrateStatus->GetElecType(),
00224                           fRawCrateStatus->GetCrate(),
00225                           varc,vmm,adcsel,vachip,vachan);
00226       rcid.SetModeBits(fRawCrateStatus->GetCommonMode(),
00227                        fRawCrateStatus->GetSparsMode(),
00228                        fRawCrateStatus->GetPedMode());
00229       Int_t offset = indx/2;
00230       if (indx&1) {
00231          // odd indices == lower half of word
00232          value = fRawBlock[zzzz_last+offset] & 0xffff;
00233       }
00234       else {
00235          // even indices == upper half of word
00236          value = (fRawBlock[zzzz_last+offset] >> 16) & 0xffff;
00237       }
00238       break;
00239    }
00240    case (ElecType::kQIE):
00241       // not yet implemented ... fall through
00242    default:
00243       MSG("RawData",Msg::kWarning)
00244          << "GetThresholdValue not implemented for electronics type "
00245          << ElecType::AsString(GetElecType()) << endl;
00246    }
00247    }

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

Reimplemented from RawDataBlock.

Definition at line 82 of file RawSparsifierTableBlock.cxx.

References fRawCrateStatus.

00083 {
00084    // deep copy assignment 
00085   if (this != &rhs) {
00086     RawDataBlock::operator=(rhs);
00087     if (fRawCrateStatus) { delete fRawCrateStatus; fRawCrateStatus = 0; }
00088   }
00089   return *this;
00090 }

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

Definition at line 51 of file RawSparsifierTableBlock.h.

References fgDebugFlags.

00051 {fgDebugFlags=dbgflgs;}


Member Data Documentation

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

not written out

Definition at line 67 of file RawSparsifierTableBlock.h.

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


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1