CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

ErrorChecker Class Reference

#include <ErrorChecker.h>

List of all members.

Public Types

typedef std::vector
< SiPixelRawDataError
DetErrors
typedef std::map< uint32_t,
DetErrors
Errors
typedef uint32_t Word32
typedef uint64_t Word64

Public Member Functions

bool checkCRC (bool &errorsInEvent, int fedId, const Word64 *trailer, Errors &errors)
bool checkHeader (bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors)
bool checkROC (bool &errorsInEvent, int fedId, const SiPixelFrameConverter *converter, Word32 &errorWord, Errors &errors)
bool checkTrailer (bool &errorsInEvent, int fedId, int nWords, const Word64 *trailer, Errors &errors)
void conversionError (int fedId, const SiPixelFrameConverter *converter, int status, Word32 &errorWord, Errors &errors)
 ErrorChecker ()
void setErrorStatus (bool ErrorStatus)

Private Member Functions

uint32_t errorDetId (const SiPixelFrameConverter *converter, int errorType, const Word32 &word) const

Private Attributes

bool includeErrors

Detailed Description

Definition at line 18 of file ErrorChecker.h.


Member Typedef Documentation

Definition at line 26 of file ErrorChecker.h.

typedef std::map<uint32_t, DetErrors> ErrorChecker::Errors

Definition at line 27 of file ErrorChecker.h.

typedef uint32_t ErrorChecker::Word32

Definition at line 23 of file ErrorChecker.h.

typedef uint64_t ErrorChecker::Word64

Definition at line 24 of file ErrorChecker.h.


Constructor & Destructor Documentation

ErrorChecker::ErrorChecker ( )

Definition at line 46 of file ErrorChecker.cc.

                           {

  includeErrors = false;
}

Member Function Documentation

bool ErrorChecker::checkCRC ( bool &  errorsInEvent,
int  fedId,
const Word64 trailer,
Errors errors 
)

Definition at line 56 of file ErrorChecker.cc.

References CRC_mask, CRC_shift, dummyDetId, and error.

Referenced by PixelDataFormatter::interpretRawData().

{
  int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask;
  if (CRC_BIT == 0) return true;
  errorsInEvent = true;
  if (includeErrors) {
    int errorType = 39;
    SiPixelRawDataError error(*trailer, errorType, fedId);
    errors[dummyDetId].push_back(error);
  }
  return false;
}
bool ErrorChecker::checkHeader ( bool &  errorsInEvent,
int  fedId,
const Word64 header,
Errors errors 
)

Definition at line 69 of file ErrorChecker.cc.

References FEDHeader::check(), dummyDetId, error, LogDebug, FEDHeader::moreHeaders(), and FEDHeader::sourceID().

Referenced by PixelDataFormatter::interpretRawData().

{
  FEDHeader fedHeader( reinterpret_cast<const unsigned char*>(header));
  if ( !fedHeader.check() ) return false; // throw exception?
  if ( fedHeader.sourceID() != fedId) { 
    LogDebug("PixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId")
      <<", sourceID = " <<fedHeader.sourceID()
      <<", fedId = "<<fedId<<", errorType = 32"; 
    errorsInEvent = true;
    if (includeErrors) {
      int errorType = 32;
      SiPixelRawDataError error(*header, errorType, fedId);
      errors[dummyDetId].push_back(error);
    }
  }
  return fedHeader.moreHeaders();
}
bool ErrorChecker::checkROC ( bool &  errorsInEvent,
int  fedId,
const SiPixelFrameConverter converter,
Word32 errorWord,
Errors errors 
)

Definition at line 113 of file ErrorChecker.cc.

References error, ERROR_mask, LogDebug, OMIT_ERR_mask, OMIT_ERR_shift, and ROC_shift.

Referenced by PixelDataFormatter::interpretRawData().

