Belle II Software  release-06-02-00
Unpacker.h
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 #include <string>
9 #include <sstream>
10 #include <iostream>
11 #include <iomanip>
12 #include <bitset>
13 #include <numeric>
14 #include <cmath>
15 #include <algorithm>
16 
17 #include <trg/cdc/dataobjects/Bitstream.h>
18 #include <trg/cdc/dataobjects/CDCTriggerTrack.h>
19 #include <trg/cdc/dataobjects/CDCTriggerSegmentHit.h>
20 #include <trg/cdc/dataobjects/CDCTriggerFinderClone.h>
21 #include <trg/cdc/dataobjects/CDCTriggerMLPInput.h>
22 #include <framework/gearbox/Const.h>
23 #include <trg/cdc/dbobjects/CDCTriggerNeuroConfig.h>
24 #include <framework/dataobjects/BinnedEventT0.h>
25 
26 namespace Belle2 {
32  namespace CDCTriggerUnpacker {
33 
34  constexpr double pi() { return std::atan(1) * 4; }
35 
36  // constants
37  static constexpr std::array<int, 9> nMergers = {10, 10, 12, 14, 16, 18, 20, 22, 24};
38 
39  // The data width are the specs under full speed.
40  // When using one of the half-speed version,
41  // TS/track are filled from MSB, leaving LSB blank.
42  static constexpr int TSFOutputWidth = TSF_TO_2D_WIDTH; // 429 (#defined in Bitstream.h)
43  static constexpr int nTrackers = NUM_2D; // 4
44  static constexpr int nAxialTSF = NUM_TSF; // 5
45  static constexpr int nStereoTSF = 4;
46  static constexpr int T2DOutputWidth = T2D_TO_3D_WIDTH; // 747
47  static constexpr unsigned lenTS = 21; // ID (8 bit) + t (9 bit) + LR (2 bit) + priority (2 bit)
48 
49  static constexpr int nMax2DTracksPerClock = 4;
50 
51  // bit width of the clock counter
52  static constexpr int clockCounterWidth = 9;
53 
54  /* number of mergers in axial super layers */
55  static constexpr std::array<int, nAxialTSF> nAxialMergers = {10, 12, 16, 20, 24};
56  /* number of wires in a super layer*/
57  static constexpr std::array<int, 9> nWiresInSuperLayer = {
58  160, 160, 192, 224, 256, 288, 320, 352, 384
59  };
60  /* Number of wire/cells in a single layer per merger unit */
61  static constexpr int nCellsInLayer = 16;
62 
63  // dataobjects
64  using TSFOutputVector = std::array<char, TSFOutputWidth>;
65  using TSFOutputArray = std::array<TSFOutputVector, nTrackers>;
66  using TSFOutputBus = std::array<TSFOutputArray, nAxialTSF>;
67  using TSFOutputBitStream = Bitstream<TSFOutputBus>;
68 
69  using T2DOutputVector = std::array<char, T2DOutputWidth>;
70  using T2DOutputBus = std::array<T2DOutputVector, nTrackers>;
71  using T2DOutputBitStream = Bitstream<T2DOutputBus>;
72 
73  using NNVector = std::array<char, NN_WIDTH>;
74  using NNBus = std::array<NNVector, nTrackers>;
75  using NNBitStream = Bitstream<NNBus>;
76  // using NNInputVector = std::array<char, NNInputWidth>;
77  // using NNInputBus = std::array<NNInputVector, nTrackers>;
78  // using NNInputBitStream = Bitstream<NNInputBus>;
79 
80  // using NNOutputVector = std::array<char, NNOutputWidth>;
81  // using NNOutputBus = std::array<NNOutputVector, nTrackers>;
82  // using NNOutputBitStream = Bitstream<NNOutputBus>;
83 
84  // functions
85  std::string padto(std::string s, unsigned l)
86  {
87  if (s.size() < l) {
88  s.insert(s.begin(), l - s.size(), ' ');
89  }
90  return s;
91  }
92  std::string padright(std::string s, unsigned l)
93  {
94  if (s.size() < l) {
95  s.insert(s.end(), l - s.size(), ' ');
96  }
97  return s;
98  }
99 
100  void printBuffer(int* buf, int nwords)
101  {
102  for (int j = 0; j < nwords; ++j) {
103  printf(" %.8x", buf[j]);
104  if ((j + 1) % 8 == 0) {
105  printf("\n");
106  }
107  }
108  printf("\n");
109  return;
110  };
111 
112  std::string rawIntToAscii(int buf)
113  {
114  std::ostringstream firmwareTypeStream;
115  firmwareTypeStream << std::hex << buf;
116  std::string firmwareTypeHex(firmwareTypeStream.str());
117  std::string firmwareType(4, '0');
118  for (int i = 0; i < 4; i++) {
119  std::istringstream firmwareTypeIStream(firmwareTypeHex.substr(i * 2, 2));
120  int character;
121  firmwareTypeIStream >> std::hex >> character;
122  firmwareType[i] = character;
123  }
124  return firmwareType;
125  };
126 
127  std::string rawIntToString(int buf)
128  {
129  std::ostringstream firmwareVersionStream;
130  firmwareVersionStream << std::hex << buf;
131  return firmwareVersionStream.str();
132  };
133 
134  /* Note: VHDL std_logic value is stored in a byte (char). The
135  * 9 values are mapped as 'U':0, 'X':1, '0':2, '1':3
136  * 'Z':4, 'W':5, 'L':6, 'H':7, '-':8 . The std_logic_vector
137  * is stored as a contiguous array of bytes. For example
138  * "0101Z" is stored in five bytes as char s[5] = {2,3,2,3,4}
139  * An HDL integer type is stored as C int, a HDL real type is
140  * stored as a C double and a VHDL string type is stored as char*.
141  * An array of HDL integer or double is stored as an array of C
142  * integer or double respectively
143  */
144 
145  /* In case you are not familiar with VHDL simulation, there are 9 possible
146  * values defined for the standard logic type, instead of just 0 and 1. The
147  * simulator needs to compute all these possible outcomes. Therefore, XSI uses
148  * a byte, instead of a bit, to represent a std_logic. This is represented
149  * with a char with possible values ranging from 0 to 8.
150  */
151  const char* std_logic_literal[] = {"U", "X", "0", "1", "Z", "W", "L", "H", "-"};
153  const char one_val = 3;
155  const char zero_val = 2;
156 
157  char std_logic(bool inBit)
158  {
159  char outBit = zero_val;
160  if (inBit) {
161  outBit = one_val;
162  }
163  return outBit;
164  }
165 
166  std::string display_value(const char* count, int size)
167  {
168  std::string res;
169  for (int i = 0; i < size; i++) {
170  if (count[i] >= 0 && count[i] < 9) {
171  res += std_logic_literal[(int) count[i]];
172  } else {
173  B2DEBUG(20, "invalid signal detected: " << static_cast<int>(count[i]));
174  res += "?";
175  }
176  }
177  return res;
178  }
179 
180  template<size_t N>
181  std::string slv_to_bin_string(std::array<char, N> signal, bool padding = false)
182  {
183  int ini = padding ? 4 - signal.size() % 4 : 0;
184  std::string res(ini, '0');
185  for (auto const& bit : signal) {
186  if (bit >= 0 && bit < 9) {
187  res += std_logic_literal[(int) bit];
188  } else {
189  B2DEBUG(20, "invalid signal detected: " << static_cast<int>(bit));
190  res += "0";
191  }
192  }
193  return res;
194  }
195 
196  template<size_t N>
197  void display_hex(const std::array<char, N>& signal)
198  {
199  std::ios oldState(nullptr);
200  oldState.copyfmt(std::cout);
201  if (std::any_of(signal.begin(), signal.end(), [](char i)
202  {return i != zero_val && i != one_val;})) {
203  B2DEBUG(20, "Some bit in the signal vector is neither 0 nor 1. \n" <<
204  "Displaying binary values instead.");
205  std::cout << slv_to_bin_string(signal) << std::endl;
206  } else {
207  std::string binString = slv_to_bin_string(signal, true);
208  std::cout << std::setfill('0');
209  for (unsigned i = 0; i < signal.size(); i += 4) {
210  std::bitset<4> set(binString.substr(i, 4));
211  std::cout << std::setw(1) << std::hex << set.to_ulong();
212  }
213  }
214  std::cout << "\n";
215  std::cout.copyfmt(oldState);
216  }
217 
218  /* extract a subset of bitstring, like substring.
219  *
220  * In principle this can be done using only integer manipulations, but for the
221  * sake of simplicity, let's just cast them to string. Beware the endianness.
222  * 0 refer to the rightmost bit in std::bitset, but the leftmost bit in
223  * std::string
224  */
225  template<size_t nbits, size_t min, size_t max>
226  std::bitset < max - min + 1 > subset(std::bitset<nbits> set)
227  {
228  const size_t outWidth = max - min + 1;
229  std::string str = set.to_string();
230  return std::bitset<outWidth>(str.substr(nbits - max - 1, outWidth));
231  }
232 
233 
241  unsigned short globalSegmentID(unsigned short localID, unsigned short iSL)
242  {
243  auto itr = nWiresInSuperLayer.begin();
244  unsigned short globalID = std::accumulate(itr, itr + iSL, 0);
245  globalID += localID;
246  return globalID;
247  }
248 
249  static const double realNaN = std::numeric_limits<double>::quiet_NaN();
250 
251  using tsOut = std::array<unsigned, 4>;
252  using tsOutArray = std::array<tsOut, 5>;
257  double omega;
259  double phi0;
261  tsOutArray ts;
262  // hw values of 2dtrack
263  int hwOmega{0};
264  int hwPhi0{0};
265  };
267  struct TRGNeuroTrack {
269  double z;
271  double theta;
273  unsigned sector;
275  std::array<float, 9> inputID;
277  std::array<float, 9> inputT;
279  std::array<float, 9> inputAlpha;
281  std::array<tsOut, 9> ts;
283  int hwZ{0};
284  int hwTheta{0};
285  };
286  struct B2LDataField {
287  B2LDataField(
289  unsigned foundtime,
290  unsigned iTracker,
292  {
293  if (int(b2line.offset + foundtime) >= 0 &&
294  int(b2line.offset + foundtime) <= bitsNN->getEntries()) {
295 
296  NNBitStream* bitsn = (*bitsNN)[foundtime + b2line.offset];
297 
298  if (int(slv_to_bin_string(bitsn->signal()[iTracker]).size()) >= (NN_WIDTH - b2line.start)) {
299  data = slv_to_bin_string(bitsn->signal()[iTracker]).substr(NN_WIDTH - 1 - b2line.end, b2line.end - b2line.start + 1);
300  } else {
301  data = "";
302  }
303  } else {
304  data = "";
305  }
306 
307 
308  name = b2line.name;
309  }
310  std::string data;
311  std::string name;
312  };
313 
314  std::vector<bool> decodedriftthreshold(std::string p_driftthreshold)
315  {
316  std::vector<bool> res;
317  for (unsigned i = 0; i < p_driftthreshold.size(); ++i) {
318  if (p_driftthreshold.substr(i, 1) == "1") {
319  res.push_back(true);
320  } else if (p_driftthreshold.substr(i, 1) == "0") {
321  res.push_back(false);
322  } else {
323  B2WARNING("Invalid input in NNBitstream appending 'false'!");
324  res.push_back(false);
325  }
326  }
327  return res;
328  }
329  std::vector<bool> decodefoundoldtrack(std::string p_foundoldtrack)
330  {
331  std::vector<bool> res;
332  for (unsigned i = 0; i < p_foundoldtrack.size(); ++i) {
333  if (p_foundoldtrack.substr(i, 1) == "1") {
334  res.push_back(true);
335  } else if (p_foundoldtrack.substr(i, 1) == "0") {
336  res.push_back(false);
337  } else {
338  B2WARNING("Invalid input in NNBitstream appending 'false'!");
339  res.push_back(false);
340  }
341  }
342  return res;
343  }
344  bool decodevalstereobit(const std::string& p_valstereobit)
345  {
346  bool res;
347  if (p_valstereobit == "1") {
348  res = true;
349  } else if (p_valstereobit == "0") {
350  res = false;
351  } else {
352  B2WARNING("Invalid input in NNBitstream appending 'false'!");
353  res = false;
354  }
355  return res;
356  }
368  unsigned TSIDInSL(unsigned tsIDInTracker, unsigned iSL, unsigned iTracker)
369  {
370  const unsigned nCellsInSL = nMergers[iSL] * nCellsInLayer;
371  // get global TS ID
372  unsigned iTS = tsIDInTracker + nCellsInSL * iTracker / nTrackers;
373  // periodic ID overflow when phi0 > 0 for the 4th tracker
374  if (iTS >= nCellsInSL) {
375  iTS -= nCellsInSL;
376  }
377  // ID in SL8 is shifted by 16
378  if (iSL == 8) {
379  if (iTS < 16) {
380  iTS += nCellsInSL;
381  }
382  iTS -= 16;
383  }
384  return iTS;
385  }
386 
389  int mlp_bin_to_signed_int(std::string signal)
390  {
391  constexpr unsigned len = 13;
392  std::bitset<len> signal_bit(signal);
393  const unsigned shift = 16 - len;
394  // shift to 16 bits, cast it to signed 16-bit int, and shift it back
395  // thus the signed bit is preserved (when right-shifting)
396  int signal_out = (int16_t (signal_bit.to_ulong() << shift)) >> shift;
397  return signal_out;
398  }
403  int recalcETF(std::string driftinput, std::vector<unsigned> tsvector, CDCTriggerTrack* track)
404  {
405  //scale factor to get a value between -1 and 1
406  float scale = 1. / (1 << (driftinput.size() - 1) / 9);
407  int ret = 0;
408  bool stor = false;
409  // make a table, with <possible etf, how often it was calculated
410  // it is possible there are different event t0 used, if some value
411  // in the hw is kept longer than it should be
412  std::vector<std::vector<int>> table;
413  for (unsigned iSL = 0; iSL < 9; ++iSL) {
414  // getting the relative drift time in clock cycles (1cc ~ 2ns)
415  int reldt = static_cast<int>(fabs((mlp_bin_to_signed_int(driftinput.substr((8 - iSL) * driftinput.size() / 9,
416  driftinput.size() / 9)) * scale * 256)));
417  int tstime = static_cast<int>(tsvector[iSL]);
418  // we do not want SLs with no LR info or pts outside of the time window
419  if (reldt != 0 && reldt < 255) {
420  for (std::vector<int>& x : table) {
421  stor = false;
422  if (x[0] == tstime - reldt) {
423  x[1]++;
424  stor = true;
425  }
426  }
427  if (!stor) {table.push_back({tstime - reldt, 1});}
428  }
429 
430  }
431  // now get the event t0 recalculated most often and return it in the end
432  int maxi = 0;
433  for (std::vector<int>& x : table) {
434  if (x[1] > maxi) {
435  ret = x[0];
436  maxi = x[1];
437  }
438  }
439  // if there is a "wrong" input in the hardware values, the corresponding error bit is set
440  if (table.size() > 1) {track->setQualityVector(128);}
441  return ret;
442 
443  }
444 
452  tsOut decodeTSHit(std::string tsIn)
453  {
454  constexpr unsigned lenID = 8;
455  constexpr unsigned lenPriorityTime = 9; //(twodcc.size() > 0) ? 13 : 9;
456  constexpr unsigned lenLR = 2;
457  constexpr unsigned lenPriorityPosition = 2;
458  constexpr std::array<unsigned, 4> tsLens = {
459  lenID, lenPriorityTime, lenLR, lenPriorityPosition
460  };
461  std::array<unsigned, 5> tsPos = { 0 };
462  std::partial_sum(tsLens.begin(), tsLens.end(), tsPos.begin() + 1);
463  tsOut tsOutput;
464  tsOutput[0] = std::bitset<tsLens[0]>(tsIn.substr(tsPos[0], tsLens[0])).to_ulong();
465  tsOutput[1] = std::bitset<tsLens[1]>(tsIn.substr(tsPos[1], tsLens[1])).to_ulong();
466  tsOutput[2] = std::bitset<tsLens[2]>(tsIn.substr(tsPos[2], tsLens[2])).to_ulong();
467  tsOutput[3] = std::bitset<tsLens[3]>(tsIn.substr(tsPos[3], tsLens[3])).to_ulong();
468  return tsOutput;
469  }
470  tsOut decodeTSHit_sim(std::string tsIn, std::string twodcc)
471  {
472  constexpr unsigned lenID = 8;
473  constexpr unsigned lenPriorityTime = 9; //(twodcc.size() > 0) ? 13 : 9;
474  constexpr unsigned lenLR = 2;
475  constexpr unsigned lenPriorityPosition = 2;
476  constexpr std::array<unsigned, 4> tsLens = {
477  lenID, lenPriorityTime, lenLR, lenPriorityPosition
478  };
479  std::string C = tsIn.substr(lenID + 5, 4);
480  std::string B = tsIn.substr(lenID, 5);
481  std::string Bp = twodcc.substr(4, 5);
482  std::string Ap = twodcc.substr(0, 4);
483  int pt;
484  std::string pts;
485  if (std::stoul(B, 0, 2) <= std::stoul(Bp, 0, 2)) {
486  pts = Ap + B + C;
487  } else {
488  B2DEBUG(14, "2DCC overflow detected!");
489  pts = std::bitset<4>(std::stoul(Ap, 0, 2) - 1).to_string() + B + C;
490  }
491  pt = std::stoul(pts, 0, 2);
492  std::array<unsigned, 5> tsPos = { 0 };
493  std::partial_sum(tsLens.begin(), tsLens.end(), tsPos.begin() + 1);
494  tsOut tsOutput;
495  tsOutput[0] = std::bitset<tsLens[0]>(tsIn.substr(tsPos[0], tsLens[0])).to_ulong();
496  tsOutput[1] = pt; // std::bitset<tsLens[1]>(tsIn.substr(tsPos[1], tsLens[1])).to_ulong();
497  tsOutput[2] = std::bitset<tsLens[2]>(tsIn.substr(tsPos[2], tsLens[2])).to_ulong();
498  tsOutput[3] = std::bitset<tsLens[3]>(tsIn.substr(tsPos[3], tsLens[3])).to_ulong();
499  return tsOutput;
500  }
501  tsOut decodeTSHit_ext(std::string tsIn, std::string expt)
502  {
503  constexpr unsigned lenID = 8;
504  constexpr unsigned lenPriorityTime = 9; //(twodcc.size() > 0) ? 13 : 9;
505  constexpr unsigned lenLR = 2;
506  constexpr unsigned lenPriorityPosition = 2;
507  constexpr std::array<unsigned, 4> tsLens = {
508  lenID, lenPriorityTime, lenLR, lenPriorityPosition
509  };
510  unsigned pt = std::stoul(expt, 0, 2);
511  std::array<unsigned, 5> tsPos = { 0 };
512  std::partial_sum(tsLens.begin(), tsLens.end(), tsPos.begin() + 1);
513  tsOut tsOutput;
514  tsOutput[0] = std::bitset<tsLens[0]>(tsIn.substr(tsPos[0], tsLens[0])).to_ulong();
515  tsOutput[1] = pt; //std::bitset<13>(expt).to_ulong();
516  tsOutput[2] = std::bitset<tsLens[2]>(tsIn.substr(tsPos[2], tsLens[2])).to_ulong();
517  tsOutput[3] = std::bitset<tsLens[3]>(tsIn.substr(tsPos[3], tsLens[3])).to_ulong();
518  return tsOutput;
519  }
520 
530  TRG2DFinderTrack decode2DTrack(const std::string& p_charge __attribute__((unused)),
531  std::string p_omega,
532  std::string p_phi,
533  const std::string& p_ts0,
534  const std::string& p_ts2,
535  const std::string& p_ts4,
536  const std::string& p_ts6,
537  const std::string& p_ts8,
538  unsigned iTracker,
539  const std::string& p_2dcc,
540  bool sim13dt)
541  {
542 //constexpr unsigned lenomega = p_omega.size();
543  unsigned shift = 16 - p_omega.size();
544  TRG2DFinderTrack trackout;
545  int omega = std::stoi(p_omega, 0, 2);
546  // shift omega to 16 bits, cast it to signed 16-bit int, and shift it back to 7 bits
547  // thus the signed bit is preserved (when right-shifting)
548  int omegafirm = (int16_t (omega << shift)) >> shift;
549  trackout.hwOmega = omegafirm;
550  //int omegafirm = (int16_t (omega.to_ulong() << shift)) >> shift;
551  // B field is 1.5T
552  const double BField = 1.5e-4; // why is it so small?
553  // omega in 1/cm
554  // omega = 1/R = c * B / pt
555  trackout.omega = Const::speedOfLight * BField / 0.3 / 34 * omegafirm;
556 
557 
558 
559 
560  int phi = std::stoi(p_phi, 0, 2);
561  trackout.hwPhi0 = phi;
562  // c.f. https://confluence.desy.de/download/attachments/34033650/output-def.pdf
563  double globalPhi0 = pi() / 4 + pi() / 2 / 80 * (phi + 1) + pi() / 2 * iTracker; // see document above
564 
565 
566  trackout.ts[0] = (sim13dt) ? decodeTSHit_sim(p_ts0, p_2dcc) : decodeTSHit(p_ts0);
567  trackout.ts[1] = (sim13dt) ? decodeTSHit_sim(p_ts2, p_2dcc) : decodeTSHit(p_ts2);
568  trackout.ts[2] = (sim13dt) ? decodeTSHit_sim(p_ts4, p_2dcc) : decodeTSHit(p_ts4);
569  trackout.ts[3] = (sim13dt) ? decodeTSHit_sim(p_ts6, p_2dcc) : decodeTSHit(p_ts6);
570  trackout.ts[4] = (sim13dt) ? decodeTSHit_sim(p_ts8, p_2dcc) : decodeTSHit(p_ts8);
571  // rotate the tracks to the correct quadrant (iTracker)
572  if (globalPhi0 > pi() * 2) {
573  globalPhi0 -= pi() * 2;
574  }
575  trackout.phi0 = globalPhi0;
576  B2DEBUG(20, "Unpacking 2DTrack in Tracker: " << iTracker);
577  B2DEBUG(20, " Omega: " << std::to_string(omega) << ", Omegafirm: " << std::to_string(omegafirm) << ", converted to: " <<
578  std::to_string(trackout.omega));
579  B2DEBUG(20, " Phi: " << std::to_string(phi) << ", converted to: " << std::to_string(trackout.phi0));
580  return trackout;
581 
582  }
583  TRG2DFinderTrack decode2DTrack(std::string trackIn, unsigned iTracker)
584  {
585  constexpr unsigned lenCharge = 2;
586  constexpr unsigned lenOmega = 7;
587  constexpr unsigned lenPhi0 = 7;
588  constexpr std::array<unsigned, 3> trackLens = {lenCharge, lenOmega, lenPhi0};
589  std::array<unsigned, 4> trackPos{ 0 };
590  std::partial_sum(trackLens.begin(), trackLens.end(), trackPos.begin() + 1);
591  const unsigned shift = 16 - lenOmega;
592  TRG2DFinderTrack trackOut;
593  std::bitset<trackLens[1]> omega(trackIn.substr(trackPos[1], trackLens[1]));
594  // shift omega to 16 bits, cast it to signed 16-bit int, and shift it back to 7 bits
595  // thus the signed bit is preserved (when right-shifting)
596  int omegaFirm = (int16_t (omega.to_ulong() << shift)) >> shift;
597  trackOut.hwOmega = omegaFirm;
598  // B field is 1.5T
599  const double BField = 1.5e-4;
600  // omega in 1/cm
601  // omega = 1/R = c * B / pt
602  // c.f. https://confluence.desy.de/download/attachments/34033650/output-def.pdf
603  trackOut.omega = Const::speedOfLight * BField / 0.3 / 34 * omegaFirm;
604  int phi0 = std::bitset<trackLens[2]>(trackIn.substr(trackPos[2], trackLens[2])).to_ulong();
605  trackOut.hwPhi0 = phi0;
606  trackOut.phi0 = pi() / 4 + pi() / 2 / 80 * (phi0 + 1);
607  for (unsigned i = 0; i < 5; ++i) {
608  trackOut.ts[i] = decodeTSHit(trackIn.substr(trackPos.back() + i * lenTS, lenTS));
609  }
610 
611  // rotate the tracks to the correct quadrant (iTracker)
612  double globalPhi0 = trackOut.phi0 + pi() / 2 * iTracker;
613  if (globalPhi0 > pi() * 2) {
614  globalPhi0 -= pi() * 2;
615  }
616  trackOut.phi0 = globalPhi0;
617  return trackOut;
618  }
619 
628  TRGNeuroTrack decodeNNTrack(std::string p_mlpout_z,
629  std::string p_mlpout_theta,
630  std::string p_tsfsel,
631  std::string p_mlpin_alpha,
632  std::string p_mlpin_drifttime,
633  std::string p_mlpin_id,
634  std::string p_netsel,
635  const DBObjPtr<CDCTriggerNeuroConfig>& neurodb,
636  const std::string& p_2dcc,
637  bool sim13dt,
638  B2LDataField p_extendedpts)
639  {
640  // constexpr unsigned lenMLP = 13;
641  float scale_z = 1. / (1 << (p_mlpout_z.size() - 1));
642  float scale_theta = 1. / (1 << (p_mlpout_theta.size() - 1));
643  float scale_alpha = 1. / (1 << (p_mlpin_alpha.size() - 1) / 9);
644  float scale_drifttime = 1. / (1 << (p_mlpin_drifttime.size() - 1) / 9);
645  float scale_id = 1. / (1 << (p_mlpin_id.size() - 1) / 9);
646  TRGNeuroTrack foundTrack;
647  int theta_raw = mlp_bin_to_signed_int(p_mlpout_theta);
648  int z_raw = mlp_bin_to_signed_int(p_mlpout_z);
649  foundTrack.hwZ = z_raw;
650  foundTrack.hwTheta = theta_raw;
651  std::vector<float> unscaledT = neurodb->getMLPs()[0].unscaleTarget({(z_raw * scale_z), (theta_raw * scale_theta)});
652  foundTrack.z = unscaledT[0];
653  foundTrack.theta = unscaledT[1];
654  foundTrack.sector = std::stoi(p_netsel, 0, 2);
655  for (unsigned iSL = 0; iSL < 9; ++iSL) {
656  foundTrack.inputAlpha[iSL] =
657  mlp_bin_to_signed_int(p_mlpin_alpha.substr((8 - iSL) * p_mlpin_alpha.size() / 9, p_mlpin_alpha.size() / 9)) * scale_alpha;
658  foundTrack.inputT[iSL] =
659  mlp_bin_to_signed_int(p_mlpin_drifttime.substr((8 - iSL) * p_mlpin_drifttime.size() / 9,
660  p_mlpin_drifttime.size() / 9)) * scale_drifttime;
661  foundTrack.inputID[iSL] =
662  mlp_bin_to_signed_int(p_mlpin_id.substr((8 - iSL) * p_mlpin_drifttime.size() / 9, p_mlpin_drifttime.size() / 9)) * scale_id;
663  if (sim13dt) {
664  foundTrack.ts[iSL] = decodeTSHit_sim(p_tsfsel.substr((8 - iSL) * lenTS, lenTS), p_2dcc);
665  } else {
666  if (p_extendedpts.name != "None") {
667  foundTrack.ts[iSL] = decodeTSHit_ext(p_tsfsel.substr((8 - iSL) * lenTS, lenTS), p_extendedpts.data.substr((8 - iSL) * 13, 13));
668  } else {
669  foundTrack.ts[iSL] = decodeTSHit(p_tsfsel.substr((8 - iSL) * lenTS, lenTS));
670  }
671  }
672  }
673  return foundTrack;
674  }
675  TRGNeuroTrack decodeNNTrack_old(std::string trackIn, std::string selectIn)
676  {
677  constexpr unsigned lenMLP = 13;
678  float scale = 1. / (1 << (lenMLP - 1));
679  TRGNeuroTrack foundTrack;
680  int theta_raw = mlp_bin_to_signed_int(trackIn.substr(1, lenMLP));
681  foundTrack.theta = theta_raw * scale * M_PI_2 + M_PI_2;
682  int z_raw = mlp_bin_to_signed_int(trackIn.substr(lenMLP + 1, lenMLP));
683  foundTrack.z = z_raw * scale * 50.;
684  foundTrack.sector = std::bitset<3>(trackIn.substr(2 * lenMLP + 1, 3)).to_ulong();
685  for (unsigned iSL = 0; iSL < 9; ++iSL) {
686  foundTrack.inputAlpha[iSL] =
687  mlp_bin_to_signed_int(selectIn.substr((2 + (8 - iSL)) * lenMLP + 4, lenMLP)) * scale;
688  foundTrack.inputT[iSL] =
689  mlp_bin_to_signed_int(selectIn.substr((11 + (8 - iSL)) * lenMLP + 4, lenMLP)) * scale;
690  foundTrack.inputID[iSL] =
691  mlp_bin_to_signed_int(selectIn.substr((20 + (8 - iSL)) * lenMLP + 4, lenMLP)) * scale;
692  foundTrack.ts[iSL] = // order: SL8, ..., SL0
693  decodeTSHit(selectIn.substr(29 * lenMLP + 4 + (8 - iSL) * lenTS, lenTS));
694  }
695  return foundTrack;
696  }
697 
702  CDCTriggerSegmentHit* addTSHit(tsOut ts, unsigned iSL, unsigned iTracker,
703  StoreArray<CDCTriggerSegmentHit>* tsHits,
704  int foundTime = 0)
705  {
706  unsigned iTS = TSIDInSL(ts[0], iSL, iTracker);
707  // check if hit is already existing in datastore
708  CDCTriggerSegmentHit* hit = nullptr;
709  //for (int ihit = 0; ihit < tsHits->getEntries(); ++ihit) {
710  // CDCTriggerSegmentHit* compare = (*tsHits)[ihit];
711  // if (compare->getISuperLayer() == iSL &&
712  // compare->getIWireCenter() == iTS &&
713  // compare->getPriorityPosition() == ts[3] &&
714  // compare->getLeftRight() == ts[2] &&
715  // compare->priorityTime() == int(ts[1])) {
716  // hit = compare;
717  // break;
718  // }
719  //}
720 // !hit is always true.
721 // if (!hit) {
722  hit = tsHits->appendNew(iSL, iTS, ts[3], ts[2], ts[1], 0, foundTime, iTracker);
723  B2DEBUG(15, "make hit at SL " << iSL << " ID " << iTS << " clock " << foundTime << " iTracker " << iTracker);
724 // }
725  return hit;
726  }
727 
742  void decode2DOutput(short foundTime,
743  T2DOutputBitStream* bits,
744  StoreArray<CDCTriggerTrack>* storeTracks,
745  StoreArray<CDCTriggerFinderClone>* storeClones,
746  StoreArray<CDCTriggerSegmentHit>* tsHits)
747  {
748  const unsigned lenTrack = 121;
749  const unsigned oldTrackWidth = 6;
750  const unsigned foundWidth = 6;
751  std::array<int, 4> posTrack;
752  for (unsigned i = 0; i < posTrack.size(); ++i) {
753  posTrack[i] = oldTrackWidth + foundWidth + lenTrack * i;
754  }
755  for (unsigned iTracker = 0; iTracker < nTrackers; ++iTracker) {
756  const auto slv = bits->signal()[iTracker];
757  std::string strOutput = slv_to_bin_string(slv).
758  substr(clockCounterWidth, T2DOutputWidth - clockCounterWidth);
759  for (unsigned i = 0; i < nMax2DTracksPerClock; ++i) {
760  // The first 6 bits indicate whether a track is found or not
761  if (slv[clockCounterWidth + oldTrackWidth + i] == one_val) {
762  TRG2DFinderTrack trk = decode2DTrack(strOutput.substr(posTrack[i], lenTrack), iTracker);
763  B2DEBUG(15, "2DOut phi0:" << trk.phi0 << ", omega:" << trk.omega
764  << ", at clock " << foundTime << ", tracker " << iTracker);
765  CDCTriggerTrack* track =
766  storeTracks->appendNew(trk.phi0, trk.omega, 0., foundTime, iTracker);
767  CDCTriggerFinderClone* clone =
768  storeClones->appendNew(slv[clockCounterWidth + i] == one_val, iTracker);
769  clone->addRelationTo(track);
770  // TODO: dig out the TS hits in DataStore, and
771  // add relations to them.
772  // Otherwise, create a new TS hit object and add the relation.
773  // However, the fastest time would be lost in this case.
774  // Problem: there might be multiple TS hits with the same ID,
775  // so the foundTime needs to be aligned first in order to compare.
776  for (unsigned iAx = 0; iAx < nAxialTSF; ++iAx) {
777  const auto& ts = trk.ts[iAx];
778  if (ts[3] > 0) {
779  unsigned iTS = TSIDInSL(ts[0], 2 * iAx, iTracker);
780  CDCTriggerSegmentHit* hit =
781  tsHits->appendNew(2 * iAx, // super layer
782  iTS, // TS number in super layer
783  ts[3], // priority position
784  ts[2], // L/R
785  ts[1], // priority time
786  0, // fastest time (unknown)
787  // set to a clock definitely outside the time window to receive the TS from TSF,
788  // so it won't cause any confusion of the TS origin.
789  // what I want to is to set it to (200 + 2DmoduleID[0,1,2,3]),
790  // so one can distinguish in which 2D this track is found.
791  // foundTime); // found time (using the unpacked clock cycle)
792  2000 + iTracker * 100 + foundTime,
793  iTracker); // quadrant
794  track->addRelationTo(hit);
795  }
796  }
797  }
798  }
799  }
800  }
801 
814  void decode2DInput(short foundTime,
815  std::array<int, 4> timeOffset,
816  TSFOutputBitStream* bits,
817  StoreArray<CDCTriggerSegmentHit>* tsHits)
818  {
819  // Get the input TS to 2D from the Bitstream
820  for (unsigned iAx = 0; iAx < nAxialTSF; ++iAx) {
821  for (unsigned iTracker = 0; iTracker < nTrackers; ++iTracker) {
822  const auto& tracker = bits->signal()[iAx][iTracker];
823  std::string strInput = slv_to_bin_string(tracker);
824  bool noMoreHit = false;
825  for (unsigned pos = clockCounterWidth; pos < TSFOutputWidth; pos += lenTS) {
826  std::string tsHitStr = strInput.substr(pos, lenTS);
827  B2DEBUG(50, tsHitStr);
828  tsOut ts = decodeTSHit(tsHitStr);
829  // check if all the hits are on the MSB side
830  if (ts[2] == 0) {
831  noMoreHit = true;
832  continue;
833  } else if (noMoreHit) {
834  B2DEBUG(20, "Discontinuous TS hit detected!");
835  }
836  unsigned iTS = TSIDInSL(ts[0], 2 * iAx, iTracker);
837  // Make TS hit object
838  CDCTriggerSegmentHit hit(2 * iAx, // super layer
839  iTS, // TS number in super layer
840  ts[3], // priority position
841  ts[2], // L/R
842  ts[1], // priority time
843  0, // fastest time (unknown)
844  foundTime + timeOffset[iTracker], // found time
845  iTracker); // quadrant
846 
847  // add if the TS hit of identical ID and foundTime is not already in the StoreArray
848  // (from the 2D input of another quarter or the 2D track output)
849 
850  /* TODO: Currently, it is very likely that a TS hit will appear
851  * multiple times in the StoreArray. To avoid adding the input from
852  * another quarter again, we need to look at the clock counter,
853  * because the data from different 2D's are not always synchronized
854  * due to Belle2Link instability. To avoid adding again from the 2D
855  * output, we need to consider the 2D latency.
856  */
857  if (std::none_of(tsHits->begin(), tsHits->end(),
858  [hit](CDCTriggerSegmentHit storeHit) {
859  return (storeHit.getSegmentID() == hit.getSegmentID() &&
860  storeHit.foundTime() == hit.foundTime());
861  })) {
862  B2DEBUG(40, "found TS hit ID " << hit.getSegmentID() <<
863  ", SL" << 2 * iAx << ", local ID " << iTS <<
864  ", 2D" << iTracker);
865  tsHits->appendNew(hit);
866  } else {
867  B2DEBUG(45, "skipping redundant hit ID " << hit.getSegmentID() << " in 2D" << iTracker);
868  }
869  }
870  }
871  }
872  }
873 
890  CDCTriggerTrack* decodeNNInput(short iclock,
891  unsigned iTracker,
892  NNBitStream* bitsIn,
893  StoreArray<CDCTriggerTrack>* store2DTracks,
894  StoreArray<CDCTriggerSegmentHit>* tsHits)
895  {
896  CDCTriggerTrack* track2D = nullptr;
897  constexpr unsigned lenTrack = 135; //119;
898  // omega (7 bit) + phi (7 bit) + 5 * TS (21 bit) + old track found(6bit) + valid stereo bit (1bit) + drift threshold (9bit)
899  const auto slvIn = bitsIn->signal()[iTracker];
900  std::string strIn = slv_to_bin_string(slvIn);
901  strIn = strIn.substr(NN_WIDTH - 570 - 496, 982);
902  // decode stereo hits
903  for (unsigned iSt = 0; iSt < nStereoTSF; ++iSt) {
904  for (unsigned iHit = 0; iHit < 10; ++iHit) {
905  // order: 10 * SL7, 10 * SL5, 10 * SL3, 10 * SL1
906  unsigned pos = ((nStereoTSF - iSt - 1) * 10 + iHit) * lenTS;
907  tsOut ts = decodeTSHit(strIn.substr(pos, lenTS));
908  if (ts[3] > 0) {
909  addTSHit(ts, iSt * 2 + 1, iTracker, tsHits, iclock);
910  }
911  }
912  }
913  std::string strTrack = strIn.substr(nStereoTSF * 10 * lenTS, lenTrack);
914  if (!std::all_of(strTrack.begin(), strTrack.end(), [](char i) {return i == '0';})) {
915  std::string infobits = strTrack.substr(5 * lenTS + 14, 16);
916  strTrack = "00" + strTrack.substr(5 * lenTS, 14) + strTrack.substr(0,
917  5 * lenTS); // add 2 dummy bits for the charge (not stored in NN)
918  TRG2DFinderTrack trk2D = decode2DTrack(strTrack, iTracker);
919  B2DEBUG(15, "NNIn phi0:" << trk2D.phi0 << ", omega:" << trk2D.omega
920  << ", at clock " << iclock << ", tracker " << iTracker);
921  B2DEBUG(300, "Content of new infobits: " << infobits);
922  std::vector<bool> foundoldtrack;
923  std::vector<bool> driftthreshold;
924  bool valstereobit;
925  unsigned i = 0;
926  for (i = 0; i < 6; i++) {
927  if (infobits.substr(i, 1) == "1") {
928  foundoldtrack.push_back(true);
929  } else if (infobits.substr(i, 1) == "0") {
930  foundoldtrack.push_back(false);
931  } else {
932  B2WARNING("Invalid input in NNBitstream appending 'false'!");
933  foundoldtrack.push_back(false);
934  }
935  }
936  i = 6;
937  if (infobits.substr(i, 1) == "1") {
938  valstereobit = true;
939  } else if (infobits.substr(i, 1) == "0") {
940  valstereobit = false;
941  } else {
942  B2WARNING("Invalid input in NNBitstream appending 'false'!");
943  valstereobit = false;
944  }
945  for (i = 7; i < 16; i++) {
946  if (infobits.substr(i, 1) == "1") {
947  driftthreshold.push_back(true);
948  } else if (infobits.substr(i, 1) == "0") {
949  driftthreshold.push_back(false);
950  } else {
951  B2WARNING("Invalid input in NNBitstream appending 'false'!");
952  driftthreshold.push_back(false);
953  }
954  }
955  B2DEBUG(15, "bits for foundoldtrack: " << foundoldtrack[0]
956  << foundoldtrack[1]
957  << foundoldtrack[2]
958  << foundoldtrack[3]
959  << foundoldtrack[4]
960  << foundoldtrack[5]);
961  B2DEBUG(15, "bits for driftthreshold: " << driftthreshold[0]
962  << driftthreshold[1]
963  << driftthreshold[2]
964  << driftthreshold[3]
965  << driftthreshold[4]
966  << driftthreshold[5]
967  << driftthreshold[6]
968  << driftthreshold[7]
969  << driftthreshold[8]);
970  B2DEBUG(15, "bits for valstereobit: " << valstereobit);
971 
972  // check if 2D track is already in list, otherwise add it
973  //for (int itrack = 0; itrack < store2DTracks->getEntries(); ++itrack) {
974  // if ((*store2DTracks)[itrack]->getPhi0() == trk2D->phi0 &&
975  // (*store2DTracks)[itrack]->getOmega() == trk2D->omega) {
976  // track2D = (*store2DTracks)[itrack];
977  // B2DEBUG(15, "found 2D track in store with phi " << trk2D->phi0 << " omega " << trk2D->omega);
978  // break;
979  // }
980  //}
981  B2DEBUG(15, "make new 2D track with phi " << trk2D.phi0 << " omega " << trk2D.omega << " clock " << iclock);
982  track2D = store2DTracks->appendNew(trk2D.phi0, trk2D.omega, 0., foundoldtrack, driftthreshold, valstereobit, iclock, iTracker);
983  // add axial hits and create relations
984  for (unsigned iAx = 0; iAx < nAxialTSF; ++iAx) {
985  const auto& ts = trk2D.ts[iAx];
986  if (ts[3] > 0) {
987  CDCTriggerSegmentHit* hit =
988  addTSHit(ts, 2 * iAx, iTracker, tsHits, iclock);
989  track2D->addRelationTo(hit);
990  }
991  }
992  // TODO: decode event time
993  }
994  return track2D;
995  }
996 
1017  void decodeNNOutput_old(short foundTime,
1018  unsigned iTracker,
1019  NNBitStream* bitsOut,
1020  NNBitStream* bitsSelectTS,
1021  StoreArray<CDCTriggerTrack>* storeNNTracks,
1022  StoreArray<CDCTriggerSegmentHit>* tsHits,
1023  StoreArray<CDCTriggerMLPInput>* storeNNInputs,
1024  CDCTriggerTrack* track2D)
1025  {
1026  const auto slvOut = bitsOut->signal()[iTracker];
1027  std::string strTrack = slv_to_bin_string(slvOut);
1028  strTrack = strTrack.substr(496, 570);
1029  const auto slvSelect = bitsSelectTS->signal()[iTracker];
1030  std::string strSelect = slv_to_bin_string(slvSelect);
1031  strSelect = strSelect.substr(496, 570);
1032  TRGNeuroTrack trkNN = decodeNNTrack_old(strTrack, strSelect);
1033  B2DEBUG(15, "make new NN track with , z:" << trkNN.z << ", theta:" << trkNN.theta <<
1034  ", sector:" << trkNN.sector << ", clock " << foundTime);
1035  double phi0 = 0;
1036  double omega = 0;
1037  if (track2D) {
1038  phi0 = track2D->getPhi0();
1039  omega = track2D->getOmega();
1040  }
1041  std::vector<unsigned> tsvector(9, 0);
1042  for (unsigned iSL = 0; iSL < 9; ++iSL) {
1043  tsvector[iSL] = trkNN.ts[iSL][2]; // save lr info in tsvector array
1044  }
1045  CDCTriggerTrack* trackNN = storeNNTracks->appendNew(phi0, omega, 0.,
1046  trkNN.z, cos(trkNN.theta) / sin(trkNN.theta), 0., track2D->getFoundOldTrack(), track2D->getDriftThreshold(),
1047  track2D->getValidStereoBit(), trkNN.sector, tsvector, foundTime, iTracker);
1048  std::vector<float> inputVector(27, 0.);
1049  for (unsigned iSL = 0; iSL < 9; ++iSL) {
1050  inputVector[3 * iSL] = trkNN.inputID[iSL];
1051  inputVector[3 * iSL + 1] = trkNN.inputT[iSL];
1052  inputVector[3 * iSL + 2] = trkNN.inputAlpha[iSL];
1053  }
1054  CDCTriggerMLPInput* storeInput =
1055  storeNNInputs->appendNew(inputVector, trkNN.sector);
1056  trackNN->addRelationTo(storeInput);
1057  track2D->addRelationTo(trackNN);
1058 
1059  for (unsigned iSL = 0; iSL < 9; ++iSL) {
1060  if (trkNN.ts[iSL][3] > 0) {
1061  CDCTriggerSegmentHit* hit = addTSHit(trkNN.ts[iSL] , iSL, iTracker, tsHits, foundTime);
1062  trackNN->addRelationTo(hit);
1063  }
1064  }
1065  }
1066 
1084  void decodeNNIO(
1085  StoreArray<CDCTriggerUnpacker::NNBitStream>* bitsNN,
1086  StoreArray<CDCTriggerTrack>* store2DTracks,
1087  StoreArray<CDCTriggerTrack>* storeNNTracks,
1088  StoreArray<CDCTriggerSegmentHit>* tsHits,
1089  StoreArray<CDCTriggerSegmentHit>* tsHitsAll,
1090  StoreArray<CDCTriggerMLPInput>* storeNNInputs,
1091  StoreObjPtr<BinnedEventT0> storeETFTime,
1092  const DBObjPtr<CDCTriggerNeuroConfig> neurodb,
1093  bool sim13dt)
1094  {
1095  for (unsigned iTracker = 0; iTracker < nTrackers; ++iTracker) {
1096  B2DEBUG(21, "----------------------------------------------------------------------------------------------------");
1097  B2DEBUG(21, padright(" Unpacking Tracker: " + std::to_string(iTracker), 100));
1098  // loop over boards belonging to geometrical sectors
1099 
1100  for (short iclock = 0; iclock < bitsNN->getEntries(); ++iclock) {
1101  // check for NNEnable bit:
1102  B2LDataField p_nnenable(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("NNEnable"));
1103  if (p_nnenable.name == "None") {
1104  B2DEBUG(5, "Neurotrigger: NNENable position unknown, skipping ... ");
1105  continue;
1106  } else if (p_nnenable.data == "1") {
1107  B2DEBUG(10, padright("Tracker: " + std::to_string(iTracker) + ", Clock: " + std::to_string(iclock) + " : NNEnable set!", 100));
1108  } else {
1109  B2DEBUG(21, padright(" UnpackerClock: " + std::to_string(iclock), 100));
1110  }
1111 
1112 
1113  CDCTriggerNeuroConfig::B2FormatLine nnall;
1114  nnall.start = 0;
1115  nnall.end = 2047;
1116  nnall.offset = 0;
1117  nnall.name = "nnall";
1118  B2LDataField p_nnall(bitsNN, iclock, iTracker, nnall);
1119  B2DEBUG(22, padright(" all bits: ", 100));
1120  B2DEBUG(22, padright(" " + p_nnall.data, 100));
1121  // define variables to fill from the bitstream, B2LDataField holds just the string, not the unpacked data yet
1122  B2LDataField p_driftthreshold(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("DriftThreshold"));
1123  if ((p_driftthreshold.name != "None") && (p_driftthreshold.data.size() == 0)) {
1124  B2DEBUG(10, "Could not load Datafield: " << p_driftthreshold.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1125  iclock);
1126  continue;
1127  }
1128 
1129  B2LDataField p_valstereobit(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("ValStereoBit"));
1130  if ((p_valstereobit.name != "None") && (p_valstereobit.data.size() == 0)) {
1131  B2DEBUG(10, "Could not load Datafield: " << p_valstereobit.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1132  iclock);
1133  continue;
1134  }
1135 
1136  B2LDataField p_foundoldtrack(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("FoundOldTrack"));
1137  if ((p_foundoldtrack.name != "None") && (p_foundoldtrack.data.size() == 0)) {
1138  B2DEBUG(10, "Could not load Datafield: " << p_foundoldtrack.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1139  iclock);
1140  continue;
1141  }
1142 
1143  B2LDataField p_phi(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("Phi"));
1144  if ((p_phi.name != "None") && (p_phi.data.size() == 0)) {
1145  B2DEBUG(10, "Could not load Datafield: " << p_phi.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1146  continue;
1147  }
1148 
1149  B2LDataField p_omega(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("Omega"));
1150  if ((p_omega.name != "None") && (p_omega.data.size() == 0)) {
1151  B2DEBUG(10, "Could not load Datafield: " << p_omega.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1152  continue;
1153  }
1154 
1155  B2LDataField p_ts8(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TS8"));
1156  if ((p_ts8.name != "None") && (p_ts8.data.size() == 0)) {
1157  B2DEBUG(10, "Could not load Datafield: " << p_ts8.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1158  continue;
1159  }
1160 
1161  B2LDataField p_ts6(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TS6"));
1162  if ((p_ts6.name != "None") && (p_ts6.data.size() == 0)) {
1163  B2DEBUG(10, "Could not load Datafield: " << p_ts6.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1164  continue;
1165  }
1166 
1167  B2LDataField p_ts4(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TS4"));
1168  if ((p_ts4.name != "None") && (p_ts4.data.size() == 0)) {
1169  B2DEBUG(10, "Could not load Datafield: " << p_ts4.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1170  continue;
1171  }
1172 
1173  B2LDataField p_ts2(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TS2"));
1174  if ((p_ts2.name != "None") && (p_ts2.data.size() == 0)) {
1175  B2DEBUG(10, "Could not load Datafield: " << p_ts2.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1176  continue;
1177  }
1178 
1179  B2LDataField p_ts0(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TS0"));
1180  if ((p_ts0.name != "None") && (p_ts0.data.size() == 0)) {
1181  B2DEBUG(10, "Could not load Datafield: " << p_ts0.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1182  continue;
1183  }
1184 
1185  B2LDataField p_tsf1(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TSF1"));
1186  if ((p_tsf1.name != "None") && (p_tsf1.data.size() == 0)) {
1187  B2DEBUG(10, "Could not load Datafield: " << p_tsf1.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1188  continue;
1189  }
1190 
1191  B2LDataField p_tsf3(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TSF3"));
1192  if ((p_tsf3.name != "None") && (p_tsf3.data.size() == 0)) {
1193  B2DEBUG(10, "Could not load Datafield: " << p_tsf3.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1194  continue;
1195  }
1196 
1197  B2LDataField p_tsf5(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TSF5"));
1198  if ((p_tsf5.name != "None") && (p_tsf5.data.size() == 0)) {
1199  B2DEBUG(10, "Could not load Datafield: " << p_tsf5.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1200  continue;
1201  }
1202 
1203  B2LDataField p_tsf7(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TSF7"));
1204  if ((p_tsf7.name != "None") && (p_tsf7.data.size() == 0)) {
1205  B2DEBUG(10, "Could not load Datafield: " << p_tsf7.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1206  continue;
1207  }
1208 
1209  B2LDataField p_tsfsel(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("TSFsel"));
1210  if ((p_tsfsel.name != "None") && (p_tsfsel.data.size() == 0)) {
1211  B2DEBUG(10, "Could not load Datafield: " << p_tsfsel.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1212  continue;
1213  }
1214 
1215  B2LDataField p_mlpin_alpha(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("MLPIn_alpha"));
1216  if ((p_mlpin_alpha.name != "None") && (p_mlpin_alpha.data.size() == 0)) {
1217  B2DEBUG(10, "Could not load Datafield: " << p_mlpin_alpha.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1218  iclock);
1219  continue;
1220  }
1221 
1222  B2LDataField p_mlpin_drifttime(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("MLPIn_driftt"));
1223  if ((p_mlpin_drifttime.name != "None") && (p_mlpin_drifttime.data.size() == 0)) {
1224  B2DEBUG(10, "Could not load Datafield: " << p_mlpin_drifttime.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1225  iclock);
1226  continue;
1227  }
1228 
1229  B2LDataField p_mlpin_id(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("MLPIn_id"));
1230  if ((p_mlpin_id.name != "None") && (p_mlpin_id.data.size() == 0)) {
1231  B2DEBUG(10, "Could not load Datafield: " << p_mlpin_id.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1232  iclock);
1233  continue;
1234  }
1235 
1236  B2LDataField p_netsel(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("Netsel"));
1237  if ((p_netsel.name != "None") && (p_netsel.data.size() == 0)) {
1238  B2DEBUG(10, "Could not load Datafield: " << p_netsel.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1239  continue;
1240  }
1241 
1242  B2LDataField p_mlpout_z(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("MLPOut_z"));
1243  if ((p_mlpout_z.name != "None") && (p_mlpout_z.data.size() == 0)) {
1244  B2DEBUG(10, "Could not load Datafield: " << p_mlpout_z.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1245  iclock);
1246  continue;
1247  }
1248 
1249  B2LDataField p_mlpout_theta(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("MLPOut_theta"));
1250  if ((p_mlpout_theta.name != "None") && (p_mlpout_theta.data.size() == 0)) {
1251  B2DEBUG(10, "Could not load Datafield: " << p_mlpout_theta.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1252  iclock);
1253  continue;
1254  }
1255 
1256  B2LDataField p_2dcc(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("2dcc"));
1257  if ((p_2dcc.name != "None") && (p_2dcc.data.size() == 0)) {
1258  B2DEBUG(10, "Could not load Datafield: " << p_2dcc.name << " from bitstream. Maybe offset was out of bounds? clock: " << iclock);
1259  continue;
1260  }
1261 
1262  B2LDataField p_extendedpts(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("extendedPriorityTimes"));
1263  if ((p_extendedpts.name != "None") && (p_extendedpts.data.size() == 0)) {
1264  B2DEBUG(10, "Could not load Datafield: " << p_extendedpts.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1265  iclock);
1266  continue;
1267  }
1268  B2LDataField p_etftime(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("etftime"));
1269  if ((p_etftime.name != "None") && (p_etftime.data.size() == 0)) {
1270  B2DEBUG(10, "Could not load Datafield: " << p_etftime.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1271  iclock);
1272  continue;
1273  }
1274  B2LDataField p_etfcc(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("etfcc"));
1275  if ((p_etfcc.name != "None") && (p_etfcc.data.size() == 0)) {
1276  B2DEBUG(10, "Could not load Datafield: " << p_etfcc.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1277  iclock);
1278  continue;
1279  }
1280  B2LDataField p_etfqual(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("etfquality"));
1281  if ((p_etfqual.name != "None") && (p_etfqual.data.size() == 0)) {
1282  B2DEBUG(10, "Could not load Datafield: " << p_etfqual.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1283  iclock);
1284  continue;
1285  }
1286  B2LDataField p_etfval(bitsNN, iclock, iTracker, neurodb->getB2FormatLine("etfvalid"));
1287  if ((p_etfval.name != "None") && (p_etfval.data.size() == 0)) {
1288  B2DEBUG(10, "Could not load Datafield: " << p_etfval.name << " from bitstream. Maybe offset was out of bounds? clock: " <<
1289  iclock);
1290  continue;
1291  }
1292 
1293  // B2LDataField (bitsNN, iclock, iTracker, neurodb->getB2FormatLine(""));
1294 
1295  CDCTriggerTrack* track2D = nullptr;
1296  // decode stereo hits
1297  if (true) { // (p_nnenable.data == "1") {
1298  unsigned sln = 0;
1299  B2DEBUG(21, padright(" Stereos: ", 100));
1300  for (auto stereolayer : {p_tsf1, p_tsf3, p_tsf5, p_tsf7}) {
1301  if (stereolayer.name == "None") {
1302  B2ERROR("Error in CDCTriggerNeuroConfig Payload, position of stereo tsf could not be found!");
1303  continue;
1304  }
1305  std::string tsstr = " | ";
1306  for (unsigned iHit = 0; iHit < 10; ++iHit) {
1307  tsOut ts = (sim13dt) ? decodeTSHit_sim(stereolayer.data.substr(iHit * lenTS, lenTS),
1308  p_2dcc.data) : decodeTSHit(stereolayer.data.substr(iHit * lenTS, lenTS));
1309  if (ts[3] > 0) { // if it is 0, it means 'no hit'
1310  unsigned iTS = TSIDInSL(ts[0], sln * 2 + 1, iTracker);
1311  tsstr += std::to_string(iTS) + ", " + std::to_string(ts[1]) + ", " + std::to_string(ts[2]) + ", " + std::to_string(ts[3]) + " | ";
1312  addTSHit(ts, sln * 2 + 1, iTracker, tsHitsAll, iclock);
1313  }
1314  }
1315  B2DEBUG(21, padright(" SL" + std::to_string(sln * 2 + 1) + tsstr, 100));
1316  ++sln;
1317  }
1318  }
1319  B2DEBUG(21, padright(" 2DCC: " + std::to_string(std::stoi(p_2dcc.data, 0, 2)) + ", (" + p_2dcc.data + ")", 100));
1320  B2DEBUG(21, padright(" ETFCC: " + std::to_string(std::stoi(p_etfcc.data, 0, 2)) + ", (" + p_etfcc.data + ")", 100));
1321  B2DEBUG(21, padright(" ETFVAL: " + std::to_string(std::stoi(p_etfval.data, 0, 2)) + ", (" + p_etfval.data + ")", 100));
1322  B2DEBUG(21, padright(" ETFT0: " + std::to_string(std::stoi(p_etftime.data, 0, 2)) + ", (" + p_etftime.data + ")", 100));
1323  B2DEBUG(21, padright(" ETFQuality: " + std::to_string(std::stoi(p_etfqual.data, 0, 2)) + ", (" + p_etfqual.data + ")", 100));
1324  bool hasETFTime = false;
1325  if (p_nnenable.data == "1") {
1326  if (p_etfval.data == "1") {
1327  storeETFTime->addBinnedEventT0(std::stoi(p_etftime.data, 0, 2), Const::CDC);
1328  hasETFTime = true;
1329  }
1330  std::vector<bool> foundoldtrack{false};
1331  std::vector<bool> driftthreshold{false};
1332  bool valstereobit;
1333  if (p_foundoldtrack.name != "None") {
1334  foundoldtrack = decodefoundoldtrack(p_foundoldtrack.data);
1335  }
1336  if (p_driftthreshold.name != "None") {
1337  driftthreshold = decodedriftthreshold(p_driftthreshold.data);
1338  }
1339  if (p_valstereobit.name != "None") {
1340  valstereobit = decodevalstereobit(p_valstereobit.data);
1341  }
1342 
1343  if (std::all_of(p_phi.data.begin(), p_phi.data.end(), [](char i) {return i == 0;})) {
1344  B2ERROR("Empty Phi Value found for 2DTrack, should not happen!");
1345  continue;
1346  }
1347  TRG2DFinderTrack trk2D = decode2DTrack(
1348  "00", //charge
1349  p_omega.data,
1350  p_phi.data,
1351  p_ts0.data,
1352  p_ts2.data,
1353  p_ts4.data,
1354  p_ts6.data,
1355  p_ts8.data,
1356  iTracker,
1357  p_2dcc.data,
1358  sim13dt);
1359  track2D = store2DTracks->appendNew(trk2D.phi0, trk2D.omega, 0., foundoldtrack, driftthreshold, valstereobit, iclock, iTracker);
1360  track2D->setRawOmega(trk2D.hwOmega);
1361  track2D->setRawPhi0(trk2D.hwPhi0);
1362  B2DEBUG(12, padright(" 2DTrack: (phi=" + std::to_string(trk2D.phi0) + ", omega=" + std::to_string(
1363  trk2D.omega) + ", update=" + std::to_string(foundoldtrack[1]) + ")", 100));
1364 
1365  // add axial hits and create relations
1366  std::string tsstr;
1367  for (unsigned iAx = 0; iAx < nAxialTSF; ++iAx) {
1368  const auto& ts = trk2D.ts[iAx];
1369  if (ts[3] > 0) {
1370  CDCTriggerSegmentHit* hit =
1371  addTSHit(ts, 2 * iAx, iTracker, tsHitsAll, iclock);
1372  unsigned iTS = TSIDInSL(ts[0], iAx * 2, iTracker);
1373  tsstr += "(SL" + std::to_string(iAx * 2) + ", " + std::to_string(iTS) + ", " + std::to_string(ts[1]) + ", " + std::to_string(
1374  ts[2]) + ", " + std::to_string(ts[3]) + "),";
1375  track2D->addRelationTo(hit);
1376  }
1377  }
1378  B2DEBUG(16, padright(" 2DTrack TS: " + tsstr, 100));
1379 
1380 
1381  if (track2D) {
1382  TRGNeuroTrack trkNN;
1383  trkNN = decodeNNTrack(p_mlpout_z.data,
1384  p_mlpout_theta.data,
1385  p_tsfsel.data,
1386  p_mlpin_alpha.data,
1387  p_mlpin_drifttime.data,
1388  p_mlpin_id.data,
1389  p_netsel.data,
1390  neurodb,
1391  p_2dcc.data,
1392  sim13dt,
1393  p_extendedpts);
1394 
1395 
1396  B2DEBUG(11, padright(" NNTrack: (z=" + std::to_string(trkNN.z) + ", theta=" + std::to_string(trkNN.theta) + ")", 100));
1397 
1398  double phi0 = track2D->getPhi0();
1399  double omega = track2D->getOmega();
1400 
1401  std::vector<unsigned> tsvector(9, 0);
1402  std::vector<unsigned> tstimevector(9, 0);
1403  tsstr = "";
1404  // turns false, as soon as there is a ts, which is not contained in the 2dfindertrack
1405  bool isin2d = true;
1406  for (unsigned iSL = 0; iSL < 9; ++iSL) {
1407  tsvector[iSL] = trkNN.ts[iSL][3];
1408  tstimevector[iSL] = trkNN.ts[iSL][1];
1409  if (trkNN.ts[iSL][3] > 0) {
1410  unsigned iTS = TSIDInSL(trkNN.ts[iSL][0], iSL, iTracker);
1411  tsstr += "(SL" + std::to_string(iSL) + ", " + std::to_string(iTS) + ", " + std::to_string(trkNN.ts[iSL][1]) + ", " + std::to_string(
1412  trkNN.ts[iSL][2]) + ", " + std::to_string(trkNN.ts[iSL][3]) + "),\n";
1413  // check, wether axials are a subset of 2dfinderTS:
1414  if (iSL % 2 == 0) {
1415  if (!(trk2D.ts[iSL / 2][0] == trkNN.ts[iSL][0] &&
1416  //trk2D.ts[iSL / 2][1] == trkNN.ts[iSL][1] &&
1417  trk2D.ts[iSL / 2][2] == trkNN.ts[iSL][2] &&
1418  trk2D.ts[iSL / 2][3] == trkNN.ts[iSL][3])) {
1419  isin2d = false;
1420  }
1421  }
1422 
1423  } else {
1424  tsstr += "( - ),\n";
1425  }
1426  }
1427 
1428  B2DEBUG(15, padright(" NNTrack TS: " + tsstr, 100));
1429 
1430  CDCTriggerTrack* trackNN = storeNNTracks->appendNew(phi0, omega, 0.,
1431  trkNN.z, cos(trkNN.theta) / sin(trkNN.theta), 0., track2D->getFoundOldTrack(), track2D->getDriftThreshold(),
1432  track2D->getValidStereoBit(), trkNN.sector, tsvector, iclock, iTracker);
1433  trackNN->setHasETFTime(hasETFTime);
1434  track2D->setHasETFTime(hasETFTime);
1435  trackNN->setRawOmega(track2D->getRawOmega());
1436  trackNN->setRawPhi0(track2D->getRawPhi0());
1437  trackNN->setRawTheta(trkNN.hwTheta);
1438  trackNN->setRawZ(trkNN.hwZ);
1439  if (hasETFTime) {
1440  trackNN->setETF_unpacked(std::stoi(p_etftime.data, 0, 2));
1441  track2D->setETF_unpacked(std::stoi(p_etftime.data, 0, 2));
1442  }
1443  trackNN->setETF_recalced(recalcETF(p_mlpin_drifttime.data, tstimevector, trackNN));
1444  track2D->setETF_recalced(recalcETF(p_mlpin_drifttime.data, tstimevector, trackNN));
1445 
1446  if (isin2d == false) {
1447  trackNN->setQualityVector(1);
1448  }
1449  std::vector<float> inputVector(27, 0.);
1450  for (unsigned iSL = 0; iSL < 9; ++iSL) {
1451  inputVector[3 * iSL] = trkNN.inputID[iSL];
1452  inputVector[3 * iSL + 1] = trkNN.inputT[iSL];
1453  inputVector[3 * iSL + 2] = trkNN.inputAlpha[iSL];
1454  }
1455  CDCTriggerMLPInput* storeInput =
1456  storeNNInputs->appendNew(inputVector, trkNN.sector);
1457  trackNN->addRelationTo(storeInput);
1458  track2D->addRelationTo(trackNN);
1459 
1460  for (unsigned iSL = 0; iSL < 9; ++iSL) {
1461  if (trkNN.ts[iSL][3] > 0) {
1462  CDCTriggerSegmentHit* hit = nullptr;
1463  // if (sim13dt) {
1464  // // get extended priority time for stereos from the allstereots storearray
1465  // for (int ihit = 0; ihit<tsHitsAll->getEntries(); ++ihit) {
1466  // CDCTriggerSegmentHit* compare = (*tsHitsAll)[ihit];
1467  // if (compare->getISuperLayer() == iSL &&
1468  // compare->getIWireCenter() == TSIDInSL(trkNN.ts[iSL][0], iSL, iTracker) &&
1469  // compare->getPriorityPosition() == trkNN.ts[iSL][3] &&
1470  // compare->getLeftRight() == trkNN.ts[iSL][2] ) {
1471  // hit = compare;
1472  // }
1473  // }
1474  // if (!(!hit)) {
1475  // tsHits->appendNew(hit->getISuperLayer(), hit->getIWireCenter(), hit->getPriorityPosition(), hit->getLeftRight(), hit->priorityTime(), 0, hit->foundTime(), iTracker);
1476  // }
1477  // // get the extended pt for axials from the already existing 2d TS
1478  // for (int ihit = 0; ihit<tsHits->getEntries(); ++ihit) {
1479  // CDCTriggerSegmentHit* compare = (*tsHits)[ihit];
1480  // if (compare->getISuperLayer() == iSL &&
1481  // compare->getIWireCenter() == TSIDInSL(trkNN.ts[iSL][0], iSL, iTracker) &&
1482  // compare->getPriorityPosition() == trkNN.ts[iSL][3] &&
1483  // compare->getLeftRight() == trkNN.ts[iSL][2] ) {
1484  // hit = compare;
1485  // }
1486  // }
1487 
1488  // }
1489 
1490  // cppcheck-suppress knownConditionTrueFalse
1491  if (!hit) {
1492  hit = addTSHit(trkNN.ts[iSL] , iSL, iTracker, tsHits, iclock);
1493  // B2DEBUG(1, "Hit with short drift time added, should not happen!");
1494  // }
1495  }
1496  trackNN->addRelationTo(hit);
1497  if (iSL % 2 == 0) {
1498  track2D->addRelationTo(hit);
1499  }
1500  }
1501  }
1502  }
1503 
1504 
1505  //
1506  // B2DEBUG(15, "bits for foundoldtrack: ");
1507  // for (auto x : foundoldtrack) {
1508  // B2DEBUG(15, x);
1509  // }
1510  // B2DEBUG(15, "bits for driftthreshold: ");
1511  // for (auto x : driftthreshold) {
1512  // B2DEBUG(15, x);
1513  // }
1514  // B2DEBUG(15, "bits for valstereobit: " << valstereobit);
1515  // B2DEBUG(15, "make new 2D track with phi " << trk2D.phi0 << " omega " << trk2D.omega << " clock " << iclock);
1516 
1517  }
1518  }
1519  }
1520  }
1521 
1522  void decodeNNIO_old(
1523  StoreArray<CDCTriggerUnpacker::NNBitStream>* bitsNN,
1524  StoreArray<CDCTriggerTrack>* store2DTracks,
1525  StoreArray<CDCTriggerTrack>* storeNNTracks,
1526  StoreArray<CDCTriggerSegmentHit>* tsHits,
1527  StoreArray<CDCTriggerMLPInput>* storeNNInputs)
1528  {
1529  for (short iclock = 0; iclock < bitsNN->getEntries(); ++iclock) {
1530  NNBitStream* bitsIn = (*bitsNN)[iclock];
1531  NNBitStream* bitsOutEnable = (*bitsNN)[iclock];
1532  for (unsigned iTracker = 0; iTracker < nTrackers; ++iTracker) {
1533  const auto slvOutEnable = bitsOutEnable->signal()[iTracker];
1534  const auto slvIn = bitsIn->signal()[iTracker];
1535  std::string stringOutEnable = slv_to_bin_string(slvOutEnable); //.substr(NN_OUT_WIDTH - 570, NN_OUT_WIDTH);
1536  std::string stringIn = slv_to_bin_string(slvIn); //.substr(NN_OUT_WIDTH - 570, NN_OUT_WIDTH);
1537  if (stringOutEnable.c_str()[0] == '1') {
1538  CDCTriggerTrack* nntrack2D = decodeNNInput(iclock, iTracker, bitsIn, store2DTracks, tsHits);
1539  if (nntrack2D) {
1540  int foundTime = iclock;
1541  if (foundTime < bitsNN->getEntries()) {
1542  NNBitStream* bitsOut = (*bitsNN)[foundTime];
1543  NNBitStream* bitsSelectTS = (*bitsNN)[iclock];
1544  decodeNNOutput_old(iclock, iTracker, bitsOut, bitsSelectTS,
1545  storeNNTracks, tsHits, storeNNInputs,
1546  nntrack2D);
1547  }
1548  }
1549  }
1550  }
1551  }
1552  }
1553  }
1555 }
Class to hold one clock cycle of raw bit content.
Definition: Bitstream.h:54
const SignalBus & signal()
accessors
Definition: Bitstream.h:70
static const double speedOfLight
[cm/ns]
Definition: Const.h:575
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
static const double realNaN
shortcut for NaN of double type
Abstract base class for different kinds of events.
const char one_val
'1' in XSI VHDL simulation
Definition: Cosim.h:43
const char * std_logic_literal[]
In case you are not familiar with VHDL simulation, there are 9 possible values defined for the standa...
Definition: Cosim.h:40
std::bitset< max - min+1 > subset(std::bitset< nbits > set)
extract a subset of bitstring, like substring.
Definition: Cosim.h:120
const char zero_val
'0' in XSI VHDL simulation
Definition: Cosim.h:45
std::string slv_to_bin_string(std::array< char, N > signal, bool padding=false)
Transform into string.
Definition: Cosim.h:64
void display_hex(const std::array< char, N > &signal)
Display signal in hex.
Definition: Cosim.h:81
std::string display_value(const char *count, int size)
Display value of the signal.
Definition: Cosim.h:48
std::string name
name of information in B2link
int offset
offset of information in B2Link
tsOutArray ts
all TS of a 2D track
Definition: Unpacker.h:261
int hwZ
raw output values of hw network
Definition: Unpacker.h:283
std::array< float, 9 > inputT
input T list of a NN track
Definition: Unpacker.h:277
std::array< float, 9 > inputAlpha
input Alpha list of a NN track
Definition: Unpacker.h:279
unsigned sector
sector of a NN track
Definition: Unpacker.h:273
std::array< float, 9 > inputID
input ID list of a NN track
Definition: Unpacker.h:275
std::array< tsOut, 9 > ts
input TS list of a NN track
Definition: Unpacker.h:281
double theta
theta of a NN track
Definition: Unpacker.h:271