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

Definition at line 556 of file EventBuilderWrapper.h.

References DataWriteFits, MessageImp::Error(), DataCalib::GetCalibration(), MessageImp::Info(), kCalib, kCfitsio, kDebug, kFits, kNone, kRaw, kZFits, runClose(), EVT_CTRL2::runCtrl, EVT_CTRL2::runNum, str, time, and EVT_CTRL2::triggerCounter.

Referenced by runOpen().

557  {
558  const uint32_t night = evt.runCtrl->night;
559  const uint32_t runid = evt.runNum>0 ? evt.runNum : time(NULL);
560 
561  // If there is still an open file: close it
562  if (fFile)
563  runClose(evt);
564 
565  // Keep a copy of the currently valid drs calibration
566  // and associate it to the run control structure
567  evt.runCtrl->calib = make_shared<DrsCalibration>(DataCalib::GetCalibration());
568 
569  // Crate the file
570  DataProcessorImp *file = 0;
571  switch (fFileFormat)
572  {
573  case FAD::kNone: file = new DataDump(fPath, night, runid, fMsg); break;
574  case FAD::kDebug: file = new DataDebug(fPath, night, runid, fMsg); break;
575  case FAD::kCfitsio: file = new DataWriteFits(fPath, night, runid, fMsg); break;
576  case FAD::kFits: file = new DataWriteFits2(fPath, night, runid, fMsg); break;
577  case FAD::kZFits: file = new DataWriteFits2(fPath, night, runid, *evt.runCtrl->calib, fMsg); break;
578  case FAD::kRaw: file = new DataWriteRaw(fPath, night, runid, fMsg); break;
579  case FAD::kCalib: file = new DataCalib(fPath, night, runid, *evt.runCtrl->calib, fDimDrsCalibration, fDimDrsRuns, fMsg); break;
580  }
581 
582  try
583  {
584  // Try to open the file
585  FAD::RunDescription desc;
586  desc.maxevt = evt.runCtrl->maxEvt;
587  desc.maxtime = evt.runCtrl->closeTime - evt.runCtrl->openTime;
588  desc.name = evt.runCtrl->runType;
589 
590  if (!file->Open(evt, desc))
591  return false;
592  }
593  catch (const exception &e)
594  {
595  fMsg.Error("Exception trying to open file: "+string(e.what()));
596  return false;
597  }
598 
599  fLastOpened = runid;
600 
601  // Signal that a file is open
602  fFile = shared_ptr<DataProcessorImp>(file);
603 
604  // Now do all the calls which potentially block (dim)
605 
606  // Time for update runs before time for update events
607  UpdateRuns(file->GetFileName());
608  fNumEvts[kEventId] = 0;
609  fNumEvts[kTriggerId] = 0;
610  fNumEvts[kCurrent] = 0;
611 
612  const Time time;
613 
614  fQueueEvents.emplace(time, fNumEvts);
615  fQueueTrigger.emplace(time, 'o', evt.triggerCounter);
616 
617  ostringstream str;
618  str << "Opened: " << file->GetFileName() << " (" << file->GetRunId() << ")";
619  fMsg.Info(str);
620 
621  return true;
622  }
static const DrsCalibration & GetCalibration()
Definition: DataCalib.h:54
Queue< tuple< Time, char, array< uint32_t, 8 > > > fQueueTrigger
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
uint32_t runNum
Definition: EventBuilder.h:115
void UpdateRuns(const string &fname="")
Queue< pair< Time, array< uint32_t, 4 > > > fQueueEvents
FAD::FileFormat_t fFileFormat
DimDescribedService fDimDrsRuns
#define DataWriteFits
int Error(const std::string &str)
Definition: MessageImp.h:49
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
std::shared_ptr< RUN_CTRL2 > runCtrl
Definition: EventBuilder.h:139
shared_ptr< DataProcessorImp > fFile
DimDescribedService fDimDrsCalibration
array< uint32_t, 4 > fNumEvts
int Info(const std::string &str)
Definition: MessageImp.h:47
void runClose(const EVT_CTRL2 &evt)
std::array< uint32_t, 8 > triggerCounter
Definition: EventBuilder.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function: