RawDeadChipBlock Class Reference

#include <RawDeadChipBlock.h>

Inheritance diagram for RawDeadChipBlock:
RawDataBlock

List of all members.

Public Types

typedef std::set< RawChannelIdRawChannelIdSet
typedef
RawChannelIdSet::const_iterator 
RawChannelIdSetConstIter

Public Member Functions

 RawDeadChipBlock ()
 RawDeadChipBlock (const Int_t *block)
 RawDeadChipBlock (const VldContext &vldc, const RawChannelIdSet &inset)
virtual ~RawDeadChipBlock ()
UInt_t GetNumberOfEntries () const
RawChannelId GetDeadEntry (UInt_t indx) const
Bool_t ChipWasDead (const RawChannelId &rcid) const
const RawChannelIdSetGetDeadChannels () const
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
 RawDeadChipBlock (const RawDeadChipBlock &rhs)
RawDeadChipBlockoperator= (const RawDeadChipBlock &rhs)

Static Public Member Functions

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

Protected Member Functions

virtual void FillDeadChannels () const

Protected Attributes

Bool_t fUnpacked
RawChannelIdSet fDeadChannels
 not written out

Static Private Attributes

static UInt_t fgDebugFlags = 0
 not written out
static UInt_t fgStdVaChannel = 0

Detailed Description

Definition at line 20 of file RawDeadChipBlock.h.


Member Typedef Documentation

Definition at line 26 of file RawDeadChipBlock.h.

typedef RawChannelIdSet::const_iterator RawDeadChipBlock::RawChannelIdSetConstIter

Definition at line 27 of file RawDeadChipBlock.h.


Constructor & Destructor Documentation

RawDeadChipBlock::RawDeadChipBlock (  ) 

Definition at line 33 of file RawDeadChipBlock.cxx.

00033                                    : RawDataBlock(), fUnpacked(false)
00034 {
00035    // Default constructor
00036 }

RawDeadChipBlock::RawDeadChipBlock ( const Int_t *  block  ) 

Definition at line 39 of file RawDeadChipBlock.cxx.

00040    : RawDataBlock(block), fUnpacked(false)
00041 {
00042    //  stored block format is:
00043    //---------------------
00044    //  0   # words in block
00045    //  1   checksum
00046    //  2   Block Id
00047    //-----
00048    //  3      # dead chips in crate 0
00049    //  4      chad for 0th dead chip (chan=0)
00050    //  5      chad ...
00051    //  3+N0   # dead chips in crate 1
00052    //  3+N0+1 chad for 0th dead chip (chan=0)
00053    //   ...
00054 }

RawDeadChipBlock::RawDeadChipBlock ( const VldContext vldc,
const RawChannelIdSet inset 
)

Definition at line 57 of file RawDeadChipBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, RawChannelId::GetChAdd(), RawChannelId::GetCrate(), VldContext::GetDetector(), RawBlockProxy::GetMajorId(), VldContext::GetSimFlag(), RawBlockRegistry::Instance(), RawBlockProxy::IsDCS(), RawBlockRegistry::LookUp(), and rdxsum_fill().

00059    : RawDataBlock(), fUnpacked(false)
00060 {
00061    // create a RawDeadChipBlock from a list of RawChannelId's
00062 
00063    // find crate # of last element (assume sorted by set)
00064    Int_t ncrates = 0;
00065    Int_t *crate_count = 0;
00066    if (inset.size()>0) {
00067       RawChannelId rcid_last = *inset.rbegin();
00068       ncrates = rcid_last.GetCrate() + 1;  // crate numbering starts at 0
00069       // build list of how many entries for each crate
00070       crate_count = new Int_t [ncrates];
00071       for (int i=0; i<ncrates; i++) crate_count[i] = 0;
00072       RawChannelIdSetConstIter iter = inset.begin();
00073       while (iter != inset.end()) {
00074          RawChannelId rcid = *iter;
00075          crate_count[rcid.GetCrate()] += 1;
00076          iter++;
00077       }
00078    }
00079    // 3 words of header + count for each crate (no skips) + # of chips
00080    fSize = 3 + ncrates + inset.size();
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("RawDeadChipBlock");
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.GetDetector(),vldc.GetSimFlag());
00095    fRawBlock[2] = rbid.GetEncoded();
00096 
00097    Int_t *p = fRawBlock + 3;
00098    Int_t this_crate = -1;
00099    RawChannelIdSetConstIter iter = inset.begin();
00100    while (iter != inset.end()) {
00101       RawChannelId rcid = *iter;
00102       while (this_crate != rcid.GetCrate()) {
00103          this_crate++;
00104          *p = crate_count[this_crate];
00105          p++;
00106       }
00107       *p = rcid.GetChAdd();
00108       p++;
00109       iter++;
00110    }
00111 
00112 
00113    // fill checksum
00114    rdxsum_fill((int32_t*)fRawBlock,0);
00115    
00116    // delete temporary
00117    delete crate_count;
00118 }

RawDeadChipBlock::~RawDeadChipBlock (  )  [virtual]

Definition at line 121 of file RawDeadChipBlock.cxx.

00122 {
00123    // dtor
00124 }

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

