CbmRoot
Loading...
Searching...
No Matches
CbmTofDetectorId_v07a.cxx
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmTofDetectorId source file -----
7// ----- Created 20/11/12 by F. Uhlig -----
8// -------------------------------------------------------------------------
9
10
12
13#include <Logger.h> // for LOG, Logger
14
15const int32_t CbmTofDetectorId_v07a::shiftarray[] = {0, 5, 9, 19, 23};
16const int32_t CbmTofDetectorId_v07a::bitarray[] = {5, 4, 10, 4, 9};
17
18// 3 2 1 shift length
27CbmTofDetectorId_v07a::CbmTofDetectorId_v07a() : CbmTofDetectorId(), result_array(), maskarray(), modulemask(0)
28{
29 for (int32_t i = 0; i < array_length; i++) {
30 maskarray[i] = (1 << bitarray[i]) - 1;
31 }
32
33 modulemask = ((maskarray[0] << shiftarray[0]) | (maskarray[1] << shiftarray[1]) | (maskarray[2] << shiftarray[2])
34 | (0 << shiftarray[3]) | (maskarray[4] << shiftarray[4]));
35}
36
38{
39 for (int32_t i = 0; i < array_length; i++) {
40 result_array[i] = ((detectorId >> shiftarray[i]) & maskarray[i]);
41 }
43}
44
45int32_t CbmTofDetectorId_v07a::GetSystemId(int32_t detectorId) { return (detectorId & maskarray[0]); }
46
47//-----------------------------------------------------------
48
49int32_t CbmTofDetectorId_v07a::GetSMType(const int32_t detectorId)
50{
51 return ((detectorId >> shiftarray[1]) & maskarray[1]);
52}
53
54//-----------------------------------------------------------
55
56int32_t CbmTofDetectorId_v07a::GetSModule(const int32_t detectorId)
57{
58 return ((detectorId >> shiftarray[2]) & maskarray[2]);
59}
60
61//-----------------------------------------------------------
62
63int32_t CbmTofDetectorId_v07a::GetCounter(const int32_t /*detectorId*/) { return -1; }
64
65//-----------------------------------------------------------
66
67int32_t CbmTofDetectorId_v07a::GetGap(const int32_t detectorId)
68{
69 return ((detectorId >> shiftarray[3]) & maskarray[3]);
70}
71
72//-----------------------------------------------------------
73
74int32_t CbmTofDetectorId_v07a::GetCell(const int32_t detectorId)
75{
76 return ((detectorId >> shiftarray[4]) & maskarray[4]);
77}
78
79//-----------------------------------------------------------
80
81int32_t CbmTofDetectorId_v07a::GetRegion(const int32_t /*detectorId*/) { return -1; }
82
83int32_t CbmTofDetectorId_v07a::GetCellId(const int32_t detectorId) { return (detectorId & modulemask); }
84
85//-----------------------------------------------------------
86
88{
89
90 LOG(debug2) << "Det System: " << detInfo.fDetectorSystem;
91 LOG(debug2) << "SMtype: " << detInfo.fSMtype;
92 LOG(debug2) << "SModule: " << detInfo.fSModule;
93 LOG(debug2) << "Counter: " << detInfo.fCounter;
94 LOG(debug2) << "Gap: " << detInfo.fGap;
95 LOG(debug2) << "Cell: " << detInfo.fCell;
96
97 return ((detInfo.fDetectorSystem << shiftarray[0]) | (detInfo.fSMtype << shiftarray[1])
98 | (detInfo.fCounter << shiftarray[2]) | (detInfo.fGap << shiftarray[3]) | (detInfo.fCell << shiftarray[4]));
99}
int32_t GetRegion(const int32_t detectorId)
int32_t SetDetectorInfo(const CbmTofDetectorInfo detectorInfo)
int32_t GetSModule(const int32_t detectorId)
static const int32_t array_length
CbmTofDetectorInfo GetDetectorInfo(const int32_t detectorId)
int32_t GetCounter(const int32_t detectorId)
static const int32_t bitarray[]
int32_t GetGap(const int32_t detectorId)
int32_t GetSMType(const int32_t detectorId)
int32_t GetCellId(const int32_t detectorId)
int32_t maskarray[array_length]
int32_t GetCell(const int32_t detectorId)
int32_t GetSystemId(int32_t detectorId)
static const int32_t shiftarray[]
int32_t result_array[array_length]