Project
Loading...
Searching...
No Matches
GPUTRDRecoParam.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
15
16#ifndef O2_GPU_TRD_RECOPARAM_H
17#define O2_GPU_TRD_RECOPARAM_H
18
19#include "GPUCommonDef.h"
20#include "GPUCommonRtypes.h"
21#include "GPUCommonArray.h"
22#include "GPUCommonMath.h"
23
24namespace o2
25{
26namespace gpu
27{
28struct GPUSettingsRec;
29
31{
32 public:
33 GPUTRDRecoParam() = default;
35 ~GPUTRDRecoParam() = default;
36
38 void init(float bz, const GPUSettingsRec* rec = nullptr);
39
40#if !defined(GPUCA_GPUCODE_DEVICE)
42 GPUd() void recalcTrkltCov(const float tilt, const float snp, const float rowSize, std::array<float, 3>& cov, const float pull = 0., const int occupancy = 0) const
43 {
44 recalcTrkltCov(tilt, snp, rowSize, cov.data(), pull, occupancy);
45 }
46#endif
47 GPUd() void recalcTrkltCov(const float tilt, const float snp, const float rowSize, float* cov, const float pull = 0., const int occupancy = 0) const;
48
49 GPUd() float getRPhiRes(float snp, float pull = 0.f, int occupancy = 0) const;
50 GPUd() float getDyRes(float snp, int occupancy = 0) const { return mDyA2 + mDyC2 * (snp - mLorentzAngle) * (snp - mLorentzAngle) + mOccDyA * occupancy; } // a^2 + c^2 * (snp - b)^2
51 GPUd() float convertAngleToDy(float snp) const { return 3.f * snp / CAMath::Sqrt(1 - snp * snp); } // when calibrated, sin(phi) = (dy / xDrift) / sqrt(1+(dy/xDrift)^2) works well
52 GPUd() float getCorrYDy() const { return mCorrYDy; }
53 GPUd() float getPileUpProbTracklet(int nBC, bool withChargeInfo, bool Q0 = true, bool Q1 = true) const;
54 GPUd() float getPileUpProbTrack(int nBC, std::array<int, 6> Q0, std::array<int, 6> Q1) const;
55
57 GPUd() float getZCorrCoeffNRC() const { return mZCorrCoefNRC; }
58
60 GPUd() int getPileUpRangeBefore() const { return mPileUpRangeBefore; }
61 GPUd() int getPileUpRangeAfter() const { return mPileUpRangeAfter; }
62
63 private:
64 // tracklet error parameterization depends on the magnetic field
65 float mLorentzAngle{0.f};
66 // rphi
67 float mRPhiA{1.f};
68 float mRPhiATgp{1.f};
69 float mRPhiC2{0.f};
70 // angle
71 float mDyA2{1.225e-3f};
72 float mDyC2{0.f};
73 // variation in y when dy variates by one sigma (= cov / sigma_dy = corr * sigma_y) (valid within 2sigma of dy)
74 float mCorrYDy{0.13f};
75 // error parametrization vs angular pull (pol2)
76 float mPullA{6.8e-3f};
77 float mPullB{0.049f};
78 // error parametrization of y position vs occupancy defined as ntracklets within chamber (prop to sqrt(occupancy))
79 float mOccA{3.3e-4f};
80 // error parametrization for dy vs occupancy defined as ntracklets within chamber (prop to sqrt(occupancy))
81 float mOccDyA{2.5e-4f};
82
83 float mZCorrCoefNRC{1.4f};
84
85 // pile-up prob parametrization, depending on charges
86 // default parametrization, all tracklets
87 int mPileUpRangeBefore{-130};
88 int mPileUpMaxProb{0};
89 int mPileUpRangeAfter{70};
90 // tracklets with Q0!=0 and Q1!=0
91 int mPileUpRangeBefore11{-130};
92 int mPileUpMaxProb11{0};
93 int mPileUpRangeAfter11{30};
94 // tracklets with Q0=0 and Q1!=0
95 int mPileUpRangeBefore01{-80};
96 int mPileUpMaxProb01{30};
97 int mPileUpRangeAfter01{70};
98 // tracklets with Q0!=0 and Q1=0
99 int mPileUpRangeBefore10{-130};
100 int mPileUpMaxProb10{-60};
101 int mPileUpRangeAfter10{30};
102 // tracklets with Q0=0 and Q1=0
103 int mPileUpRangeBefore00{-10};
104 int mPileUpMaxProb00{22};
105 int mPileUpRangeAfter00{40};
106
107 ClassDefNV(GPUTRDRecoParam, 4);
108};
109
117GPUdi() float GPUTRDRecoParam::getRPhiRes(float snp, float pull, int occupancy) const
118{
119 // flat uncertainty + radial-alignment uncertainty depending on tan(phi)
120 float tgp = (CAMath::Abs(snp) < 0.99999f) ? CAMath::Abs(snp) / CAMath::Sqrt(1 - snp * snp) : 1e6;
121 float resIdeal = mRPhiA + mRPhiATgp * tgp;
122 if (pull > 10) {
123 // parametrization does not really work well for such large pull values
124 pull = 10.f;
125 }
126 float resPull = mPullA * pull * pull + mPullB * pull; // parametrization as pol2 summed in quadrature
127 float resOccupancy = mOccA * occupancy; // parametrization as sqrt() summed in quadrature
128 return (resIdeal * resIdeal + mRPhiC2 * (snp - mLorentzAngle) * (snp - mLorentzAngle) + resPull * resPull + resOccupancy);
129}
130
131GPUdi() float GPUTRDRecoParam::getPileUpProbTracklet(int nBC, bool withChargeInfo, bool Q0, bool Q1) const
132{
133 // get the probability that the tracklet with charges Q0 and Q1 belongs to a given BC, with a (signed) distance nBC from the TRD-triggered BC
134 // parametrization depends on whether charges are 0 (bool is false) or not (bool is true)
135
136 float prob = 0.;
137
138 int maxBC = mPileUpRangeAfter;
139 int minBC = mPileUpRangeBefore;
140 int maxProbBC = mPileUpMaxProb;
141 if (nBC <= mPileUpRangeBefore || nBC >= mPileUpRangeAfter) {
142 return prob;
143 }
144
145 if (withChargeInfo) {
146 if (Q0 && Q1) {
147 maxBC = mPileUpRangeAfter11;
148 minBC = mPileUpRangeBefore11;
149 maxProbBC = mPileUpMaxProb11;
150 }
151 if (!Q0 && Q1) {
152 maxBC = mPileUpRangeAfter01;
153 minBC = mPileUpRangeBefore01;
154 maxProbBC = mPileUpMaxProb01;
155 }
156 if (Q0 && !Q1) {
157 maxBC = mPileUpRangeAfter10;
158 minBC = mPileUpRangeBefore10;
159 maxProbBC = mPileUpMaxProb10;
160
161 // if Q1 = 0, there is a second maximum at nBC=0, probably due to tracklets with low energy loss in the drift/TR regions
162 // so we enlarge the probability around there
163 if (nBC > maxProbBC && nBC <= 0) {
164 prob += 2. / (maxBC - minBC) / (0 - maxProbBC) * (nBC - maxProbBC);
165 }
166 if (nBC > 0 && nBC < maxBC) {
167 prob += 2. / (maxBC - minBC) / (0 - maxBC) * (nBC - maxBC);
168 }
169 }
170 if (!Q0 && !Q1) {
171 maxBC = mPileUpRangeAfter00;
172 minBC = mPileUpRangeBefore00;
173 maxProbBC = mPileUpMaxProb00;
174 }
175 }
176
177 // prob is 0 if the BC is too far, maximal for a given nBC, and with two linear functions in between. The maximum is chosen so that the integral is 1.
178 if (nBC <= minBC || nBC >= maxBC) {
179 return 0.;
180 }
181 float maxProb = 2. / (maxBC - minBC);
182 if (nBC > minBC && nBC <= maxProbBC) {
183 prob += maxProb / (maxProbBC - minBC) * (nBC - minBC);
184 } else {
185 prob += maxProb / (maxProbBC - maxBC) * (nBC - maxBC);
186 }
187 return prob;
188}
189
190GPUdi() float GPUTRDRecoParam::getPileUpProbTrack(int nBC, std::array<int, 6> Q0, std::array<int, 6> Q1) const
191{
192 // get the probability that the track belongs to a given BC, with a (signed) distance nBC from the TRD-triggered BC
193 // it depends on the individual probabilities for every of its tracklets.
194 //
195 // If P(BC|L0,L1,...) is the probability that the track belongs to a given BC, given the information on the tracklet charges in L0,L1, ...
196 // P(BC|L0,L1,...) proportional to P(BC)*P(L0,L1,...|BC), prop to P(BC)*P(L0|BC)*P(L1|BC)*... since for a given track and BC, charge in different layers are independent
197 // prop to P(BC) * P(BC|L0)/P(BC) * P(BC|L1)/P(BC) * ...
198 //
199 // P(BC) is the probability with no charge information: we start from this probability, and each tracklet adds new information on pileup probability
200
201 // basic probability, if we had no info on the charges
202 float probNoInfo = GPUTRDRecoParam::getPileUpProbTracklet(nBC, false);
203
204 float probTrack = probNoInfo;
205 if (probNoInfo < 1e-6f)
206 return 0.;
207
208 // For each tracklet, we add the info on its charge
209 for (int i = 0; i < 6; i++) {
210 // negative charge values if the tracklet is not present
211 if (Q0[i] < 0 || Q1[i] < 0)
212 continue;
213 float probTracklet = GPUTRDRecoParam::getPileUpProbTracklet(nBC, true, (Q0[i] != 0), (Q1[i] != 0));
214 probTrack *= probTracklet / probNoInfo;
215 }
216
217 return probTrack;
218}
219
220} // namespace gpu
221} // namespace o2
222
223#endif // O2_GPU_TRD_RECOPARAM_H
int32_t i
void init(float bz, const GPUSettingsRec *rec=nullptr)
Load parameterization for given magnetic field.
const float const float std::array< float, 3 > & cov
GPUd() int getPileUpRangeAfter() const
const float const float rowSize
GPUd() void recalcTrkltCov(const float tilt
Recalculate tracklet covariance based on phi angle of related track.
std::array< int, 6 > std::array< int, 6 > Q1 const
GPUTRDRecoParam(const GPUTRDRecoParam &)=default
const float const float std::array< float, 3 > const float pull
const float const float std::array< float, 3 > const float const int occupancy
GPUd() int getPileUpRangeBefore() const
Get BC intervals for pile-up.
std::array< int, 6 > Q0
GLenum array
Definition glcorearb.h:4274
GLdouble f
Definition glcorearb.h:310
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GPUdi() o2
Definition TrackTRD.h:39
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
GPUReconstruction * rec