Belle II Software development
trgtopUnpackerModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <trg/top/modules/trgtopUnpacker/trgtopUnpackerModule.h>
10
11#include <iostream>
12
13/* --------------- WARNING ---------------------------------------------- *
14If you have more complex parameter types in your class then simple int,
15double or std::vector of those you might need to uncomment the following
16include directive to avoid an undefined reference on compilation.
17* ---------------------------------------------------------------------- */
18// #include <framework/core/ModuleParam.templateDetails.h>
19
20//using namespace std;
21using namespace Belle2;
22
23//-----------------------------------------------------------------
24// Register the Module
25//-----------------------------------------------------------------
26REG_MODULE(TRGTOPUnpacker);
27
29{
30 return std::string("1.00");
31}
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
38 : Module::Module(), m_eventNumber(0), m_trigType(0), m_nodeId(0), m_nWords(0), m_reportedAlreadyRun_1(false),
39 m_reportedAlreadyRun_2(false)
40{
41 // Set module properties
42
43
44 std::string desc = "TRGTOPUnpackerModule(" + version() + ")";
45 setDescription(desc);
47
48 B2DEBUG(20, "TRGTOPUnpacker: Constructor done.");
49
50
51 // Parameter definitions
52 addParam("overrideControlBits", m_overrideControlBits,
53 "Override control bits in data",
54 true);
55 // false);
56
57}
58
59TRGTOPUnpackerModule::~TRGTOPUnpackerModule()
60{
61}
62
64{
65
66 m_TRGTOPCombinedT0DecisionArray.registerInDataStore();
67 // m_TRGTOPCombinedTimingArray.registerInDataStore();
68 m_TRGTOPSlotTimingArray.registerInDataStore();
69
70 // m_TRGTOPCombinedTimingArray.registerRelationTo(m_TRGTOPSlotTimingArray);
71 // m_TRGTOPSlotTimingArray.registerRelationTo(m_TRGTOPCombinedTimingArray);
72
73}
74
75
77{
79 m_reportedAlreadyRun_2 = false;
80}
81
83{
84
85 StoreArray<RawTRG> raw_trgarray;
86
87 for (int i = 0; i < raw_trgarray.getEntries(); i++) {
88
89 // Check PCIe40 data or Copper data
90 if (raw_trgarray[i]->GetMaxNumOfCh(0) == 48) { m_pciedata = true; }
91 else if (raw_trgarray[i]->GetMaxNumOfCh(0) == 4) { m_pciedata = false; }
92 else { B2FATAL("TRGTOPUnpackerModule: Invalid value of GetMaxNumOfCh from raw data: " << LogVar("Number of ch: ", raw_trgarray[i]->GetMaxNumOfCh(0))); }
93
94 int node_id = 0;
95 int ch_id_1 = 0;
96 int ch_id_2 = 1;
97 if (m_pciedata) {
98 node_id = 0x10000001;
99 ch_id_1 = 23;
100 ch_id_2 = 24;
101 } else {
102 node_id = 0x12000001;
103 ch_id_1 = 0;
104 ch_id_2 = 1;
105 }
106
107 for (int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
108
109 m_nodeId = raw_trgarray[i]->GetNodeID(j);
110
111 if (m_nodeId == node_id) {
112
113 int numberOfChannels = raw_trgarray[i]->GetMaxNumOfCh(i);
114
115 // B2INFO("raw_trgarray.GetMaxNumOfCh() = " << numberOfChannels);
116
117 for (int channel = 0; channel < numberOfChannels; channel++) {
118
119 if (channel != ch_id_1 && channel != ch_id_2) continue;
120
121 m_nWords = raw_trgarray[i]->GetDetectorNwords(j, channel);
122
123 // B2INFO("raw_trgarray[" << i << "]->GetDetectorNwords(" << j << ", " << channel << ") = " << m_nWords);
124
125 // if ( m_nWords > 3 ) { ////general header is 3 words long
126 if (m_nWords > 0) {
127
128 m_eventNumber = raw_trgarray[i]->GetEveNo(j);
129 m_trigType = raw_trgarray[i]->GetTRGType(j);
130
131 // B2INFO("raw_trgarray.getEntries() = " << raw_trgarray.getEntries());
132 // B2INFO("raw_trgarray[i]->GetNumEntries() = " << raw_trgarray[i]->GetNumEntries());
133 // B2INFO("raw_trgarray[]->GetEveNo(j) = " << raw_trgarray[i]->GetEveNo(j));
134 // B2INFO("raw_trgarray[]->GetNodeID(j) = " << std::hex << raw_trgarray[i]->GetNodeID(j) << std::dec);
135 // B2INFO("raw_trgarray[]->GetDetectorNwords(j,0) = " << m_nWords);
136
137 readDAQEvent(raw_trgarray[i], j, channel);
138
139 }
140 }
141 }
142 }
143 }
144}
145
146void TRGTOPUnpackerModule::readDAQEvent(RawTRG* raw_daq, int j, int channel)
147{
148 // if (raw_daq->GetDetectorNwords(j, channel) > 3) { ///general header is 3 words long
149 if (raw_daq->GetDetectorNwords(j, channel) > 0) {
150 unpackT0Decisions(raw_daq->GetDetectorBuffer(j, channel), channel);
151 }
152}
153
154void TRGTOPUnpackerModule::unpackT0Decisions(int* rdat, int channel)
155{
156
157 // B2INFO("channel, data size (32bit words) = " << channel << ", " << m_nWords);
158
159 // Information for each data window
160
161 // rvc from the header of the buffer
162 int rvcL1 = rdat[2] & 0x7ff;
163
164 // L1 event number
165 int eventNumberL1 = (rdat[2] >> 12) & 0xfffff;
166
167 // B2INFO("l1_rvc from header = " << rvcL1);
168 // B2INFO("eventNumberL1 (evt) from buffer header = " << eventNumberL1);
169
170 bool dataFormatKnown = false;
171
172 int windowSize = -1;
173 int numberOfWindows = -1;
174
175 int dataFormatVersionExpected = -1;
176 // cppcheck-suppress variableScope
177 int revoClockDeltaExpected = 4;
178 // cppcheck-suppress variableScope
179 int cntr127DeltaExpected = 4;
180
181 // 3 = 3: header only
182 // 1875 = 3 + 48*39: format used starting ~June 30 2019 and until Oct. 1, 2019 (until Receive FW version 0x02067301)
183 // 771 = 3 + 24*32: format used starting ~Oct. 1, 2019 (Receive FW version 0x02067301 and newer)
184 // 1539 = 3 + 48*32: format used starting ~Mar. 25, 2021 (Receive FW version 0x03020003 and newer)
185 // 3075 = 3 + 96*32: format used starting ~Mar. 25, 2021 (Receive FW version 0x03020003 and newer)
186
187 // m_nWords==3 means only a header
188 if (m_nWords == 3) {
189 windowSize = 0;
190 numberOfWindows = 0;
191 dataFormatKnown = true;
192 dataFormatVersionExpected = 0;
193 } else if (m_nWords == 771) {
194 windowSize = 32;
195 numberOfWindows = 24;
196 dataFormatKnown = true;
197 dataFormatVersionExpected = 2;
198 } else if (m_nWords == 1875) {
199 windowSize = 39;
200 numberOfWindows = 48;
201 dataFormatKnown = true;
202 dataFormatVersionExpected = 1;
203 } else if (m_nWords == 1539) {
204 windowSize = 32;
205 numberOfWindows = 48;
206 dataFormatKnown = true;
207 dataFormatVersionExpected = 4;
208 } else if (m_nWords == 3075) {
209 windowSize = 32;
210 numberOfWindows = 96;
211 dataFormatKnown = true;
212 dataFormatVersionExpected = 5;
213 }
214
215 if (!dataFormatKnown) {
217 B2INFO("Unknown data format / error / exiting. This condition is reported only once per run.");
219 }
220 return;
221 }
222
223 // FTSW / rvc / the difference is 1280 (expected)
224 // int revoClockDeltaJump1 = -92;
225 // int revoClockDeltaJump2 = 1188;
226
227 // VME / 16bit counter
228 // int cntr127DeltaJump1 = -92;
229 // int cntr127DeltaJump2 = -65532;
230
231 // if ( dataFormatVersionExpected > 0 ) B2INFO("---------------------------------------------------------------------------------------------------------------");
232
233 // B2INFO("Data format version (as expected according to data size) = " << dataFormatVersionExpected);
234
235 // if ( numberOfWindows != 0 ) {
236 // B2INFO("Number of 32bit words in TOP L1 data buffer = " << m_nWords);
237 // B2INFO("Number of windows = " << numberOfWindows);
238 // B2INFO("Window size in 32bit words = " << windowSize);
239 // }
240
241 // various test patterns will be used to check the data
242 unsigned int testPattern;
243
244 int revoClockLast = -1;
245 int cntr127Last = -1;
246
247 bool performBufferAnalysis = true;
248 bool reportAllErrors = true;
249 // bool reportSummaryErrors = true;
250
251 // check if this event's buffer is a dummy buffer
252 int counterDummyWindows = 0;
253 unsigned int testPatternDummyEvent = 0xbbbb;
254 for (int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
255 int index = iWindow * windowSize + 3;
256 testPattern = (rdat[index] >> 16) & 0xffff;
257 if (testPattern == testPatternDummyEvent) {
258 counterDummyWindows++;
259 }
260 // March 30, 2022: need to be able to override the settings in data
261 if (!m_overrideControlBits) {
262 // Oct. 31, 2020: three most significant bits are now used to control unpacker from FW
263 // Note that setting either flag for any of the windows changes it for all windows here
264 testPattern = (rdat[index + 2] >> 29) & 0x7;
265 if (testPattern & 0x1) performBufferAnalysis = false;
266 if (testPattern & 0x2) reportAllErrors = false;
267 // if (testPattern & 0x4) reportSummaryErrors = false;
268 }
269 }
270
271 // note that events with empty buffer have numberOfWindows=0
272 if (counterDummyWindows == numberOfWindows) {
273 performBufferAnalysis = false;
274 } else {
275 if (counterDummyWindows != 0) {
276 if (reportAllErrors) B2ERROR("Corrupted data? numberOfWindows = " << numberOfWindows << ", counterDummyWindows = " <<
277 counterDummyWindows);
278 performBufferAnalysis = false;
279 }
280 }
281
282 /*
283 int numberRvcJumps = 0;
284 int numberCntr127Jumps = 0;
285 int windowRvcJumpFirst = -1;
286 int windowCntr127JumpFirst = -1;
287 int clocksRvcJumpFirst = -1;
288 int clocksCntr127JumpFirst = -1;
289
290 if (performBufferAnalysis) {
291 for (int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
292 int index = iWindow * windowSize + 3;
293
294 // revoclk (comes from b2tt) has the range between 0 and 1279 @127MHz => 1279*7.8ns ~10us = 1 revolution (11bits are used)
295 int revoClockNow = rdat[index] & 0x7ff;
296 // B2INFO("rvc now = " << revoClockNow);
297 // first need to know max revoClock (1279)
298 if (revoClockLast != -1) {
299 // if (revoClockLast != -1 && revoClockNow > revoClockLast) {
300 int revoClockDeltaNow = revoClockNow - revoClockLast;
301 if (revoClockDeltaNow != revoClockDeltaExpected) {
302 // -1276 is simply going to the next cycle of rvc counting, but 1188 or -92 means that there was one frame missing in data / corrupted data
303 if (revoClockDeltaNow != -1276) {
304 if (reportAllErrors) B2INFO("rvc changed by an unexpected number of units (1): " << revoClockDeltaNow << ", last rvc = " <<
305 revoClockLast <<
306 ", current rvc = " << revoClockNow << ", window " << iWindow << ", index = " << index);
307 numberRvcJumps++;
308 if (windowRvcJumpFirst < 0) {
309 windowRvcJumpFirst = iWindow;
310 clocksRvcJumpFirst = revoClockDeltaNow;
311 }
312 }
313 }
314 }
315 revoClockLast = revoClockNow;
316
317 int cntr127Now = (rdat[index + 1] >> 16) & 0xffff;
318 // B2INFO("cntr127 now = " << cntr127Now);
319 // first need to know max cntr127
320 if (cntr127Last != -1) {
321 // if (cntr127Last != -1 && cntr127Now > cntr127Last) {
322 int cntr127DeltaNow = cntr127Now - cntr127Last;
323 if (cntr127DeltaNow != cntr127DeltaExpected) {
324 // 65444 is the value of the difference in cntr127 (VME counter) because we use 16 bits of 64 bit-long counter
325 if (cntr127DeltaNow != 65444) {
326 if (reportAllErrors) B2INFO("cntr127 changed by an unexpected number of units (1): " << cntr127DeltaNow << ", cntr127 last = " <<
327 cntr127Last <<
328 ", cntr127 now = " << cntr127Now << ", window " << iWindow << ", index = " << index + 1);
329 numberCntr127Jumps++;
330 if (windowCntr127JumpFirst < 0) {
331 windowCntr127JumpFirst = iWindow;
332 clocksCntr127JumpFirst = cntr127DeltaNow;
333 }
334 }
335 }
336 }
337 cntr127Last = cntr127Now;
338 }
339 }
340 */
341
342 /*
343 if (numberRvcJumps > 0) {
344 B2INFO("The number of rvc jumps = " << numberRvcJumps);
345 B2INFO("The window of the first rvc jump = " << windowRvcJumpFirst);
346 B2INFO("The number of clock cycles associated with the first rvc jump = " << clocksRvcJumpFirst);
347 }
348
349 if (numberCntr127Jumps > 0) {
350 B2INFO("The number of cntr127 jumps = " << numberCntr127Jumps);
351 B2INFO("The window of the first cntr127 jump = " << windowCntr127JumpFirst);
352 B2INFO("The number of clock cycles associated with the first cntr127 jump = " << clocksCntr127JumpFirst);
353 }
354 */
355
356 // debugging: report everything from every single window when we are seeing unexpected jumps in either of the two counters
357 /*
358 if (numberRvcJumps > 0 || numberCntr127Jumps > 0) {
359 B2INFO("===========================================================================================================");
360 B2INFO("l1_rvc from header = " << rvcL1);
361 B2INFO("eventNumberL1 (evt) from buffer header = " << eventNumberL1);
362 B2INFO("Reporting the entire data buffer");
363 B2INFO("Header 0 = : " << std::hex << rdat[0] << std::dec);
364 B2INFO("Header 1 = : " << std::hex << rdat[1] << std::dec);
365 B2INFO("Header 2 = : " << std::hex << rdat[2] << std::dec);
366 for (int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
367 int index = iWindow * windowSize + 3;
368
369 B2INFO("---------------------------------------------------------------------------------");
370 int revoClockNow = rdat[index] & 0x7ff;
371 B2INFO("w rvc ---------------------------- = " << iWindow << " " << revoClockNow);
372
373 int cntr127Now = (rdat[index + 1] >> 16) & 0xffff;
374 B2INFO("w cntr127 ---------------------------- = " << iWindow << " " << cntr127Now);
375
376 for (int i = 0; i < 24; i++) {
377 B2INFO("w i = : " << iWindow << " " << i << " " << std::hex << rdat[index+i] << std::dec);
378 }
379 }
380 }
381 */
382
383 // reset "most recent" rvc and cntr127
384 revoClockLast = -1;
385 cntr127Last = -1;
386
387 // events with no buffer (i.e. no payload), empty (i.e. dummy) windows and presumably corrupted events are NOT analyzed
388 if (performBufferAnalysis) {
389
390 int slotT0Last[8];
391 int slotNHitLast[8];
392 int slotSegmentLast[8];
393
394 int otherInformationLast[8];
395
396 int combinedT0Last;
397 int combinedT0RVC2GDLLast;
398
399 // Loop over windows in B2L buffer and locate all unique slot-level TOP L1 decisions
400 for (int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
401
402 // B2INFO("REAL DEBUG: window number = " << iWindow);
403
404 int clockCycle = iWindow * 4;
405
406 // error counters for possible data corruption in the current window
407 unsigned int errorCountWindow = 0;
408
409 // a pointer-like variable for accessing the data in the buffer sequentially
410 int index = iWindow * windowSize + 3;
411
412 unsigned int testPatternExpected = 0;
413 if (dataFormatVersionExpected == 1) testPatternExpected = 0xbbba;
414 else if (dataFormatVersionExpected >= 2) testPatternExpected = 0xdddd;
415
416 testPattern = (rdat[index] >> 16) & 0xffff;
417 // B2INFO("testPattern = " << std::hex << testPattern << std::dec);
418 if (testPattern != testPatternExpected) {
419 if (reportAllErrors) B2ERROR("An unexpected test pattern: " << std::hex << testPattern << std::dec << ", window " << iWindow <<
420 ", index = " << index);
421 errorCountWindow++;
422 }
423
424 int dataFormatVersionNow = (rdat[index] >> 11) & 0x1f;
425 // B2INFO("dataFormatVersionNow = " << dataFormatVersionNow);
426 if (dataFormatVersionNow == 3 && dataFormatVersionExpected == 2) {
427 dataFormatVersionExpected = 3;
428 }
429 if (dataFormatVersionNow == 4 && dataFormatVersionExpected == 2) {
430 dataFormatVersionExpected = 4;
431 }
432 if (dataFormatVersionNow == 5) {
433 dataFormatVersionExpected = 5;
434 }
435
436 if (dataFormatVersionNow != dataFormatVersionExpected) {
437 if (reportAllErrors) {
438 if (!m_reportedAlreadyRun_2) {
439 B2ERROR("An unexpected data format version: " << dataFormatVersionNow << ", window " << iWindow << ", index = " <<
440 index);
441 m_reportedAlreadyRun_2 = true;
442 }
443 }
444 errorCountWindow++;
445 }
446
447 // revoclk (comes from b2tt) has the range between 0 and 1279 @127MHz => 1279*7.8ns ~10us = 1 revolution (11bits are used)
448 int revoClockNow = rdat[index] & 0x7ff;
449 // B2INFO("window = " << iWindow << ", rvc now = " << revoClockNow);
450 // first need to know max revoClock (1279)
451 if (revoClockLast != -1) {
452 // if (revoClockLast != -1 && revoClockNow > revoClockLast) {
453 int revoClockDeltaNow = revoClockNow - revoClockLast;
454 if (revoClockDeltaNow != revoClockDeltaExpected) {
455 if (revoClockDeltaNow != -1276) {
456 if (reportAllErrors) B2INFO("rvc changed by an unexpected number of units (2): " << revoClockDeltaNow << ", last rvc = " <<
457 revoClockLast <<
458 ", current rvc = " << revoClockNow << ", window " << iWindow << ", index = " << index);
459 // errorCountWindow++;
460 }
461 }
462 }
463 if (revoClockNow > 1279) {
464 if (reportAllErrors) B2ERROR("An unexpected rvc value = " << revoClockNow << ", window " << iWindow << ", index = " << index);
465 errorCountWindow++;
466 }
467 revoClockLast = revoClockNow;
468
469 int cntr127Now = (rdat[index + 1] >> 16) & 0xffff;
470 // B2INFO("cntr127 now = " << cntr127Now);
471 // first need to know max cntr127
472 if (cntr127Last != -1) {
473 // if (cntr127Last != -1 && cntr127Now > cntr127Last) {
474 int cntr127DeltaNow = cntr127Now - cntr127Last;
475 if (cntr127DeltaNow != cntr127DeltaExpected) {
476 // 65444 is the value of the difference in cntr127 (VME counter) because we use 16 bits of 64 bit-long counter
477 if (cntr127DeltaNow != 65444 && cntr127DeltaNow != -65532) {
478 if (reportAllErrors) B2INFO("cntr127 changed by an unexpected number of units (2): " << cntr127DeltaNow << ", cntr127 last = " <<
479 cntr127Last <<
480 ", cntr127 now = " << cntr127Now << ", window " << iWindow << ", index = " << index + 1);
481 errorCountWindow++;
482 }
483 }
484 }
485 cntr127Last = cntr127Now;
486
487 //
488
489 int slotT0[8];
490 int slotNHit[8];
491 int slotSegment[8];
492
493 int otherInformation[8];
494
495 // int versionFW = rdat[index + 3];
496
497 int combinedT0 = rdat[index + 2] & 0x3ffff;
498 int combinedT0RVC2GDL = (rdat[index + 2] >> 18) & 0x7ff;
499 int combinedT0ClockCycle = clockCycle;
500
501 slotT0[0] = (rdat[index + 4] >> 16) & 0xffff;
502 slotT0[1] = (rdat[index + 4]) & 0xffff;
503 slotT0[2] = (rdat[index + 5] >> 16) & 0xffff;
504 slotT0[3] = (rdat[index + 5]) & 0xffff;
505 slotT0[4] = (rdat[index + 6] >> 16) & 0xffff;
506 slotT0[5] = (rdat[index + 6]) & 0xffff;
507 slotT0[6] = (rdat[index + 7] >> 16) & 0xffff;
508 slotT0[7] = (rdat[index + 7]) & 0xffff;
509
510 slotNHit[0] = (rdat[index + 8] >> 20) & 0x3ff;
511 slotNHit[1] = (rdat[index + 8] >> 10) & 0x3ff;
512 slotNHit[2] = (rdat[index + 8]) & 0x3ff;
513
514 slotNHit[3] = (rdat[index + 9] >> 20) & 0x3ff;
515 slotNHit[4] = (rdat[index + 9] >> 10) & 0x3ff;
516 slotNHit[5] = (rdat[index + 9]) & 0x3ff;
517
518 slotNHit[6] = (rdat[index + 10] >> 10) & 0x3ff;
519 slotNHit[7] = (rdat[index + 10]) & 0x3ff;
520
521 slotSegment[0] = (rdat[index + 11] >> 28) & 0xf;
522 slotSegment[1] = (rdat[index + 11] >> 24) & 0xf;
523 slotSegment[2] = (rdat[index + 11] >> 20) & 0xf;
524 slotSegment[3] = (rdat[index + 11] >> 16) & 0xf;
525 slotSegment[4] = (rdat[index + 11] >> 12) & 0xf;
526 slotSegment[5] = (rdat[index + 11] >> 8) & 0xf;
527 slotSegment[6] = (rdat[index + 11] >> 4) & 0xf;
528 slotSegment[7] = (rdat[index + 11] >> 0) & 0xf;
529
530 // the following information is board-dependent
531 otherInformation[0] = (rdat[index + 12] >> 16) & 0xffff;
532 otherInformation[1] = (rdat[index + 12]) & 0xffff;
533 otherInformation[2] = (rdat[index + 13] >> 16) & 0xffff;
534 otherInformation[3] = (rdat[index + 13]) & 0xffff;
535 otherInformation[4] = (rdat[index + 14] >> 16) & 0xffff;
536 otherInformation[5] = (rdat[index + 14]) & 0xffff;
537 otherInformation[6] = (rdat[index + 15] >> 16) & 0xffff;
538 otherInformation[7] = (rdat[index + 15]) & 0xffff;
539
540 if (iWindow != 0) {
541
542 // try to retrieve combined t0 decisions (limited info)
543 if (channel == 0) {
544 if (combinedT0 != combinedT0Last ||
545 combinedT0RVC2GDL != combinedT0RVC2GDLLast
546 ) {
547
548 // int toptrgT0_revoToNS = combinedT0%revoToNS;
549 // int rvcL1_NS = rvcL1 * 8;
550 // int deltaT0 = rvcL1_NS >= toptrgT0_revoToNS ? rvcL1_NS - toptrgT0_revoToNS : rvcL1_NS - toptrgT0_revoToNS + revoToNS;
551 // int latencyL12TOPTRG = revoClockNow >= rvcL1 ? revoClockNow - rvcL1 : revoClockNow - rvcL1 + 1280;
552
553 TRGTOPCombinedT0Decision combinedT0Decision(combinedT0,
554 revoClockNow,
555 combinedT0ClockCycle,
556 combinedT0RVC2GDL,
557 eventNumberL1,
558 rvcL1
559 );
560
561 m_TRGTOPCombinedT0DecisionArray.appendNew(combinedT0Decision);
562
563 /*
564 cout << "-DEBUG- new combined decision: t0 (2ns), eventNumberL1, rvc2GDL, clock cycle, rvcNOW, rvcL1, latency, deltaT0 (ns) = "
565 << combinedT0/2 << ", "
566 << eventNumberL1 << ", "
567 << combinedT0RVC2GDL << ", "
568 << combinedT0ClockCycle << ", "
569 << revoClockNow << ", "
570 << rvcL1 << ", "
571 << latencyL12TOPTRG << ", "
572 << deltaT0
573 << endl;
574 */
575
576 combinedT0Last = combinedT0;
577 combinedT0RVC2GDLLast = combinedT0RVC2GDL;
578 }
579
580 // retrieve slot-level decisions (limited info) for slots 1 through 8 as observed on the board used for slots 9 through 16
581 for (int i = 0; i < 8; i++) {
582
583 if (otherInformation[i] != otherInformationLast[i]) {
584
585 int slotOther = i + 1;
586
587 TRGTOPSlotTiming slotTiming(slotOther,
588 2 * otherInformation[i],
589 0,
590 0,
591 0,
592 clockCycle,
593 errorCountWindow,
594 0,
595 -1
596 );
597
598 // auto* thisSlotTiming = m_TRGTOPSlotTimingArray.appendNew(slotTiming);
599 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
600
601 otherInformationLast[i] = otherInformation[i];
602
603 }
604 }
605 }
606
607 // retrieve slot-level decisions (complete info) for the currently-processed readout board
608
609 int slotNow = 1;
610 if (channel == 0) slotNow = 9;
611
612 for (int i = 0; i < 8; i++) {
613
614 if (slotT0[i] != slotT0Last[i] ||
615 slotNHit[i] != slotNHitLast[i] ||
616 slotSegment[i] != slotSegmentLast[i]) {
617
618 /*
619 cout << "-DEBUG- slot, index, clockCycle = " << slotNow << ", " << index << ", " << clockCycle
620 << ", combT0 = " << combT0
621 <<", rvcL1 from header = " << rvcL1
622 << ", eventNumberL1 (evt) = " << eventNumberL1
623 << ", FW version = " << std::hex << versionFW << std::dec
624 << ", slot T0 = " << slotT0[i]
625 << ", NHit = " << slotNHit[i]
626 << ", Segment = " << slotSegment[i]
627 << ", other information = " << otherInformation[i]
628 << endl;
629 */
630
631 // TRGTOPSlotTiming* thisSlotTiming(NULL);
632
633 // logL is currently not available (use nHit in lieu of that), so set to 0
634 // firstTS info is only available for slots 1 through 8 (channel == 1)
635 // -1 for firstTS means no info
636 // 1 as the next to the last parameter means "information from the board being read-out"
637
638 if (channel == 1) {
639
640 TRGTOPSlotTiming slotTiming(slotNow,
641 2 * slotT0[i],
642 slotSegment[i],
643 slotNHit[i],
644 0,
645 clockCycle,
646 errorCountWindow,
647 1,
648 otherInformation[i]
649 );
650 // thisSlotTiming = m_TRGTOPSlotTimingArray.appendNew(slotTiming);
651 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
652 } else {
653
654 TRGTOPSlotTiming slotTiming(slotNow,
655 2 * slotT0[i],
656 slotSegment[i],
657 slotNHit[i],
658 0,
659 clockCycle,
660 errorCountWindow,
661 1,
662 -1
663 );
664 // thisSlotTiming = m_TRGTOPSlotTimingArray.appendNew(slotTiming);
665 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
666 }
667
668 // slot-level decisions are not currently related to combined decisions
669 // thisSlotTiming->addRelationTo(thisCombinedTiming);
670 // thisCombinedTiming->addRelationTo(thisSlotTiming);
671
672 slotT0Last[i] = slotT0[i];
673 slotNHitLast[i] = slotNHit[i];
674 slotSegmentLast[i] = slotSegment[i];
675
676 }
677
678 slotNow++;
679
680 }
681 } else {
682
683 combinedT0Last = combinedT0;
684 for (int i = 0; i < 8; i++) {
685 slotT0Last[i] = slotT0[i];
686 slotNHitLast[i] = slotNHit[i];
687 slotSegmentLast[i] = slotSegment[i];
688 otherInformationLast[i] = otherInformation[i];
689
690 combinedT0Last = combinedT0;
691 combinedT0RVC2GDLLast = combinedT0RVC2GDL;
692 }
693 }
694 }
695 }
696
697}
698
699
701{
702}
703
705{
706}
707
708
709
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
The Raw TOP class Class for RawCOPPER class data taken by TOP Currently, this class is almost same as...
Definition: RawTRG.h:27
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
virtual void readDAQEvent(RawTRG *, int, int)
Read data from TRG DAQ.
bool m_reportedAlreadyRun_1
PCIe40 data or copper data.
bool m_pciedata
N words in raw data.
virtual void initialize() override
Initialize the Module.
virtual void event() override
This method is the core of the module.
virtual void endRun() override
This method is called if the current run ends.
virtual void terminate() override
This method is called at the end of the event processing.
virtual void beginRun() override
Called when entering a new run.
virtual void unpackT0Decisions(int *, int)
Unpacker main function.
TRGTOPUnpackerModule()
Constructor: Sets the description, the properties and the parameters of the module.
int m_trigType
Event number (according to L1/global)
std::string version() const
returns version of TRGGDLUnpackerModule.
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
int GetDetectorNwords(int n, int finesse_num)
get Detector buffer length
Definition: RawCOPPER.h:657
int * GetDetectorBuffer(int n, int finesse_num)
get Detector buffer
Definition: RawCOPPER.h:681
Abstract base class for different kinds of events.