Project
Loading...
Searching...
No Matches
GPUTRDInterfaces.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 GPUTRDINTERFACES_H
16#define GPUTRDINTERFACES_H
17
18// This is an interface header for making the TRD tracking portable between O2, and Ru2 format
19
20#include "GPUCommonDef.h"
21#include "GPUCommonMath.h"
22#include "GPUTPCGMMergedTrack.h"
23#include "GPUTPCGMTrackParam.h"
24#include "GPUTRDDef.h"
25
26namespace o2::gpu
27{
28template <typename T>
29class trackInterface;
30template <typename T>
31class propagatorInterface;
32} // namespace o2::gpu
33
36
37namespace o2::gpu
38{
39
40GPUdi() trackInterface<o2::track::TrackParCov>::trackInterface(const GPUTPCGMMergedTrack& trk) { set(trk.OuterParam().X, trk.OuterParam().alpha, trk.OuterParam().P, trk.OuterParam().C); }
41GPUdi() trackInterface<o2::track::TrackParCov>::trackInterface(const gputpcgmmergertypes::GPUTPCOuterParam& param) { set(param.X, param.alpha, param.P, param.C); }
42
43template <>
45{
46 public:
48 GPUd() propagatorInterface(const propagatorParam* prop) : mProp(prop){};
49 GPUd() propagatorInterface(const propagatorInterface<o2::base::Propagator>&) = delete;
50 GPUd() propagatorInterface& operator=(const propagatorInterface<o2::base::Propagator>&) = delete;
51
52 GPUdi() bool propagateToX(float x, float maxSnp, float maxStep) { return mProp->PropagateToXBxByBz(*mParam, x, maxSnp, maxStep); }
53 GPUdi() int32_t getPropagatedYZ(float x, float& projY, float& projZ) { return static_cast<int32_t>(mParam->getYZAt(x, mProp->getNominalBz(), projY, projZ)); }
54
55 GPUdi() void setTrack(trackInterface<o2::track::TrackParCov>* trk) { mParam = trk; }
56 GPUdi() void setFitInProjections(bool flag) {}
57
58 GPUdi() float getAlpha() { return (mParam) ? mParam->getAlpha() : 99999.f; }
59 GPUdi() bool update(const float p[2], const float cov[3])
60 {
61 if (mParam) {
62 gpustd::array<float, 2> pTmp = {p[0], p[1]};
63 gpustd::array<float, 3> covTmp = {cov[0], cov[1], cov[2]};
64 return mParam->update(pTmp, covTmp);
65 } else {
66 return false;
67 }
68 }
69 GPUdi() float getPredictedChi2(const float p[2], const float cov[3])
70 {
71 if (mParam) {
72 gpustd::array<float, 2> pTmp = {p[0], p[1]};
73 gpustd::array<float, 3> covTmp = {cov[0], cov[1], cov[2]};
74 return mParam->getPredictedChi2(pTmp, covTmp);
75 } else {
76 return 99999.f;
77 }
78 }
79 GPUdi() bool rotate(float alpha) { return (mParam) ? mParam->rotate(alpha) : false; }
80
81 trackInterface<o2::track::TrackParCov>* mParam{nullptr};
83};
84
85} // namespace o2::gpu
86
87#include "GPUTPCGMPropagator.h"
88#include "GPUParam.h"
89#include "GPUDef.h"
92
93namespace o2::gpu
94{
95
96template <>
98{
99 public:
102 GPUd() trackInterface(const GPUTPCGMMergedTrack& trk) : GPUTPCGMTrackParam(trk.GetParam()), mAlpha(trk.GetAlpha()) {}
103 GPUd() trackInterface(const gputpcgmmergertypes::GPUTPCOuterParam& param) : GPUTPCGMTrackParam(), mAlpha(param.alpha)
104 {
105 SetX(param.X);
106 for (int32_t i = 0; i < 5; i++) {
107 SetPar(i, param.P[i]);
108 }
109 for (int32_t i = 0; i < 15; i++) {
110 SetCov(i, param.C[i]);
111 }
112 };
115 GPUd() trackInterface(const o2::dataformats::TrackTPCITS& param) : GPUTPCGMTrackParam(), mAlpha(param.getParamOut().getAlpha())
116 {
117 SetX(param.getParamOut().getX());
118 SetPar(0, param.getParamOut().getY());
119 SetPar(1, param.getParamOut().getZ());
120 SetPar(2, param.getParamOut().getSnp());
121 SetPar(3, param.getParamOut().getTgl());
122 SetPar(4, param.getParamOut().getQ2Pt());
123 for (int32_t i = 0; i < 15; i++) {
124 SetCov(i, param.getParamOut().getCov()[i]);
125 }
126 }
127 GPUd() trackInterface(const o2::tpc::TrackTPC& param) : GPUTPCGMTrackParam(), mAlpha(param.getParamOut().getAlpha())
128 {
129 SetX(param.getParamOut().getX());
130 SetPar(0, param.getParamOut().getY());
131 SetPar(1, param.getParamOut().getZ());
132 SetPar(2, param.getParamOut().getSnp());
133 SetPar(3, param.getParamOut().getTgl());
134 SetPar(4, param.getParamOut().getQ2Pt());
135 for (int32_t i = 0; i < 15; i++) {
136 SetCov(i, param.getParamOut().getCov()[i]);
137 }
138 }
139
140 GPUd() float getX() const
141 {
142 return GetX();
143 }
144 GPUd() float getAlpha() const { return mAlpha; }
145 GPUd() float getY() const { return GetY(); }
146 GPUd() float getZ() const { return GetZ(); }
147 GPUd() float getSnp() const { return GetSinPhi(); }
148 GPUd() float getTgl() const { return GetDzDs(); }
149 GPUd() float getQ2Pt() const { return GetQPt(); }
150 GPUd() float getEta() const { return -CAMath::Log(CAMath::Tan(0.5f * (0.5f * M_PI - CAMath::ATan(getTgl())))); }
151 GPUd() float getPt() const { return CAMath::Abs(getQ2Pt()) > 0 ? CAMath::Abs(1.f / getQ2Pt()) : 99999.f; }
152 GPUd() float getSigmaY2() const { return GetErr2Y(); }
153 GPUd() float getSigmaZ2() const { return GetErr2Z(); }
154
155 GPUd() const float* getPar() const { return GetPar(); }
156 GPUd() const float* getCov() const { return GetCov(); }
157 GPUd() void resetCovariance(float s) { ResetCovariance(); }
158 GPUd() void updateCovZ2(float addZerror) { SetCov(2, GetErr2Z() + addZerror); }
159 GPUd() void setAlpha(float alpha) { mAlpha = alpha; }
160 GPUd() void set(float x, float alpha, const float param[5], const float cov[15])
161 {
162 SetX(x);
163 for (int32_t i = 0; i < 5; i++) {
164 SetPar(i, param[i]);
165 }
166 for (int32_t j = 0; j < 15; j++) {
167 SetCov(j, cov[j]);
168 }
170 }
171
173
174 private:
175 float mAlpha = 0.f; // rotation along phi wrt global coordinate system
176
177 ClassDefNV(trackInterface, 1);
178};
179
180template <>
182{
183 public:
185 GPUd() propagatorInterface(const propagatorParam* pField) : GPUTPCGMPropagator(), mTrack(nullptr)
186 {
187 this->SetMaterialTPC();
188 this->SetPolynomialField(pField);
189 this->SetMaxSinPhi(GPUCA_MAX_SIN_PHI);
190 this->SetToyMCEventsFlag(0);
191 this->SetFitInProjections(0);
192 this->SelectFieldRegion(GPUTPCGMPropagator::TRD);
193 };
197 {
198 SetTrack(trk, trk->getAlpha());
199 mTrack = trk;
200 }
201 GPUd() bool propagateToX(float x, float maxSnp, float maxStep)
202 {
203 //bool ok = PropagateToXAlpha(x, GetAlpha(), true) == 0 ? true : false;
204 int32_t retVal = PropagateToXAlpha(x, GetAlpha(), true);
205 bool ok = (retVal == 0) ? true : false;
206 ok = mTrack->CheckNumericalQuality();
207 return ok;
208 }
209 GPUd() int32_t getPropagatedYZ(float x, float& projY, float& projZ) { return GetPropagatedYZ(x, projY, projZ); }
210 GPUd() void setFitInProjections(bool flag) { SetFitInProjections(flag); }
211 GPUd() bool rotate(float alpha)
212 {
213 if (RotateToAlpha(alpha) == 0) {
214 mTrack->setAlpha(alpha);
215 return mTrack->CheckNumericalQuality();
216 }
217 return false;
218 }
219 GPUd() bool update(const float p[2], const float cov[3])
220 {
221 // TODO sigma_yz not taken into account yet, is not zero due to pad tilting!
222 return Update(p[0], p[1], 0, false, cov[0], cov[2]) == 0 ? true : false;
223 }
224 GPUd() float getAlpha() { return GetAlpha(); }
225 // TODO sigma_yz not taken into account yet, is not zero due to pad tilting!
226 GPUd() float getPredictedChi2(const float p[2], const float cov[3]) const { return PredictChi2(p[0], p[1], cov[0], cov[2]); }
227
229};
230} // namespace o2::gpu
231
232#endif // GPUTRDINTERFACES_H
int32_t i
#define GPUdDefault()
#define GPUCA_MAX_SIN_PHI
int32_t retVal
uint32_t j
Definition RawData.h:0
o2::track::TrackParCov TrackParCov
Definition Recon.h:39
Result of refitting TPC-ITS matched track.
@ TRD
outer TPC -> outer TRD
GPUd() int32_t getPropagatedYZ(float x
propagatorInterface & operator=(const propagatorInterface< GPUTPCGMPropagator > &)=delete
propagatorInterface(const propagatorInterface< GPUTPCGMPropagator > &)=delete
trackInterface< GPUTPCGMTrackParam > * mTrack
GPUd() void setTrack(trackInterface< GPUTPCGMTrackParam > *trk)
GPUd() void setFitInProjections(bool flag)
GPUd() propagatorInterface(const propagatorParam *pField)
GPUd() propagatorInterface(const propagatorParam *prop)
GPUdi() void setFitInProjections(bool flag)
GPUdDefault() trackInterface(const trackInterface< GPUTPCGMTrackParam > &param)=default
GPUd() void updateCovZ2(float addZerror)
GPUd() trackInterface(const gputpcgmmergertypes
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLint GLenum GLint x
Definition glcorearb.h:403
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLfloat param
Definition glcorearb.h:271
void set(T *h, size_t v)
Definition PageParser.h:107
std::array< T, N > array
GPUdi() o2
Definition TrackTRD.h:38
GPUd() const expr uint32_t MultivariatePolynomialHelper< Dim
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...