Project
Loading...
Searching...
No Matches
CalibdEdxTrackTopologySpline.cxx
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
16
17#if !defined(GPUCA_STANDALONE)
18#include "TFile.h"
19#endif
21
22using namespace o2::gpu;
23using namespace o2::tpc;
24
25#if !defined(GPUCA_STANDALONE)
27 : FlatObject()
28{
29 TFile dEdxFile(dEdxSplinesFile);
30 setFromFile(dEdxFile, name);
31}
32#endif
33
40
47
48void CalibdEdxTrackTopologySpline::recreate(const int32_t nKnots[])
49{
52
53 int32_t buffSize = 0;
54 int32_t offsets1[FSplines];
55 int32_t offsets2[FSplines];
56 for (uint32_t i = 0; i < FSplines; i++) {
57 mCalibSplinesqMax[i].recreate(nKnots);
58 buffSize = alignSize(buffSize, mCalibSplinesqMax[i].getBufferAlignmentBytes());
59 offsets1[i] = buffSize;
60 buffSize += mCalibSplinesqMax[i].getFlatBufferSize();
61 }
62 for (uint32_t i = 0; i < FSplines; i++) {
63 mCalibSplinesqTot[i].recreate(nKnots);
64 buffSize = alignSize(buffSize, mCalibSplinesqTot[i].getBufferAlignmentBytes());
65 offsets2[i] = buffSize;
66 buffSize += mCalibSplinesqTot[i].getFlatBufferSize();
67 }
68
70
71 for (uint32_t i = 0; i < FSplines; i++) {
72 mCalibSplinesqMax[i].moveBufferTo(mFlatBufferPtr + offsets1[i]);
73 }
74 for (uint32_t i = 0; i < FSplines; i++) {
75 mCalibSplinesqTot[i].moveBufferTo(mFlatBufferPtr + offsets2[i]);
76 }
77}
78
80{
82
83 const char* oldFlatBufferPtr = obj.mFlatBufferPtr;
84 FlatObject::cloneFromObject(obj, newFlatBufferPtr);
85
86 for (uint32_t i = 0; i < FSplines; i++) {
87 char* buffer = FlatObject::relocatePointer(oldFlatBufferPtr, mFlatBufferPtr, obj.mCalibSplinesqMax[i].getFlatBufferPtr());
88 mCalibSplinesqMax[i].cloneFromObject(obj.mCalibSplinesqMax[i], buffer);
89 }
90
91 for (uint32_t i = 0; i < FSplines; i++) {
92 char* buffer = FlatObject::relocatePointer(oldFlatBufferPtr, mFlatBufferPtr, obj.mCalibSplinesqTot[i].getFlatBufferPtr());
93 mCalibSplinesqTot[i].cloneFromObject(obj.mCalibSplinesqTot[i], buffer);
94 }
95 mMaxTanTheta = obj.mMaxTanTheta;
96 mMaxSinPhi = obj.mMaxSinPhi;
97
98 for (uint32_t i = 0; i < FSplines; ++i) {
99 mScalingFactorsqTot[i] = obj.mScalingFactorsqTot[i];
100 mScalingFactorsqMax[i] = obj.mScalingFactorsqMax[i];
101 }
102}
103
105{
107 char* oldFlatBufferPtr = mFlatBufferPtr;
108 FlatObject::moveBufferTo(newFlatBufferPtr);
109 char* currFlatBufferPtr = mFlatBufferPtr;
110 mFlatBufferPtr = oldFlatBufferPtr;
111 setActualBufferAddress(currFlatBufferPtr);
112}
113
115{
117 for (uint32_t i = 0; i < FSplines; i++) {
118 mCalibSplinesqMax[i].destroy();
119 mCalibSplinesqTot[i].destroy();
120 }
122}
123
125{
127
128 FlatObject::setActualBufferAddress(actualFlatBufferPtr);
129 int32_t offset = 0;
130 for (uint32_t i = 0; i < FSplines; i++) {
131 offset = alignSize(offset, mCalibSplinesqMax[i].getBufferAlignmentBytes());
132 mCalibSplinesqMax[i].setActualBufferAddress(mFlatBufferPtr + offset);
133 offset += mCalibSplinesqMax[i].getFlatBufferSize();
134 }
135 for (uint32_t i = 0; i < FSplines; i++) {
136 offset = alignSize(offset, mCalibSplinesqTot[i].getBufferAlignmentBytes());
137 mCalibSplinesqTot[i].setActualBufferAddress(mFlatBufferPtr + offset);
138 offset += mCalibSplinesqTot[i].getFlatBufferSize();
139 }
140}
141
143{
145
146 for (uint32_t i = 0; i < FSplines; i++) {
147 char* buffer = relocatePointer(mFlatBufferPtr, futureFlatBufferPtr, mCalibSplinesqMax[i].getFlatBufferPtr());
148 mCalibSplinesqMax[i].setFutureBufferAddress(buffer);
149 }
150 for (uint32_t i = 0; i < FSplines; i++) {
151 char* buffer = relocatePointer(mFlatBufferPtr, futureFlatBufferPtr, mCalibSplinesqTot[i].getFlatBufferPtr());
152 mCalibSplinesqTot[i].setFutureBufferAddress(buffer);
153 }
154 FlatObject::setFutureBufferAddress(futureFlatBufferPtr);
155}
156
157#if !defined(GPUCA_STANDALONE)
158
160 TFile& inpf, const char* name)
161{
163 return FlatObject::readFromFile<CalibdEdxTrackTopologySpline>(inpf, name);
164}
165
167{
168 LOGP(info, "Warnings when reading from file can be ignored");
170 *this = *cont;
171 delete cont;
172 LOGP(info, "CalibdEdxTrackTopologySpline sucessfully loaded from file");
173}
174
176{
178 LOGP(info, "Warnings when writting to file can be ignored");
179 return FlatObject::writeToFile(*this, outf, name);
180}
181
183{
185
186 int32_t buffSize = 0;
187 int32_t offsets1[FSplines];
188 int32_t offsets2[FSplines];
189
190 auto defaultF = [&](const double x[], double f[]) {
191 f[0] = 1.f;
192 };
193 double xMin[FDimX]{};
194 double xMax[FDimX]{};
195
196 for (int32_t iDimX = 0; iDimX < FDimX; ++iDimX) {
197 xMin[iDimX] = 0;
198 xMax[iDimX] = 1;
199 }
200
201 for (uint32_t ireg = 0; ireg < FSplines; ++ireg) {
202 SplineType splineTmpqMax;
203 splineTmpqMax.approximateFunction(xMin, xMax, defaultF);
204 mCalibSplinesqMax[ireg] = splineTmpqMax;
205 buffSize = alignSize(buffSize, mCalibSplinesqMax[ireg].getBufferAlignmentBytes());
206 offsets1[ireg] = buffSize;
207 buffSize += mCalibSplinesqMax[ireg].getFlatBufferSize();
208 }
209
210 for (uint32_t ireg = 0; ireg < FSplines; ++ireg) {
211 SplineType splineTmpqTot;
212 splineTmpqTot.approximateFunction(xMin, xMax, defaultF);
213 mCalibSplinesqTot[ireg] = splineTmpqTot;
214 buffSize = alignSize(buffSize, mCalibSplinesqTot[ireg].getBufferAlignmentBytes());
215 offsets2[ireg] = buffSize;
216 buffSize += mCalibSplinesqTot[ireg].getFlatBufferSize();
217 }
218
220
221 for (uint32_t i = 0; i < FSplines; i++) {
222 mCalibSplinesqMax[i].moveBufferTo(mFlatBufferPtr + offsets1[i]);
223 }
224 for (uint32_t i = 0; i < FSplines; i++) {
225 mCalibSplinesqTot[i].moveBufferTo(mFlatBufferPtr + offsets2[i]);
226 }
227}
228
230{
231 std::vector<float>* tanThetaMax = nullptr;
232 std::vector<float>* sinPhiMax = nullptr;
233 inpf.GetObject("tanThetaMax", tanThetaMax);
234 inpf.GetObject("sinPhiMax", sinPhiMax);
235 if (tanThetaMax) {
236 mMaxTanTheta = (*tanThetaMax).front();
237 delete tanThetaMax;
238 }
239 if (sinPhiMax) {
240 mMaxSinPhi = (*sinPhiMax).front();
241 delete sinPhiMax;
242 }
243}
244
245std::string CalibdEdxTrackTopologySpline::getSplineName(const int32_t region, const ChargeType charge)
246{
247 const std::string typeName[2] = {"qMax", "qTot"};
248 const std::string polname = fmt::format("spline_{}_region{}", typeName[charge], region).data();
249 return polname;
250}
251
252#endif
int16_t charge
Definition RawEventData.h:5
unsigned int uint32_t
int32_t i
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
void setFutureBufferAddress(char *futureFlatBufferPtr)
Definition FlatObject.h:569
void destroy()
_______________ Utilities _______________________________________________
Definition FlatObject.h:361
static T * relocatePointer(const char *oldBase, char *newBase, const T *ptr)
Relocates a pointer inside a buffer to the new buffer address.
Definition FlatObject.h:283
void setActualBufferAddress(char *actualFlatBufferPtr)
_____________ Methods for moving the class with its external buffer to another location _____________...
Definition FlatObject.h:559
static int32_t writeToFile(T &obj, TFile &outf, const char *name)
write a child class object to the file
Definition FlatObject.h:492
void startConstruction()
_____________ Construction _________
Definition FlatObject.h:354
void moveBufferTo(char *newBufferPtr)
Definition FlatObject.h:408
void finishConstruction(int32_t flatBufferSize)
Definition FlatObject.h:370
static constexpr size_t alignSize(size_t sizeBytes, size_t alignmentBytes)
_______________ Generic utilities _______________________________________________
Definition FlatObject.h:275
void cloneFromObject(const FlatObject &obj, char *newFlatBufferPtr)
Definition FlatObject.h:385
void setFutureBufferAddress(char *futureFlatBufferPtr)
static constexpr size_t getBufferAlignmentBytes()
_____________ FlatObject functionality, see FlatObject class for description ____________
Definition FlatObject.h:195
void setFromFile(TFile &inpf, const char *name)
CalibdEdxTrackTopologySpline()=default
_____________ Constructors / destructors __________________________
void cloneFromObject(const CalibdEdxTrackTopologySpline &obj, char *newFlatBufferPtr)
static CalibdEdxTrackTopologySpline * readFromFile(TFile &inpf, const char *name)
read a class object from the file
int32_t writeToFile(TFile &outf, const char *name="CalibdEdxTrackTopologySpline")
_______________ IO ________________________
void setRangesFromFile(TFile &inpf)
sets maximum TanTheta and maximum snp from file
void setDefaultSplines()
set default splines: the return value of the splines will be 1 (no correction will be applied)
CalibdEdxTrackTopologySpline & operator=(const CalibdEdxTrackTopologySpline &)
Assignment operator.
void setActualBufferAddress(char *actualFlatBufferPtr)
static std::string getSplineName(const int32_t region, const ChargeType charge)
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint const GLchar * name
Definition glcorearb.h:781
GLdouble f
Definition glcorearb.h:310
GLintptr offset
Definition glcorearb.h:660
Global TPC definitions and constants.
ChargeType
Definition Defs.h:72