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