Belle II Software  release-08-01-10
BKLMElementNumbers.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 
9 #pragma once
10 
11 /* KLM headers. */
12 #include <klm/dataobjects/KLMElementNumberDefinitions.h>
13 
14 /* C++ headers. */
15 #include <cstdint>
16 #include <string>
17 
18 namespace Belle2 {
28 
29  public:
30 
34  enum Section {
35 
38 
41 
42  };
43 
47  enum Sector {
48 
55 
56  };
57 
61  enum Layer {
62 
65 
66  };
67 
71  enum Plane {
72 
74  c_ZPlane = 0,
75 
78 
79  };
80 
85 
90 
99  static KLMChannelNumber channelNumber(int section, int sector, int layer,
100  int plane, int strip);
101 
111  static void channelNumberToElementNumbers(
112  KLMChannelNumber channel, int* section, int* sector, int* layer, int* plane,
113  int* strip);
114 
122  static KLMPlaneNumber planeNumber(int section, int sector, int layer,
123  int plane);
124 
133  static void planeNumberToElementNumbers(
134  KLMPlaneNumber planeGlobal, int* section, int* sector, int* layer,
135  int* plane);
136 
144  static KLMModuleNumber moduleNumber(int section, int sector, int layer,
145  bool fatalError = true);
146 
154  static void moduleNumberToElementNumbers(
155  KLMModuleNumber module, int* section, int* sector, int* layer);
156 
162  static KLMSectorNumber sectorNumber(int section, int sector);
163 
170  static int layerGlobalNumber(int section, int sector, int layer);
171 
179  static int getNStrips(int section, int sector, int layer, int plane);
180 
186  static bool checkSection(int section, bool fatalError = true);
187 
193  static bool checkSector(int sector, bool fatalError = true);
194 
200  static bool checkLayer(int layer, bool fatalError = true);
201 
207  static bool checkPlane(int plane, bool fatalError = true);
208 
218  static bool checkChannelNumber(
219  int section, int sector, int layer, int plane, int strip, bool fatalError = true);
220 
226  static std::string getHSLBName(int copper, int slot);
227 
231  static constexpr int getMaximalSectionNumber()
232  {
233  return m_MaximalSectionNumber;
234  }
235 
239  static constexpr int getMaximalSectorNumber()
240  {
241  return m_MaximalSectorNumber;
242  }
243 
247  static constexpr int getMaximalLayerNumber()
248  {
249  return m_MaximalLayerNumber;
250  }
251 
255  static constexpr int getMaximalPlaneNumber()
256  {
257  return m_MaximalPlaneNumber;
258  }
259 
263  static constexpr int getMaximalSectorGlobalNumber()
264  {
266  }
267 
271  static constexpr int getMaximalLayerGlobalNumber()
272  {
274  }
275 
279  static constexpr int getTotalChannelNumber()
280  {
281  return m_TotalChannelNumber;
282  }
283 
291  static void layerGlobalNumberToElementNumbers(int layerGlobal, int* section, int* sector, int* layer);
292 
296  static int getSectionByModule(int module)
297  {
298  return (module & BKLM_SECTION_MASK) >> BKLM_SECTION_BIT;
299  }
300 
304  static int getSectorByModule(int module)
305  {
306  return ((module & BKLM_SECTOR_MASK) >> BKLM_SECTOR_BIT) + 1;
307  }
308 
312  static int getLayerByModule(int module)
313  {
314  return ((module & BKLM_LAYER_MASK) >> BKLM_LAYER_BIT) + 1;
315  }
316 
320  static int getPlaneByModule(int module)
321  {
322  return (module & BKLM_PLANE_MASK) >> BKLM_PLANE_BIT;
323  }
324 
328  static int getStripByModule(int module)
329  {
330  return ((module & BKLM_STRIP_MASK) >> BKLM_STRIP_BIT) + 1;
331  }
332 
338  static void setSectionInModule(int& module, int section)
339  {
340  module = (module & (~BKLM_SECTION_MASK)) | (section << BKLM_SECTION_BIT);
341  }
342 
348  static void setSectorInModule(int& module, int sector)
349  {
350  module = (module & (~BKLM_SECTOR_MASK)) | ((sector - 1) << BKLM_SECTOR_BIT);
351  }
352 
358  static void setLayerInModule(int& module, int layer)
359  {
360  module = (module & (~BKLM_LAYER_MASK)) | ((layer - 1) << BKLM_LAYER_BIT);
361  }
362 
368  static void setPlaneInModule(int& module, int plane)
369  {
370  module = (module & (~BKLM_PLANE_MASK)) | (plane << BKLM_PLANE_BIT);
371  }
372 
378  static void setStripInModule(int& module, int strip)
379  {
380  module = (module & (~BKLM_STRIP_MASK)) | ((strip - 1) << BKLM_STRIP_BIT);
381  }
382 
387  static uint16_t getModuleByModule(int module)
388  {
389  return module & BKLM_MODULEID_MASK;
390  }
391 
395  static uint16_t getChannelByModule(int module)
396  {
397  return module & BKLM_MODULESTRIPID_MASK;
398  }
399 
403  static bool hitsFromSameModule(int module1, int module2)
404  {
405  return getModuleByModule(module1) == getModuleByModule(module2);
406  }
407 
411  static bool hitsFromSamePlane(int module1, int module2)
412  {
413  const int mask = BKLM_MODULEID_MASK | BKLM_PLANE_MASK;
414  return (module1 & mask) == (module2 & mask);
415  }
416 
420  static bool hitsFromSameChannel(int module1, int module2)
421  {
422  return getChannelByModule(module1) == getChannelByModule(module2);
423  }
424 
425  protected:
426 
428  static constexpr int m_MaximalSectionNumber = 1;
429 
431  static constexpr int m_MaximalSectorNumber = 8;
432 
434  static constexpr int m_MaximalLayerNumber = 15;
435 
437  static constexpr int m_MaximalPlaneNumber = 1;
438 
440  static constexpr int m_TotalChannelNumber = 21978;
441 
443  static constexpr int BKLM_STRIP_BIT = 0;
444 
449  static constexpr int BKLM_PLANE_BIT = 6;
450 
452  static constexpr int BKLM_LAYER_BIT = 7;
453 
458  static constexpr int BKLM_SECTOR_BIT = 11;
459 
461  static constexpr int BKLM_SECTION_BIT = 14;
462 
464  static constexpr int BKLM_STRIP_MASK = (63 << BKLM_STRIP_BIT);
465 
467  static constexpr int BKLM_PLANE_MASK = (1 << BKLM_PLANE_BIT);
468 
470  static constexpr int BKLM_LAYER_MASK = (15 << BKLM_LAYER_BIT);
471 
476  static constexpr int BKLM_SECTOR_MASK = (7 << BKLM_SECTOR_BIT);
477 
479  static constexpr int BKLM_SECTION_MASK = (1 << BKLM_SECTION_BIT);
480 
482  static constexpr int BKLM_MODULEID_MASK =
484 
486  static constexpr int BKLM_MODULESTRIPID_MASK =
489 
490  };
491 
493 }
BKLM element numbers.
static void planeNumberToElementNumbers(KLMPlaneNumber planeGlobal, int *section, int *sector, int *layer, int *plane)
Get element numbers by plane number.
static constexpr int BKLM_STRIP_BIT
Bit position for strip-1 [0..47].
static bool hitsFromSameChannel(int module1, int module2)
Check whether the hits are from the same channel.
static void channelNumberToElementNumbers(KLMChannelNumber channel, int *section, int *sector, int *layer, int *plane, int *strip)
Get element numbers by channel number.
static void setStripInModule(int &module, int strip)
Set strip number in module identifier.
Sector
Constants for sector numbers.
@ c_ChimneySector
Chimney sector: BB3 in 1-based notation; BB2 in 0-based notation.
static constexpr int getMaximalLayerGlobalNumber()
Get maximal layer global number.
static int getSectorByModule(int module)
Get sector number by module identifier.
static void setLayerInModule(int &module, int layer)
Set layer number in module identifier.
static uint16_t getModuleByModule(int module)
Get module number by module identifier (the input identifier may contain other data).
static constexpr int BKLM_MODULESTRIPID_MASK
Bit mask for module-and-strip identifier.
static constexpr int m_MaximalPlaneNumber
Maximal plane number (0-based).
static constexpr int m_MaximalSectionNumber
Maximal section number (0-based).
static KLMPlaneNumber planeNumber(int section, int sector, int layer, int plane)
Get plane number.
static uint16_t getChannelByModule(int module)
Get channel number by module identifier.
static int getStripByModule(int module)
Get strip number by module identifier.
static constexpr int BKLM_PLANE_BIT
Bit position for plane-1 [0..1].
static bool checkSector(int sector, bool fatalError=true)
Check if sector number is correct.
static bool checkSection(int section, bool fatalError=true)
Check if section number is correct.
static constexpr int getTotalChannelNumber()
Get total number of channels.
static bool checkChannelNumber(int section, int sector, int layer, int plane, int strip, bool fatalError=true)
Check channel number.
static void setSectionInModule(int &module, int section)
Set section number in module identifier.
static constexpr int BKLM_SECTOR_MASK
Bit mask for sector-1 [0..7].
static KLMChannelNumber channelNumber(int section, int sector, int layer, int plane, int strip)
Get channel number.
static bool checkLayer(int layer, bool fatalError=true)
Check if layer number is correct.
static int getPlaneByModule(int module)
Get plane number (0 = z, 1 = phi) by module identifier.
static void layerGlobalNumberToElementNumbers(int layerGlobal, int *section, int *sector, int *layer)
Get element numbers by layer global number (0-based).
static bool checkPlane(int plane, bool fatalError=true)
Check if plane number is correct.
static constexpr int BKLM_LAYER_MASK
Bit mask for layer-1 [0..15]; 0 is innermost and 14 is outermost.
static constexpr int BKLM_MODULEID_MASK
Bit mask for module identifier.
static KLMSectorNumber sectorNumber(int section, int sector)
Get sector number.
Layer
Constants for layer numbers.
@ c_FirstRPCLayer
First RPC layer.
static constexpr int getMaximalLayerNumber()
Get maximal layer number (1-based).
static constexpr int BKLM_PLANE_MASK
Bit mask for plane-1 [0..1]; 0 is inner-plane and phiReadout plane,.
static int getLayerByModule(int module)
Get layer number by module identifier.
Section
Constants for section numbers.
static int getSectionByModule(int module)
Get section number by module identifier.
static std::string getHSLBName(int copper, int slot)
Get HSLB name.
static constexpr int BKLM_SECTOR_BIT
Bit position for sector-1 [0..7].
static constexpr int BKLM_SECTION_BIT
Bit position for detector end [0..1]; forward is 0.
static constexpr int getMaximalSectorNumber()
Get maximal sector number (1-based).
static constexpr int BKLM_SECTION_MASK
Bit mask for detector end [0..1]; forward is 0.
static constexpr int m_MaximalSectorNumber
Maximal sector number (1-based).
static KLMModuleNumber moduleNumber(int section, int sector, int layer, bool fatalError=true)
Get module number.
static bool hitsFromSameModule(int module1, int module2)
Check whether the hits are from the same module.
static constexpr int getMaximalSectionNumber()
Get maximal section number (0-based).
static constexpr int m_MaximalLayerNumber
Maximal layer number (1-based).
static bool hitsFromSamePlane(int module1, int module2)
Check whether the hits are from the same plane.
static void moduleNumberToElementNumbers(KLMModuleNumber module, int *section, int *sector, int *layer)
Get element numbers by module number.
static constexpr int m_TotalChannelNumber
Total number of channels (1-based).
static constexpr int getMaximalSectorGlobalNumber()
Get maximal sector global number.
static constexpr int getMaximalPlaneNumber()
Get maximal plane number (0-based).
static void setSectorInModule(int &module, int sector)
Set sector number in module identifier.
static int layerGlobalNumber(int section, int sector, int layer)
Get layer global number.
static constexpr int BKLM_LAYER_BIT
Bit position for layer-1 [0..14]; 0 is innermost.
static constexpr int BKLM_STRIP_MASK
Bit mask for strip-1 [0..47].
static void setPlaneInModule(int &module, int plane)
Set plane number in module identifier.
static int getNStrips(int section, int sector, int layer, int plane)
Get number of strips.
uint16_t KLMSectorNumber
Sector number.
uint16_t KLMChannelNumber
Channel number.
uint16_t KLMModuleNumber
Module number.
uint16_t KLMPlaneNumber
Plane number.
Abstract base class for different kinds of events.