RawPedestalTableBlock Class Reference

#include <RawPedestalTableBlock.h>

Inheritance diagram for RawPedestalTableBlock:
RawDataBlock

List of all members.

Public Member Functions

 RawPedestalTableBlock ()
 RawPedestalTableBlock (const Int_t *block)
virtual ~RawPedestalTableBlock ()
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 GetPedValue (Int_t indx, RawChannelId &rcid, Int_t &value) const
Int_t GetPedValue (const RawChannelId &rcid) const
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
 RawPedestalTableBlock (const RawPedestalTableBlock &rhs)
RawPedestalTableBlockoperator= (const RawPedestalTableBlock &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 20 of file RawPedestalTableBlock.h.


Constructor & Destructor Documentation

RawPedestalTableBlock::RawPedestalTableBlock (  ) 

Definition at line 44 of file RawPedestalTableBlock.cxx.

00045    : fRawCrateStatus(0)
00046 {
00047    // Default constructor
00048 }

RawPedestalTableBlock::RawPedestalTableBlock ( const Int_t *  block  ) 

Definition at line 51 of file RawPedestalTableBlock.cxx.

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

RawPedestalTableBlock::~RawPedestalTableBlock (  )  [virtual]

Definition at line 71 of file RawPedestalTableBlock.cxx.

References fRawCrateStatus.

00072 {
00073    // dtor
00074    if (fRawCrateStatus) delete fRawCrateStatus;
00075    fRawCrateStatus = 0;
00076 }

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

Definition at line 54 of file RawPedestalTableBlock.h.

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


Member Function Documentation

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

Reimplemented from RawDataBlock.

Definition at line 90 of file RawPedestalTableBlock.cxx.

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

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

const RawCrateStatus * RawPedestalTableBlock::GetCrateStatus (  )  const

Definition at line 169 of file RawPedestalTableBlock.cxx.

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

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

00170 {
00171    // get the crate id --> status
00172    if (fRawCrateStatus) return fRawCrateStatus;
00173 
00174    if (fSize > indx_crateid) {
00175       const Int_t* crateid_ptr = fRawBlock+indx_crateid;
00176       fRawCrateStatus = new RawCrateStatus(GetBlockId(),crateid_ptr);
00177                                            
00178       return fRawCrateStatus;
00179    }
00180    return 0;
00181 }

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

Definition at line 51 of file RawPedestalTableBlock.h.

References fgDebugFlags.

00051 { return fgDebugFlags; }

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

Definition at line 34 of file RawPedestalTableBlock.h.

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

Referenced by FormatToOStream(), and GetPedValue().

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

VldTimeStamp RawPedestalTableBlock::GetLoadTime (  )  const

Definition at line 159 of file RawPedestalTableBlock.cxx.

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

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

00160 {
00161    // get the start time
00162    if (fSize >= zzzz_last) 
00163       return VldTimeStamp(fRawBlock[indx_loadsec],fRawBlock[indx_loadnsec]);
00164 
00165    return VldTimeStamp((time_t)0,(Int_t)0);
00166 }

Int_t RawPedestalTableBlock::GetNumberOfValues (  )  const

Definition at line 184 of file RawPedestalTableBlock.cxx.

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

Referenced by FormatToOStream(), GetPedValue(), and DbuDaqMonitorModule::WriteVaChipPedsEntry().

00185 {
00186    // get the number of pedestals
00187    if (fSize > indx_nvalues) return fRawBlock[indx_nvalues];
00188    return -1;
00189 }

Int_t RawPedestalTableBlock::GetPedValue ( const RawChannelId rcid  )  const

Definition at line 244 of file RawPedestalTableBlock.cxx.

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

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

void RawPedestalTableBlock::GetPedValue ( Int_t  indx,
RawChannelId rcid,
Int_t &  value 
) const

Definition at line 192 of file RawPedestalTableBlock.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::WriteVaChipPedsEntry().

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

Int_t RawPedestalTableBlock::GetRun ( void   )  const

Definition at line 135 of file RawPedestalTableBlock.cxx.

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

Referenced by FormatToOStream().

00136 {
00137    // get the run number
00138    if (fSize > indx_run) return fRawBlock[indx_run];
00139    return -1;
00140 }

Short_t RawPedestalTableBlock::GetRunType (  )  const

Definition at line 151 of file RawPedestalTableBlock.cxx.

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

Referenced by FormatToOStream().

00152 {
00153    // get the run type
00154    if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00155    return -1;
00156 }

Short_t RawPedestalTableBlock::GetSubRun (  )  const

Definition at line 143 of file RawPedestalTableBlock.cxx.

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

Referenced by FormatToOStream().

00144 {
00145    // get the subrun number
00146    if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00147    return -1;
00148 }

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

Reimplemented from RawDataBlock.

Definition at line 79 of file RawPedestalTableBlock.cxx.

References fRawCrateStatus.

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

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

Definition at line 50 of file RawPedestalTableBlock.h.

References fgDebugFlags.

00050 {fgDebugFlags=dbgflgs;}


Member Data Documentation

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

not written out

Definition at line 66 of file RawPedestalTableBlock.h.

Referenced by GetDebugFlags(), and SetDebugFlags().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1