FACT++  1.0
bool checkRoiConsistency ( const READ_STRUCT rd,
uint16_t  roi[] 
)

Definition at line 515 of file EventBuilder.cc.

References factPrintf(), MessageImp::kError, MessageImp::kFatal, and READ_STRUCT::S.

Referenced by mBufEvt().

516 {
517  int xjr = -1;
518  int xkr = -1;
519 
520  //points to the very first roi
521  int roiPtr = sizeof(PEVNT_HEADER)/2 + 2;
522 
523  roi[0] = ntohs(rd.S[roiPtr]);
524 
525  for (int jr = 0; jr < 9; jr++)
526  {
527  roi[jr] = ntohs(rd.S[roiPtr]);
528 
529  if (roi[jr]>1024)
530  {
531  factPrintf(MessageImp::kError, "Illegal roi in channel %d (allowed: roi<=1024)", jr, roi[jr]);
532  return false;
533  }
534 
535  // Check that the roi of pixels jr are compatible with the one of pixel 0
536  if (jr!=8 && roi[jr]!=roi[0])
537  {
538  xjr = jr;
539  break;
540  }
541 
542  // Check that the roi of all other DRS chips on boards are compatible
543  for (int kr = 1; kr < 4; kr++)
544  {
545  const int kroi = ntohs(rd.S[roiPtr]);
546  if (kroi != roi[jr])
547  {
548  xjr = jr;
549  xkr = kr;
550  break;
551  }
552  roiPtr += kroi+4;
553  }
554  }
555 
556  if (xjr>=0)
557  {
558  if (xkr<0)
559  factPrintf(MessageImp::kFatal, "Inconsistent Roi accross chips [DRS=%d], expected %d, got %d", xjr, roi[0], roi[xjr]);
560  else
561  factPrintf(MessageImp::kFatal, "Inconsistent Roi accross channels [DRS=%d Ch=%d], expected %d, got %d", xjr, xkr, roi[xjr], ntohs(rd.S[roiPtr]));
562 
563  return false;
564  }
565 
566  if (roi[8] < roi[0])
567  {
568  factPrintf(MessageImp::kError, "Mismatch of roi (%d) in channel 8. Should be larger or equal than the roi (%d) in channel 0.", roi[8], roi[0]);
569  return false;
570  }
571 
572  return true;
573 }
void factPrintf(int severity, const char *fmt,...)
uint16_t S[MAX_LEN/2]
Error, something unexpected happened, but can still be handled by the program.
Definition: MessageImp.h:19
An error which cannot be handled at all happend, the only solution is program termination.
Definition: MessageImp.h:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function: