CbmRoot
Loading...
Searching...
No Matches
CbmTofDetectorId_v21a.cxx
Go to the documentation of this file.
1/* Copyright (C) 2012-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig, Norbert Herrmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmTofDetectorId source file -----
7// ----- Created 20/11/12 by F. Uhlig -----
8// -------------------------------------------------------------------------
9
10
12
13#include <iomanip>
14#include <iostream>
15
16using namespace std;
17
18const int32_t CbmTofDetectorId_v21a::shiftarray[] = {0, 4, 11, 15, 21, 22, 28};
19const int32_t CbmTofDetectorId_v21a::bitarray[] = {4, 7, 4, 6, 1, 6, 4};
20
21
22CbmTofDetectorId_v21a::CbmTofDetectorId_v21a() : CbmTofDetectorId(), result_array(), maskarray(), modulemask(0)
23{
24 for (int32_t i = 0; i < array_length; i++) {
25 maskarray[i] = (1 << bitarray[i]) - 1;
26 }
27
28 for (int32_t i = 0; i < array_length - 1; i++) {
29 if (i == 4) continue; // ignore side bit
30 modulemask |= (maskarray[i] << shiftarray[i]);
31 }
32 char prev = std::cout.fill();
33 std::cout << "<I> V21a module mask 0x" << std::setfill('0') << std::setw(8) << std::right << std::hex << modulemask
34 << std::setfill(prev) << std::dec << std::endl;
35}
36
38{
39 for (int32_t i = 0; i < array_length; i++) {
40 result_array[i] = ((detectorId >> shiftarray[i]) & maskarray[i]);
41 }
42
45}
46
47int32_t CbmTofDetectorId_v21a::GetSystemId(int32_t detectorId) { return (detectorId & maskarray[0]); }
48
49//-----------------------------------------------------------
50
51int32_t CbmTofDetectorId_v21a::GetSMType(const int32_t detectorId)
52{
53 return ((detectorId >> shiftarray[2]) & maskarray[2]);
54}
55int32_t CbmTofDetectorId_v21a::GetModuleType(const int32_t detectorId) { return GetSMType(detectorId); }
56int32_t CbmTofDetectorId_v21a::GetCounterType(const int32_t detectorId)
57{
58 return ((detectorId >> shiftarray[6]) & maskarray[6]);
59}
60
61//-----------------------------------------------------------
62
63int32_t CbmTofDetectorId_v21a::GetSModule(const int32_t detectorId)
64{
65 return ((detectorId >> shiftarray[1]) & maskarray[1]);
66}
67int32_t CbmTofDetectorId_v21a::GetModuleId(const int32_t detectorId) { return GetSModule(detectorId); }
68
69//-----------------------------------------------------------
70
71int32_t CbmTofDetectorId_v21a::GetCounter(const int32_t detectorId)
72{
73 return ((detectorId >> shiftarray[3]) & maskarray[3]);
74}
75
76//-----------------------------------------------------------
77
78int32_t CbmTofDetectorId_v21a::GetSide(const int32_t detectorId)
79{
80 return ((detectorId >> shiftarray[4]) & maskarray[4]);
81}
82int32_t CbmTofDetectorId_v21a::GetGap(const int32_t detectorId) { return GetSide(detectorId); }
83
84//-----------------------------------------------------------
85
86int32_t CbmTofDetectorId_v21a::GetCell(const int32_t detectorId)
87{
88 return ((detectorId >> shiftarray[5]) & maskarray[5]);
89}
90
91int32_t CbmTofDetectorId_v21a::GetStrip(const int32_t detectorId) { return GetCell(detectorId); }
92
93//-----------------------------------------------------------
94
95int32_t CbmTofDetectorId_v21a::GetRegion(const int32_t /*detectorId*/) { return -1; }
96
97int32_t CbmTofDetectorId_v21a::GetCellId(const int32_t detectorId) { return (detectorId & modulemask); }
98
99//-----------------------------------------------------------
100
101int32_t CbmTofDetectorId_v21a ::SetDetectorInfo(const CbmTofDetectorInfo detInfo)
102{
103 /*
104 std::cout << "SetDetectorInfo for "
105 << "Mtype " << detInfo.fSMtype
106 << ", MId " << detInfo.fSModule << " "
107 << ", CType " << detInfo.fCounterType <<" "
108 << ", CId " << detInfo.fCounter
109 << ", Side " << detInfo.fGap
110 << ", Strip " << detInfo.fCell
111 << std::endl;
112*/
113 return (
114 (((detInfo.fDetectorSystem) & maskarray[0]) << shiftarray[0])
115 | (((detInfo.fSMtype) & maskarray[2]) << shiftarray[2]) | (((detInfo.fSModule) & maskarray[1]) << shiftarray[1])
116 | (((detInfo.fCounter) & maskarray[3]) << shiftarray[3]) | (((detInfo.fGap) & maskarray[4]) << shiftarray[4])
117 | (((detInfo.fCell) & maskarray[5]) << shiftarray[5]) | (((detInfo.fCounterType) & maskarray[6]) << shiftarray[6]));
118}
ECbmModuleId
Definition CbmDefs.h:39
int32_t maskarray[array_length]
int32_t GetStrip(const int32_t detectorId)
int32_t GetGap(const int32_t detectorId)
static const int32_t bitarray[]
int32_t GetSMType(const int32_t detectorId)
int32_t GetSide(const int32_t detectorId)
int32_t GetRegion(const int32_t detectorId)
int32_t GetCounterType(const int32_t detectorId)
int32_t GetSModule(const int32_t detectorId)
int32_t GetModuleType(const int32_t detectorId)
int32_t result_array[array_length]
int32_t GetModuleId(const int32_t detectorId)
int32_t GetSystemId(int32_t detectorId)
int32_t GetCellId(const int32_t detectorId)
CbmTofDetectorInfo GetDetectorInfo(const int32_t detectorId)
static const int32_t shiftarray[]
int32_t GetCounter(const int32_t detectorId)
static const int32_t array_length
int32_t GetCell(const int32_t detectorId)
Hash for CbmL1LinkKey.