|
| 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 | + |
| 12 | +/// \file GPUTRDTrack.inc |
| 13 | +/// \author Ole Schmidt, Sergey Gorbunov |
| 14 | + |
| 15 | +#ifndef GPUTRDTRACK_INC_H |
| 16 | +#define GPUTRDTRACK_INC_H |
| 17 | + |
| 18 | +#include "GPUTRDTrack.h" |
| 19 | + |
| 20 | +template <typename T> |
| 21 | +GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t() |
| 22 | +{ |
| 23 | + // default constructor |
| 24 | + initialize(); |
| 25 | +} |
| 26 | + |
| 27 | +template <typename T> |
| 28 | +GPUd() void GPUTRDTrack_t<T>::initialize() |
| 29 | +{ |
| 30 | + // set all members to their default values (needed since in-class initialization not possible with AliRoot) |
| 31 | + mChi2 = 0.f; |
| 32 | + mSignal = -1.f; |
| 33 | + mRefGlobalTrackId = 0; |
| 34 | + mCollisionId = -1; |
| 35 | + mFlags = 0; |
| 36 | + mIsCrossingNeighbor = 0; |
| 37 | + for (int i = 0; i < kNLayers; ++i) { |
| 38 | + mAttachedTracklets[i] = -1; |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +#ifdef GPUCA_ALIROOT_LIB |
| 43 | +#include "AliHLTExternalTrackParam.h" |
| 44 | +#include "GPUTRDTrackData.h" |
| 45 | + |
| 46 | +template <typename T> |
| 47 | +GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t(const AliHLTExternalTrackParam& t) : T(t) |
| 48 | +{ |
| 49 | + initialize(); |
| 50 | +} |
| 51 | + |
| 52 | +template <typename T> |
| 53 | +GPUd() void GPUTRDTrack_t<T>::ConvertTo(GPUTRDTrackDataRecord& t) const |
| 54 | +{ |
| 55 | + //------------------------------------------------------------------ |
| 56 | + // convert to GPU structure |
| 57 | + //------------------------------------------------------------------ |
| 58 | + t.mAlpha = T::getAlpha(); |
| 59 | + t.fX = T::getX(); |
| 60 | + t.fY = T::getY(); |
| 61 | + t.fZ = T::getZ(); |
| 62 | + t.fq1Pt = T::getQ2Pt(); |
| 63 | + t.mSinPhi = T::getSnp(); |
| 64 | + t.fTgl = T::getTgl(); |
| 65 | + for (int i = 0; i < 15; i++) { |
| 66 | + t.fC[i] = T::getCov()[i]; |
| 67 | + } |
| 68 | + t.fTPCTrackID = getRefGlobalTrackIdRaw(); |
| 69 | + for (int i = 0; i < kNLayers; i++) { |
| 70 | + t.fAttachedTracklets[i] = getTrackletIndex(i); |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +template <typename T> |
| 75 | +GPUd() void GPUTRDTrack_t<T>::ConvertFrom(const GPUTRDTrackDataRecord& t) |
| 76 | +{ |
| 77 | + //------------------------------------------------------------------ |
| 78 | + // convert from GPU structure |
| 79 | + //------------------------------------------------------------------ |
| 80 | + T::set(t.fX, t.mAlpha, &(t.fY), t.fC); |
| 81 | + setRefGlobalTrackIdRaw(t.fTPCTrackID); |
| 82 | + mChi2 = 0.f; |
| 83 | + mSignal = -1.f; |
| 84 | + mFlags = 0; |
| 85 | + mIsCrossingNeighbor = 0; |
| 86 | + mCollisionId = -1; |
| 87 | + for (int iLayer = 0; iLayer < kNLayers; iLayer++) { |
| 88 | + mAttachedTracklets[iLayer] = t.fAttachedTracklets[iLayer]; |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +#endif |
| 93 | + |
| 94 | +#if defined(GPUCA_HAVE_O2HEADERS) |
| 95 | +#include "ReconstructionDataFormats/TrackTPCITS.h" |
| 96 | +#include "DataFormatsTPC/TrackTPC.h" |
| 97 | + |
| 98 | +template <typename T> |
| 99 | +GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t(const o2::dataformats::TrackTPCITS& t) : T(t) |
| 100 | +{ |
| 101 | + initialize(); |
| 102 | +} |
| 103 | + |
| 104 | +template <typename T> |
| 105 | +GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t(const o2::tpc::TrackTPC& t) : T(t) |
| 106 | +{ |
| 107 | + initialize(); |
| 108 | +} |
| 109 | + |
| 110 | +#endif |
| 111 | + |
| 112 | +template <typename T> |
| 113 | +GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t(const GPUTRDTrack_t<T>& t) |
| 114 | + : T(t), mChi2(t.mChi2), mSignal(t.mSignal), mRefGlobalTrackId(t.mRefGlobalTrackId), mCollisionId(t.mCollisionId), mFlags(t.mFlags), mIsCrossingNeighbor(t.mIsCrossingNeighbor) |
| 115 | +{ |
| 116 | + // copy constructor |
| 117 | + for (int i = 0; i < kNLayers; ++i) { |
| 118 | + mAttachedTracklets[i] = t.mAttachedTracklets[i]; |
| 119 | + } |
| 120 | +} |
| 121 | + |
| 122 | +template <typename T> |
| 123 | +GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t(const T& t) : T(t) |
| 124 | +{ |
| 125 | + // copy constructor from anything |
| 126 | + initialize(); |
| 127 | +} |
| 128 | + |
| 129 | +template <typename T> |
| 130 | +GPUd() GPUTRDTrack_t<T>& GPUTRDTrack_t<T>::operator=(const GPUTRDTrack_t<T>& t) |
| 131 | +{ |
| 132 | + // assignment operator |
| 133 | + if (&t == this) { |
| 134 | + return *this; |
| 135 | + } |
| 136 | + *(T*)this = t; |
| 137 | + mChi2 = t.mChi2; |
| 138 | + mSignal = t.mSignal; |
| 139 | + mRefGlobalTrackId = t.mRefGlobalTrackId; |
| 140 | + mCollisionId = t.mCollisionId; |
| 141 | + mFlags = t.mFlags; |
| 142 | + mIsCrossingNeighbor = t.mIsCrossingNeighbor; |
| 143 | + for (int i = 0; i < kNLayers; ++i) { |
| 144 | + mAttachedTracklets[i] = t.mAttachedTracklets[i]; |
| 145 | + } |
| 146 | + return *this; |
| 147 | +} |
| 148 | + |
| 149 | +template <typename T> |
| 150 | +GPUd() int GPUTRDTrack_t<T>::getNlayersFindable() const |
| 151 | +{ |
| 152 | + // returns number of layers in which the track is in active area of TRD |
| 153 | + int retVal = 0; |
| 154 | + for (int iLy = 0; iLy < kNLayers; iLy++) { |
| 155 | + if ((mFlags >> iLy) & 0x1) { |
| 156 | + ++retVal; |
| 157 | + } |
| 158 | + } |
| 159 | + return retVal; |
| 160 | +} |
| 161 | + |
| 162 | +template <typename T> |
| 163 | +GPUd() int GPUTRDTrack_t<T>::getNmissingConsecLayers(int iLayer) const |
| 164 | +{ |
| 165 | + // returns number of consecutive layers in which the track was |
| 166 | + // inside the deadzone up to (and including) the given layer |
| 167 | + int retVal = 0; |
| 168 | + while (!getIsFindable(iLayer)) { |
| 169 | + ++retVal; |
| 170 | + --iLayer; |
| 171 | + if (iLayer < 0) { |
| 172 | + break; |
| 173 | + } |
| 174 | + } |
| 175 | + return retVal; |
| 176 | +} |
| 177 | + |
| 178 | +#endif // GPUTRDTRACK_INC_H |
0 commit comments