Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 43 additions & 42 deletions DataFormats/Detectors/TPC/include/DataFormatsTPC/TrackTPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef ALICEO2_TPC_TRACKTPC
#define ALICEO2_TPC_TRACKTPC

#include "GPUCommonDef.h"
#include "ReconstructionDataFormats/Track.h"
#include "CommonDataFormat/RangeReference.h"
#include "DataFormatsTPC/ClusterNative.h"
Expand Down Expand Up @@ -40,42 +41,42 @@ class TrackTPC : public o2::track::TrackParCov
using o2::track::TrackParCov::TrackParCov; // inherit

/// Default constructor
TrackTPC() = default;
GPUdDefault() TrackTPC() = default;

/// Destructor
~TrackTPC() = default;

unsigned short getFlags() const { return mFlags; }
unsigned short getClustersSideInfo() const { return mFlags & HasBothSidesClusters; }
bool hasASideClusters() const { return mFlags & HasASideClusters; }
bool hasCSideClusters() const { return mFlags & HasCSideClusters; }
bool hasBothSidesClusters() const { return (mFlags & (HasASideClusters | HasCSideClusters)) == (HasASideClusters | HasCSideClusters); }
bool hasASideClustersOnly() const { return (mFlags & HasBothSidesClusters) == HasASideClusters; }
bool hasCSideClustersOnly() const { return (mFlags & HasBothSidesClusters) == HasCSideClusters; }

void setHasASideClusters() { mFlags |= HasASideClusters; }
void setHasCSideClusters() { mFlags |= HasCSideClusters; }

float getTime0() const { return mTime0; } ///< Reference time of the track, i.e. t-bins of a primary track with eta=0.
float getDeltaTBwd() const { return mDeltaTBwd; } ///< max possible decrement to getTimeVertex
float getDeltaTFwd() const { return mDeltaTFwd; } ///< max possible increment to getTimeVertex
void setDeltaTBwd(float t) { mDeltaTBwd = t; } ///< set max possible decrement to getTimeVertex
void setDeltaTFwd(float t) { mDeltaTFwd = t; } ///< set max possible increment to getTimeVertex

float getChi2() const { return mChi2; }
const o2::track::TrackParCov& getOuterParam() const { return mOuterParam; }
void setTime0(float v) { mTime0 = v; }
void setChi2(float v) { mChi2 = v; }
void setOuterParam(o2::track::TrackParCov&& v) { mOuterParam = v; }
const ClusRef& getClusterRef() const { return mClustersReference; }
void shiftFirstClusterRef(int dif) { mClustersReference.setFirstEntry(dif + mClustersReference.getFirstEntry()); }
int getNClusters() const { return mClustersReference.getEntries(); }
int getNClusterReferences() const { return getNClusters(); }
void setClusterRef(uint32_t entry, uint16_t ncl) { mClustersReference.set(entry, ncl); }
GPUdDefault() ~TrackTPC() = default;

GPUd() unsigned short getFlags() const { return mFlags; }
GPUd() unsigned short getClustersSideInfo() const { return mFlags & HasBothSidesClusters; }
GPUd() bool hasASideClusters() const { return mFlags & HasASideClusters; }
GPUd() bool hasCSideClusters() const { return mFlags & HasCSideClusters; }
GPUd() bool hasBothSidesClusters() const { return (mFlags & (HasASideClusters | HasCSideClusters)) == (HasASideClusters | HasCSideClusters); }
GPUd() bool hasASideClustersOnly() const { return (mFlags & HasBothSidesClusters) == HasASideClusters; }
GPUd() bool hasCSideClustersOnly() const { return (mFlags & HasBothSidesClusters) == HasCSideClusters; }

GPUd() void setHasASideClusters() { mFlags |= HasASideClusters; }
GPUd() void setHasCSideClusters() { mFlags |= HasCSideClusters; }

GPUd() float getTime0() const { return mTime0; } ///< Reference time of the track, i.e. t-bins of a primary track with eta=0.
GPUd() float getDeltaTBwd() const { return mDeltaTBwd; } ///< max possible decrement to getTimeVertex
GPUd() float getDeltaTFwd() const { return mDeltaTFwd; } ///< max possible increment to getTimeVertex
GPUd() void setDeltaTBwd(float t) { mDeltaTBwd = t; } ///< set max possible decrement to getTimeVertex
GPUd() void setDeltaTFwd(float t) { mDeltaTFwd = t; } ///< set max possible increment to getTimeVertex

GPUd() float getChi2() const { return mChi2; }
GPUd() const o2::track::TrackParCov& getOuterParam() const { return mOuterParam; }
GPUd() void setTime0(float v) { mTime0 = v; }
GPUd() void setChi2(float v) { mChi2 = v; }
GPUd() void setOuterParam(o2::track::TrackParCov&& v) { mOuterParam = v; }
GPUd() const ClusRef& getClusterRef() const { return mClustersReference; }
GPUd() void shiftFirstClusterRef(int dif) { mClustersReference.setFirstEntry(dif + mClustersReference.getFirstEntry()); }
GPUd() int getNClusters() const { return mClustersReference.getEntries(); }
GPUd() int getNClusterReferences() const { return getNClusters(); }
GPUd() void setClusterRef(uint32_t entry, uint16_t ncl) { mClustersReference.set(entry, ncl); }

template <class T>
static inline void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex, const ClusRef& ref)
GPUd() static inline void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex, const ClusRef& ref)
{
// data for given tracks starts at clinfo[ ref.getFirstEntry() ],
// 1st ref.getEntries() cluster indices are stored as uint32_t
Expand All @@ -90,38 +91,38 @@ class TrackTPC : public o2::track::TrackParCov
}

