Belle II Software  release-05-02-19
CDCTrigger.h
1 #include <array>
2 #include <string>
3 #include <bitset>
4 #include <numeric>
5 
6 namespace Belle2 {
11  namespace CDCTrigger {
12  constexpr int tsInfoWidth = 21;
13 
14  using tsOut = std::array<unsigned, 4>;
15  using tsOutArray = std::array<tsOut, 5>;
16  tsOut decodeTSHit(std::string tsIn)
17  {
18  constexpr unsigned lenID = 8;
19  constexpr unsigned lenPriorityTime = 9;
20  constexpr unsigned lenLR = 2;
21  constexpr unsigned lenPriorityPosition = 2;
22  constexpr std::array<unsigned, 4> tsLens = {lenID, lenPriorityTime, lenLR, lenPriorityPosition};
23  std::array<unsigned, 5> tsPos = { 0 };
24  std::partial_sum(tsLens.begin(), tsLens.end(), tsPos.begin() + 1);
25  tsOut tsOutput;
26  tsOutput[0] = std::bitset<tsLens[0]>(tsIn.substr(tsPos[0], tsLens[0])).to_ulong();
27  tsOutput[1] = std::bitset<tsLens[1]>(tsIn.substr(tsPos[1], tsLens[1])).to_ulong();
28  tsOutput[2] = std::bitset<tsLens[2]>(tsIn.substr(tsPos[2], tsLens[2])).to_ulong();
29  tsOutput[3] = std::bitset<tsLens[3]>(tsIn.substr(tsPos[3], tsLens[3])).to_ulong();
30  return tsOutput;
31  }
32 
33  static constexpr std::array<int, 9> nWiresInSuperLayer = {160, 160, 192, 224, 256, 288, 320, 352, 384};
34 
35  static constexpr int nTrackers = 4;
36 
44  unsigned short globalSegmentID(unsigned short localID, unsigned short iSL)
45  {
46  auto itr = nWiresInSuperLayer.begin();
47  unsigned short globalID = std::accumulate(itr, itr + iSL, 0);
48  globalID += localID;
49  return globalID;
50  }
51  }
53 }
Belle2::tsOutArray
std::array< tsOut, 5 > tsOutArray
TS array.
Definition: CDCTrigger2DFinderFirmwareModule.h:27
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::tsOut
std::array< unsigned, 4 > tsOut
TS.
Definition: CDCTrigger2DFinderFirmwareModule.h:25