BmnRoot
Loading...
Searching...
No Matches
BmnConverterThread.cxx
Go to the documentation of this file.
2
3// ROOT
4#include "TFile.h"
5// BmnRoot
6#include "BmnADCDigit.h"
7#include "BmnAbstractTDCDigit.h"
8#include "BmnConverterTools.h"
9#include "BmnHRBDigit.h"
10#include "BmnHgndRaw.h"
11#include "BmnMSCDigit.h"
12#include "BmnMSCZSDigit.h"
13#include "BmnMath.h"
14#include "BmnT0Raw.h"
15#include "BmnTDCDigit.h"
16#include "BmnTQDCADCDigit.h"
17#include "BmnVspRawDigit.h"
18// CBM
19#include "StorableTimeslice.h"
20#include "StsXyterMessage.h"
21
22using namespace std::chrono;
23
25{ // std::function<void(TString, TObject**) > branch_reg_fun) {
26 fRawTree->Branch("BmnEventHeader.", &eventHeaderDAQ);
27 // FairRootManager* frm = FairRootManager::Instance();
28 // frm->Register("BmnEventHeader.", "BmnEventHeader._dir", eventHeaderDAQ, fSaveOutput);
29 fRawTree->Branch("SYNC", &sync);
30 fRawTree->Branch("ADC32", &adc32);
31 fRawTree->Branch("ADC64", &adc64);
32 fRawTree->Branch("ADC128", &adc128);
33 fRawTree->Branch("ADC", &adc);
34 fRawTree->Branch("VSP_RAW", &vsp);
35 fRawTree->Branch("TDC", &tdc);
36 fRawTree->Branch("TQDC_ADC", &tqdc_adc);
37 fRawTree->Branch("TQDC_TDC", &tqdc_tdc);
38 fRawTree->Branch("TDC_HGND", &tdc_hgnd);
39 fRawTree->Branch("HRB", &hrb);
40}
41
43{
44 fRawTreeSpills->Branch("MSC", &msc);
45 fRawTreeSpills->Branch("T0Raw", &t0raw);
46}
47
49{
50 if (merger) {
51 mergerFile = merger->GetFile();
52 mergerFile->cd();
53 }
54 TString ext = (threadId == -1) ? "" : to_string(threadId);
55 // TString ext = "";//(threadId == -1) ? "" : to_string(threadId);
56 fRawTree = new TTree((TString) "BMN_RAW" + ext, (TString) "BMN_RAW" + ext);
57 fRawTree->SetAutoSave(0); // Very important
58 fRawTreeSpills = new TTree((TString) "BMN_RAW_SPILLS" + ext, (TString) "BMN_RAW_SPILLS" + ext);
59 fRawTreeSpills->SetAutoSave(0); // Very important
61 sync = new TClonesArray(BmnSyncDigit::Class());
62 adc32 = new TClonesArray(BmnADCDigit::Class());
63 adc64 = new TClonesArray(BmnADCDigit::Class());
64 adc128 = new TClonesArray(BmnADCDigit::Class());
65 adc = new TClonesArray(BmnADCDigit::Class());
66 vsp = new TClonesArray(BmnVspRawDigit::Class());
67 tdc = new TClonesArray(BmnTDCDigit::Class());
68 tqdc_adc = new TClonesArray(BmnTQDCADCDigit::Class());
69 tqdc_tdc = new TClonesArray(BmnTDCDigit::Class());
70 tdc_hgnd = new TClonesArray(BmnAbstractTDCDigit::Class());
71 hrb = new TClonesArray(BmnHRBDigit::Class());
72 msc = new TClonesArray(fPeriodId > 7 ? BmnMSCDigit<UChar_t>::Class() : BmnMSCDigit<UInt_t>::Class());
73 t0raw = new TClonesArray(BmnT0Raw<kT0_BIN_BLOCK_WORDS>::Class());
74}
75
76void BmnConverterThread::SetTrees(TTree* tree, TTree* treeSpills)
77{
78 fRawTree = tree;
79 fRawTree->SetBranchAddress("BmnEventHeader.", &eventHeaderDAQ);
80 fRawTree->SetBranchAddress("SYNC", &sync);
81 fRawTree->SetBranchAddress("ADC32", &adc32);
82 fRawTree->SetBranchAddress("ADC64", &adc64);
83 fRawTree->SetBranchAddress("ADC128", &adc128);
84 fRawTree->SetBranchAddress("ADC", &adc);
85 fRawTree->SetBranchAddress("VSP_RAW", &vsp);
86 fRawTree->SetBranchAddress("TDC", &tdc);
87 fRawTree->SetBranchAddress("TQDC_ADC", &tqdc_adc);
88 fRawTree->SetBranchAddress("TQDC_TDC", &tqdc_tdc);
89 fRawTree->SetBranchAddress("TDC_HGND", &tdc_hgnd);
90 fRawTree->SetBranchAddress("HRB", &hrb);
91 fRawTreeSpills = treeSpills;
92 fRawTreeSpills->SetBranchAddress("MSC", &msc);
93 fRawTreeSpills->SetBranchAddress("T0Raw", &t0raw);
94}
95
96void BmnConverterThread::WriteSpill(Int_t spillId)
97{
98 auto f = merger->GetFile();
99 TTree* tree = new TTree("BMN_RAW", "BMN_RAW");
100 TTree* treeSpills = new TTree("BMN_RAW_SPILLS", "BMN_RAW_SPILLS");
101 tree->Branch("BmnEventHeader.", &eventHeaderDAQ);
102 tree->Branch("SYNC", &sync);
103 tree->Branch("ADC32", &adc32);
104 tree->Branch("ADC64", &adc64);
105 tree->Branch("ADC128", &adc128);
106 tree->Branch("ADC", &adc);
107 tree->Branch("VSP_RAW", &vsp);
108 tree->Branch("TDC", &tdc);
109 tree->Branch("TQDC_ADC", &tqdc_adc);
110 tree->Branch("TQDC_TDC", &tqdc_tdc);
111 tree->Branch("TDC_HGND", &tdc_hgnd);
112 tree->Branch("HRB", &hrb);
113 treeSpills->Branch("MSC", &msc);
114 treeSpills->Branch("T0Raw", &t0raw);
115 for (size_t j = 0; j < vecTree->size(); j++) {
116 if ((*vecTree)[j].first == spillId) {
117 if ((*vecTree)[j].second.first == threadId) {
118 fRawTree->GetEntry((*vecTree)[j].second.second);
119 tree->Fill();
120 }
121 }
122 }
123 for (size_t j = 0; j < vecTreeSpills->size(); j++) {
124 if ((*vecTreeSpills)[j].first == spillId) {
125 if ((*vecTreeSpills)[j].second.first == threadId) {
126 fRawTreeSpills->GetEntry((*vecTreeSpills)[j].second.second);
127 treeSpills->Fill();
128 }
129 }
130 }
131 f->Write();
132}
133
134void BmnConverterThread::Calculate()
135{
136 LOGF(debug2, "Calculate task %d in id %d", taskId, threadId);
137 if (taskId == 1) {
138 ProcessEvent(rawData, dataLen);
139 // if(!isTaskMode){
140 fRawTree->Fill();
141 //}
142 } else if (taskId == 2) {
143 ConvertStatEvent(rawData, dataLen);
144 SpillEnd();
145 } else if (taskId == 3) {
146 WriteSpill(dataLen);
147 }
148 LOGF(debug2, "Calculate task %d in id %d done", taskId, threadId);
149}
150
152{
153 fRawTree->Write();
154}
155
160
162{
163 // fRawTree->Write();
164 // fRawTreeSpills->Write();
165 if (mergerFile) {
166 mergerFile->Write();
167 mergerFile->Close();
168 mergerFile.reset();
169 LOGF(info, "thread file closed");
170 }
171}
172
174 Int_t len,
175 UInt_t* data,
176 BmnEventType fCurEvType,
177 UInt_t fRunId,
178 UInt_t fEventId)
179{
180 dataLen = len;
181 if (data)
182 std::memcpy(rawData, data, sizeof(UInt_t) * len);
183 fCurEvent.fCurEvType = fCurEvType;
184 fCurEvent.fRunId = fRunId;
185 // fCurEvent.fPeriodId = fPeriodId;
186 fCurEvent.fEventId = fEventId;
187 this->taskId = id;
188}
189
190// not actually spill end since 8th period
191
193{
194 if (fRawTreeSpills) {
195 fRawTreeSpills->Fill();
197 }
198}
199
200BmnStatus BmnConverterThread::ConvertStatEvent(UInt_t* d, UInt_t& len)
201{
203 ProcessEvent(d, len);
204 // if (fRootFileOut) fRawTree->Fill();
205 /*if ((fCurEvType == kBMNEOS) && (fPrevEvType != kBMNEOS)) {
206 LOGF(debug1, "\tspill! nSpillEvents %d", nSpillEvents);
207 isSpillStart = kTRUE;
208 nSpillEvents = 0;
209 fSpillCntr++;
210 // if (msc->GetEntriesFast() > 0)
211
212 }*/
213 return kBMNSUCCESS;
214}
215
216BmnStatus BmnConverterThread::ProcessEvent(UInt_t* d, UInt_t len)
217{
218 // timer.Start();
220 if ((fCurEvent.fEventId % 5000 <= 1) && (fCurEvent.fCurEvType != kBMNSTAT) && (fCurEvent.fEventId > 0))
221 LOG(info) << "Converted event #" << fCurEvent.fEventId;
222 // } else if (fVerbose == 0)
223 // DrawBar(fCurentPositionRawFile, fLengthRawFile);
224
225 UInt_t idx = 1;
226 // BmnEventType evType = kBMNPAYLOAD;
227 BmnTrigInfo trigInfo;
228 while (idx < len) {
229 Bool_t recognized = kTRUE;
230 DeviceHeader* dh = reinterpret_cast<DeviceHeader*>(d + idx);
231 // printf("[%u]\n", idx);
232 // if (fCurEvType == kBMNSTAT)
233 // dh->Print();
234 UInt_t serial = dh->Serial;
235 uint8_t id = dh->DeviceId;
236 // if (serial == 0) id = kGENERIC_DEVICE;
237 UInt_t payload = dh->GetNWords();
238 idx += sizeof(DeviceHeader) / kNBYTESINWORD;
239 if (payload > 2000000) {
240 LOGF(warn, "Event %d:\n serial = 0x%06X\n id = Ox%02X\n payload = %d", fCurEvent.fEventId, serial, id,
241 payload);
242 break;
243 }
244 if (fCurEvent.fCurEvType == kBMNSTAT)
245 LOGF(debug4, "STAT iev %7d idx %6u/%6u idev %02X serial 0x%08X payload %4u", fCurEvent.fEventId, idx,
246 len, id, serial, payload);
247 switch (id) {
248 case kTQDC16VS_E:
249 FillTQDC_E(&d[idx], serial, payload);
250 break;
251 case kTDC72VXS: // Trig & ToF400 VXS TDC
252 case kTDC64VHLE_E: // ToF700 VHL TDC
253 FillTDC72VXS(&d[idx], serial, payload, id);
254 break;
255 case kTTVXS:
256 FillTTVXS(&d[idx], serial, payload);
257 break;
258 case kGENERIC_DEVICE:
259 ProcessGenericDevice(&d[idx], dh);
260 break;
261 case kMSC16VE_E:
262 // printf("MSC16VE-E serial 0x%08X words %u\n", serial, payload);
263 if (msc)
264 FillMSC16VE_E(&d[idx], dh);
265 break;
266 case kADC64VE_XGE:
267 case kADC64VE: {
268 BmnConverterTools::Process_ADC64<Short_t>(&d[idx], payload, serial,
269 [&](Int_t n_samples) -> TClonesArray* {
270 switch (n_samples) {
271 case 32:
272 return adc32;
273 break;
274 case 64:
275 return adc64;
276 break;
277 case 128:
278 return adc128;
279 break;
280 default:
281 return nullptr;
282 break;
283 }
284 });
285 break;
286 }
287 case kADC64WR: {
288 BmnConverterTools::Process_ADC64<UShort_t>(&d[idx], payload, serial,
289 [&](Int_t n_samples) -> TClonesArray* { return adc; });
290 break;
291 }
292 case kFVME:
293 Process_FVME(&d[idx], payload, serial, trigInfo);
294 break;
295 case kHRB:
296 Process_HRB(&d[idx], payload, serial);
297 break;
298 case kUT24VE_TRC:
299 FillUT24VE_TRC(&d[idx], serial, payload);
300 break;
301 case kVIRTUAL_DEVICE:
302 FillVirtualDevice(&d[idx], dh);
303 break;
304 default:
305 // printf("Device id %02X not recognized\n", id);
306 recognized = kFALSE;
307 break;
308 }
309 if (payload + idx > len) {
310 printf(
311 "Error in the event #%d: 0x%08X : %2X device payload length mismatch! pauload %5u idx/len: %5u/%5u \n",
312 fCurEvent.fEventId, serial, id, payload, idx, len);
313 return kBMNERROR;
314 } else {
315 if (recognized)
316 idx += payload;
317 else
318 idx--;
319 }
320 }
321 if (time_slice_map.size())
322 FillVSP(nullptr);
323 eventHeaderDAQ->SetRunId(fCurEvent.fRunId);
324 eventHeaderDAQ->SetPeriodId(fPeriodId);
326 eventHeaderDAQ->SetEventTimeTS(TTimeStamp(time_t(fCurEvent.fTime_s), fCurEvent.fTime_ns));
327 eventHeaderDAQ->SetEventTime(TTimeStamp(time_t(fCurEvent.fTime_s), fCurEvent.fTime_ns).AsDouble());
330 eventHeaderDAQ->SetTrigInfo(trigInfo);
331 // eventHeaderDAQ->SetTimeShift(fTimeShifts);
332 // eventHeaderDAQ->SetStartSignalInfo(fT0Time, fT0Width);
333 // eventHeaderDAQ->SetSpillStart(isSpillStart);
334 // if ((fCurEvent.fCurEvType == kBMNSTAT) || (fCurEvent.fCurEvType == kBMNEOS))
335 // eventHeaderDAQ->SetEventId(0);
336 return kBMNSUCCESS;
337}
338
339BmnStatus BmnConverterThread::Process_FVME(UInt_t* d, UInt_t len, UInt_t serial, BmnTrigInfo& spillInfo)
340{
341 // printf("FVME serial %08X len %u\n",serial, len);
342 if (fCurEvent.fCurEvType == kBMNSTAT) {
343 fCurEvent.fCurEvType = kBMNEOS;
344 // printf("stat FVME serial %08X len %u\n", serial, len);
345 }
346 UInt_t modId = 0;
347 UInt_t slot = 0;
348 UInt_t type = 0;
349 for (UInt_t i = 0; i < len; i++) {
350 type = d[i] >> 28;
351 // if (fCurEvType == kBMNSTAT)
352 // printf(" type %02X i %u\n", type, i);
353 switch (type) {
354 case kEVHEADER:
355 // if (fCurEvType == kBMNSTAT)
356 // printf("Ev header \n");
357 break;
358 case kEVTRAILER:
359 // if (fCurEvType == kBMNSTAT)
360 // printf("Ev trailer\n");
361 return kBMNSUCCESS;
362 break;
363 case kSTATUS:
364 case kPADDING:
365 break;
366 case kMODHEADER:
367 modId = (d[i] >> 16) & 0x7F;
368 slot = (d[i] >> 23) & 0x1F;
369 // if (fCurEvType == kBMNSTAT)
370 // printf("\tmodid 0x%02X slot %d serial 0x%08X\n", modId, slot, serial);
371 break;
372 case kMODTRAILER:
373 // if (fCurEvType == kBMNSTAT)
374 // printf("\tmodule trailer\n");
375 if (!((d[i] >> 16) & 0x1))
376 printf(ANSI_COLOR_RED "Readout overflow error\n" ANSI_COLOR_RESET);
377 if (!((d[i] >> 17) & 0x1))
378 printf(ANSI_COLOR_RED "Readout error\n" ANSI_COLOR_RESET);
379 if (!((d[i] >> 18) & 0x1))
380 printf(ANSI_COLOR_RED "TTC error\n" ANSI_COLOR_RESET);
381 if (!((d[i] >> 19) & 0x1))
382 printf(ANSI_COLOR_RED "Access error\n" ANSI_COLOR_RESET);
383 modId = 0x00;
384 slot = 0x00;
385 break;
386 default: // data
387 {
388 // BmnStatus parsing_status(kBMNSUCCESS);
389 switch (modId) {
390 case kTDC64V:
391 case kTDC64VHLE:
392 case kTDC72VHL:
393 case kTDC32VL:
394 FillTDC(d, serial, slot, modId, i);
395 break;
396 case kTQDC16:
397 case kTQDC16VS:
398 FillTQDC(d, serial, slot, modId, i);
399 break;
400 case kMSC16V:
401 FillMSC(d, serial, slot, i);
402 break;
403 case kTRIG:
404 /*parsing_status = */ FillFVME2TMWR(d, serial, i, len);
405 break;
406 case kU40VE_RC:
407 FillU40VE(d, slot, i, spillInfo);
408 break;
409 }
410 }
411 }
412 }
413 return kBMNSUCCESS;
414}
415
416BmnStatus BmnConverterThread::Process_HRB(UInt_t* d, UInt_t len, UInt_t serial)
417{
418 // UInt_t evId = d[0];
419 UInt_t tH = d[1];
420 UInt_t tL = d[2];
421 UInt_t nWords = 4; // 4 words per plane (per 96 channels, why 4 words - 3 is enough???)
422 UInt_t nSmpl = (len - 3) / nWords; // 3 words are read now. Why divide by 4 (To ask Vadim)
423
424 for (UInt_t iSmpl = 0; iSmpl < nSmpl; ++iSmpl) {
425 for (UInt_t iWord = 0; iWord < nWords; ++iWord) {
426 UInt_t word32 = d[3 + iWord + iSmpl * nWords];
427 for (Int_t iCh = 0; iCh < 32; ++iCh) {
428 if (word32 & BIT(iCh)) {
429 TClonesArray& ar_hrb = *hrb;
430 new (ar_hrb[hrb->GetEntriesFast()]) BmnHRBDigit(serial, iCh + 32 * iWord, iSmpl, tH, tL);
431 }
432 }
433 }
434 }
435
436 return kBMNSUCCESS;
437}
438
439BmnStatus BmnConverterThread::FillU40VE(UInt_t* d, UInt_t slot, UInt_t& idx, BmnTrigInfo& trigInfo)
440{
441 UInt_t type = d[idx] >> 28;
442 // printf("\t\tU40VE start type %u slot %u idx %u\n", type, slot, idx);
443 Bool_t countersDone = kFALSE;
444 while (type == kWORDTAI || type == kWORDTRIG || type == kWORDAUX) {
445 if (fPeriodId > 4 && type == kWORDTRIG && slot == kEVENTTYPESLOT) {
446 fCurEvent.fCurEvType = ((d[idx] & BIT(3)) >> 3) ? kBMNPEDESTAL : kBMNPAYLOAD;
447 // UInt_t trigSrc = ((d[idx] >> 16) & (BIT(8) - 1));
448 // printf("EvId %6u trig source %u evType %d\n", fEventId, trigSrc, evType);
449 // if (!( ((d[idx]>>10) & 0x1) ^ (fPeriodId >= 7 && fBmnSetup == kBMNSETUP)))
450 // printf("Ev not Good!\n");
451 // printf("evGood %d\n", (d[idx] & BIT(10)));
452 }
453 if (type == kWORDAUX && !countersDone) {
454 trigInfo.SetTrigCand(d[idx + 0] & 0xFFFFFFF);
455 trigInfo.SetTrigAccepted(d[idx + 1] & 0xFFFFFFF);
456 trigInfo.SetTrigBefo(d[idx + 2] & 0xFFFFFFF);
457 trigInfo.SetTrigAfter(d[idx + 3] & 0xFFFFFFF);
458 trigInfo.SetTrigRjct(d[idx + 4] & 0xFFFFFFF);
459 trigInfo.SetTrigAll(d[idx + 5] & 0xFFFFFFF);
460 trigInfo.SetTrigAvail(d[idx + 6] & 0xFFFFFFF);
461 idx += 4;
462 countersDone = kTRUE;
463 }
464 idx++; // go to the next DATA-word
465 type = d[idx] >> 28;
466 // printf("\t type %u slot %u idx %u\n", type, slot, idx);
467 }
468
469 return kBMNSUCCESS;
470}
471
472BmnStatus BmnConverterThread::FillTDC(UInt_t* d, UInt_t serial, UInt_t slot, UInt_t modId, UInt_t& idx)
473{
474 UInt_t type = d[idx] >> 28;
475 while (type != kMODTRAILER) { // data will be finished when module trailer appears
476 if (type == TDC_ERROR) {
477 LOGF(warning, "TDC (modID 0x%02X serial 0x%08X slot %d tdcID %d) error flags: 0x%04X", modId, serial, slot,
478 ((d[idx] >> 24) & 0xF), (d[idx] & ((1 << 15) - 1)));
479 if ((d[idx] & BIT(12)) || (d[idx] & BIT(13))) {
480 LOGF(warning, "TDC data loss in 0x%08X ", serial);
481 return kBMNERROR;
482 }
483 }
484 if (type == TDC_LEADING || type == TDC_TRAILING) {
485 UInt_t tdcId = (d[idx] >> 24) & 0xF;
486 UInt_t time =
487 (modId == kTDC64V) ? (d[idx] & 0x7FFFF) : ((d[idx] & 0x7FFFF) << 2) | ((d[idx] & 0x180000) >> 19);
488 UInt_t channel = (modId == kTDC64V) ? (d[idx] >> 19) & 0x1F : (d[idx] >> 21) & 0x7;
489 // if (modId == kTDC64V && tdcId == 2) channel += 32;
490 TClonesArray& ar_tdc = *tdc;
491 new (ar_tdc[tdc->GetEntriesFast()])
492 BmnTDCDigit(serial, modId, slot, (type == TDC_LEADING), channel, tdcId, time);
493 if (fCurEvent.fCurEvType == kBMNSTAT)
494 LOGF(debug4, "tdc %08X : %d channel %d", serial, slot, channel);
495 }
496 idx++; // go to the next DATA-word
497 type = d[idx] >> 28;
498 }
499 return kBMNSUCCESS;
500}
501
502BmnStatus BmnConverterThread::FillTQDC(UInt_t* d, UInt_t serial, UInt_t slot, UInt_t modId, UInt_t& idx)
503{
504 UInt_t type = d[idx] >> 28;
505 UShort_t trigTimestamp = 0;
506 UShort_t adcTimestamp = 0;
507 UShort_t tdcTimestamp = 0;
508 UInt_t iSampl = 0;
509 UInt_t channel = 0;
510 Short_t valI[ADC_SAMPLING_LIMIT];
511 Bool_t inADC = kFALSE;
512 while (type != kMODTRAILER) {
513 if (type == TDC_ERROR) {
514 LOGF(warning, "TDC (serial 0x%08X slot %d tdcID %d) error flags: 0x%04X", serial, slot,
515 ((d[idx] >> 24) & ((1 << 4) - 1)), (d[idx] & ((1 << 15) - 1)));
516 if ((d[idx] & BIT(12)) || (d[idx] & BIT(13))) {
517 LOGF(warning, "TQDC data loss in 0x%08X ", serial);
518 return kBMNERROR;
519 }
520 }
521 UInt_t mode = (d[idx] >> 26) & 0x3;
522 if (!inADC) { // printf("type %d mode %d word %0X\n", type, mode, d[idx]);
523 if ((mode == 0) && (type == TDC_LEADING || type == TDC_TRAILING)) { // TDC time
524 channel = (d[idx] >> 19) & 0x1F;
525 UInt_t time = ((d[idx] & 0x7FFFF) << 2) | ((d[idx] >> 24) & 0x3); // in 25 ps
526 // printf("TDC time %d channel %d\n", time, channel);
527 new ((*tqdc_tdc)[tqdc_tdc->GetEntriesFast()])
528 BmnTDCDigit(serial, modId, slot, (type == TDC_LEADING), channel, 0, time, tdcTimestamp);
529 // printf("tqdc tdc %08X : %d channel %d\n", serial, slot, channel);
530 } else if ((type == 4) && (mode != 0)) { // Trig | ADC Timestamp
531 channel = (d[idx] >> 19) & 0x1F;
532 if (d[idx] & BIT(16)) { // ADC TS
533 adcTimestamp = d[idx] & 0xFFFF;
534 inADC = kTRUE;
535 } else { // Trig TS
536 trigTimestamp = d[idx] & 0xFFFF;
537 }
538 } else if (type == TDC_EV_HEADER) {
539 tdcTimestamp = d[idx] & 0xFFF;
540 // UInt_t iEv = (d[idx] >> 12) & 0xFFF;
541 // printf("TDC ev header: %d\n", iEv);
542 } else if (type == TDC_EV_TRAILER) {
543 // UInt_t iEv = (d[idx] >> 12) & 0xFFF;
544 // printf("TDC ev trailer: %d\n", iEv);
545 }
546 } else {
547 if ((type == 5) && (mode == 2) && (iSampl < ADC_SAMPLING_LIMIT)) {
548 Short_t val = (d[idx] & ((1 << 14) - 1)) - (1 << (14 - 1));
549 valI[iSampl++] = val;
550 } else {
551 new ((*tqdc_adc)[tqdc_adc->GetEntriesFast()])
552 BmnTQDCADCDigit(serial, channel, slot, iSampl, valI, trigTimestamp, adcTimestamp);
553 inADC = kFALSE;
554 iSampl = 0;
555 --idx;
556 // printf("tqdc adc %08X : %d channel %d\n", serial, slot, channel);
557 }
558 }
559 type = d[++idx] >> 28;
560 }
561 return kBMNSUCCESS;
562}
563
564BmnStatus BmnConverterThread::FillBlockADC(UInt_t* d, UInt_t serial, uint8_t channel, uint16_t& len, TClonesArray* ar)
565{
566 int16_t valI[ADC_SAMPLING_LIMIT];
567 const uint8_t NBytesInSample = 2;
568 uint16_t iWord = 0;
569 while (iWord < len) {
570 uint16_t adcTS = d[iWord] & (BIT(16) - 1);
571 uint16_t SigLen = d[iWord] >> 16;
572 uint16_t NSamples = SigLen / NBytesInSample;
573 uint16_t NSampleWords = SigLen / kNBYTESINWORD + ((SigLen % kNBYTESINWORD) ? 1 : 0);
574 // printf("adc len %2u ts %3u NSampleWords %u\n", NSamples, adcTS, NSampleWords);
575 if (iWord + NSampleWords + 1 > len) {
576 printf("Error! TQDC ADC wrong payload length! iWord %u SigLen %u len %u\n", iWord, SigLen, len);
577 return kBMNERROR;
578 }
579 uint16_t iSampleWord = 0;
580 while (iSampleWord++ < NSampleWords) {
581 int16_t adcLo = static_cast<int16_t>(d[iWord + iSampleWord] & (BIT(16) - 1));
582 int16_t adcHi = static_cast<int16_t>(d[iWord + iSampleWord] >> 16);
583 // printf("\tadcHi %4d adcLow %4d\n", adcHi, adcLo);
584 valI[iSampleWord * 2 - 2] = adcLo;
585 valI[iSampleWord * 2 - 1] = adcHi;
586 }
587 // no slot id for ethernet
588 if (NSamples)
589 new ((*ar)[ar->GetEntriesFast()]) BmnTQDCADCDigit(serial, channel, 0, NSamples, valI, 0, adcTS);
590 iWord += iSampleWord;
591 }
592 return kBMNSUCCESS;
593}
594
595BmnStatus BmnConverterThread::FillBlockTDC(UInt_t* d, UInt_t serial, uint16_t& len, TClonesArray* ar, UInt_t modid = 0)
596{
597 // uint16_t tdcTS = 0;
598 // uint8_t tdcId = 0;
599 uint16_t tdcLine = 0;
600 while (tdcLine < len) {
601 UInt_t word = d[tdcLine];
602 UInt_t bt = word >> 28;
603 switch (bt) {
604 case TDC_EV_HEADER: {
605 // uint16_t evId = (word >> 12) & (BIT(12) - 1);
606 // tdcId = (word >> 24) & (BIT(4) - 1);
607 // tdcTS = word & (BIT(12) - 1);
608 // printf("\tTDC header ev %u TS %u\n", evId, tdcTS);
609 break;
610 }
611 case TDC_EV_TRAILER: {
612 // uint16_t evId = (word >> 12) & (BIT(12) - 1);
613 // uint16_t tdcWC = word & (BIT(12) - 1);
614 // printf("\tTDC trailer ev %u WC %u\n", evId, tdcWC);
615 break;
616 }
617 case TDC_LEADING:
618 case TDC_TRAILING: {
619 uint8_t channel = (word >> 21) & (BIT(7) - 1);
620 // uint16_t time = (word>>2) & (BIT(19) - 1);
621 UInt_t time = word & (BIT(21) - 1);
622 // printf("\tTDC %s ch %u id %d time %u\n", (bt == TDC_LEADING) ? "leading" : "trailing",
623 // channel, tdcId, time);
624 new ((*ar)[ar->GetEntriesFast()])
625 BmnTDCDigit(serial, modid, 0, (bt == TDC_LEADING), channel, 0, time, 0); // ignore tdcId in TQDC
626 break;
627 }
628 case TDC_ERROR:
629 LOGF(warning, "TDC (serial 0x%08X tdcID %d) error flags: 0x%04X %s", serial,
630 ((word >> 24) & ((1 << 4) - 1)), (word & ((1 << 15) - 1)),
631 ((word & BIT(12)) || (word & BIT(13))) ? "data lost" : "");
632 break;
633 }
634 tdcLine++;
635 }
636 return kBMNSUCCESS;
637}
638
639BmnStatus BmnConverterThread::FillTQDC_E(UInt_t* d, UInt_t serial, UInt_t& len)
640{
641 UInt_t index = 0;
642 // MStreamHeader* ms = reinterpret_cast<MStreamHeader*> (d);
643 index += sizeof(MStreamHeader) / kNBYTESINWORD;
644 // ms->Print();
645 MStreamTAI* ms0 = reinterpret_cast<MStreamTAI*>(d + index);
646 if (ms0->valid())
647 FillWR(serial, fCurEvent.fEventId, ms0->Sec, ms0->NSec);
648 index += sizeof(MStreamTAI) / kNBYTESINWORD;
649 // printf("len %u msHeader len %u\n", len, ms.Len / kNBYTESINWORD);
650 // printf("taiFlags %u TAI %s\n",
651 // ms0->Flags, TTimeStamp(time_t(ms0->Sec), ms0->NSec).AsString());
652 while (index < len) {
653 TqdcDataHeader* th = reinterpret_cast<TqdcDataHeader*>(d + index);
654 index += sizeof(TqdcDataHeader) / kNBYTESINWORD;
655 // printf("TQDC DataType %u channel %2u adcBits %u len %4u %8X\n", th->DataType, th->Chan,
656 // th->AdcBits, th->Len,*th);
657 uint16_t blockLen = th->Len / kNBYTESINWORD;
658 switch (th->DataType) {
660 FillBlockTDC(d + index, serial, blockLen, tqdc_tdc);
661 break;
663 FillBlockADC(d + index, serial, th->Chan, blockLen, tqdc_adc);
664 break;
665 default:
666 printf("Wrong TQDC data type %u !\n", th->DataType);
667 break;
668 }
669 index += blockLen;
670 }
671 return kBMNSUCCESS;
672}
673
674BmnStatus BmnConverterThread::FillTDC72VXS(UInt_t* d, UInt_t serial, UInt_t& len, UInt_t modid = 0)
675{
676 UInt_t index = 0;
677 // MStreamHeader* ms = reinterpret_cast<MStreamHeader*> (d);
678 index += sizeof(MStreamHeader) / kNBYTESINWORD;
679 // ms->Print();
680 MStreamTAI* ms0 = reinterpret_cast<MStreamTAI*>(d + index);
681 if (ms0->valid())
682 FillWR(serial, fCurEvent.fEventId, ms0->Sec, ms0->NSec);
683 // printf("taiFlags %u TAI %s\n",
684 // ms0->Flags, TTimeStamp(time_t(ms0->Sec), ms0->NSec).AsString());
685 index += sizeof(MStreamTAI) / kNBYTESINWORD;
686 while (index < len) {
687 uint8_t dtype = d[index] >> 28;
688 bool overflow = d[index] & BIT(16);
689 uint16_t blockLen = (d[index++] & (BIT(16) - 1)) / kNBYTESINWORD;
690 if (!overflow)
691 switch (dtype) {
693 // printf("TDC at index %4u len %4u\n", index, blockLen);
694 FillBlockTDC(d + index, serial, blockLen, tdc, modid);
695 break;
697 break;
698 default:
699 printf("Wrong VXS data type %u !\n", dtype);
700 break;
701 }
702 index += blockLen;
703 }
704 return kBMNSUCCESS;
705}
706
707BmnStatus BmnConverterThread::FillTTVXS(UInt_t* d, UInt_t serial, UInt_t& len)
708{
709 UInt_t index = 0;
710 // MStreamHeader* ms = reinterpret_cast<MStreamHeader*> (d);
711 index += sizeof(MStreamHeader) / kNBYTESINWORD;
712 // ms->Print();
713 MStreamTAI* ms0 = reinterpret_cast<MStreamTAI*>(d + index);
714 index += sizeof(MStreamTAI) / kNBYTESINWORD;
715 if (ms0->valid())
716 FillWR(serial, fCurEvent.fEventId, ms0->Sec, ms0->NSec);
717 // LOGF(debug, "ts :\t %s TTVXS 0x%08X valid %d",
718 // TTimeStamp(time_t(ms0->Sec), ms0->NSec).AsString(), serial, ms0->valid());
719 // LOGF(debug, "ts :\t %10u %9u TTVXS 0x%08X", ms0->Sec, ms0->NSec, serial);
720 while (index < len) {
721 uint8_t dtype = d[index] >> 28;
722 bool overflow = d[index] & BIT(16);
723 uint16_t blockLen = (d[index++] & (BIT(16) - 1)) / kNBYTESINWORD;
724 // printf("type 0x%02X len %4u\n", dtype, blockLen);
725 if (!overflow)
726 switch (dtype) {
727 case kMSTREAM_TYPE_TRIG: {
728 // printf("Trig at index %4u len %4u\n", index, blockLen);
729 // uint8_t trigType = (d[index] << 8) & (BIT(8) - 1);
730 // uint8_t trigSrc = d[index] & (BIT(8) - 1);
731 // printf("Trig type %4u src %4u\n", trigType, trigSrc);
732 } break;
734 break;
735 default:
736 printf("Wrong TTVXS data type %u !\n", dtype);
737 break;
738 }
739 index += blockLen;
740 }
741 return kBMNSUCCESS;
742}
743
744BmnStatus BmnConverterThread::ProcessGenericDevice(UInt_t* d, DeviceHeader* dev_hdr)
745{
746 // dev_hdr->Print();
747 if ((dev_hdr->Serial & 0x00FFFFFF) == kVSP_SERIALS)
748 return MapVSP(d, dev_hdr);
749 else if (dev_hdr->Serial == kHGND_SERIALS)
750 return FillTDC250HGND(d, dev_hdr->Serial, dev_hdr->Len);
751 else
752 LOGF(error, "BmnRawSource::ProcessGenericDevice: Unknown device serial 0x%08X", dev_hdr->Serial);
753
754 return kBMNSUCCESS;
755}
756
757BmnStatus BmnConverterThread::FillTDC250HGND(UInt_t* d, UInt_t serial, UInt_t len)
758{
759 if (!d || len == 0)
760 return kBMNSUCCESS;
761
762 uint16_t* words = reinterpret_cast<uint16_t*>(d);
763 size_t total_words = len / sizeof(uint16_t);
764
765 if (FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug4)) {
766 for (size_t i = 0; i < total_words; ++i)
767 LOGF(debug4, "0x%04x", words[i]);
768 }
769
770 size_t index = 0;
771 std::vector<uint16_t> event_words;
772 std::unique_ptr<BmnHgndRaw::FIFO_block> event;
773
774 while (index < total_words) {
775 uint16_t* word = words + index;
777 LOGF(error, "BmnRawSource::FillTDC250HGND: Wrong header 0x%04X", *word);
778 return kBMNERROR;
779 }
780
781 auto event_type = BmnHgndRaw::Block::get_event_packet_version(*word);
782 uint32_t event_length = BmnHgndRaw::Block::get_block_size(event_type); // in 16-bit words
783
784 LOGF(debug4, "Event type %d, 16bit words %d (index=%zu, total=%zu)", (uint32_t)event_type, event_length, index,
785 total_words);
786
787 if (index + event_length > total_words) {
788 LOGF(error, "BmnRawSource::FillTDC250HGND: Event block overruns buffer");
789 return kBMNERROR;
790 }
791
792 event_words.assign(word, word + event_length);
793 if (FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug4)) {
794 for (size_t i = 0; i < event_words.size(); ++i) {
795 LOGF(debug4, "0x%04x", event_words[i]);
796 }
797 }
798
799 if (event_type == BmnHgndRaw::Block::EventPacketVersion::V1) {
800 event = std::make_unique<BmnHgndRaw::Event_type_1>(event_words);
801 } else if (event_type == BmnHgndRaw::Block::EventPacketVersion::V2) {
802 event = std::make_unique<BmnHgndRaw::Event_type_2>(event_words);
803 if (!event->validate()) {
804 LOGF(error, "BmnRawSource::FillTDC250HGND: Event block validation failed");
805 return kBMNERROR;
806 }
807
808 auto* ev2 = dynamic_cast<BmnHgndRaw::Event_type_2*>(event.get());
809 if (!ev2) {
810 LOGF(error, "BmnRawSource::FillTDC250HGND: Event cast to Event_type_2 failed");
811 return kBMNERROR;
812 }
813
814 uint8_t trise_100ps = ev2->TDC_rise_time; // raw time rise
815 uint8_t tfall_100ps = ev2->TDC_falling_time; // raw time fall
816 int64_t time_sec = ev2->timestamp >> 31; // WR timestamp, seconds part
817 time_sec -= tai_utc_dif;
818 uint64_t time_nsec = ((ev2->timestamp & 0x7ffffff0) >> 4) * 32; // WR timestamp, ns part. 32ns step
819 uint16_t time_100ps =
820 (ev2->timestamp & 0xf) * 32 + trise_100ps; // 3.2ns step + 100ps step subns part. trise
821 uint16_t plen_100ps =
822 (ev2->pulse_length + 1) * 32 + tfall_100ps - trise_100ps; // pulse len x100ps +fall -rise
823
824 LOGF(debug4, "ch_num = 0x%02X", ev2->channel_number);
825 LOGF(debug4, "timestamp = 0x%016lX", ev2->timestamp);
826 LOGF(debug4, "time_sec = 0x%08X", time_sec);
827 LOGF(debug4, "time_nsec = 0x%08X", time_nsec);
828 LOGF(debug4, "trise_100ps = 0x%02X", trise_100ps);
829 LOGF(debug4, "tfall_100ps = 0x%02X", tfall_100ps);
830 LOGF(debug4, "time_100ps = 0x%04X", time_100ps);
831 LOGF(debug4, "plen_100ps = 0x%04X", plen_100ps);
832 LOGF(debug4, "global_ch = 0x%04X", ev2->channel_number_global);
833
834 new ((*tdc_hgnd)[tdc_hgnd->GetEntriesFast()])
835 BmnAbstractTDCDigit(serial, ev2->channel_number_global, time_sec, time_nsec, time_100ps, plen_100ps);
836 } else {
837 LOGF(error, "BmnRawSource::FillTDC250HGND: Wrong event type");
838 return kBMNERROR;
839 }
840
841 index += event_length;
842 }
843
844 return kBMNSUCCESS;
845}
846
847BmnStatus BmnConverterThread::MapVSP(UInt_t* d, DeviceHeader* dev_hdr)
848{
849 LOGF(debug, "MapVSP");
850 if (dev_hdr->GetNWords() < 3) {
851 LOGF(warning, "Empty VSP block");
852 return kBMNERROR;
853 }
854 uint8_t iComp = (dev_hdr->Serial & 0xFF000000) >> 24;
855 time_slice_map[iComp] = d;
856 return kBMNSUCCESS;
857}
858
859BmnStatus BmnConverterThread::FillVSP(TClonesArray* ar)
860{
861 LOGF(debug, "FillVSP");
862 const uint8_t kuMaxComps = 10; // maximum AFCKs (comps)
863 uint16_t fvuCurrentTsMsbCycle[kuMaxComps] = {}; // FLES Timestamp cycling
864 uint64_t fvulCurrentTsMsb[kuMaxComps] = {}; // FLES Ts_Msb buffer values
865 unique_ptr<fles::StorableTimeslice> stti(new fles::StorableTimeslice(1));
866 uint8_t nComp = time_slice_map.size();
867 // if (nComp != 2)
868 // LOGF(warning, "\t ncomps = %lu", nComp);
869 // append components with a single timeslice
870 for (uint8_t iw01 = 0; iw01 < nComp; iw01++)
871 (*stti).append_component(1);
872 // append microslice #0 to each component
873 for (auto& el : time_slice_map) {
874 uint8_t iw01 = el.first;
875 auto* mslice_descr = el.second;
876 (*stti).append_microslice(iw01, 0, *((fles::MicrosliceDescriptor*)mslice_descr),
877 (uint8_t*)mslice_descr + sizeof(fles::MicrosliceDescriptor));
878 }
879 for (uint8_t uw02 = 0; uw02 < nComp; uw02++) {
880 // microslice descriptor #0 (must be only one microslice) of component (FEB) #uw02
881 const fles::MicrosliceDescriptor& msd = (*stti).descriptor(uw02, 0);
882 // get the current DPB idx
883 uint16_t fuCurrentEquipmentId = static_cast<uint16_t>(msd.eq_id);
884 uint16_t fusCurrentDpbIdx = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
885
886 // get the trigger number from microslice
887 uint64_t tgn = msd.idx;
888 if (tgn != fCurEvent.fEventId)
889 LOGF(warning, "!!! Misplaced VSP event! tgn = %lu while EventId = %u !!!\n", tgn, fCurEvent.fEventId);
890 uint32_t tgNev = static_cast<uint32_t>(tgn); // Ex24
891 // printf("fles tgN = %lu\t",tgn); printf("fles CurrDpbId = %u\n", fusCurrentDpbIdx);
892 // if ( tgn% kuUpdateTgN==0 ) {
893 // printf("ev. tgN = %u\t",tgNev);
894 // printf("fles tgN = %lu\t",tgn);
895 // printf("fles CurrDpbId = %u\n", fusCurrentDpbIdx);}
896 // do what is needed with the microslice
897
898 uint32_t size = 0; // the buffer size of the Microslice
899 uint32_t uNbMessages = 0; // the number of complete messages
900 // double dTriggerTime = 0; // TrigTime in ns
901 uint64_t uiTrgTimeFLES = 0; // TrigTime in clocks
902 uint64_t uiHitTimeFLES = 0; // Hits Time in clocks
903
904 size = msd.size;
905 static const uint32_t kuBytesPerMessage = 4;
906 // Compute the number of complete messages in the input microslice buffer
907 uNbMessages = (size - (size % kuBytesPerMessage)) / kuBytesPerMessage;
908 // Prepare variables for the loop on contents
909 // const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( (*stti).content(0,0) );
910 const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>((*stti).content(uw02, 0));
911
912 // uiTrgTimeFLES = 0;
913 uint64_t uiTrgTime_TsMsb = 0;
914 uint64_t uiHitTime_TsMsb = 0;
915 uint64_t uiTrgTime_Epoch = 0;
916
917 uint16_t uiTsMsbMessageNumber = 0; // to take only the 1st TsMsb message
918 uint16_t uiEpochMessageNumber = 0; // to take only the 1st TsMsb message
919
920 uint16_t usHitMissedEvts = 0; // local counter of Hits with the Missed Events Flag
921 if (uNbMessages == 0)
922 continue;
923 BmnVspRawDigit* dig = new ((*vsp)[vsp->GetEntriesFast()]) BmnVspRawDigit(tgn, fusCurrentDpbIdx);
924
925 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
926 // Fill message
927 uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]);
928
929 stsxyter::Message mess(static_cast<uint32_t>(ulData & 0xFFFFFFFF));
930 stsxyter::MessType typeMess = mess.GetMessType();
931 // if (fbTxtFileOutEna) *foutHitInfoUNI << "typeMess " << static_cast< uint16_t >( typeMess) << std::endl;
932 switch (typeMess) {
934 // The first message in the TS is a special ones: EPOCH
935 uiEpochMessageNumber++;
936 // dTriggerTime = mess.GetEpochVal() * stsxyter::kdClockCycleNs;
937 if (uiEpochMessageNumber == 1)
938 uiTrgTime_Epoch = mess.GetEpochVal(); // all 29 bits, may24
939 else
940 printf("fles WARNING: more than one EPOCH message in event tgN = %lu, exactly: %u\n", tgn,
941 uiEpochMessageNumber);
942 break;
943 }
945 uiTsMsbMessageNumber++;
946 uint64_t uVal = mess.GetTsMsbValBinning();
947 if (uVal < fvulCurrentTsMsb[uw02]) {
948 printf("TsMsbCycle: event trigger# %u", tgNev);
949 printf("\tDPB: %u, Old TsMsb= %lu, new TsMsb=%lu, Old MsbCy=%u\n", uw02, fvulCurrentTsMsb[uw02],
950 uVal, fvuCurrentTsMsbCycle[uw02]);
951
952 if ((fvulCurrentTsMsb[uw02] - uVal) > 10000000)
953 fvuCurrentTsMsbCycle[uw02]++;
954
955 } // if( uVal < fvulCurrentTsMsb[uw02] )
956 fvulCurrentTsMsb[uw02] = uVal;
957 uiHitTime_TsMsb = uVal << 10; // shift to 10 bits;
958 uiHitTime_TsMsb += static_cast<uint64_t>(stsxyter::kulTsCycleNbBinsBinning)
959 * fvuCurrentTsMsbCycle[uw02]; // TsMsbCycle added
960 if (uiTsMsbMessageNumber == 1) {
961 uiTrgTime_TsMsb =
962 uiHitTime_TsMsb & 0xFFE0000000; // remove the lower 29 bits, the faster procedure
963 }
964 break;
965 } // case stsxyter::MessType::TsMsb :
967 uint16_t usRawTs = static_cast<uint16_t>(mess.GetHitTimeBinning());
968 uiHitTimeFLES = uiHitTime_TsMsb + static_cast<uint64_t>(usRawTs);
969 uint16_t usElinkIdx = mess.GetLinkIndexHitBinning();
970 uint16_t usChan = mess.GetHitChannel();
971 uint16_t usRawAdc = mess.GetHitAdc();
972
973 if (mess.IsHitMissedEvts())
974 usHitMissedEvts++;
975 dig->AppendHit(uiHitTimeFLES, usElinkIdx, usChan, usRawAdc);
976 break;
977 }
978 default:
979 break;
980 } // switch( typeMess )
981
982 } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx )
983 dig->SetTHitMissedEvts(usHitMissedEvts);
984 uiTrgTimeFLES = uiTrgTime_TsMsb + uiTrgTime_Epoch;
985 dig->SetTTrigTime(uiTrgTimeFLES);
986 }
987 time_slice_map.clear();
988 return kBMNSUCCESS;
989}
990
991BmnStatus BmnConverterThread::FillMSC16VE_E(UInt_t* d, DeviceHeader* dev_hdr)
992{
993 // msc->Delete();
994 UInt_t index = 0;
995 const uint32_t len = dev_hdr->GetNWords();
996 MSC16VE_EHeader* ms = reinterpret_cast<MSC16VE_EHeader*>(d);
997 index += sizeof(MSC16VE_EHeader) / kNBYTESINWORD;
998 // ms->Hdr.Print();
999 if (ms->Hdr.Len > (len - 1)) {
1000 LOGF(error, "MSC header payload length mismatch!");
1001 return kBMNERROR;
1002 }
1003 // LOGF(info, "MSC TAI\t%s taiFlags %u ", TTimeStamp(time_t(ms->Tai.Sec), ms->Tai.NSec).AsString(),
1004 // ms->Tai.Flags); LOGF(info, "MSC ver %u CntrBitsNum %u SliceInt %3u ns ChanNum %2u ExtCondNum %u",
1005 // ms->GetVersion(), ms->NCntrBits, ms->SliceInt, ms->ChanNumber, ms->ExtCondCnt);
1006 Bool_t hasValues = kFALSE;
1007 std::array<uint8_t, MSC_N_COUNTERS> cntrs = {};
1008 switch (ms->GetVersion()) {
1009 case 1: {
1010 const uint8_t NumsInWord = 4;
1011 while (index < len) {
1012 uint8_t type = d[index] >> 28;
1013 // printf(" index %4u len %4u type %u\n", index, len, type);
1014 if (type == MSC_TIME_SLICE_INFO) {
1015 if (hasValues) {
1016 UInt_t ext_cond = (d[index] >> 24) & (BIT(4) - 1);
1017 UInt_t sliceNum = (d[index]) & (BIT(24) - 1);
1018 auto sc_time_shift = ms->SliceInt * sliceNum * 1ns;
1019 SysPoint p{(ms->Tai.Sec - tai_utc_dif) * 1s + ms->Tai.NSec * 1ns + sc_time_shift};
1020 LOGF(debug, "MSC ext_cond %2u sliceNum %7u time %s", ext_cond, sliceNum,
1022 new ((*msc)[msc->GetEntriesFast()])
1023 BmnMSCDigit<uint8_t>(dev_hdr->Serial, 0, cntrs, fCurEvent.fEventId, p, ext_cond);
1024 hasValues = kFALSE;
1025 memset(cntrs.data(), 0, sizeof(UChar_t) * MSC_N_COUNTERS);
1026 }
1027 } else {
1028 for (uint8_t i = 0; i < NumsInWord; i++) {
1029 UInt_t cnt = (d[index] >> (i * ms->NCntrBits)) & (BIT(ms->NCntrBits) - 1);
1030 cntrs[type * NumsInWord + i] = cnt;
1031 // LOGF(info,"\tcnt[%2u] = %2u", (type * NumsInWord + i), cnt);
1032 hasValues = kTRUE;
1033 }
1034 }
1035 index++;
1036 }
1037 } break;
1038 case 2: {
1039 UInt_t missing_hits = d[index++];
1040 if (missing_hits)
1041 LOGF(info, "missing_hits %3u !!!", missing_hits);
1042 LOGF(debug, "missing_hits %u", missing_hits);
1043 // uint8_t channel = ms->ChanNumber;
1044 // TimeDist& scaler_cnts = metadata->Scalers()[make_pair(serial, channel)];
1045 // TimeDist& ext_cnts = metadata->ExtConditions();
1046 SysPoint point{(ms->Tai.Sec - tai_utc_dif) * 1s + ms->Tai.NSec * 1ns};
1047 uint32_t n_slices = ms->Hdr.Len - 1 - (sizeof(MSC16VE_EHeader) - sizeof(MStreamHeader)) / kNBYTESINWORD;
1048 BmnMSCZSDigit<uint8_t>* dig = new ((*msc)[msc->GetEntriesFast()])
1049 BmnMSCZSDigit<uint8_t>(dev_hdr->Serial, ms->ChanNumber, point, n_slices);
1050 vector<uint8_t>& vals = dig->GetValues();
1051 vector<SysPoint>& times = dig->GetTimes();
1052 vector<uint8_t>& conds = dig->GetExtCond();
1053 int32_t istart = index;
1054 while (index < len) {
1055 uint8_t cnt = d[index] & (BIT(ms->NCntrBits) - 1);
1056 uint8_t ext_cond = (d[index] >> ms->NCntrBits) & (BIT(ms->ExtCondCnt) - 1);
1057 UInt_t sliceNum = d[index] >> (ms->NCntrBits + ms->ExtCondCnt);
1058 auto sc_time_shift = ms->SliceInt * sliceNum * 1ns;
1059 SysPoint point_slice{point + sc_time_shift};
1060 int32_t iVal = index - istart;
1061 // LOGF(info, "iVal %4u", iVal);
1062 vals[iVal] = cnt;
1063 times[iVal] = point_slice;
1064 conds[iVal] = ext_cond;
1065 // LOGF(info, "MSC i %2u len %3u", index, len);
1066 LOGF(debug, "MSC ext_cond %2u cnt %2u sliceNum %7u time %s", ext_cond, cnt, sliceNum,
1067 BmnFunctionSet::TimePoint2String(point_slice).c_str());
1068
1069 // scaler_cnts.insert(make_pair(p, cnt));
1070 // ext_cnts.insert(make_pair(p, ext_cond));
1071
1072 // cntrs[ms->ChanNumber] = cnt;
1073 // new ((*msc)[msc->GetEntriesFast()]) BmnMSCDigit<uint8_t>(serial, 0, cntrs, fEventId,
1074 // p, ext_cond); memset(cntrs.data(), 0, sizeof(UChar_t) * MSC_N_COUNTERS);
1075 index++;
1076 }
1077 } break;
1078 default:
1079 LOGF(warning, "MSC16 ver $u not implemented", ms->GetVersion());
1080 return kBMNERROR;
1081 break;
1082 }
1083 // if ((fRootFileOut) && (msc->GetEntries()))
1084 // fRawTreeSpills->Fill();
1085 return kBMNSUCCESS;
1086}
1087
1088BmnStatus BmnConverterThread::FillVirtualDevice(UInt_t* d, DeviceHeader* dh)
1089{
1090 LOGF(info, "Found virtual device 0x%08X block", dh->Serial);
1091 LOGF(info, "Ev %u type %u", fCurEvent.fEventId, (UInt_t)(fCurEvent.fCurEvType));
1092 if (dh->Serial != SERIAL_TO_CFG) {
1093 LOGF(info, "Not T0 device");
1094 return kBMNSUCCESS;
1095 }
1096 const Int_t bin_block_len = kT0_BIN_BLOCK_WORDS * kNBYTESINWORD;
1097 if (fExportExternalSpillStat) {
1098 std::ofstream outfile(Form("virt_device_run_%u_%08X_%02X_t_%lld_%lld.txt", fCurEvent.fRunId, dh->Serial,
1099 dh->DeviceId, // fSubName.Data(),
1100 fCurEvent.fTime_s, fCurEvent.fTime_ns),
1101 ios::out | ios::binary);
1102 for (UInt_t i = 0; i < kT0_BIN_BLOCK_WORDS; i++)
1103 outfile << std::hex << d[i];
1104 outfile.write(reinterpret_cast<const char*>(d) + bin_block_len, dh->Len - bin_block_len);
1105 }
1106 // t0raw->Delete();
1107 auto lastT0 = new ((*t0raw)[t0raw->GetEntriesFast()]) BmnT0Raw<kT0_BIN_BLOCK_WORDS>(d);
1108 const Int_t date_len = 19; // 23.12.2022 14:17:46
1109 TString str(reinterpret_cast<const char*>(d + kT0_BIN_BLOCK_WORDS), date_len);
1110 TPRegexp re_str_cfg_t0("(\\d{2})\\.(\\d{2})\\.(\\d{4})\\s(\\d{2}:\\d{2}:\\d{2})");
1111 int32_t re_subst_ret = re_str_cfg_t0.Substitute(str, "$3-$2-$1 $4");
1112 LOGF(info, "ts line return %d", re_subst_ret);
1113 for (UInt_t i = 0; i < kT0_BIN_BLOCK_WORDS; i++) {
1114 LOGF(debug, "cntr[%3d]: %8u", i, d[i]);
1115 }
1116 uint64_t t_2020_sec(d[kT0_BIN_BLOCK_2020_SEC]);
1117 uint64_t t_unix_sec(*reinterpret_cast<uint64_t*>(d + kT0_BIN_BLOCK_UNIX_SEC));
1118 // LOGF(info, "t_2020_sec %u", t_2020_sec);
1119 // LOGF(info, "t_unix_sec %u", t_unix_sec);
1120 TTimeStamp ts_unix_sec(t_unix_sec, 0);
1121 TTimeStamp ts_2020_sec(t_2020_sec + TTimeStamp(2020, 1, 1, 0, 0, 0), 0);
1122 LOGF(info, "unix ts: %s", ts_unix_sec.AsString());
1123 LOGF(info, "2020 ts: %s", ts_2020_sec.AsString());
1124 uint32_t trig_bit_conf(d[kT0_BIN_BLOCK_WORDS - 1]);
1125 lastT0->SetTriggerMask(trig_bit_conf);
1126 bitset<32> trig_bit_conf_bs(trig_bit_conf);
1127 LOGF(debug, "trig bitset %u", trig_bit_conf);
1128 LOGF(debug, "trig bitset %s", trig_bit_conf_bs.to_string());
1129 uint32_t pos = kT0_BIN_BLOCK_WORDS * kNBYTESINWORD + date_len;
1130 string tcfg(reinterpret_cast<const char*>(d) + pos, dh->Len - pos);
1132 return kBMNERROR;
1133 }
1134
1135 ts_unix_sec =
1136 TTimeStamp(ts_unix_sec.GetSec() - 3 * 3600,
1137 ts_unix_sec.GetNanoSec()); // crutch: shifting time zone from Moscow -> GMT for uniformity
1138 if (t_unix_sec > 0)
1139 lastT0->SetTS(ts_unix_sec);
1140 else {
1141 if (t_2020_sec > 0) {
1142 lastT0->SetTS(ts_2020_sec);
1143 } else if (re_subst_ret > 0) {
1144 TDatime dt(str);
1145 TTimeStamp ts_from_string(static_cast<UInt_t>(dt.GetDate()), static_cast<UInt_t>(dt.GetTime()), 0u);
1146 LOGF(info, "ts line: %s", ts_from_string.AsString());
1147 ts_from_string = TTimeStamp(
1148 ts_from_string.GetSec() - 3 * 3600,
1149 ts_from_string.GetNanoSec()); // crutch: shifting time zone from Moscow -> GMT for uniformity
1150 // struct tm tm_time;
1151 // strptime(str.Data(), "%d.%m.%Y %H:%M:%S", &tm_time);
1152 // std::time_t time_t_time = std::mktime(&tm_time);
1153 // SysPoint time_point = SysClock::from_time_t(time_t_time);
1154 // time_point -= 3h; // crutch: shifting time zone from Moscow -> GMT for uniformity
1155 // LOG(info) << "T0 point: " << BmnFunctionSet::TimePoint2String(time_point);
1156 // lastT0->SetTime(time_point);
1157 lastT0->SetTS(ts_from_string);
1158 } else
1159 LOGF(warning, "Unable to find raw T0 block timestamp!");
1160 }
1161 auto tsle =
1162 lastT0->GetTime() - BmnFunctionSet::TimeStamp2TP(TTimeStamp(time_t(fCurEvent.fTime_s), fCurEvent.fTime_ns));
1163 // lastT0->SetTimeSinceLastEv(tsle);
1164 // Get time since last event (surely it will be incorrect for several ns, but at average precise enough to assign it
1165 // to the spill)
1166 lastT0->SetTimeSinceLastEvNs(duration_cast<nanoseconds>(tsle).count());
1167 // if (fRootFileOut)
1168 // fRawTreeSpillsT0->Fill();
1169 return kBMNSUCCESS;
1170}
1171
1172BmnStatus BmnConverterThread::FillUT24VE_TRC(UInt_t* d, UInt_t& serial, UInt_t& len)
1173{
1174 UInt_t index = 0;
1175 MStreamHeader* ms = reinterpret_cast<MStreamHeader*>(d);
1176 index += sizeof(MStreamHeader) / kNBYTESINWORD;
1177 // ms->Print();
1178 // start bit input time in the MStreamTAI, and should be the 4th word timeslice
1179 MStreamTAI* ms0 = reinterpret_cast<MStreamTAI*>(d + index);
1180 if (ms0->valid()) {
1181 BmnSyncDigit* sd = FillWR(serial, fCurEvent.fEventId, ms0->Sec, ms0->NSec);
1182 fCurEvent.fTime_ns = sd->GetTime_ns();
1183 fCurEvent.fTime_s = sd->GetTime_sec();
1184 }
1185 index += sizeof(MStreamTAI) / kNBYTESINWORD;
1186 if (ms->Len / kNBYTESINWORD > len)
1187 LOGF(error, "UT24VE-TRC Error! MSHeader payload length larger than from device header!");
1188 fCurEvent.fCurEvType = (d[index] & BIT(16)) ? kBMNPEDESTAL : kBMNPAYLOAD;
1189 // bool randomTrigger = d[index] & BIT(17);
1190 // bool periodicTrigger = d[index] & BIT(18);
1191 // bool externalTTL = d[index] & BIT(19);
1194 vector<uint32_t>& vec = eventHeaderDAQ->GetInputSignalsVector();
1195 while (++index < len) {
1196 uint32_t sig_states = d[index];
1197 vec.push_back(sig_states);
1198 bitset<32> sig_states_bs(sig_states);
1199 LOGF(debug2, "TRC states d[%3u] %s", index, sig_states_bs.to_string());
1200 }
1201 return kBMNSUCCESS;
1202}
1203
1204BmnSyncDigit* BmnConverterThread::FillWR(UInt_t serial, ULong64_t iEvent, Long64_t t_sec, Long64_t t_ns)
1205{
1206 // LOGF(debug4, "Fill WR %08X", serial);
1207 // LOGF(info, "Fill WR %08X RS ts %s", serial, TTimeStamp(time_t(t_sec), t_ns).AsString());
1208 if (tai_utc_dif == 0) {
1209 tai_utc_dif = GetUTCShift(TTimeStamp(time_t(t_sec), t_ns));
1210 if (tai_utc_dif == 0)
1211 LOGF(warn, "Possibly wrong state of %08X", serial);
1212 }
1213 return new ((*sync)[sync->GetEntriesFast()]) BmnSyncDigit(serial, iEvent, t_sec - tai_utc_dif, t_ns);
1214}
1215
1216BmnStatus BmnConverterThread::FillFVME2TMWR(UInt_t* d, UInt_t serial, UInt_t& idx, UInt_t& len)
1217{
1218 while (idx < len) {
1219 UInt_t word = d[idx];
1220 UInt_t id = word >> 28;
1221 switch (id) {
1222 case TMWR_TAI: {
1223 UInt_t d0 = d[idx + 0];
1224 UInt_t d1 = d[idx + 1];
1225 UInt_t d2 = d[idx + 2];
1226 UInt_t d3 = d[idx + 3];
1227 if ((d0 >> 28) != 2 || (d1 >> 28) != 2 || (d2 >> 28) != 2 || (d3 >> 28) != 2)
1228 return kBMNERROR; // check TAI code
1229 Long64_t ts_t0_s = -1;
1230 Long64_t ts_t0_ns = -1;
1231 Long64_t GlobalEvent = -1;
1232 ts_t0_ns = (d0 & 0x0FFFFFFF) | ((d1 & 0x3) << 28);
1233 ts_t0_s = ((d1 >> 4) & 0xFFFFFF) | ((d2 & 0xFFFF) << 24);
1234 GlobalEvent = ((d3 & 0x0FFFFFFF) << 12) | ((d2 >> 16) & 0xFFF);
1235 BmnSyncDigit* sd = FillWR(serial, GlobalEvent, ts_t0_s, ts_t0_ns);
1236 if (fPeriodId < 8) {
1237 fCurEvent.fTime_ns = sd->GetTime_ns();
1238 fCurEvent.fTime_s = sd->GetTime_sec();
1239 }
1240 idx += 4;
1241 LOGF(debug3, "ts :\t %10lli %9lli TMWR 0x%08X", ts_t0_s, ts_t0_ns, serial);
1242 } break;
1243 case TMWR_REL_TS: {
1244 UInt_t d0 = d[idx + 0];
1245 UInt_t d1 = d[idx + 1];
1246 if (((d0 >> 28) != 4) || ((d1 >> 28) != 5))
1247 return kBMNERROR;
1248 // Int_t rts(((d0 & (BIT(24) - 1)) << 8) | ((d1 >> 20) & (BIT(8) - 1)));
1249 // UInt_t ext_word((d1 >> 16) & (BIT(4) - 1));
1250 // UInt_t trg_word(d1 & (BIT(16) - 1));
1251 idx += 2;
1252 // printf("rts %7d ext_tr word %u tr word %u\n" , rts, ext_word, trg_word);
1253 } break;
1255 case TMWR_EOS_CNT: {
1256 // UInt_t d0 = d[idx + 0];
1257 // UInt_t logic_cnt(d0 & (BIT(28) - 1));
1258 // printf("logic_cnt %7u %s\n" , logic_cnt, id == TMWR_EOS_CNT_MATCHED ? "matched" :
1259 // "");
1260 idx++;
1261 } break;
1262 case TMWR_PULSE:
1263 case TMWR_REL_TS_TB:
1264 idx++; // just skip
1265 break;
1266 case kMODTRAILER:
1267 case kSTATUS:
1268 case kPADDING:
1269 idx--;
1270 return kBMNSUCCESS;
1271 default:
1272 printf("unrecognized TMWR id %u\n", id);
1273 idx++;
1274 break;
1275 }
1276 }
1277 return kBMNSUCCESS;
1278}
1279
1280BmnStatus BmnConverterThread::FillMSC(UInt_t* d, UInt_t serial, UInt_t slot, UInt_t& idx)
1281{
1282 UInt_t type = d[idx] >> 28;
1283 UInt_t iCnt = 0;
1284 BmnMSCDigit<UInt_t>* dig =
1285 new ((*msc)[msc->GetEntriesFast()]) BmnMSCDigit<UInt_t>(serial, slot, fCurEvent.fEventId);
1286 std::array<UInt_t, MSC_N_COUNTERS>& cntrArrCur = dig->GetValue();
1287 // printf("MSC type %u serial %08X last eventID = %6u\n", type, serial, fEventId);
1288 while (type < 6) {
1289 if (type < 5) {
1290 // UInt_t cnt3 = (d[idx] >> 21) & (BIT(8) - 1);
1291 // UInt_t cnt2 = (d[idx] >> 14) & (BIT(8) - 1);
1292 // UInt_t cnt1 = (d[idx] >> 7) & (BIT(8) - 1);
1293 // UInt_t cnt0 = d[idx] & (BIT(8) - 1);
1294 // printf("type = %u %06u %06u %06u %06u \n", type, cnt3, cnt2, cnt1, cnt0);
1295 } else if (type == 5) {
1296 UInt_t cnt = d[idx] & (BIT(28) - 1);
1297 if (iCnt >= MSC_N_COUNTERS)
1298 continue;
1299 cntrArrCur[iCnt++] = cnt;
1300 // printf("\ttype = %u arr[%2u] = %8u\n", type, iCnt - 1, cntrArrCur[iCnt - 1]);
1301 }
1302 type = (d[++idx] >> 28) & (BIT(5) - 1);
1303 }
1304
1305 return kBMNSUCCESS;
1306};
1307
1308BmnStatus BmnConverterThread::InitUTCShift()
1309{
1310 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1972, 1, 1, 0, 0, 9), 10));
1311 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1972, 7, 1, 0, 0, 10), 11));
1312 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1973, 1, 1, 0, 0, 11), 12));
1313 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1974, 1, 1, 0, 0, 12), 13));
1314 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1975, 1, 1, 0, 0, 13), 14));
1315 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1976, 1, 1, 0, 0, 14), 15));
1316 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1977, 1, 1, 0, 0, 15), 16));
1317 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1978, 1, 1, 0, 0, 16), 17));
1318 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1979, 1, 1, 0, 0, 17), 18));
1319 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1980, 1, 1, 0, 0, 18), 19));
1320 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1981, 7, 1, 0, 0, 19), 20));
1321 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1982, 7, 1, 0, 0, 20), 21));
1322 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1983, 7, 1, 0, 0, 21), 22));
1323 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1985, 7, 1, 0, 0, 22), 23));
1324 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1988, 1, 1, 0, 0, 23), 24));
1325 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1990, 1, 1, 0, 0, 24), 25));
1326 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1991, 1, 1, 0, 0, 25), 26));
1327 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1992, 7, 1, 0, 0, 26), 27));
1328 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1993, 7, 1, 0, 0, 27), 28));
1329 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1994, 7, 1, 0, 0, 28), 29));
1330 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1996, 1, 1, 0, 0, 29), 30));
1331 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1997, 7, 1, 0, 0, 30), 31));
1332 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1999, 1, 1, 0, 0, 31), 32));
1333 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2006, 1, 1, 0, 0, 32), 33));
1334 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2009, 1, 1, 0, 0, 33), 34));
1335 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2012, 7, 1, 0, 0, 34), 35));
1336 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2015, 7, 1, 0, 0, 35), 36));
1337 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2017, 1, 1, 0, 0, 36), 37));
1338 utc_valid = TTimeStamp(2026, 12, 30, 0, 0, 1);
1339 return kBMNSUCCESS;
1340}
1341
1342Int_t BmnConverterThread::GetUTCShift(TTimeStamp t)
1343{
1344 if (t < leaps.begin()->first) {
1345 LOGF(warning, "Wrong time! %s", t.AsString());
1346 return 0;
1347 }
1348 if (t > utc_valid)
1349 LOGF(warning, "Warning! Leap seconds table expired!");
1350 Int_t shift = 0;
1351 auto it = leaps.lower_bound(t);
1352 if ((it == leaps.end()))
1353 it--;
1354 else if (it->first > t)
1355 it--;
1356 shift = it->second;
1357 return shift;
1358}
1359
1361{
1362 sync->Delete();
1363 tdc->Delete();
1364 tqdc_adc->Delete();
1365 tqdc_tdc->Delete();
1366 tdc_hgnd->Delete();
1367 hrb->Delete();
1368 adc32->Delete();
1369 adc64->Delete();
1370 adc128->Delete();
1371 adc->Delete();
1372 vsp->Delete();
1373}
1374
1376{
1377 msc->Delete();
1378 t0raw->Delete();
1379}
const Float_t d
Z-ccordinate of the first GEM-station.
Definition BmnMwpcHit.cxx:7
void memset(T *dest, T i, size_t num)
uses binary expansion of copied volume for speed up
Definition L1Grid.h:25
int i
Definition P4_F32vec4.h:22
float f
Definition P4_F32vec4.h:21
BmnStatus
Definition BmnEnums.h:24
@ kBMNERROR
Definition BmnEnums.h:26
@ kBMNSUCCESS
Definition BmnEnums.h:25
BmnEventType
Definition BmnEnums.h:69
@ kBMNSTAT
Definition BmnEnums.h:73
@ kBMNEOS
Definition BmnEnums.h:72
@ kBMNPAYLOAD
Definition BmnEnums.h:71
@ kBMNPEDESTAL
Definition BmnEnums.h:70
std::chrono::time_point< SysClock > SysPoint
#define ANSI_COLOR_RED
Definition BmnMath.h:16
#define ANSI_COLOR_RESET
Definition BmnMath.h:18
#define ADC_SAMPLING_LIMIT
Definition BmnADCDigit.h:6
const uint32_t kTRIG
Definition RawTypes.h:54
const uint32_t kMSTREAM_TYPE_TRIG
Definition RawTypes.h:41
const uint32_t kADC64VE_XGE
Definition RawTypes.h:62
const uint32_t kTDC72VXS
Definition RawTypes.h:65
const uint32_t kFVME
Definition RawTypes.h:66
const uint32_t kTTVXS
Definition RawTypes.h:55
const uint32_t TDC_ERROR
Definition RawTypes.h:86
const uint32_t kU40VE_RC
Definition RawTypes.h:72
const uint32_t kEVENTTYPESLOT
Definition RawTypes.h:75
const uint32_t kVSP_SERIALS
Definition RawTypes.h:68
const uint32_t kMODTRAILER
Definition RawTypes.h:24
const uint32_t kTDC72VHL
Definition RawTypes.h:48
const uint32_t kT0_BIN_BLOCK_2020_SEC
Definition RawTypes.h:94
const uint32_t kTQDC16
Definition RawTypes.h:50
const uint32_t TDC_TRAILING
Definition RawTypes.h:85
const uint32_t kSTATUS
Definition RawTypes.h:29
const uint32_t kMSTREAM_TYPE_TDC
Definition RawTypes.h:39
const uint32_t TMWR_REL_TS
Definition RawTypes.h:32
const uint32_t kVIRTUAL_DEVICE
Definition RawTypes.h:52
const uint32_t kTQDC16VS_E
Definition RawTypes.h:53
const uint32_t kADC64WR
Definition RawTypes.h:63
const uint32_t kEVTRAILER
Definition RawTypes.h:26
const uint32_t TMWR_REL_TS_TB
Definition RawTypes.h:33
const uint32_t TMWR_EOS_CNT
Definition RawTypes.h:35
const uint32_t kUT24VE_TRC
Definition RawTypes.h:58
const uint32_t kMSTREAM_TYPE_STAT
Definition RawTypes.h:42
const uint32_t kTDC64VHLE
Definition RawTypes.h:46
const uint32_t TMWR_TAI
Definition RawTypes.h:31
const uint32_t TDC_EV_HEADER
Definition RawTypes.h:82
const uint32_t TDC_EV_TRAILER
Definition RawTypes.h:83
const uint32_t TDC_LEADING
Definition RawTypes.h:84
const uint32_t MSC_N_COUNTERS
Definition RawTypes.h:88
const uint32_t kMSTREAM_TYPE_ADC
Definition RawTypes.h:40
const uint32_t kNBYTESINWORD
Definition RawTypes.h:19
const uint32_t kGENERIC_DEVICE
Definition RawTypes.h:67
const uint32_t kT0_BIN_BLOCK_UNIX_SEC
Definition RawTypes.h:95
const uint32_t kHGND_SERIALS
Definition RawTypes.h:69
const uint32_t kTDC32VL
Definition RawTypes.h:49
const uint32_t kWORDTAI
Definition RawTypes.h:76
const uint32_t kADC64VE
Definition RawTypes.h:61
const uint32_t SERIAL_TO_CFG
Definition RawTypes.h:71
const uint32_t kWORDTRIG
Definition RawTypes.h:77
const uint32_t kEVHEADER
Definition RawTypes.h:25
const uint32_t kHRB
Definition RawTypes.h:64
const uint32_t TMWR_PULSE
Definition RawTypes.h:34
const uint32_t kTDC64VHLE_E
Definition RawTypes.h:47
const uint32_t kMSC16V
Definition RawTypes.h:56
const uint32_t kT0_BIN_BLOCK_WORDS
Definition RawTypes.h:93
const uint32_t kTQDC16VS
Definition RawTypes.h:51
const uint8_t MSC_TIME_SLICE_INFO
Definition RawTypes.h:91
const uint32_t kMSC16VE_E
Definition RawTypes.h:57
const uint32_t kWORDAUX
Definition RawTypes.h:78
const uint32_t kTDC64V
Definition RawTypes.h:45
const uint32_t kPADDING
Definition RawTypes.h:30
const uint32_t kMODHEADER
Definition RawTypes.h:23
const uint32_t TMWR_EOS_CNT_MATCHED
Definition RawTypes.h:36
UInt_t rawData[10000000]
TClonesArray * tqdc_tdc
void SetTrees(TTree *tree, TTree *treeSpills)
std::map< uint8_t, uint32_t * > time_slice_map
std::shared_ptr< TBufferMergerFile > mergerFile
TBufferMerger * merger
TClonesArray * tqdc_adc
BmnEventHeader * eventHeaderDAQ
TClonesArray * tdc_hgnd
void SetData(Int_t taskId, Int_t len=0, UInt_t *data=nullptr, BmnEventType fCurEvType=kBMNEMPTY, UInt_t fRunId=7444, UInt_t fEventId=-1)
static BmnStatus ParseRawT0TextConfig(string &s, BmnT0Raw< kT0_BIN_BLOCK_WORDS > *rt0dig)
vector< uint32_t > & GetInputSignalsVector()
void SetEventType(BmnEventType event_type)
void SetInputSignalsAR(UInt_t v)
void SetEventTimeTS(TTimeStamp event_time)
void SetTripWord(Bool_t flag)
void SetTrigInfo(BmnTrigInfo &trig_info)
void SetInputSignalsBR(UInt_t v)
void SetPeriodId(UInt_t period_id)
void SetEventId(UInt_t event_id)
static std::string TimePoint2String(SysPoint p)
static SysPoint TimeStamp2TP(TTimeStamp p)
std::array< IntType, MSC_N_COUNTERS > & GetValue()
Definition BmnMSCDigit.h:64
std::vector< IntType > & GetValues()
std::vector< uint8_t > & GetExtCond()
std::vector< SysPoint > & GetTimes()
Long64_t GetTime_sec() const
Long64_t GetTime_ns() const
void SetTrigBefo(UInt_t _v)
Definition BmnTrigInfo.h:39
void SetTrigAccepted(UInt_t _v)
Definition BmnTrigInfo.h:31
void SetTrigAfter(UInt_t _v)
Definition BmnTrigInfo.h:47
void SetTrigAll(UInt_t _v)
Definition BmnTrigInfo.h:63
void SetTrigRjct(UInt_t _v)
Definition BmnTrigInfo.h:55
void SetTrigCand(UInt_t _v)
Definition BmnTrigInfo.h:23
void SetTrigAvail(UInt_t _v)
Definition BmnTrigInfo.h:71
void AppendHit(uint64_t HitTime, uint16_t ElinkIdx, uint16_t Chan, uint16_t Adc)
void SetTHitMissedEvts(uint16_t val)
void SetTTrigTime(uint64_t val)
The StorableTimeslice class contains the data of a single timeslice.
bool is_word_event_header(uint16_t word)
Definition BmnHgndRaw.h:18
uint16_t get_block_size(EventPacketVersion packet_version=ERR)
Definition BmnHgndRaw.h:45
EventPacketVersion get_event_packet_version(uint16_t word)
Definition BmnHgndRaw.h:31
MessType
Message types.
Microslice descriptor struct.
uint64_t idx
Microslice index / start time.
uint32_t size
Content size (bytes)
uint16_t eq_id
Equipment identifier.