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 44 of file ErrorChecker.cc.

                           {

  includeErrors = false;
}

Member Function Documentation

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

Definition at line 54 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 67 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 111 of file ErrorChecker.cc.

References error, ERROR_mask, LogDebug, 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;
     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 85 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 161 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 209 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  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  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 49 of file ErrorChecker.cc.

Referenced by PixelDataFormatter::setErrorStatus().

{
  includeErrors = ErrorStatus;
}

Member Data Documentation

Definition at line 46 of file ErrorChecker.h.