Project
Loading...
Searching...
No Matches
TPCPadBitMap.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef O2_GPU_TPC_PAD_BITMAP_H
16#define O2_GPU_TPC_PAD_BITMAP_H
17
18#include "GPUCommonDef.h"
19
20#include "clusterFinderDefs.h"
21#include "GPUCommonMath.h"
23
24namespace o2::tpc
25{
26template <class T>
27class CalDet;
28} // namespace o2::tpc
29
30namespace o2::gpu
31{
32
34 public:
35#ifndef GPUCA_GPUCODE
38
41#endif
42
43 GPUdi() void set(int32_t sector, tpccf::Row row, tpccf::Pad pad, bool c)
44 {
45 mBitMap[sector].set(globalPad(row, pad), c);
46 }
47
48 GPUdi() void set(int32_t sector, uint16_t globalPad, bool c)
49 {
50 mBitMap[sector].set(globalPad, c);
51 }
52
53 GPUdi() bool isSet(int32_t sector, tpccf::Row row, tpccf::Pad pad) const
54 {
55 return mBitMap[sector].get(globalPad(row, pad));
56 }
57
58 GPUdi() bool isSet(int32_t sector, uint16_t globalPad) const
59 {
60 return mBitMap[sector].get(globalPad);
61 }
62
63 GPUdi() uint16_t globalPad(tpccf::Row row, tpccf::Pad pad) const
64 {
65 return mPadOffsetPerRow[row] + pad;
66 }
67
68 private:
70 class SectorBitMap
71 {
72 public:
73 using T = uint32_t;
74 static GPUglobalconstexpr() int32_t NWORDS = (TPC_REAL_PADS_IN_SECTOR + sizeof(T) * 8 - 1) / sizeof(T);
75 GPUdi() SectorBitMap()
76 {
77 reset();
78 }
79
80 GPUdi() void set(uint16_t globalPad, bool c)
81 {
82 const auto word = globalPad / (sizeof(T) * 8);
83 const auto pos = globalPad % (sizeof(T) * 8);
84 const auto mask = T(1) << pos;
85 mDeadChannelMap[word] = (mDeadChannelMap[word] & ~mask) | (T(c) << pos);
86 }
87
88 GPUdi() bool get(uint16_t globalPad) const
89 {
90 const auto word = globalPad / (sizeof(T) * 8);
91 const auto pos = globalPad % (sizeof(T) * 8);
92 const auto mask = T(1) << pos;
93 return (mDeadChannelMap[word] & mask) == mask;
94 }
95
96 GPUd() void reset()
97 {
98 for (int32_t iword = 0; iword < NWORDS; ++iword) {
99 mDeadChannelMap[iword] = 0;
100 }
101 }
102
103 private:
104 T mDeadChannelMap[NWORDS];
105 };
106
107 uint16_t mPadOffsetPerRow[o2::tpc::constants::MAXGLOBALPADROW];
108 SectorBitMap mBitMap[o2::tpc::constants::MAXSECTOR];
109};
110
111} // namespace o2::gpu
112
113#endif
#define GPUdi()
#define GPUglobalconstexpr()
#define GPUd()
uint16_t pos
Definition RawData.h:3
uint32_t c
Definition RawData.h:2
#define TPC_REAL_PADS_IN_SECTOR
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLint GLuint mask
Definition glcorearb.h:291
Global TPC definitions and constants.
Definition SimTraits.h:172
GPUdi() void set(int32_t sector
SectorBitMap mBitMap[o2::tpc::constants::MAXSECTOR]
tpccf::Row tpccf::Pad pad
tpccf::Row tpccf::Pad bool c
GPUdi() uint16_t globalPad(tpccf uint16_t mPadOffsetPerRow[o2::tpc::constants::MAXGLOBALPADROW]
void setFromMap(const o2::tpc::CalDet< bool > &)
setting the stored values from CalDet