diff --git a/core/data/CMakeLists.txt b/core/data/CMakeLists.txt index 6babfa6053faf405582127de3db115bb26161b1c..9eaf4743e0b3a9b9fec6d554c469480da54aac2b 100644 --- a/core/data/CMakeLists.txt +++ b/core/data/CMakeLists.txt @@ -97,6 +97,7 @@ set(SRCS tof/CbmTofDetectorId_v07a.cxx tof/CbmTofDetectorId_v12b.cxx tof/CbmTofDetectorId_v14a.cxx + tof/CbmTofDetectorId_v20a.cxx tof/CbmTofAddress.cxx tof/CbmTofDigi.cxx tof/CbmTofTracklet.cxx diff --git a/core/data/tof/CbmTofDetectorId.h b/core/data/tof/CbmTofDetectorId.h index dfccd65a403f142b260ca601bc759373d5f1d8d8..f0d1e617fb721853164d650987dfc8e28ea39f52 100644 --- a/core/data/tof/CbmTofDetectorId.h +++ b/core/data/tof/CbmTofDetectorId.h @@ -9,7 +9,7 @@ ** the information about TOF modules from a unique detetcor ID ** @author F. Uhlig <f.uhlig@gsi.de> **/ - + #ifndef CBMTOFDETECTORID_H #define CBMTOFDETECTORID_H 1 @@ -17,62 +17,51 @@ #include "CbmDefs.h" -class CbmTofDetectorInfo { - -public: - CbmTofDetectorInfo() - : fDetectorSystem(0) - , fSMtype(0) - , fSModule(0) - , fCounter(0) - , fGap(0) - , fCell(0) {}; - - CbmTofDetectorInfo(Int_t detsystem, - Int_t smtype, - Int_t smodule, - Int_t counter, - Int_t gap, - Int_t cell) - : fDetectorSystem(detsystem) - , fSMtype(smtype) - , fSModule(smodule) - , fCounter(counter) - , fGap(gap) - , fCell(cell) {}; - - CbmTofDetectorInfo(ECbmModuleId detsystem, - Int_t smtype, - Int_t smodule, - Int_t counter, - Int_t gap, - Int_t cell) - : fDetectorSystem(ToIntegralType(detsystem)) - , fSMtype(smtype) - , fSModule(smodule) - , fCounter(counter) - , fGap(gap) - , fCell(cell) {}; - +class CbmTofDetectorInfo +{ + + public: + + CbmTofDetectorInfo() : fDetectorSystem(0), fSMtype(0), fSModule(0), + fCounter(0), fCounterType(0), fGap(0), fCell(0) {}; + + CbmTofDetectorInfo(Int_t detsystem, Int_t smtype, Int_t smodule, + Int_t counter, Int_t gap, Int_t cell) + : fDetectorSystem(detsystem), fSMtype(smtype), fSModule(smodule), + fCounter(counter), fGap(gap), fCell(cell) {}; + + CbmTofDetectorInfo(ECbmModuleId detsystem, Int_t smtype, Int_t smodule, + Int_t counter, Int_t gap, Int_t cell) + : fDetectorSystem(ToIntegralType(detsystem)), fSMtype(smtype), fSModule(smodule), + fCounter(counter), fGap(gap), fCell(cell) {}; + +CbmTofDetectorInfo(ECbmModuleId detsystem, Int_t smtype, Int_t smodule, + Int_t counter, Int_t counterType, Int_t gap, Int_t cell) + : fDetectorSystem(ToIntegralType(detsystem)), fSMtype(smtype), fSModule(smodule), + fCounter(counter), fCounterType(counterType), fGap(gap), fCell(cell) {}; + Int_t fDetectorSystem; Int_t fSMtype; Int_t fSModule; Int_t fCounter; + Int_t fCounterType; Int_t fGap; Int_t fCell; }; -class CbmTofDetectorId { +class CbmTofDetectorId +{ -public: + public: + /** Constructor **/ - CbmTofDetectorId() { ; } - - + CbmTofDetectorId() {;} + + /** Destructor **/ - virtual ~CbmTofDetectorId() { ; } - + virtual ~CbmTofDetectorId() {;} + /** Get System identifier from detector ID **/ // Int_t GetSystemId(const Int_t detectorId); @@ -114,7 +103,8 @@ public: // char* itoa(int value, char* result, int base); -private: + private: + }; #endif diff --git a/core/data/tof/CbmTofDetectorId_v20a.cxx b/core/data/tof/CbmTofDetectorId_v20a.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a1fbc2b686a903e78e0e949556714c55bc5798c6 --- /dev/null +++ b/core/data/tof/CbmTofDetectorId_v20a.cxx @@ -0,0 +1,130 @@ +// ------------------------------------------------------------------------- +// ----- CbmTofDetectorId source file ----- +// ----- Created 20/11/12 by F. Uhlig ----- +// ------------------------------------------------------------------------- + + +#include "CbmTofDetectorId_v20a.h" + +const Int_t CbmTofDetectorId_v20a::shiftarray[] = {0,4,11,15,21,25,26}; +const Int_t CbmTofDetectorId_v20a::bitarray[] = {4,7, 4, 6, 4, 1, 6}; + + +CbmTofDetectorId_v20a::CbmTofDetectorId_v20a() + : CbmTofDetectorId(), + result_array(), + maskarray(), + modulemask(0) +{ + for (Int_t i=0; i < array_length; i++) { + maskarray[i]=(1 << bitarray[i]) - 1; + } + + modulemask =( (maskarray[0] << shiftarray[0]) | + (maskarray[1] << shiftarray[1]) | + (maskarray[2] << shiftarray[2]) | + (maskarray[3] << shiftarray[3]) | + (maskarray[4] << shiftarray[4]) | + (maskarray[5] << shiftarray[5]) | + (maskarray[6] << shiftarray[6]) + ); +} + +CbmTofDetectorInfo CbmTofDetectorId_v20a::GetDetectorInfo(const Int_t detectorId) +{ + for (Int_t i=0; i < array_length; i++) { + result_array[i] = (( detectorId >> shiftarray[i] ) & maskarray[i] ); + } + + return CbmTofDetectorInfo(result_array[0], result_array[2], result_array[1], + result_array[3], result_array[4], result_array[5]); + +} + +Int_t CbmTofDetectorId_v20a::GetSystemId(Int_t detectorId) +{ + return (detectorId & maskarray[0]); +} + +//----------------------------------------------------------- + +Int_t CbmTofDetectorId_v20a::GetSMType(const Int_t detectorId) +{ + return (( detectorId >> shiftarray[2] ) & maskarray[2] ); +} +Int_t CbmTofDetectorId_v20a::GetModuleType(const Int_t detectorId) +{ + return GetSMType(detectorId); +} +Int_t CbmTofDetectorId_v20a::GetCounterType(const Int_t detectorId) +{ + return GetCounterType(detectorId); +} + +//----------------------------------------------------------- + +Int_t CbmTofDetectorId_v20a::GetSModule(const Int_t detectorId) +{ + return (( detectorId >> shiftarray[1] ) & maskarray[1] ); +} +Int_t CbmTofDetectorId_v20a::GetModuleId(const Int_t detectorId) +{ + return GetSModule(detectorId); +} + +//----------------------------------------------------------- + +Int_t CbmTofDetectorId_v20a::GetCounter(const Int_t detectorId) +{ + return (( detectorId >> shiftarray[3] ) & maskarray[3] ); +} + +//----------------------------------------------------------- + +Int_t CbmTofDetectorId_v20a::GetSide(const Int_t detectorId) +{ + return (( detectorId >> shiftarray[4] ) & maskarray[4] ); +} +Int_t CbmTofDetectorId_v20a::GetGap(const Int_t detectorId) +{ + return GetSide(detectorId); +} + +//----------------------------------------------------------- + +Int_t CbmTofDetectorId_v20a::GetCell(const Int_t detectorId) +{ + return (( detectorId >> shiftarray[5] ) & maskarray[5] ); +} + +Int_t CbmTofDetectorId_v20a::GetStrip(const Int_t detectorId) +{ + return GetCell(detectorId); +} + +//----------------------------------------------------------- + +Int_t CbmTofDetectorId_v20a::GetRegion(const Int_t /*detectorId*/) +{ + return -1; +} + +Int_t CbmTofDetectorId_v20a::GetCellId(const Int_t detectorId) +{ + return (detectorId & modulemask); +} + +//----------------------------------------------------------- + +Int_t CbmTofDetectorId_v20a ::SetDetectorInfo(const CbmTofDetectorInfo detInfo) +{ + return ( (((detInfo.fDetectorSystem) & maskarray[0]) << shiftarray[0]) | + (((detInfo.fSMtype) & maskarray[2]) << shiftarray[2]) | + (((detInfo.fSModule) & maskarray[1]) << shiftarray[1]) | + (((detInfo.fCounter) & maskarray[3]) << shiftarray[3]) | + (((detInfo.fCounterType) & maskarray[4]) << shiftarray[4]) | + (((detInfo.fGap) & maskarray[5]) << shiftarray[5]) | + (((detInfo.fCell) & maskarray[6]) << shiftarray[6]) + ); +} + diff --git a/core/data/tof/CbmTofDetectorId_v20a.h b/core/data/tof/CbmTofDetectorId_v20a.h new file mode 100644 index 0000000000000000000000000000000000000000..da47f03a3c0a4fecf5604a0ce7bb4b50c1c525ae --- /dev/null +++ b/core/data/tof/CbmTofDetectorId_v20a.h @@ -0,0 +1,104 @@ +// ------------------------------------------------------------------------- +// ----- CbmTofDetectorId_v12b header file ----- +// ----- Created 20/11/12 by F. Uhlig ----- +// ------------------------------------------------------------------------- + + +/** CbmTofDetectorId.h + ** Defines unique detector identifier for all TOF modules. + ** This class is the implementation for tof geometry version v20a + ** nh, 11.03.2014 + ** PAL, 23.09.2015: make the class common to both v14 and v15 geometries + ** Field 4 used as Side index (or fake Gap index in digitizer) + ** Naming as in TDR: SM -> Module, Module -> Counter, Cell -> Strip + ** All classes which uses this scheme should have a data member + ** of this class + ** @author F. Uhlig <f.uhlig@gsi.de> + **/ + +// 3 2 1 shift length +/** Current definition: 10987654321098765432109876543210 + ** System ID (kTOF=6) on bits 0-3 00000000000000000000000000001111 15 + ** Module ID on bits 4-11 00000000000000000000011111110000 <<4 127 + ** Module Type on bits 12-15 00000000000000000111100000000000 <<11 15 + ** Counter ID on bits 16-23 00000000000111111000000000000000 <<15 63 + * Counter Type 00000001111000000000000000000000 <<21 15 + ** Side/Gap NR on bits 20-23 00000010000000000000000000000000 <<25 1 + ** Strip ID on bits 24-31 11111100000000000000000000000000 <<26 255 + **/ + + +#ifndef CBMTOFDETECTORID_V20A_H +#define CBMTOFDETECTORID_V20A_H 1 + +#include"CbmTofDetectorId.h" + +class CbmTofDetectorId_v20a : public CbmTofDetectorId +{ + + public: + + /** Constructor **/ + CbmTofDetectorId_v20a(); + + /** Destructor **/ + ~CbmTofDetectorId_v20a() {}; + + /** Get complete system info from detector ID + ** This will return a pointer to an integer + ** array of length array_length + **/ + CbmTofDetectorInfo GetDetectorInfo(const Int_t detectorId); + + /** Get the global sytem ID **/ + Int_t GetSystemId(Int_t detectorId); + + /** Get Module Type from detector ID **/ + Int_t GetSMType(const Int_t detectorId); + Int_t GetModuleType(const Int_t detectorId); + Int_t GetCounterType(const Int_t detectorId); + + /** Get Module ID from detector ID **/ + Int_t GetSModule(const Int_t detectorId); + Int_t GetModuleId(const Int_t detectorId); + + /** Get counter ID from detector ID **/ + Int_t GetCounter(const Int_t detectorId); + + /** Get sector number from detector ID **/ + Int_t GetGap(const Int_t detectorId); + + /** Get sector number from detector ID **/ + Int_t GetSide(const Int_t detectorId); + + /** Get cell number from detector ID **/ + Int_t GetCell(const Int_t detectorId); + /** Get Strip ID from detector ID **/ + Int_t GetStrip(const Int_t detectorId); + + /** Get region number from detector ID **/ + Int_t GetRegion(const Int_t detectorId); + + /** Get full cell number from detector ID. + ** This is masking the the gap number + ** if this is set. + **/ + Int_t GetCellId(const Int_t detectorId); + + /** Calculate the unique detector ID + ** This will return a pointer to an integer + ** array of length array_length + **/ + Int_t SetDetectorInfo(const CbmTofDetectorInfo detectorInfo); + + private: + + static const Int_t array_length = 7; + static const Int_t shiftarray[]; + static const Int_t bitarray[]; + Int_t result_array[array_length]; + Int_t maskarray[array_length]; + Int_t modulemask; +}; + +#endif