Definition at line 47 of file RawDeadChipBlock.h.

References fDeadChannels.

00048      : RawDataBlock(rhs), fUnpacked(false) { fDeadChannels.clear(); }


Member Function Documentation

Bool_t RawDeadChipBlock::ChipWasDead ( const RawChannelId rcid  )  const

Definition at line 188 of file RawDeadChipBlock.cxx.

References RawChannelId::ClearModeBits(), fDeadChannels, fgStdVaChannel, FillDeadChannels(), and RawChannelId::SetVaChannel().

00189 { 
00190    // look up whether chip was registered as dead
00191    FillDeadChannels();
00192 
00193    // table was built with {pedestal,spars,common} mode bits off
00194    RawChannelId rcid0 = rcid;
00195    rcid0.ClearModeBits();   // standardize mode bits
00196    // only one entry for every va *chip* so vachannel is irrelevant
00197    // but standardize it so that lookup can proceed
00198    rcid0.SetVaChannel(fgStdVaChannel);
00199 
00200    return fDeadChannels.end() != fDeadChannels.find(rcid0); 
00201 }

void RawDeadChipBlock::FillDeadChannels (  )  const [protected, virtual]

Definition at line 159 of file RawDeadChipBlock.cxx.

References RawChannelId::ClearModeBits(), det, fDeadChannels, fgStdVaChannel, RawDataBlock::fRawBlock, RawDataBlock::fSize, fUnpacked, RawDataBlock::GetBlockId(), RawBlockId::GetDetector(), ElecType::kVA, RawChannelId::SetVaChannel(), and zzzz_last.

Referenced by ChipWasDead(), GetDeadChannels(), and GetNumberOfEntries().

00160 {
00161    // unpack the data into a STL set of RawChannelId's
00162 
00163    if (fUnpacked) return;
00164 
00165    Detector::Detector_t det = GetBlockId().GetDetector();
00166    // assume this block is only sensible for VA electronics
00167    ElecType::Elec_t elec = ElecType::kVA;
00168 
00169    Int_t  crate = -1;
00170    Int_t* ptr = fRawBlock+zzzz_last;
00171    while (ptr < fRawBlock+fSize) {
00172       // start of new crate
00173       crate++;
00174       int ndead = *ptr; ptr++;
00175       for (int i=0; i<ndead; i++) {
00176          Int_t chad = *ptr; ptr++;
00177          RawChannelId rcid0(det,elec,crate,chad);
00178          rcid0.ClearModeBits();   // standardize mode bits
00179          // only one entry for every va *chip* so vachannel is irrelevant
00180          // but standardize it so that lookup can proceed
00181          rcid0.SetVaChannel(fgStdVaChannel);
00182          fDeadChannels.insert(rcid0);
00183       }
00184    }
00185 }

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

Reimplemented from RawDataBlock.

const std::set< RawChannelId > & RawDeadChipBlock::GetDeadChannels (  )  const [inline]

Definition at line 76 of file RawDeadChipBlock.h.

References fDeadChannels, and FillDeadChannels().

Referenced by GetDeadEntry().

00077 { FillDeadChannels(); return fDeadChannels; }

RawChannelId RawDeadChipBlock::GetDeadEntry ( UInt_t  indx  )  const [inline]

Definition at line 79 of file RawDeadChipBlock.h.

References GetDeadChannels(), and GetNumberOfEntries().

00080 {
00081    if ( indx > GetNumberOfEntries() ) return RawChannelId();
00082    RawChannelIdSetConstIter iter = GetDeadChannels().begin();
00083    for (UInt_t i=0; i<indx; i++) iter++;
00084    return *iter;
00085 }

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

Definition at line 44 of file RawDeadChipBlock.h.

References fgDebugFlags.

00044 { return fgDebugFlags; }

UInt_t RawDeadChipBlock::GetNumberOfEntries (  )  const [inline]
RawDeadChipBlock & RawDeadChipBlock::operator= ( const RawDeadChipBlock rhs  ) 

Reimplemented from RawDataBlock.

Definition at line 127 of file RawDeadChipBlock.cxx.

References fDeadChannels, and fUnpacked.

00128 {
00129    // deep copy assignment 
00130    if (this != &rhs) {
00131      RawDataBlock::operator=(rhs);
00132      // clear the unpacked info to allow it to be re-filled
00133      fUnpacked = false;
00134      fDeadChannels.clear();
00135    }
00136    return *this;
00137 }

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

Definition at line 43 of file RawDeadChipBlock.h.

References fgDebugFlags.

00043 {fgDebugFlags=dbgflgs;}


Member Data Documentation

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

not written out

Definition at line 64 of file RawDeadChipBlock.h.

Referenced by GetDebugFlags(), and SetDebugFlags().

UInt_t RawDeadChipBlock::fgStdVaChannel = 0 [static, private]

Definition at line 68 of file RawDeadChipBlock.h.

Referenced by ChipWasDead(), and FillDeadChannels().

Bool_t RawDeadChipBlock::fUnpacked [mutable, protected]

Definition at line 58 of file RawDeadChipBlock.h.

Referenced by FillDeadChannels(), and operator=().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1