Project
Loading...
Searching...
No Matches
GPUdEdx.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 GPUDEDX_H
16#define GPUDEDX_H
17
18#include "GPUCommonDef.h"
19
20#include "GPUDef.h"
21#include "GPUCommonMath.h"
22#include "GPUParam.h"
23#include "GPUdEdxInfo.h"
24#include "DataFormatsTPC/Defs.h"
25#include "CalibdEdxContainer.h"
26#include "GPUTPCGeometry.h"
27#include "GPUDebugStreamer.h"
28#include "GPUDataTypesIO.h"
29
30namespace o2::gpu
31{
32
34{
35 public:
36 // The driver must call clear(), fill clusters row by row outside-in, then run computedEdx() to get the result
38 GPUd() void fillCluster(float qtot, float qmax, int32_t padRow, uint8_t sector, float trackSnp, float trackTgl, const GPUCalibObjectsConst& calib, float z, float pad, float relTime);
39 GPUd() void fillSubThreshold(int32_t padRow);
40 GPUd() void computedEdx(GPUdEdxInfo& output, const GPUParam& param);
41
42 static GPUglobalconstexpr() size_t MAX_NCL = GPUTPCGeometry::NROWS;
43
44 private:
45 GPUd() float GetSortTruncMean(GPUCA_PAR_DEDX_STORAGE_TYPE_A* array, int32_t count, int32_t trunclow, int32_t trunchigh);
46 GPUd() void checkSubThresh(int32_t roc);
47
48 GPUCA_PAR_DEDX_STORAGE_TYPE_A mChargeTot[MAX_NCL]; // No need for default, just some memory
49 GPUCA_PAR_DEDX_STORAGE_TYPE_A mChargeMax[MAX_NCL]; // No need for default, just some memory
50 float mSubThreshMinTot = 0.f;
51 float mSubThreshMinMax = 0.f;
52 uint8_t mNClsROC[4] = {0};
53 uint8_t mNClsROCSubThresh[4] = {0};
54 uint8_t mCount = 0;
55 uint8_t mLastROC = 255;
56 uint8_t mNSubThresh = 0;
57};
58
59GPUdi() void GPUdEdx::checkSubThresh(int32_t roc)
60{
61 if (roc != mLastROC) {
62 if (mNSubThresh && mCount + mNSubThresh < MAX_NCL) {
63 for (int32_t i = 0; i < mNSubThresh; i++) {
64 mChargeTot[mCount] = (GPUCA_PAR_DEDX_STORAGE_TYPE_A)mSubThreshMinTot;
65 mChargeMax[mCount++] = (GPUCA_PAR_DEDX_STORAGE_TYPE_A)mSubThreshMinMax;
66 }
67 mNClsROC[mLastROC] += mNSubThresh;
68 mNClsROCSubThresh[mLastROC] += mNSubThresh;
69 }
70 mNSubThresh = 0;
71 mSubThreshMinTot = 1e10f;
72 mSubThreshMinMax = 1e10f;
73 }
74
75 mLastROC = roc;
76}
77
78GPUdnii() void GPUdEdx::fillCluster(float qtot, float qmax, int32_t padRow, uint8_t sector, float trackSnp, float trackTgl, const GPUCalibObjectsConst& calib, float z, float pad, float relTime)
79{
80 // container containing all the dE/dx corrections
81 auto calibContainer = calib.dEdxCalibContainer;
82 constexpr GPUTPCGeometry geo;
83
84 const int32_t roc = geo.GetROC(padRow);
85 checkSubThresh(roc);
86 if (mCount >= MAX_NCL) {
87 return;
88 }
89 float snp2 = trackSnp * trackSnp;
90 if (snp2 > constants::MAX_SIN_PHI_LOW) {
91 snp2 = constants::MAX_SIN_PHI_LOW;
92 }
93
94 // setting maximum for snp for which the calibration object was created
95 const float snp = CAMath::Abs(trackSnp);
96
97 // tanTheta local dip angle: z angle - dz/dx (cm/cm)
98 const float sec2 = 1.f / (1.f - snp2);
99 const float tgl2 = trackTgl * trackTgl;
100 const float tanTheta = CAMath::Sqrt(tgl2 * sec2);
101
102 // getting the topology correction
103 const uint32_t padPos = CAMath::Min<uint32_t>(GPUTPCGeometry::NPads(padRow) - 1, CAMath::Float2UIntRn(pad)); // position of the pad is shifted half a pad ( pad=3 -> centre position of third pad)
104 const float absRelPad = CAMath::Abs(pad - padPos);
105 const int32_t region = geo.GetRegion(padRow);
106 z = CAMath::Abs(z);
107 const float threshold = calibContainer->getZeroSupressionThreshold(sector, padRow, padPos); // TODO: Use the mean zero supresion threshold of all pads in the cluster?
108 const bool useFullGainMap = calibContainer->isUsageOfFullGainMap();
109 float qTotIn = qtot;
110 const float fullGainMapGain = calibContainer->getGain(sector, padRow, padPos);
111 if (useFullGainMap) {
112 qmax /= fullGainMapGain;
113 qtot /= fullGainMapGain;
114 } else {
115 qTotIn *= fullGainMapGain;
116 }
117
118 const float qMaxTopologyCorr = calibContainer->getTopologyCorrection(region, o2::tpc::ChargeType::Max, tanTheta, snp, z, absRelPad, relTime, threshold, qTotIn);
119 const float qTotTopologyCorr = calibContainer->getTopologyCorrection(region, o2::tpc::ChargeType::Tot, tanTheta, snp, z, absRelPad, relTime, threshold, qTotIn);
120 qmax /= qMaxTopologyCorr;
121 qtot /= qTotTopologyCorr;
122
124 sector,
125 static_cast<tpc::GEMstack>(roc)};
126
127 const float qMaxResidualCorr = calibContainer->getResidualCorrection(stack, tpc::ChargeType::Max, trackTgl, trackSnp);
128 const float qTotResidualCorr = calibContainer->getResidualCorrection(stack, tpc::ChargeType::Tot, trackTgl, trackSnp);
129 qmax /= qMaxResidualCorr;
130 qtot /= qTotResidualCorr;
131
132 const float residualGainMapGain = calibContainer->getResidualGain(sector, padRow, padPos);
133 qmax /= residualGainMapGain;
134 qtot /= residualGainMapGain;
135
136 mChargeTot[mCount] = (GPUCA_PAR_DEDX_STORAGE_TYPE_A)qtot;
137 mChargeMax[mCount++] = (GPUCA_PAR_DEDX_STORAGE_TYPE_A)qmax;
138 mNClsROC[roc]++;
139 if (qtot < mSubThreshMinTot) {
140 mSubThreshMinTot = qtot;
141 }
142 if (qmax < mSubThreshMinMax) {
143 mSubThreshMinMax = qmax;
144 }
145
146 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamdEdx)) {
147 float padlx = geo.Row2X(padRow);
148 float padly = geo.LinearPad2Y(sector, padRow, padPos);
149 o2::utils::DebugStreamer::instance()->getStreamer("debug_dedx", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_dedx").data()
150 << "qTot=" << mChargeTot[mCount - 1]
151 << "qMax=" << mChargeMax[mCount - 1]
152 << "region=" << region
153 << "padRow=" << padRow
154 << "sector=" << sector
155 << "lx=" << padlx
156 << "ly=" << padly
157 << "tanTheta=" << tanTheta
158 << "trackTgl=" << trackTgl
159 << "sinPhi=" << trackSnp
160 << "z=" << z
161 << "absRelPad=" << absRelPad
162 << "relTime=" << relTime
163 << "threshold=" << threshold
164 << "qTotIn=" << qTotIn
165 << "qMaxTopologyCorr=" << qMaxTopologyCorr
166 << "qTotTopologyCorr=" << qTotTopologyCorr
167 << "qMaxResidualCorr=" << qMaxResidualCorr
168 << "qTotResidualCorr=" << qTotResidualCorr
169 << "residualGainMapGain=" << residualGainMapGain
170 << "fullGainMapGain=" << fullGainMapGain
171 << "\n";
172 })
173}
174
175GPUdi() void GPUdEdx::fillSubThreshold(int32_t padRow)
176{
177 const int32_t roc = GPUTPCGeometry::GetROC(padRow);
178 checkSubThresh(roc);
179 mNSubThresh++;
180}
181
182} // namespace o2::gpu
183
184#endif
Definition of container class for dE/dx corrections.
int32_t i
#define GPUCA_DEBUG_STREAMER_CHECK(...)
#define GPUCA_PAR_DEDX_STORAGE_TYPE_A
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
uint32_t roc
Definition RawData.h:3
uint32_t stack
Definition RawData.h:1
float int32_t padRow
Definition GPUdEdx.h:38
float int32_t uint8_t sector
Definition GPUdEdx.h:38
float int32_t uint8_t float float const GPUCalibObjectsConst float float pad
Definition GPUdEdx.h:38
static GPUglobalconstexpr() size_t MAX_NCL
GPUd() void clear()
float int32_t uint8_t float float const GPUCalibObjectsConst float float float relTime
Definition GPUdEdx.h:38
float int32_t uint8_t float float trackTgl
Definition GPUdEdx.h:38
float int32_t uint8_t float float const GPUCalibObjectsConst & calib
Definition GPUdEdx.h:38
float int32_t uint8_t float trackSnp
Definition GPUdEdx.h:38
GLint GLsizei count
Definition glcorearb.h:399
GLenum array
Definition glcorearb.h:4274
GLdouble f
Definition glcorearb.h:310
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLfloat param
Definition glcorearb.h:271
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GPUdi() o2
Definition TrackTRD.h:39
GPUdnii() void GPUdEdx
Definition GPUdEdx.h:78
GEMstack
TPC GEM stack types.
Definition Defs.h:55
@ Tot
Definition Defs.h:74
@ Max
Definition Defs.h:73
@ streamdEdx
stream corrections and cluster properties used for the dE/dx
GEM stack identification.
Definition Defs.h:79
vec clear()