Forked from
Computing / cbmroot
3877 commits behind the upstream repository.
-
Administrator authored
This version is an exact copy of the last revision of the trunk branch of the old SVN repository of CbmRoor at https://subversion.gsi.de/cbmsoft/cbmroot/trunk The old SVN repository will still be available for read access.
Administrator authoredThis version is an exact copy of the last revision of the trunk branch of the old SVN repository of CbmRoor at https://subversion.gsi.de/cbmsoft/cbmroot/trunk The old SVN repository will still be available for read access.
CbmPsdAddress.h 3.84 KiB
/** \file CbmPsdAddress.h
** \author Nikolay Karpushkin <karpushkin@inr.ru>
** \date 09.10.2019
**/
/** \class CbmPsdAddress
** \brief CBM PSD interface class to the unique address
** \author Nikolay Karpushkin <karpushkin@inr.ru>
** \version 1.0
**
** CbmPsdAddress is the class for the concrete interfaces to the unique address,
** which is encoded in a 32-bit field (Int_t), for the PSD detector elements.
**
** 3 2 1 0 Shift Bits Values
** Current definition: 10987654321098765432109876543210
** System ID (ECbmModuleId::kPsd=8) on bits 0- 3 00000000000000000000000000001111 << 0 4 15
** Module ID on bits 4- 9 00000000000000000000001111110000 << 4 6 63
** Section ID on bits 10-14 00000000000000000111110000000000 <<10 5 31 // to be reduced to 15
** Empty on bits 15-31 11111111111111111000000000000000 <<16 17 2^17-1
**
**/
#ifndef CBMPSDADDRESS_H
#define CBMPSDADDRESS_H 1
#include <RtypesCore.h> // for UInt_t, Int_t
#include <cassert> // for assert
#include "CbmDefs.h" // for ECbmModuleId::kPsd
class CbmPsdAddress
{
public:
/**
* \brief Return address from system ID, module, Section.
* \param[in] moduleId Module ID.
* \param[in] SectionId Section ID.
* \return Address from system ID, module, Section.
**/
static UInt_t GetAddress(Int_t moduleId,
Int_t sectionId) {
assert(!(moduleId < 0 || moduleId > fgkModuleIdLength || sectionId < 0 || sectionId > fgkSectionIdLength));
return (ToIntegralType(ECbmModuleId::kPsd) << fgkSystemIdShift) | (moduleId << fgkModuleIdShift) | (sectionId << fgkSectionIdShift) ;
}
/**
* \brief Return System identifier from address.
* \param[in] address Unique channel address.
* \return System identifier from address.
**/
static UInt_t GetSystemId(UInt_t address) {
return (address & (fgkSystemIdLength << fgkSystemIdShift)) >> fgkSystemIdShift;
}
/**
* \brief Return module ID from address.
* \param[in] address Unique channel address.
* \return Module ID from address.
**/
static UInt_t GetModuleId(UInt_t address) {
return (address & (fgkModuleIdLength << fgkModuleIdShift)) >> fgkModuleIdShift;
}
/**
* \brief Return sector ID from address.
* \param[in] address Unique channel address.
* \return Sector ID from address.
**/
static UInt_t GetSectionId(UInt_t address) {
return (address & (fgkSectionIdLength << fgkSectionIdShift)) >> fgkSectionIdShift;