Project
Loading...
Searching...
No Matches
PackedCharge.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_PACKED_CHARGE_H
16#define O2_GPU_PACKED_CHARGE_H
17
18#include "clusterFinderDefs.h"
19#include "GPUCommonMath.h"
20
21namespace o2::gpu
22{
23
25{
26 public:
27 using BasicType = uint16_t;
28 static_assert(sizeof(BasicType) == 2);
29
40
42 GPUdi() explicit PackedCharge(tpccf::Charge q) : PackedCharge(q, false, false) {}
43 GPUdi() PackedCharge(tpccf::Charge q, bool peak3x3, bool wasSplit)
44 {
45 mVal = q * tpccf::Charge(1 << DecimalBits);
46 mVal = CAMath::Min<BasicType>(MaxVal, mVal); // ensure only lower 14 bits are set
47 mVal |= (peak3x3) ? Has3x3PeakMask : Null;
48 mVal |= (wasSplit) ? IsSplitMask : Null;
49 }
50
51 GPUdi() tpccf::Charge unpack() const { return tpccf::Charge(mVal & ChargeMask) / tpccf::Charge(1 << DecimalBits); }
52 GPUdi() bool has3x3Peak() const { return mVal & Has3x3PeakMask; }
53 GPUdi() bool isSplit() const { return mVal & IsSplitMask; }
54 GPUdi() bool isZero() const { return mVal == 0; }
55
56 private:
57 BasicType mVal;
58};
59
60} // namespace o2::gpu
61
62#endif
GPUdi() PackedCharge(tpccf
GPUdi() explicit PackedCharge(tpccf
GPUdDefault() PackedCharge()=default