FACT++  1.0
bool EventBuilderWrapper::eventCheck ( const EVT_CTRL2 evt)
inline

Definition at line 841 of file EventBuilderWrapper.h.

References end, MessageImp::Error(), EVT_CTRL2::FADhead, EVT_CTRL2::fEvent, i, kFileClosed, EVT_CTRL2::runCtrl, and EVT_CTRL2::time.

Referenced by eventCheck().

842  {
843  const EVENT *event = evt.fEvent;
844 
845  const Time tm(evt.time);
846 
847  const array<uint16_t,2> roi = {{ event->Roi, event->RoiTM }};
848 
849  if (roi!=fVecRoi)
850  {
851  fQueueRoi.emplace(tm, roi);
852  fVecRoi = roi;
853  }
854 
855  const FAD::EventHeader *beg = reinterpret_cast<const FAD::EventHeader*>(evt.FADhead);
856  const FAD::EventHeader *end = reinterpret_cast<const FAD::EventHeader*>(evt.FADhead)+40;
857 
858  // FIMXE: Compare with target configuration
859 
860  // Copy data to array
861  array<uint32_t,40> clk;
862  array<int16_t,160> tmp;
863 
864  for (int i=0; i<40; i++)
865  clk[i] = UINT32_MAX;
866 
867  for (int i=0; i<160; i++)
868  tmp[i] = INT16_MIN;
869 
870  //fill(clk.data(), clk.data()+ 40, UINT32_MAX);
871  //fill(tmp.data(), tmp.data()+160, INT16_MIN);
872 
873  for (const FAD::EventHeader *ptr=beg; ptr!=end; ptr++)
874  {
875  // FIXME: Compare with expectations!!!
876  if (ptr->fStartDelimiter==0)
877  {
878  if (ptr==beg)
879  beg++;
880  continue;
881  }
882 
883  clk[ptr->Id()] = ptr->fFreqRefClock;
884  for (int i=0; i<4; i++)
885  tmp[ptr->Id()*4+i] = ptr->fTempDrs[i];
886 
887  if (beg->fStatus != ptr->fStatus)
888  {
889  fMsg.Error("Inconsistency in FAD status detected.... closing run.");
890  return false;
891  }
892 
893  if (beg->fRunNumber != ptr->fRunNumber)
894  {
895  fMsg.Error("Inconsistent run number detected.... closing run.");
896  return false;
897  }
898 
899  /*
900  if (beg->fVersion != ptr->fVersion)
901  {
902  Error("Inconsist firmware version detected.... closing run.");
903  CloseRunFile(runNr, 0, 0);
904  break;
905  }
906  */
907  if (beg->fEventCounter != ptr->fEventCounter)
908  {
909  fMsg.Error("Inconsistent FAD event number detected.... closing run.");
910  return false;
911  }
912 
913  if (beg->fTriggerCounter != ptr->fTriggerCounter)
914  {
915  fMsg.Error("Inconsistent FTM trigger number detected.... closing run.");
916  return false;
917  }
918 
919  // FIXME: Check with first event!
920  if (beg->fAdcClockPhaseShift != ptr->fAdcClockPhaseShift)
921  {
922  fMsg.Error("Inconsistent phase shift detected.... closing run.");
923  return false;
924  }
925 
926  // FIXME: Check with first event!
927  if (memcmp(beg->fDac, ptr->fDac, sizeof(beg->fDac)))
928  {
929  fMsg.Error("Inconsistent DAC values detected.... closing run.");
930  return false;
931  }
932 
933  if (beg->fTriggerType != ptr->fTriggerType)
934  {
935  fMsg.Error("Inconsistent trigger type detected.... closing run.");
936  return false;
937  }
938  }
939 
940  // check REFCLK_frequency
941  // check consistency with command configuration
942  // how to log errors?
943  // need gotNewRun/closedRun to know it is finished
944 
945  fQueueTempRefClk.emplace(tm, clk, tmp);
946 
947  if (evt.runCtrl->fileStat == kFileClosed)
948  {
949  static Time oldt(boost::date_time::neg_infin);
950  if (tm>oldt+boost::posix_time::seconds(1))
951  {
952  fQueueTrigger.emplace(tm, 0, evt.runCtrl->triggerCounter);
953  oldt = tm;
954  }
955  }
956 
957  return true;
958  }
PEVNT_HEADER * FADhead
Definition: EventBuilder.h:131
Queue< tuple< Time, char, array< uint32_t, 8 > > > fQueueTrigger
EVENT * fEvent
Definition: EventBuilder.h:132
int i
Definition: db_dim_client.c:21
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
Queue< pair< Time, array< uint16_t, 2 > > > fQueueRoi
int Error(const std::string &str)
Definition: MessageImp.h:49
std::shared_ptr< RUN_CTRL2 > runCtrl
Definition: EventBuilder.h:139
double end
timeval time
Definition: EventBuilder.h:129
array< uint16_t, 2 > fVecRoi
Queue< tuple< Time, array< uint32_t, 40 >, array< int16_t, 160 > > > fQueueTempRefClk

+ Here is the call graph for this function:

+ Here is the caller graph for this function: