CbmRoot
CbmPsdAddress.h
Go to the documentation of this file.
1 
23 #ifndef CBMPSDADDRESS_H
24 #define CBMPSDADDRESS_H 1
25 
26 #include "CbmDefs.h" // for ECbmModuleId::kPsd
27 #include <RtypesCore.h> // for UInt_t, Int_t
28 #include <cassert> // for assert
29 
31 public:
38  static UInt_t GetAddress(Int_t moduleId, Int_t sectionId) {
39  assert(!(moduleId < 0 || moduleId > fgkModuleIdLength || sectionId < 0
40  || sectionId > fgkSectionIdLength));
42  | (moduleId << fgkModuleIdShift) | (sectionId << fgkSectionIdShift);
43  }
44 
50  static UInt_t GetSystemId(UInt_t address) {
51  return (address & (fgkSystemIdLength << fgkSystemIdShift))
53  }
54 
60  static UInt_t GetModuleId(UInt_t address) {
61  return (address & (fgkModuleIdLength << fgkModuleIdShift))
63  }
64 
70  static UInt_t GetSectionId(UInt_t address) {
71  return (address & (fgkSectionIdLength << fgkSectionIdShift))
73  }
74 
81  static UInt_t SetModuleId(UInt_t address, Int_t newModuleId) {
82  assert(!(newModuleId < 0 || newModuleId > fgkModuleIdLength));
83  return GetAddress(newModuleId, GetSectionId(address));
84  }
85 
92  static UInt_t SetSectionId(UInt_t address, Int_t newSectionId) {
93  assert(!(newSectionId < 0 || newSectionId > fgkSectionIdLength));
94  return GetAddress(GetModuleId(address), newSectionId);
95  }
96 
97 
98 private:
99  // Length of the index of the corresponding volume
100  static const Int_t fgkSystemIdLength = 15; // 2^4 - 1
101  static const Int_t fgkModuleIdLength = 63; // 2^6 - 1
102  static const Int_t fgkSectionIdLength = 31; // 2^5 - 1
103 
104  // Number of a start bit for each volume
105  static const Int_t fgkSystemIdShift = 0;
106  static const Int_t fgkModuleIdShift = 4;
107  static const Int_t fgkSectionIdShift = 10;
108 };
109 
110 #endif
CbmPsdAddress::fgkSystemIdShift
static const Int_t fgkSystemIdShift
Definition: CbmPsdAddress.h:105
CbmPsdAddress::SetModuleId
static UInt_t SetModuleId(UInt_t address, Int_t newModuleId)
Set new module ID for address.
Definition: CbmPsdAddress.h:81
CbmPsdAddress::SetSectionId
static UInt_t SetSectionId(UInt_t address, Int_t newSectionId)
Set new section ID for address.
Definition: CbmPsdAddress.h:92
CbmPsdAddress::GetSystemId
static UInt_t GetSystemId(UInt_t address)
Return System identifier from address.
Definition: CbmPsdAddress.h:50
CbmPsdAddress::GetAddress
static UInt_t GetAddress(Int_t moduleId, Int_t sectionId)
Return address from system ID, module, Section.
Definition: CbmPsdAddress.h:38
CbmPsdAddress::fgkSystemIdLength
static const Int_t fgkSystemIdLength
Definition: CbmPsdAddress.h:100
CbmPsdAddress::fgkSectionIdShift
static const Int_t fgkSectionIdShift
Definition: CbmPsdAddress.h:107
CbmPsdAddress::fgkSectionIdLength
static const Int_t fgkSectionIdLength
Definition: CbmPsdAddress.h:102
CbmPsdAddress::fgkModuleIdShift
static const Int_t fgkModuleIdShift
Definition: CbmPsdAddress.h:106
CbmPsdAddress::GetModuleId
static UInt_t GetModuleId(UInt_t address)
Return module ID from address.
Definition: CbmPsdAddress.h:60
CbmPsdAddress::fgkModuleIdLength
static const Int_t fgkModuleIdLength
Definition: CbmPsdAddress.h:101
ToIntegralType
constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition: CbmDefs.h:24
CbmPsdAddress
CBM PSD interface class to the unique address.
Definition: CbmPsdAddress.h:30
ECbmModuleId::kPsd
@ kPsd
Projectile spectator detector.
CbmPsdAddress::GetSectionId
static UInt_t GetSectionId(UInt_t address)
Return sector ID from address.
Definition: CbmPsdAddress.h:70
CbmDefs.h