1 #ifndef FACT_EventBuilderWrapper 2 #define FACT_EventBuilderWrapper 6 #if BOOST_VERSION < 104400 7 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)) 8 #undef BOOST_HAS_RVALUE_REFS 11 #include <boost/thread.hpp> 12 #include <boost/filesystem.hpp> 13 #include <boost/date_time/posix_time/posix_time_types.hpp> 23 #define DataWriteFits DataWriteFits2 28 namespace ba = boost::asio;
29 namespace bs = boost::system;
30 namespace fs = boost::filesystem;
125 fMsg.
Error(
"Data path "+path+
" does not exist!");
132 fMsg.
Info(
"Data path set to "+path+
".");
139 if (night==fNightAsInt)
143 if (crosscheck!=to_string(night))
145 fMsg.
Warn(
"The crosscheck for the night failed. "+crosscheck+
" is not equal to "+to_string(night)+
"... keeping old one.");
146 fMsg.
Warn(
"This is a severe error. Please restart fadctrl.");
154 const uint32_t night_test = Time(now-boost::posix_time::seconds(1)).NightAsInt();
155 if (night_test != night)
163 if (Time().NightAsInt() != night)
166 if (night<fNightAsInt)
168 fMsg.
Warn(
"New night "+to_string(night)+
" ["+now.
GetAsStr()+
"] before current night "+to_string(night)+
"... keeping old one.");
169 fMsg.
Warn(
"Please check the system clock.");
176 while (--fRunNumber>0)
180 if (access((name+
"bin").c_str(), F_OK) == 0)
182 if (access((name+
"fits").c_str(), F_OK) == 0)
184 if (access((name+
"fits.fz").c_str(), F_OK) == 0)
186 if (access((name+
"fits.gz").c_str(), F_OK) == 0)
188 if (access((name+
"drs.fits").c_str(), F_OK) == 0)
197 if (fRunNumber==1000)
199 fMsg.
Error(
"You have a file with run-number 1000 in "+fPath+
" ["+to_string(night)+
"]");
205 str <<
"First night...";
207 str <<
"Night has changed from " << fNightAsInt <<
" [" << now <<
"]... ";
208 str <<
" next run-number is " << night <<
"-" << setfill(
'0') << setw(3) << fRunNumber <<
" [" << (fPath.empty()?
".":fPath) <<
"]";
218 fFileFormat(
FAD::
kNone), fLastOpened(0), fLastClosed(0),
219 fDimWriteStats (
"FAD_CONTROL", imp),
220 fDimRuns (
"FAD_CONTROL/RUNS",
"I:2;C",
221 "Run files statistics" 222 "|stats[int]:last opened or closed run" 223 "|file[string]:filename of last opened file"),
224 fDimEvents (
"FAD_CONTROL/EVENTS",
"I:4",
226 "|evtsCount[int]:Num evts cur. run, total (all run), evt ID, trig. Num"),
227 fDimTrigger (
"FAD_CONTROL/TRIGGER_COUNTER",
"I:1;I:1;I:1;I:1;I:1;I:1;I:1;I:1",
229 "|N_trg[uint32]:Number of physics triggers" 230 "|N_ped[uint32]:Number of pure pedestal triggers" 231 "|N_lpe[uint32]:Number of external light pulser triggers" 232 "|N_tim[uint32]:Number of time calibration triggers" 233 "|N_lpi[uint32]:Number of internal light pulser triggers" 234 "|N_ext1[uint32]:Number of external triggers at input ext1" 235 "|N_ext2[uint32]:Number of external triggers at input ext2" 236 "|N_misc[uint32]:Number of all other triggers"),
237 fDimRawData (
"FAD_CONTROL/RAW_DATA",
"S:1;S:1;I:1;I:1;S:1;I:1;I:2;I:40;S:1440;S:160;F",
238 "|roi[uint16]:number of samples per pixel" 239 "|roi_tm[uint16]:number of samples per time-marker channel" 240 "|num_fad[uint32]:event number from FADs" 241 "|num_ftm[uint32]:trigger number from FTM" 242 "|type[uint16]:trigger type from FTM" 243 "|num_boards[uint32]:number of active boards" 244 "|time[uint32]:PC time as unix time stamp" 245 "|time_board[uint32]:Time stamp of FAD boards" 246 "|start_pix[int16]:start sample of pixels" 247 "|start_tm[int16]:start sample of time marker channels" 248 "|adc[int16]:adc data"),
249 fDimEventData (
"FAD_CONTROL/EVENT_DATA",
"I:1;I:1;F:1440;F:1440;F:1440;F:1440",
"|run:|evt:|avg:|rms:|max:|pos"),
250 fDimFeedbackData(
"FAD_CONTROL/FEEDBACK_DATA",
"F:1440",
""),
251 fDimFwVersion (
"FAD_CONTROL/FIRMWARE_VERSION",
"F:42",
252 "Firmware version number of fad boards" 253 "|firmware[float]:Version number of firmware, for each board. 40=min, 41=max"),
254 fDimRunNumber (
"FAD_CONTROL/RUN_NUMBER",
"I:42",
255 "Run numbers coming from FAD boards" 256 "|runNumbers[int]:current run number of each FAD board. 40=min, 41=max"),
257 fDimStatus (
"FAD_CONTROL/STATUS",
"S:42",
258 "Status of FAD boards" 259 "|status[bitpattern]:Status of each FAD board. Maybe buggy"),
260 fDimDNA (
"FAD_CONTROL/DNA",
"X:40",
262 "|DNA[hex]:Hex identifier of each FAD board"),
263 fDimTemperature (
"FAD_CONTROL/TEMPERATURE",
"S:1;F:160",
265 "|cnt[uint16]:Counter of averaged values" 266 "|temp[deg C]:average temp of all DRS chips"),
267 fDimPrescaler (
"FAD_CONTROL/PRESCALER",
"S:42",
268 "Trigger generator prescaler of fad boards" 269 "|prescaler[int]:Trigger generator prescaler value, for each board"),
270 fDimRefClock (
"FAD_CONTROL/REFERENCE_CLOCK",
"S:1;F:40",
271 "Reference clock of FAD boards" 272 "|cnt[uint16]:Counter of averaged values" 273 "|clk[Hz]:Averaged clock of ref clocks of FAD boards"),
274 fDimRoi (
"FAD_CONTROL/REGION_OF_INTEREST",
"S:2",
"roi:|roi_rm:"),
275 fDimDac (
"FAD_CONTROL/DAC",
"S:336",
276 "DAC settings of each FAD board" 277 "|DAC[int]:DAC counts, sequentially DAC 0 board 0, 0/1, 0/2... (plus min max)"),
278 fDimDrsRuns (
"FAD_CONTROL/DRS_RUNS",
"I:1;I:3;I:1",
279 "|roi:Region of interest of secondary baseline" 280 "|run:Run numbers of DRS runs (0=none)" 281 "|night:Night as int of the first run (0 if none)"),
282 fDimDrsCalibration(
"FAD_CONTROL/DRS_CALIBRATION",
"I:1;I:3;F:1474560;F:1474560;F:1474560;F:1474560;F:1474560;F:1474560;F:163840;F:163840",
283 "|roi:Region of interest of secondary baseline" 284 "|run:Run numbers of DRS runs (0=none)"),
285 fDimStatistics1 (
"FAD_CONTROL/STATISTICS1",
"I:5;X:3;I:1;I:2;C:40;I:40;I:40",
286 "Event Builder status for GUI display" 287 "|bufferInfo[int]:Events in buffer, incomp., comp., write, proc., tot." 288 "|memInfo[int]:total mem allocated, used mem, max memory" 289 "|deltaT[ms]:Time in ms for rates" 290 "|rateNew[int]:Number of new start events received" 291 "|numConn[int]:Number of connections per board" 292 "|rateBytes[int]:Bytes read during last cylce" 293 "|relBytes[int]:Relative number of total bytes received (received - released)"),
294 fDimFileFormat(
"FAD_CONTROL/FILE_FORMAT",
"S:1",
"|format[int]:Current file format"),
295 fDimIncomplete(
"FAD_CONTROL/INCOMPLETE",
"X:1",
"|incomplete[bits]:bit_index=c*10+b. board b(0..3) in crate c(0..9)"),
305 fNightAsInt(0), fRunInProgress(-1),
306 fMaxEvent(make_pair(-FLT_MAX,
EventData()))
309 throw logic_error(
"EventBuilderWrapper cannot be instantiated twice.");
315 memset(fNumEvts.data(), 0,
sizeof(fNumEvts));
316 fDimEvents.
Update(fNumEvts);
318 for (
size_t i=0;
i<40;
i++)
319 ConnectSlot(
i, tcp::endpoint());
335 uint32_t
StartNewRun(int64_t maxtime, int64_t maxevt,
const pair<string, FAD::Configuration> &ref)
337 if (maxtime<=0 || maxtime>24*60*60)
339 if (maxevt<=0 || maxevt>INT32_MAX)
342 if (!InitRunNumber())
345 const FAD::RunDescription descr =
354 const lock_guard<mutex> lock(mtx_newrun);
361 return fThreadMain.joinable();
375 if (IsThreadRunning())
377 fMsg.
Warn(
"Start - EventBuilder still running");
383 for (
size_t i=0;
i<40;
i++)
384 ConnectSlot(
i, addr[
i]);
386 fMsg.
Message(
"Starting EventBuilder thread");
395 std::thread([
this] { this->fThreadMain.join(); }).detach();
405 if (addr==tcp::endpoint())
411 fDimIncomplete.
Update(uint64_t(0));
415 struct sockaddr_in sockaddr;
416 sockaddr.sin_family = AF_INET;
417 sockaddr.sin_addr.s_addr = htonl(addr.address().to_v4().to_ulong());
418 sockaddr.sin_port = htons(addr.port());
419 memcpy(&
g_port[i].sockAddr, &sockaddr,
sizeof(
struct sockaddr_in));
425 fDimIncomplete.
Update(uint64_t(0));
433 if (
g_port[i].sockAddr.sin_port==0)
442 fMsg.
Message(
"Signal abort to EventBuilder thread...");
448 fMsg.
Message(
"Signal reset to EventBuilder thread...");
454 fMsg.
Message(
"Signal exit to EventBuilder thread...");
468 const bool changed = f!=fFileFormat;
471 fDimFileFormat.
Update(uint16_t(f));
473 string msg =
"File format set to: ";
485 fMsg.
Message(
"Resetted DRS calibration.");
498 fDimFileFormat.
Update(uint16_t(fFileFormat));
499 fMsg.
Message(
"Resetted DRS calibration for secondary baseline.");
502 fMsg.
Warn(
"Could not reset DRS calibration of secondary baseline.");
512 fMsg.
Info(
"Successfully loaded DRS calibration from "+
string(fname));
529 vector<char>
data(
sizeof(values)+fname.size()+1);
530 memcpy(
data.data(), values,
sizeof(values));
531 strcpy(
data.data()+
sizeof(values), fname.c_str());
543 fDimEvents.
setData(stat.second.data(),
sizeof(uint32_t)*4);
544 fDimEvents.
Update(stat.first);
551 fDimTrigger.
setData(get<2>(stat).
data(),
sizeof(uint32_t)*8);
552 fDimTrigger.
Update(get<0>(stat));
558 const uint32_t night = evt.
runCtrl->night;
585 FAD::RunDescription desc;
586 desc.maxevt = evt.
runCtrl->maxEvt;
588 desc.name = evt.
runCtrl->runType;
590 if (!file->Open(evt, desc))
593 catch (
const exception &e)
595 fMsg.
Error(
"Exception trying to open file: "+
string(e.what()));
602 fFile = shared_ptr<DataProcessorImp>(file);
607 UpdateRuns(file->GetFileName());
608 fNumEvts[kEventId] = 0;
609 fNumEvts[kTriggerId] = 0;
610 fNumEvts[kCurrent] = 0;
614 fQueueEvents.emplace(time, fNumEvts);
618 str <<
"Opened: " << file->GetFileName() <<
" (" << file->GetRunId() <<
")";
643 if (!fFile->WriteEvt(e))
648 fNumEvts[kCurrent]++;
649 fNumEvts[kEventId] = e.
evNum;
650 fNumEvts[kTriggerId] = e.
trgNum;
653 static Time oldt(boost::date_time::neg_infin);
655 if (newt>oldt+boost::posix_time::seconds(1))
657 fQueueEvents.emplace(newt, fNumEvts);
672 if (fRunInProgress==fFile->GetRunId())
676 const bool rc = fFile->Close(evt);
678 fLastClosed = fFile->GetRunId();
681 str <<
"Closed: " << fFile->GetFileName() <<
" (" << fFile->GetRunId() <<
")";
683 str <<
"... failed!";
691 CloseRun(fLastClosed);
696 fQueueEvents.emplace(time, fNumEvts);
715 run.
calib = make_shared<DrsCalibration>(cal);
722 fDimRoi.
setData(roi.second.data(),
sizeof(uint16_t)*2);
723 fDimRoi.
Update(roi.first);
729 const auto delay = boost::posix_time::seconds(5);
731 const Time &tm = get<0>(dat);
733 const array<uint32_t,40> &clk = get<1>(dat);
734 const array<int16_t,160> &tmp = get<2>(dat);
739 static list<pair<Time,array<uint32_t,40>>> listclk;
740 listclk.emplace_back(tm, clk);
745 static list<pair<Time,array<int16_t,160>>> listtmp;
746 listtmp.emplace_back(tm, tmp);
750 static Time oldt(boost::date_time::neg_infin);
763 auto it=listclk.begin();
764 if (it==listclk.end() || it->first+delay>tm)
774 Clock() { memset(
this, 0,
sizeof(Clock)); }
778 vector<uint16_t> clknum(40);
781 avgclk.num = listclk.size();
782 for (
auto it=listclk.begin(); it!=listclk.end(); it++)
783 for (
int i=0;
i<40;
i++)
784 if (it->second[
i]!=UINT32_MAX)
786 avgclk.val[
i] += it->second[
i];
789 for (
int i=0;
i<40;
i++)
790 avgclk.val[
i] *= 2.048/clknum[
i];
803 auto it=listtmp.begin();
804 if (it==listtmp.end() || it->first+delay>tm)
814 Temp() { memset(
this, 0,
sizeof(Temp)); }
818 vector<uint32_t> tmpnum(160);
821 avgtmp.num = listtmp.size();
822 for (
auto it=listtmp.begin(); it!=listtmp.end(); it++)
823 for (
int i=0;
i<160;
i++)
824 if (it->second[
i]!=INT16_MIN)
826 avgtmp.val[
i] += it->second[
i];
829 for (
int i=0;
i<160;
i++)
830 avgtmp.val[
i] /= tmpnum[
i]*16;
833 fDimTemperature.
setData(avgtmp);
834 fDimTemperature.
Update(tm);
843 const EVENT *
event = evt.
fEvent;
845 const Time tm(evt.
time);
847 const array<uint16_t,2> roi = {{
event->Roi,
event->RoiTM }};
851 fQueueRoi.emplace(tm, roi);
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;
861 array<uint32_t,40> clk;
862 array<int16_t,160> tmp;
864 for (
int i=0;
i<40;
i++)
867 for (
int i=0;
i<160;
i++)
873 for (
const FAD::EventHeader *ptr=beg; ptr!=
end; ptr++)
876 if (ptr->fStartDelimiter==0)
883 clk[ptr->Id()] = ptr->fFreqRefClock;
884 for (
int i=0;
i<4;
i++)
885 tmp[ptr->Id()*4+
i] = ptr->fTempDrs[
i];
887 if (beg->fStatus != ptr->fStatus)
889 fMsg.
Error(
"Inconsistency in FAD status detected.... closing run.");
893 if (beg->fRunNumber != ptr->fRunNumber)
895 fMsg.
Error(
"Inconsistent run number detected.... closing run.");
907 if (beg->fEventCounter != ptr->fEventCounter)
909 fMsg.
Error(
"Inconsistent FAD event number detected.... closing run.");
913 if (beg->fTriggerCounter != ptr->fTriggerCounter)
915 fMsg.
Error(
"Inconsistent FTM trigger number detected.... closing run.");
920 if (beg->fAdcClockPhaseShift != ptr->fAdcClockPhaseShift)
922 fMsg.
Error(
"Inconsistent phase shift detected.... closing run.");
927 if (memcmp(beg->fDac, ptr->fDac,
sizeof(beg->fDac)))
929 fMsg.
Error(
"Inconsistent DAC values detected.... closing run.");
933 if (beg->fTriggerType != ptr->fTriggerType)
935 fMsg.
Error(
"Inconsistent trigger type detected.... closing run.");
945 fQueueTempRefClk.emplace(tm, clk, tmp);
949 static Time oldt(boost::date_time::neg_infin);
950 if (tm>oldt+boost::posix_time::seconds(1))
952 fQueueTrigger.emplace(tm, 0, evt.
runCtrl->triggerCounter);
965 const EVENT *evt =
reinterpret_cast<const EVENT*
>(v.data());
969 fDimRawData.
Update(Time(evt->PCTime, evt->PCUsec));
977 fDimEventData.
setData(get<2>(tup));
978 fDimEventData.
Update(get<0>(tup));
985 const EVENT *
event = evt.
fEvent;
986 const int16_t *
start =
event->StartPix;
997 const uint16_t roi =
event->Roi;
1009 const shared_ptr<DrsCalibration> cal = run.
calib;
1013 vector<float> vec((1440+160)*roi);
1014 cal->Apply(vec.data(),
event->Adc_Data,
start, roi);
1027 if (fQueueRawData.
empty() && now>fLastDimRawData+boost::posix_time::seconds(5))
1029 vector<char> data1(
sizeof(EVENT)+vec.size()*
sizeof(float));
1030 memcpy(data1.data(), event,
sizeof(EVENT));
1031 memcpy(data1.data()+
sizeof(EVENT), vec.data(), vec.size()*
sizeof(float));
1032 fQueueRawData.emplace(data1);
1034 fLastDimRawData = now;
1043 edat.evNum = evt.
evNum;
1046 if (evt.
trgTyp==0 && max>fMaxEvent.first)
1047 fMaxEvent = make_pair(max, edat);
1051 if (fQueueEventData.empty() && now>fLastDimEventData+boost::posix_time::milliseconds(4999))
1053 edat.evNum = evt.
evNum;
1054 edat.runNum = evt.
runNum;
1056 fQueueEventData.emplace(evt.
time, evt.
trgTyp, evt.
trgTyp==0 ? fMaxEvent.second : edat);
1058 fMaxEvent.first = -FLT_MAX;
1060 fLastDimEventData = now;
1085 l.splice(l.begin(), l, --it);
1088 memcpy(l.front().data(),
start, 1440*
sizeof(int16_t));
1093 const lock_guard<mutex> lock(mtx_newrun);
1094 return fExpectedRuns.find(fRunNumber-1)!=fExpectedRuns.end();
1104 if (!InitRunNumber())
1111 "Run number " << run <<
" smaller than next available " 1112 "run number " << fRunNumber <<
" in " << fPath <<
" [" << fNightAsInt <<
"]";
1125 const lock_guard<mutex> lock(mtx_newrun);
1127 map<uint32_t,FAD::RunDescription>::iterator it = fExpectedRuns.begin();
1128 while (it!=fExpectedRuns.end())
1130 if (it->first<run.
runId)
1133 str <<
"runOpen - Missed run " << it->first <<
".";
1137 const auto is = it++;
1138 fExpectedRuns.erase(is);
1142 if (it->first==run.
runId)
1148 if (it==fExpectedRuns.end())
1151 str <<
"runOpen - Run " << run.
runId <<
" wasn't expected (maybe manual triggers)";
1155 run.
night = fNightAsInt;
1160 const FAD::RunDescription &conf = it->second;
1163 run.
maxEvt = conf.maxevt;
1165 run.
night = conf.night;
1167 fExpectedRuns.erase(it);
1172 fRunInProgress = run.
runId;
1179 fRunInProgress = -1;
1187 str <<
"EventBuilder: " <<
message;
1197 fMsg.
Update(str, severity);
1239 fDimStatistics1.
setData(&stat.second,
sizeof(GUI_STAT));
1240 fDimStatistics1.
Update(stat.first);
1247 fQueueStatistics1.emplace(Time(), stat);
1253 fDimIncomplete.
Update(rep);
1258 template<
typename T,
class S>
1261 const int offset =
reinterpret_cast<const char *
>(
t) - reinterpret_cast<const char *>(vec);
1263 const T *min = NULL;
1264 const T *val = NULL;
1265 const T *max = NULL;
1270 for (
int i=0;
i<40;
i++)
1272 const char *base =
reinterpret_cast<const char*
>(vec+
i);
1273 const T *ref =
reinterpret_cast<const T*
>(base+offset);
1300 arr[40] = val ? *min : 1;
1301 arr[41] = val ? *max : 0;
1306 template<
typename T>
1309 const int offset =
reinterpret_cast<const char *
>(
t) - reinterpret_cast<const char *>(h);
1318 for (
int i=0;
i<40;
i++)
1320 const char *base =
reinterpret_cast<const char*
>(&fVecHeader[
i]);
1321 const T *ref =
reinterpret_cast<const T*
>(base+offset);
1347 template<
typename T,
size_t N>
1350 svc.
setData(const_cast<T*>(data.data()),
sizeof(T)*n);
1354 template<
typename T>
1355 void Print(
const char *name,
const pair<
bool,array<T, 43>> &data)
1357 cout << name <<
"|" << data.first <<
"|" << data.second[1] <<
"|" << data.second[0] <<
"<x<" << data.second[1] <<
":";
1358 for (
int i=0;
i<40;
i++)
1359 cout <<
" " << data.second[
i+3];
1367 const Time &
t = get<0>(dat);
1368 const bool changed = get<1>(dat);
1369 const FAD::EventHeader &h = get<2>(dat);
1371 const FAD::EventHeader old = fVecHeader[h.Id()];
1372 fVecHeader[h.Id()] = h;
1374 if (old.fVersion != h.fVersion || changed)
1376 const array<uint16_t,42> ver = Compare(&fVecHeader[0], &fVecHeader[0].
fVersion);
1378 array<float,42>
data;
1379 for (
int i=0;
i<42;
i++)
1382 str << (ver[i]>>8) <<
'.' << (ver[
i]&0xff);
1383 data[
i] = stof(str.str());
1385 Update(fDimFwVersion, data, t);
1388 if (old.fRunNumber != h.fRunNumber || changed)
1390 const array<uint32_t,42>
run = Compare(&fVecHeader[0], &fVecHeader[0].fRunNumber);
1391 fDimRunNumber.
setData(&run[0], 42*
sizeof(uint32_t));
1395 if (old.fTriggerGeneratorPrescaler != h.fTriggerGeneratorPrescaler || changed)
1398 fDimPrescaler.
setData(&pre[0], 42*
sizeof(uint16_t));
1402 if (old.fDNA != h.fDNA || changed)
1404 const array<uint64_t,42> dna = Compare(&fVecHeader[0], &fVecHeader[0].
fDNA);
1405 Update(fDimDNA, dna, t, 40);
1408 if (old.fStatus != h.fStatus || changed)
1410 const array<uint16_t,42> sts = CompareBits(&fVecHeader[0], &fVecHeader[0].
fStatus);
1411 Update(fDimStatus, sts, t);
1414 if (memcmp(old.fDac, h.fDac,
sizeof(h.fDac)) || changed)
1416 array<uint16_t, FAD::kNumDac*42> dacs;
1420 const array<uint16_t, 42> dac = Compare(&fVecHeader[0], &fVecHeader[0].
fDac[
i]);
1421 memcpy(&dacs[i*42], &dac[0],
sizeof(uint16_t)*42);
1424 Update(fDimDac, dacs, t);
1432 const uint16_t
id = h.Id();
1436 if (fNumConnected.size()!=40)
1437 fNumConnected.resize(40);
1441 const bool changed = con!=fNumConnected || !IsThreadRunning();
1443 fNumConnected = con;
1445 fQueueProcHeader.emplace(Time(), changed, h);
1454 return EventBuilderWrapper::This->
runOpen(evt);
1459 return EventBuilderWrapper::This->
runWrite(evt);
1464 EventBuilderWrapper::This->
runClose(evt);
1469 return EventBuilderWrapper::This->
eventCheck(evt);
1474 EventBuilderWrapper::This->
gotNewRun(run);
1484 EventBuilderWrapper::This->
applyCalib(evt, size);
1489 EventBuilderWrapper::This->
factOut(severity, message);
1494 EventBuilderWrapper::This->
factStat(stat);
1506 const FAD::EventHeader &h = *
reinterpret_cast<FAD::EventHeader*
>(buf);
1507 EventBuilderWrapper::This->
debugHead(h);
DimDescribedService fDimDNA
void ConnectSlot(unsigned int i, const tcp::endpoint &addr)
DimDescribedService fDimStatistics1
DimDescribedService fDimRawData
static const DrsCalibration & GetCalibration()
array< FAD::EventHeader, 40 > fVecHeader
bool runWrite(const EVT_CTRL2 &evt)
void Update(DimDescribedService &svc, const array< T, N > &data, const Time &t=Time(), int n=N)
bool IncreaseRunNumber(uint32_t run)
uint32_t GetRunNumber() const
DimDescribedService fDimFileFormat
DimDescribedService fDimStatus
void SetMaxMemory(unsigned int mb) const
static Step CorrectStep(float *vec, uint16_t nch, uint16_t roi, const int16_t *prev, const int16_t *start, const int16_t offset, const uint16_t *map=NULL)
Queue< tuple< Time, char, array< uint32_t, 8 > > > fQueueTrigger
DimDescribedService fDimRuns
Time GetPrevSunRise(double horizon) const
static bool ResetTrgOff(DimDescribedService &dim, DimDescribedService &runs)
bool eventCheck(const EVT_CTRL2 &evt)
bool UpdateDimEventData(const tuple< Time, uint32_t, EventData > &tup)
static void SlidingAverage(float *const vec, const uint32_t roi, const uint16_t w)
array< T, 42 > Compare(const S *vec, const T *t)
EventBuilderWrapper(MessageImp &imp)
void runClose(const EVT_CTRL2 &evt)
bool IsDisconnected(int i) const
void setQuality(int quality)
The base implementation of a distributed messaging system.
Adds some functionality to boost::posix_time::ptime for our needs.
uint32_t NightAsInt() const
void factStat(const GUI_STAT &stat)
bool runOpen(const EVT_CTRL2 &evt)
bool UpdateDimTempRefClk(const tuple< Time, array< uint32_t, 40 >, array< int16_t, 160 >> &dat)
void applyCalib(const EVT_CTRL2 &evt, const size_t &size)
uint gi_NumConnect[NBOARDS]
void Print(const char *name, const pair< bool, array< T, 43 >> &data)
Queue< pair< Time, array< uint16_t, 2 > > > fQueueRoi
void factOut(int severity, const char *message)
FACT_SOCK g_port[NBOARDS]
map< uint32_t, FAD::RunDescription > fExpectedRuns
bool UpdateDimStatistics1(const pair< Time, GUI_STAT > &stat)
int64_t first
Size of this column in the tile.
bool UpdateDimEvents(const pair< Time, array< uint32_t, 4 >> &stat)
bool FileOpened(const std::string &fileName)
DimDescribedService fDimDac
static bool DoesPathExist(std::string path, MessageImp &log)
void debugHead(const FAD::EventHeader &h)
DimDescribedService fDimPrescaler
void UpdateRuns(const string &fname="")
virtual int ResetSecondaryDrsBaseline()
array< T, 42 > CompareBits(const FAD::EventHeader *h, const T *t)
DimDescribedService fDimFeedbackData
void gotNewRun(RUN_CTRL2 &run)
Queue< pair< Time, array< uint32_t, 4 > > > fQueueEvents
DimDescribedService fDimRunNumber
DimDescribedService fDimTemperature
bool UpdateDimRoi(const pair< Time, array< uint16_t, 2 >> &roi)
void SetOutputFormat(FAD::FileFormat_t f)
FAD::FileFormat_t fFileFormat
DimDescribedService fDimDrsRuns
DimDescribedService fDimRefClock
void debugHead(void *buf)
bool runOpen(const EVT_CTRL2 &evt)
Queue< tuple< Time, uint32_t, EventData > > fQueueEventData
DimDescribedService fDimEventData
bool procHeader(const tuple< Time, bool, FAD::EventHeader > &dat)
bool eventCheck(const EVT_CTRL2 &evt)
DimDescribedService fDimRoi
void StartThread(const vector< tcp::endpoint > &addr)
void setData(const void *ptr, size_t sz)
void factReportIncomplete(uint64_t rep)
int Error(const std::string &str)
void gotNewRun(RUN_CTRL2 &run)
vector< uint > fNumConnected
int Update(const std::string &txt, int severity=kMessage)
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
void factOut(int severity, const char *message)
int Warn(const std::string &str)
bool runWrite(const EVT_CTRL2 &e)
DimWriteStatistics fDimWriteStats
boost::thread fThreadMain
Queue< pair< Time, GUI_STAT > > fQueueStatistics1
std::shared_ptr< RUN_CTRL2 > runCtrl
DimDescribedService fDimIncomplete
provides a statistics service telling the free space on disk and the total size written so far ...
uint32_t StartNewRun(int64_t maxtime, int64_t maxevt, const pair< string, FAD::Configuration > &ref)
bool IsRunInProgress() const
bool UpdateDimRawData(const vector< char > &v)
Queue< tuple< Time, bool, FAD::EventHeader > > fQueueProcHeader
static bool ReadFits(const string &fname, MessageImp &msg)
void factStat(const GUI_STAT &stat)
virtual ~EventBuilderWrapper()
pair< float, EventData > fMaxEvent
void IgnoreSlot(unsigned int i)
DimDescribedService fDimTrigger
DimDescribedService fDimEvents
void SetEventTimeout(uint16_t to) const
bool SetCurrentFolder(const std::string &folder)
Configures that current folder where files are written to.
shared_ptr< DataProcessorImp > fFile
virtual void CloseRun(uint32_t)
void factReportIncomplete(uint64_t rep)
DimDescribedService fDimDrsCalibration
void LoadDrsCalibration(const char *fname)
bool IsConnected(int i) const
array< uint32_t, 4 > fNumEvts
bool InitRunNumber(const string &path="")
int Info(const std::string &str)
void runClose(const EVT_CTRL2 &evt)
static double GetPixelStats(float *ptr, const float *data, uint16_t roi, uint16_t begskip=0, uint16_t endskip=0)
int Message(const std::string &str)
std::list< std::array< int16_t, 1440 > > prevStart
void applyCalib(const EVT_CTRL2 &evt, const size_t &size)
std::array< uint32_t, 8 > triggerCounter
static EventBuilderWrapper * This
void ResetThread(bool soft)
bool IsIgnored(int i) const
DimDescribedService fDimFwVersion
std::shared_ptr< DrsCalibration > calib
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
void SetIgnore(int i, bool b) const
Queue< vector< char > > fQueueRawData
bool UpdateDimTrigger(const tuple< Time, char, array< uint32_t, 8 >> &stat)
virtual int CloseOpenFiles()
static void RemoveSpikes4(float *ptr, uint32_t roi)
array< uint16_t, 2 > fVecRoi
static void Update(DimDescribedService &dim, DimDescribedService &runs)
static std::string FormFileName(const std::string &path, uint64_t night, uint32_t runid, const std::string &extension)
Queue< tuple< Time, array< uint32_t, 40 >, array< int16_t, 160 > > > fQueueTempRefClk
bool IsConnecting(int i) const