template <class T>
inline void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex) const
GPUd() inline void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex) const
{
getClusterReference<T>(clinfo, nCluster, sectorIndex, rowIndex, clusterIndex, mClustersReference);
}

template <class T>
static inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex, const ClusRef& ref)
GPUd() static inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex, const ClusRef& ref)
{
uint32_t clusterIndex;
getClusterReference<T>(clinfo, nCluster, sectorIndex, rowIndex, clusterIndex, ref);
return (clusters.clusters[sectorIndex][rowIndex][clusterIndex]);
}

template <class T>
inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex) const
GPUd() inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex) const
{
return getCluster<T>(clinfo, nCluster, clusters, sectorIndex, rowIndex, mClustersReference);
}

template <class T>
inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters) const
GPUd() inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters) const
{
uint8_t sectorIndex, rowIndex;
return (getCluster<T>(clinfo, nCluster, clusters, sectorIndex, rowIndex));
}

const dEdxInfo& getdEdx() const { return mdEdx; }
void setdEdx(const dEdxInfo& v) { mdEdx = v; }
GPUd() const dEdxInfo& getdEdx() const { return mdEdx; }
GPUd() void setdEdx(const dEdxInfo& v) { mdEdx = v; }

private:
float mTime0 = 0.f; ///< Reference Z of the track assumed for the vertex, scaled with pseudo
Expand Down
53 changes: 27 additions & 26 deletions DataFormats/common/include/CommonDataFormat/RangeReference.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define ALICEO2_RANGEREFERENCE_H

#include "GPUCommonRtypes.h"
#include "GPUCommonDef.h"

namespace o2
{
Expand All @@ -27,22 +28,22 @@ template <typename FirstEntry = int, typename NElem = int>
class RangeReference
{
public:
RangeReference(FirstEntry ent, NElem n) { set(ent, n); }
RangeReference(const RangeReference<FirstEntry, NElem>& src) = default;
RangeReference() = default;
~RangeReference() = default;
void set(FirstEntry ent, NElem n)
GPUd() RangeReference(FirstEntry ent, NElem n) { set(ent, n); }
GPUdDefault() RangeReference(const RangeReference<FirstEntry, NElem>& src) = default;
GPUdDefault() RangeReference() = default;
GPUdDefault() ~RangeReference() = default;
GPUd() void set(FirstEntry ent, NElem n)
{
mFirstEntry = ent;
mEntries = n;
}
void clear() { set(0, 0); }
FirstEntry getFirstEntry() const { return mFirstEntry; }
NElem getEntries() const { return mEntries; }
void setFirstEntry(FirstEntry ent) { mFirstEntry = ent; }
void setEntries(NElem n) { mEntries = n; }
void changeEntriesBy(NElem inc) { mEntries += inc; }
bool operator==(const RangeReference& other) const
GPUd() void clear() { set(0, 0); }
GPUd() FirstEntry getFirstEntry() const { return mFirstEntry; }
GPUd() NElem getEntries() const { return mEntries; }
GPUd() void setFirstEntry(FirstEntry ent) { mFirstEntry = ent; }
GPUd() void setEntries(NElem n) { mEntries = n; }
GPUd() void changeEntriesBy(NElem inc) { mEntries += inc; }
GPUd() bool operator==(const RangeReference& other) const
{
return mFirstEntry == other.mFirstEntry && mEntries == other.mEntries;
}
Expand All @@ -58,34 +59,34 @@ class RangeReference
template <int NBitsN>
class RangeRefComp
{
using Base = std::uint32_t;
using Base = unsigned int;

private:
static constexpr int NBitsTotal = sizeof(Base) * 8;
static constexpr Base MaskN = ((0x1 << NBitsN) - 1);
static constexpr Base MaskR = (~Base(0)) & (~MaskN);
Base mData = 0; ///< packed 1st entry reference + N entries
void sanityCheck()
GPUd() void sanityCheck()
{
static_assert(NBitsN < NBitsTotal, "NBitsN too large");
}

public:
RangeRefComp(int ent, int n) { set(ent, n); }
RangeRefComp() = default;
RangeRefComp(const RangeRefComp& src) = default;
void set(int ent, int n)
GPUd() RangeRefComp(int ent, int n) { set(ent, n); }
GPUdDefault() RangeRefComp() = default;
GPUdDefault() RangeRefComp(const RangeRefComp& src) = default;
GPUd() void set(int ent, int n)
{
mData = (Base(ent) << NBitsN) + (Base(n) & MaskN);
}
static constexpr Base getMaxFirstEntry() { return MaskR >> NBitsN; }
static constexpr Base getMaxEntries() { return MaskN; }
int getFirstEntry() const { return mData >> NBitsN; }
int getEntries() const { return mData & ((0x1 << NBitsN) - 1); }
void setFirstEntry(int ent) { mData = (Base(ent) << NBitsN) | (mData & MaskN); }
void setEntries(int n) { mData = (mData & MaskR) | (Base(n) & MaskN); }
void changeEntriesBy(int inc) { setEntries(getEntries() + inc); }
bool operator==(const RangeRefComp& other) const
GPUd() static constexpr Base getMaxFirstEntry() { return MaskR >> NBitsN; }
GPUd() static constexpr Base getMaxEntries() { return MaskN; }
GPUd() int getFirstEntry() const { return mData >> NBitsN; }
GPUd() int getEntries() const { return mData & ((0x1 << NBitsN) - 1); }
GPUd() void setFirstEntry(int ent) { mData = (Base(ent) << NBitsN) | (mData & MaskN); }
GPUd() void setEntries(int n) { mData = (mData & MaskR) | (Base(n) & MaskN); }
GPUd() void changeEntriesBy(int inc) { setEntries(getEntries() + inc); }
GPUd() bool operator==(const RangeRefComp& other) const
{
return mData == other.mData;
}
Expand Down