{
 int errorType = (errorWord >> ROC_shift) & ERROR_mask;

 switch (errorType) {
    case(25) : {
     LogDebug("")<<"  invalid ROC=25 found (errorType=25)";
     errorsInEvent = true;
     break;
   }
   case(26) : {
     //LogDebug("")<<"  gap word found (errorType=26)";
     return false;
   }
   case(27) : {
     //LogDebug("")<<"  dummy word found (errorType=27)";
     return false;
   }
   case(28) : {
     LogDebug("")<<"  error fifo nearly full (errorType=28)";
     errorsInEvent = true;
     break;
   }
   case(29) : {
     LogDebug("")<<"  timeout on a channel (errorType=29)";
     errorsInEvent = true;
     if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) {
       LogDebug("")<<"  ...first errorType=29 error, this gets masked out";
       return false;
     }
     break;
   }
   case(30) : {
     LogDebug("")<<"  TBM error trailer (errorType=30)";
     errorsInEvent = true;
     break;
   }
   case(31) : {
     LogDebug("")<<"  event number error (errorType=31)";
     errorsInEvent = true;
     break;
   }
   default: return true;
 };

 if(includeErrors) {
   SiPixelRawDataError error(errorWord, errorType, fedId);
   uint32_t detId;
   detId = errorDetId(converter, errorType, errorWord);
   errors[detId].push_back(error);
 }
 return false;
}
bool ErrorChecker::checkTrailer ( bool &  errorsInEvent,
int  fedId,
int  nWords,
const Word64 trailer,
Errors errors 
)

Definition at line 87 of file ErrorChecker.cc.

References FEDTrailer::check(), dummyDetId, error, FEDTrailer::lenght(), and FEDTrailer::moreTrailers().

Referenced by PixelDataFormatter::interpretRawData().

{
  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
  if ( !fedTrailer.check()) { 
    if(includeErrors) {
      int errorType = 33;
      SiPixelRawDataError error(*trailer, errorType, fedId);
      errors[dummyDetId].push_back(error);
    }
    errorsInEvent = true;
    LogError("PixelDataFormatter::interpretRawData, fedTrailer.check: ")
      <<"fedTrailer.check failed, Fed: " << fedId << ", errorType = 33";
    return false; 
  } 
  if ( fedTrailer.lenght()!= nWords) {
    LogError("PROBLEM in PixelDataFormatter,  fedTrailer.lenght()!= nWords !!")<< " Fed: " << fedId << ", errorType = 34";
    errorsInEvent = true;
    if(includeErrors) {
      int errorType = 34;
      SiPixelRawDataError error(*trailer, errorType, fedId);
      errors[dummyDetId].push_back(error);
    }
  }
  return fedTrailer.moreTrailers();
}
void ErrorChecker::conversionError ( int  fedId,
const SiPixelFrameConverter converter,
int  status,
Word32 errorWord,
Errors errors 
)

Definition at line 167 of file ErrorChecker.cc.

References error, LogDebug, and ntuplemaker::status.

Referenced by PixelDataFormatter::interpretRawData().

{
  switch (status) {
  case(1) : {
    LogDebug("ErrorChecker::conversionError") << " Fed: " << fedId << "  invalid channel Id (errorType=35)";
    if(includeErrors) {
      int errorType = 35;
      SiPixelRawDataError error(errorWord, errorType, fedId);
      uint32_t detId = errorDetId(converter, errorType, errorWord);
      errors[detId].push_back(error);
    }
    break;
  }
  case(2) : {
    LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << "  invalid ROC Id (errorType=36)";
    if(includeErrors) {
      int errorType = 36;
      SiPixelRawDataError error(errorWord, errorType, fedId);
      uint32_t detId = errorDetId(converter, errorType, errorWord);
      errors[detId].push_back(error);
    }
    break;
  }
  case(3) : {
    LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << "  invalid dcol/pixel value (errorType=37)";
    if(includeErrors) {
      int errorType = 37;
      SiPixelRawDataError error(errorWord, errorType, fedId);
      uint32_t detId = errorDetId(converter, errorType, errorWord);
      errors[detId].push_back(error);
    }
    break;
  }
  case(4) : {
    LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << "  dcol/pixel read out of order (errorType=38)";
    if(includeErrors) {
      int errorType = 38;
      SiPixelRawDataError error(errorWord, errorType, fedId);
      uint32_t detId = errorDetId(converter, errorType, errorWord);
      errors[detId].push_back(error);
    }
    break;
  }
  default: LogDebug("ErrorChecker::conversionError")<<"  cabling check returned unexpected result, status = "<< status;
  };
}
uint32_t ErrorChecker::errorDetId ( const SiPixelFrameConverter converter,
int  errorType,
const Word32 word 
) const [private]

