Project
Loading...
Searching...
No Matches
TPCFastTransform.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 "Rtypes.h"
19#endif
20
21#include "TPCFastTransform.h"
22#include "GPUCommonLogger.h"
23
24#include <iostream>
25
26#if !defined(GPUCA_STANDALONE)
27#include "TFile.h"
28#include "GPUCommonLogger.h"
29#endif
30
31#if !defined(GPUCA_STANDALONE)
33#endif
34
35using namespace o2::gpu;
36
38 : FlatObject(), mTimeStamp(0), mCorrection(), mApplyCorrection(1), mT0(0.f), mVdrift(0.f), mLumi(TPCFastTransform::DEFLUMI), mLumiError(0.f), mLumiScaleFactor(1.0f), mIDC(TPCFastTransform::DEFIDC), mIDCError(0.f), mCTP2IDCFallBackThreshold(30.f)
39{
40 // Default Constructor: creates an empty uninitialized object
41}
42
43void TPCFastTransform::cloneFromObject(const TPCFastTransform& obj, char* newFlatBufferPtr)
44{
46
47 const char* oldFlatBufferPtr = obj.mFlatBufferPtr;
48
49 FlatObject::cloneFromObject(obj, newFlatBufferPtr);
50
51 mTimeStamp = obj.mTimeStamp;
52 mApplyCorrection = obj.mApplyCorrection;
53 mT0 = obj.mT0;
54 mVdrift = obj.mVdrift;
55 mLumi = obj.mLumi;
56 mLumiError = obj.mLumiError;
57 mIDC = obj.mIDC;
58 mIDCError = obj.mIDCError;
59 mCTP2IDCFallBackThreshold = obj.mCTP2IDCFallBackThreshold;
60 mLumiScaleFactor = obj.mLumiScaleFactor;
61 // variable-size data
62
63 char* distBuffer = FlatObject::relocatePointer(oldFlatBufferPtr, mFlatBufferPtr, obj.mCorrection.getFlatBufferPtr());
64 mCorrection.cloneFromObject(obj.mCorrection, distBuffer);
65}
66
67void TPCFastTransform::moveBufferTo(char* newFlatBufferPtr)
68{
70 FlatObject::moveBufferTo(newFlatBufferPtr);
72}
73
74void TPCFastTransform::setActualBufferAddress(char* actualFlatBufferPtr)
75{
77 FlatObject::setActualBufferAddress(actualFlatBufferPtr);
79}
80
81void TPCFastTransform::setFutureBufferAddress(char* futureFlatBufferPtr)
82{
84
85 const char* oldFlatBufferPtr = mFlatBufferPtr;
86
87 char* distBuffer = FlatObject::relocatePointer(oldFlatBufferPtr, futureFlatBufferPtr, mCorrection.getFlatBufferPtr());
88 mCorrection.setFutureBufferAddress(distBuffer);
89 FlatObject::setFutureBufferAddress(futureFlatBufferPtr);
90}
91
93{
95
97
98 assert(correction.isConstructed());
99
100 mTimeStamp = 0;
101 mApplyCorrection = 1;
102 mT0 = 0.f;
103 mVdrift = 0.f;
104 mLumi = DEFLUMI;
105 mLumiError = 0.f;
106 mIDC = DEFIDC;
107 mIDCError = 0.f;
108 mCTP2IDCFallBackThreshold = 30.f;
109 mLumiScaleFactor = 1.f;
110
111 // variable-size data
112
113 mCorrection.cloneFromObject(correction, nullptr);
114}
115
116void TPCFastTransform::setCalibration(int64_t timeStamp, float t0, float vDrift)
117{
122
123 mTimeStamp = timeStamp;
124 mT0 = t0;
125 mVdrift = vDrift;
126 mConstructionMask |= ConstructionExtraState::CalibrationIsSet;
127}
128
130{
132
133 assert(mConstructionMask & ConstructionState::InProgress); // construction in process
134 assert(mConstructionMask & ConstructionExtraState::CalibrationIsSet); // all parameters are set
135
136 FlatObject::finishConstruction(mCorrection.getFlatBufferSize());
137
138 mCorrection.moveBufferTo(mFlatBufferPtr);
139}
140
142{
143 LOG(info) << "TPC Fast Transformation: ";
144 LOG(info) << "mTimeStamp = " << mTimeStamp;
145 LOG(info) << "mApplyCorrection = " << mApplyCorrection;
146 LOG(info) << "mT0 = " << mT0;
147 LOG(info) << "mVdrift = " << mVdrift;
148 LOG(info) << "mLumi = " << mLumi;
149 LOG(info) << "mLumiError = " << mLumiError;
150 LOG(info) << "mIDC = " << mIDC;
151 LOG(info) << "mIDCError = " << mIDCError;
152 LOG(info) << "mCTP2IDCFallBackThreshold = " << mCTP2IDCFallBackThreshold;
153 LOG(info) << "mLumiScaleFactor = " << mLumiScaleFactor;
154 mCorrection.print();
155}
156
157#if !defined(GPUCA_STANDALONE)
158
159int32_t TPCFastTransform::writeToFile(std::string outFName, std::string name)
160{
162 assert(isConstructed());
163
164 if (outFName.empty()) {
165 outFName = "tpcFastTransform.root";
166 }
167 if (name.empty()) {
168 name = "TPCFastTransform";
169 }
170 TFile outf(outFName.data(), "recreate");
171 if (outf.IsZombie()) {
172 LOG(error) << "Failed to open output file " << outFName;
173 return -1;
174 }
175
176 bool isBufferExternal = !isBufferInternal();
177 if (isBufferExternal) {
179 }
180 outf.WriteObjectAny(this, Class(), name.data());
181 outf.Close();
182 if (isBufferExternal) {
184 }
185 return 0;
186}
187
192
193TPCFastTransform* TPCFastTransform::loadFromFile(std::string inpFName, std::string name)
194{
196
197 if (inpFName.empty()) {
198 inpFName = "tpcFastTransform.root";
199 }
200 if (name.empty()) {
201 name = "TPCFastTransform";
202 }
203 TFile inpf(inpFName.data());
204 if (inpf.IsZombie()) {
205 LOG(error) << "Failed to open input file " << inpFName;
206 return nullptr;
207 }
208 TPCFastTransform* transform = reinterpret_cast<TPCFastTransform*>(inpf.GetObjectChecked(name.data(), TPCFastTransform::Class()));
209 if (!transform) {
210 LOG(error) << "Failed to load " << name << " from " << inpFName;
211 return nullptr;
212 }
213 if (transform->mFlatBufferSize > 0 && transform->mFlatBufferContainer == nullptr) {
214 LOG(error) << "Failed to load " << name << " from " << inpFName << ": empty flat buffer container";
215 return nullptr;
216 }
217 transform->rectifyAfterReadingFromFile(); // == transform->setActualBufferAddress(transform->mFlatBufferContainer);
218 return transform;
219}
220
221#endif
222
223#if !defined(GPUCA_STANDALONE)
228
229void TPCSlowSpaceChargeCorrection::getCorrections(const float gx, const float gy, const float gz, const int32_t slice, float& gdxC, float& gdyC, float& gdzC) const
230{
231 const o2::tpc::Side side = (slice < o2::tpc::SECTORSPERSIDE) ? o2::tpc::Side::A : o2::tpc::Side::C;
232 mCorr->getCorrections(gx, gy, gz, side, gdxC, gdyC, gdzC);
233}
234
236{
237 mCorrectionSlow = new TPCSlowSpaceChargeCorrection;
238 mCorrectionSlow->mCorr = new o2::tpc::SpaceCharge<float>();
239 mCorrectionSlow->mCorr->setGlobalCorrectionsFromFile<float>(inpf, o2::tpc::Side::A);
240 mCorrectionSlow->mCorr->setGlobalCorrectionsFromFile<float>(inpf, o2::tpc::Side::C);
241}
242#endif
243
244float TPCFastTransform::getIDC() const
245{
246 auto val = mIDC;
247 if (!isIDCSet()) {
248 if (mLumi < mCTP2IDCFallBackThreshold) {
249 bool static report = true;
250 if (report) {
251 report = false;
252 LOG(warn) << "IDC scaling is requested but map IDC record is empty. Since map Lumi " << mLumi << " is less than fall-back threshold " << mCTP2IDCFallBackThreshold << ", interpret Lumi record as IDC";
253 }
254 val = mLumi;
255 } else {
256#if !defined(GPUCA_STANDALONE)
257 LOG(fatal) << "IDC scaling is requested but map IDC record is empty. The map Lumi " << mLumi << " exceeds Lumi->IDC fall-back threshold " << mCTP2IDCFallBackThreshold;
258#endif
259 }
260 }
261 return val;
262}
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
char error[CURL_ERROR_SIZE]
uint32_t side
Definition RawData.h:0
This class contains the algorithms for calculation the distortions and corrections.
Definition of TPCFastTransform class.
void setFutureBufferAddress(char *futureFlatBufferPtr)
Definition FlatObject.h:569
uint32_t mConstructionMask
mask for constructed object members, first two bytes are used by this class
Definition FlatObject.h:321
int32_t mFlatBufferSize
size of the flat buffer
Definition FlatObject.h:320
void adoptInternalBuffer(char *buf)
Definition FlatObject.h:546
char * mFlatBufferContainer
Definition FlatObject.h:322
bool isConstructed() const
Tells if the object is constructed.
Definition FlatObject.h:260
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
void startConstruction()
_____________ Construction _________
Definition FlatObject.h:354
void moveBufferTo(char *newBufferPtr)
Definition FlatObject.h:408
void finishConstruction(int32_t flatBufferSize)
Definition FlatObject.h:370
bool isBufferInternal() const
Tells if the buffer is internal.
Definition FlatObject.h:263
void cloneFromObject(const FlatObject &obj, char *newFlatBufferPtr)
Definition FlatObject.h:385
void clearInternalBufferPtr()
Definition FlatObject.h:553
@ InProgress
construction started: temporary memory is reserved
Definition FlatObject.h:317
void setFutureBufferAddress(char *futureFlatBufferPtr)
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
void cloneFromObject(const TPCFastSpaceChargeCorrection &obj, char *newFlatBufferPtr)
Construction interface.
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
void finishConstruction()
Finishes initialization: puts everything to the flat buffer, releases temporary memory.
void moveBufferTo(char *newBufferPtr)
void cloneFromObject(const TPCFastTransform &obj, char *newFlatBufferPtr)
Construction interface.
int32_t writeToFile(std::string outFName="", std::string name="")
void setSlowTPCSCCorrection(TFile &inpf)
setting the reference corrections
void setCalibration(int64_t timeStamp, float t0, float vDrift)
TPCFastTransform()
_____________ Constructors / destructors __________________________
static TPCFastTransform * loadFromFile(std::string inpFName="", std::string name="")
void setFutureBufferAddress(char *futureFlatBufferPtr)
void print() const
Print method.
void getCorrections(const DataT x, const DataT y, const DataT z, const Side side, DataT &corrX, DataT &corrY, DataT &corrZ) const
void setGlobalCorrectionsFromFile(std::string_view file, const Side side)
GLuint const GLchar * name
Definition glcorearb.h:781
GLuint GLfloat * val
Definition glcorearb.h:1582
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
void report(gsl::span< o2::InteractionTimeRecord > irs, int threshold, bool verbose)
Side
TPC readout sidE.
Definition Defs.h:37
@ A
Definition Defs.h:37
@ C
Definition Defs.h:38
simple struct to hold the space charge object which can be used for CPU reconstruction only
void getCorrections(const float gx, const float gy, const float gz, const int32_t sector, float &gdxC, float &gdyC, float &gdzC) const
getting the corrections for global coordinates
o2::tpc::SpaceCharge< float > * mCorr
reference space charge corrections
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"