Belle II Software  release-08-01-10
CDCTrigger.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 <array>
9 #include <string>
10 #include <bitset>
11 #include <numeric>
12 
13 namespace Belle2 {
18  namespace CDCTrigger {
19  constexpr int tsInfoWidth = 21;
20 
21  using tsOut = std::array<unsigned, 4>;
22  using tsOutArray = std::array<tsOut, 5>;
23  tsOut decodeTSHit(std::string tsIn)
24  {
25  constexpr unsigned lenID = 8;
26  constexpr unsigned lenPriorityTime = 9;
27  constexpr unsigned lenLR = 2;
28  constexpr unsigned lenPriorityPosition = 2;
29  constexpr std::array<unsigned, 4> tsLens = {lenID, lenPriorityTime, lenLR, lenPriorityPosition};
30  std::array<unsigned, 5> tsPos = { 0 };
31  std::partial_sum(tsLens.begin(), tsLens.end(), tsPos.begin() + 1);
32  tsOut tsOutput;
33  tsOutput[0] = std::bitset<tsLens[0]>(tsIn.substr(tsPos[0], tsLens[0])).to_ulong();
34  tsOutput[1] = std::bitset<tsLens[1]>(tsIn.substr(tsPos[1], tsLens[1])).to_ulong();
35  tsOutput[2] = std::bitset<tsLens[2]>(tsIn.substr(tsPos[2], tsLens[2])).to_ulong();
36  tsOutput[3] = std::bitset<tsLens[3]>(tsIn.substr(tsPos[3], tsLens[3])).to_ulong();
37  return tsOutput;
38  }
39 
40  static constexpr std::array<int, 9> nWiresInSuperLayer = {160, 160, 192, 224, 256, 288, 320, 352, 384};
41 
42  static constexpr int nTrackers = 4;
43 
51  unsigned short globalSegmentID(unsigned short localID, unsigned short iSL)
52  {
53  auto itr = nWiresInSuperLayer.begin();
54  unsigned short globalID = std::accumulate(itr, itr + iSL, 0);
55  globalID += localID;
56  return globalID;
57  }
58  }
60 }
Abstract base class for different kinds of events.