Definition at line 215 of file ErrorChecker.cc.

References sipixelobjects::ElectronicIndex::dcol, dummyDetId, sipixelobjects::ElectronicIndex::link, LINK_mask, LINK_shift, GeomDetEnumerators::PixelBarrel, sipixelobjects::ElectronicIndex::pxid, sipixelobjects::DetectorIndex::rawId, sipixelobjects::ElectronicIndex::roc, ROC_mask, ROC_shift, ntuplemaker::status, DetId::subdetId(), and SiPixelFrameConverter::toDetector().

{
  if (!converter) return dummyDetId;

  ElectronicIndex cabling;

  switch (errorType) {
    case  25 : case  30 : case  31 : case  36 : {
      // set dummy values for cabling just to get detId from link if in Barrel
      cabling.dcol = 0;
      cabling.pxid = 2;
      cabling.roc  = 1;
      cabling.link = (word >> LINK_shift) & LINK_mask;  

      DetectorIndex detIdx;
      int status = converter->toDetector(cabling, detIdx);
      if (status) break;
      if(DetId(detIdx.rawId).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) return detIdx.rawId;
      break;
    }
    case  29 : {
      int chanNmbr = 0;
      const int DB0_shift = 0;
      const int DB1_shift = DB0_shift + 1;
      const int DB2_shift = DB1_shift + 1;
      const int DB3_shift = DB2_shift + 1;
      const int DB4_shift = DB3_shift + 1;
      const uint32_t DataBit_mask = ~(~uint32_t(0) << 1);

      int CH1 = (word >> DB0_shift) & DataBit_mask;
      int CH2 = (word >> DB1_shift) & DataBit_mask;
      int CH3 = (word >> DB2_shift) & DataBit_mask;
      int CH4 = (word >> DB3_shift) & DataBit_mask;
      int CH5 = (word >> DB4_shift) & DataBit_mask;
      int BLOCK_bits      = 3;
      int BLOCK_shift     = 8;
      uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
      int BLOCK = (word >> BLOCK_shift) & BLOCK_mask;
      int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
      if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
      else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
      if ((chanNmbr<1)||(chanNmbr>36)) break;  // signifies unexpected result
      
      // set dummy values for cabling just to get detId from link if in Barrel
      cabling.dcol = 0;
      cabling.pxid = 2;
      cabling.roc  = 1;
      cabling.link = chanNmbr;  
      DetectorIndex detIdx;
      int status = converter->toDetector(cabling, detIdx);
      if (status) break;
      if(DetId(detIdx.rawId).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) return detIdx.rawId;
      break;
    }
    case  37 : case  38: {
      cabling.dcol = 0;
      cabling.pxid = 2;
      cabling.roc  = (word >> ROC_shift) & ROC_mask;
      cabling.link = (word >> LINK_shift) & LINK_mask;

      DetectorIndex detIdx;
      int status = converter->toDetector(cabling, detIdx);
      if (status) break;

      return detIdx.rawId;
      break;
    }
  default : break;
  };
  return dummyDetId;
}
void ErrorChecker::setErrorStatus ( bool  ErrorStatus)

Definition at line 51 of file ErrorChecker.cc.

Referenced by PixelDataFormatter::setErrorStatus().

{
  includeErrors = ErrorStatus;
}

Member Data Documentation

Definition at line 46 of file ErrorChecker.h.