Project
Loading...
Searching...
No Matches
Chebyshev3D.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 ALICEO2_MATHUTILS_CHEBYSHEV3D_H_
17#define ALICEO2_MATHUTILS_CHEBYSHEV3D_H_
18
19#include <TNamed.h> // for TNamed
20#include <TObjArray.h> // for TObjArray
21#include <cstdio> // for FILE, stdout
22#include "MathUtils/Chebyshev3DCalc.h" // for Chebyshev3DCalc, etc
23#include "Rtypes.h" // for Float_t, Int_t, Double_t, Bool_t, etc
24#include "TString.h" // for TString
25
26class TH1; // lines 15-15
27class TMethodCall; // lines 16-16
28
29namespace o2
30{
31namespace math_utils
32{
33
64class Chebyshev3D : public TNamed
65{
66 public:
68
70
71 Chebyshev3D(const char* inpFile);
72
73 Chebyshev3D(FILE* stream);
74
75#ifdef _INC_CREATION_Chebyshev3D_
85 Chebyshev3D(const char* funName, Int_t dimOut, const Float_t* bmin, const Float_t* bmax, const Int_t* npoints,
86 Float_t prec = 1E-6, const Float_t* precD = nullptr);
96 Chebyshev3D(void (*ptr)(float*, float*), Int_t dimOut, const Float_t* bmin, const Float_t* bmax, const Int_t* npoints,
97 Float_t prec = 1E-6, const Float_t* precD = nullptr);
109 Chebyshev3D(void (*ptr)(float*, float*), int dimOut, const Float_t* bmin, const Float_t* bmax,
110 const Int_t* npX, const Int_t* npY, const Int_t* npZ,
111 Float_t prec = 1E-6, const Float_t* precD = nullptr);
120 Chebyshev3D(void (*ptr)(float*, float*), int DimOut, const Float_t* bmin, const Float_t* bmax, Float_t prec = 1E-6,
121 Bool_t run = kTRUE, const Float_t* precD = nullptr);
122#endif
123
124 ~Chebyshev3D() override
125 {
126 Clear();
127 }
128
129 Chebyshev3D& operator=(const Chebyshev3D& rhs);
130
131 void Eval(const Float_t* par, Float_t* res);
132
133 Float_t Eval(const Float_t* par, int idim);
134
135 void Eval(const Double_t* par, Double_t* res);
136
137 Double_t Eval(const Double_t* par, int idim);
138
139 void evaluateDerivative(int dimd, const Float_t* par, Float_t* res);
140
141 void evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, Float_t* res);
142
143 Float_t evaluateDerivative(int dimd, const Float_t* par, int idim);
144
145 Float_t evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, int idim);
146
147 void evaluateDerivative3D(const Float_t* par, Float_t dbdr[3][3]);
148
149 void evaluateDerivative3D2(const Float_t* par, Float_t dbdrdr[3][3][3]);
150
151 void Print(const Option_t* opt = "") const override;
152
153 Bool_t isInside(const Float_t* par) const;
154
155 Bool_t isInside(const Double_t* par) const;
156
158 {
159 return (Chebyshev3DCalc*)mChebyshevParameter.UncheckedAt(i);
160 }
161
163 {
164 return mMinBoundaries[i];
165 }
166
168 {
169 return mMaxBoundaries[i];
170 }
171
173 {
174 return (float*)mMinBoundaries;
175 }
176
178 {
179 return (float*)mMaxBoundaries;
180 }
181
183 {
184 return (float*)mBoundaryMappingScale;
185 }
186
188 {
189 return (float*)mBoundaryMappingOffset;
190 }
191
193 {
194 return mPrecision;
195 }
196
197 void shiftBound(int id, float dif);
198
199 void loadData(const char* inpFile);
200
201 void loadData(FILE* stream);
202
203#ifdef _INC_CREATION_Chebyshev3D_
204 void invertSign();
205 int* getNcNeeded(float xyz[3], int dimVar, float mn, float mx, float prec, Int_t npCheck = 30);
206 void estimateNumberOfPoints(float prec, int gridBC[3][3], Int_t npd1 = 30, Int_t npd2 = 30, Int_t npd3 = 30);
207 void saveData(const char* outfile, Bool_t append = kFALSE) const;
208 void saveData(FILE* stream = stdout) const;
209
210 void setuserFunction(const char* name);
211 void setuserFunction(void (*ptr)(float*, float*));
212 void evaluateUserFunction(const Float_t* x, Float_t* res);
213 TH1* TestRMS(int idim, int npoints = 1000, TH1* histo = nullptr);
214 static Int_t calculateChebyshevCoefficients(const Float_t* funval, int np, Float_t* outCoefs, Float_t prec = -1);
215#endif
216
217 protected:
218 void Clear(const Option_t* option = "") override;
219
220 void setDimOut(const int d, const float* prec = nullptr);
221
222 void prepareBoundaries(const Float_t* bmin, const Float_t* bmax);
223
224#ifdef _INC_CREATION_Chebyshev3D_
225 void evaluateUserFunction();
226 void defineGrid(const Int_t* npoints);
227 Int_t chebyshevFit(); // fit all output dimensions
228 Int_t chebyshevFit(int dmOut);
229 void setPrecision(float prec)
230 {
231 mPrecision = prec;
232 }
233#endif
234
235 Float_t mapToInternal(Float_t x, Int_t d) const; // map x to [-1:1]
237 {
238 return x / mBoundaryMappingScale[d] + mBoundaryMappingOffset[d];
239 } // map from [-1:1] to x
240 Double_t mapToInternal(Double_t x, Int_t d) const; // map x to [-1:1]
241 Double_t mapToExternal(Double_t x, Int_t d) const
242 {
243 return x / mBoundaryMappingScale[d] + mBoundaryMappingOffset[d];
244 } // map from [-1:1] to x
245
246 private:
247 Int_t mOutputArrayDimension;
248 Float_t mPrecision;
249 Float_t mMinBoundaries[3];
250 Float_t mMaxBoundaries[3];
251 Float_t mBoundaryMappingScale[3];
252 Float_t mBoundaryMappingOffset[3];
253 TObjArray mChebyshevParameter;
254
255 Int_t mMaxCoefficients;
256 Int_t mNumberOfPoints[3];
257 Float_t mTemporaryCoefficient[3];
258 Float_t* mTemporaryUserResults;
259 Float_t* mTemporaryChebyshevGrid;
260 Int_t mTemporaryChebyshevGridOffs[3];
261 TString mUserFunctionName;
262 TMethodCall* mUserMacro;
263
264 static const Float_t sMinimumPrecision;
265
266 ClassDefOverride(o2::math_utils::Chebyshev3D,
267 2) // Chebyshev parametrization for 3D->N function
268};
269
271inline Bool_t Chebyshev3D::isInside(const Float_t* par) const
272{
273 for (int i = 3; i--;) {
274 if (mMinBoundaries[i] > par[i] || par[i] > mMaxBoundaries[i]) {
275 return kFALSE;
276 }
277 }
278 return kTRUE;
279}
280
282inline Bool_t Chebyshev3D::isInside(const Double_t* par) const
283{
284 for (int i = 3; i--;) {
285 if (mMinBoundaries[i] > par[i] || par[i] > mMaxBoundaries[i]) {
286 return kFALSE;
287 }
288 }
289 return kTRUE;
290}
291
293inline void Chebyshev3D::Eval(const Float_t* par, Float_t* res)
294{
295 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
296 for (int i = 3; i--;) {
297 coef[i] = mapToInternal(par[i], i);
298 }
299 for (int i = mOutputArrayDimension; i--;) {
300 res[i] = getChebyshevCalc(i)->Eval(coef);
301 }
302}
303
305inline void Chebyshev3D::Eval(const Double_t* par, Double_t* res)
306{
307 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
308 for (int i = 3; i--;) {
309 coef[i] = mapToInternal(par[i], i);
310 }
311 for (int i = mOutputArrayDimension; i--;) {
312 res[i] = getChebyshevCalc(i)->Eval(coef);
313 }
314}
315
317inline Double_t Chebyshev3D::Eval(const Double_t* par, int idim)
318{
319 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
320 for (int i = 3; i--;) {
321 coef[i] = mapToInternal(par[i], i);
322 }
323 return getChebyshevCalc(idim)->Eval(coef);
324}
325
327inline Float_t Chebyshev3D::Eval(const Float_t* par, int idim)
328{
329 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
330 for (int i = 3; i--;) {
331 coef[i] = mapToInternal(par[i], i);
332 }
333 return getChebyshevCalc(idim)->Eval(coef);
334}
335
337inline void Chebyshev3D::evaluateDerivative3D(const Float_t* par, Float_t dbdr[3][3])
338{
339 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
340 for (int i = 3; i--;) {
341 coef[i] = mapToInternal(par[i], i);
342 }
343 for (int ib = 3; ib--;) {
344 for (int id = 3; id--;) {
345 dbdr[ib][id] = getChebyshevCalc(ib)->evaluateDerivative(id, coef) * mBoundaryMappingScale[id];
346 }
347 }
348}
349
351inline void Chebyshev3D::evaluateDerivative3D2(const Float_t* par, Float_t dbdrdr[3][3][3])
352{
353 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
354 for (int i = 3; i--;) {
355 coef[i] = mapToInternal(par[i], i);
356 }
357 for (int ib = 3; ib--;) {
358 for (int id = 3; id--;) {
359 for (int id1 = 3; id1--;) {
360 dbdrdr[ib][id][id1] = getChebyshevCalc(ib)->evaluateDerivative2(id, id1, coef) *
361 mBoundaryMappingScale[id] * mBoundaryMappingScale[id1];
362 }
363 }
364 }
365}
366
367// Evaluates Chebyshev parameterization derivative for 3d->DimOut function
368inline void Chebyshev3D::evaluateDerivative(int dimd, const Float_t* par, Float_t* res)
369{
370 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
371 for (int i = 3; i--;) {
372 coef[i] = mapToInternal(par[i], i);
373 }
374 for (int i = mOutputArrayDimension; i--;) {
375 res[i] = getChebyshevCalc(i)->evaluateDerivative(dimd, coef) * mBoundaryMappingScale[dimd];
376 };
377}
378
379// Evaluates Chebyshev parameterization 2nd derivative over dimd1 and dimd2 dimensions for 3d->DimOut function
380inline void Chebyshev3D::evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, Float_t* res)
381{
382 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
383 for (int i = 3; i--;) {
384 coef[i] = mapToInternal(par[i], i);
385 }
386 for (int i = mOutputArrayDimension; i--;) {
387 res[i] = getChebyshevCalc(i)->evaluateDerivative2(dimd1, dimd2, coef) *
388 mBoundaryMappingScale[dimd1] * mBoundaryMappingScale[dimd2];
389 }
390}
391
394inline Float_t Chebyshev3D::evaluateDerivative(int dimd, const Float_t* par, int idim)
395{
396 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
397 for (int i = 3; i--;) {
398 coef[i] = mapToInternal(par[i], i);
399 }
400 return getChebyshevCalc(idim)->evaluateDerivative(dimd, coef) * mBoundaryMappingScale[dimd];
401}
402
405inline Float_t Chebyshev3D::evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, int idim)
406{
407 Float_t coef[3]; // mapped arguments, local so that evaluation is reentrant
408 for (int i = 3; i--;) {
409 coef[i] = mapToInternal(par[i], i);
410 }
411 return getChebyshevCalc(idim)->evaluateDerivative2(dimd1, dimd2, coef) *
412 mBoundaryMappingScale[dimd1] * mBoundaryMappingScale[dimd2];
413}
414
417{
418#ifdef _BRING_TO_BOUNDARY_
419 T res = (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d];
420 if (res < -1) {
421 return -1;
422 }
423 if (res > 1) {
424 return 1;
425 }
426 return res;
427#else
428 return (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d];
429#endif
430}
431
433inline Double_t Chebyshev3D::mapToInternal(Double_t x, Int_t d) const
434{
435#ifdef _BRING_TO_BOUNDARY_
436 T res = (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d];
437 if (res < -1) {
438 return -1;
439 }
440 if (res > 1) {
441 return 1;
442 }
443 return res;
444#else
445 return (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d];
446#endif
447}
448} // namespace math_utils
449} // namespace o2
450
451#endif
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
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 Print launch bounds used for RTC code as debugging option
uint32_t res
Definition RawData.h:0
TBranch * ptr
Float_t Eval(const Float_t *par) const
Float_t evaluateDerivative(int dim, const Float_t *par) const
Float_t evaluateDerivative2(int dim1, int dim2, const Float_t *par) const
Float_t * getBoundMax() const
void evaluateDerivative3D(const Float_t *par, Float_t dbdr[3][3])
Returns the gradient matrix.
void prepareBoundaries(const Float_t *bmin, const Float_t *bmax)
Bool_t isInside(const Float_t *par) const
Checks if the point is inside of the fitted box.
void loadData(const char *inpFile)
Float_t * getBoundMin() const
void Clear(const Option_t *option="") override
Float_t mapToExternal(Float_t x, Int_t d) const
Float_t * getBoundaryMappingOffset() const
void evaluateDerivative(int dimd, const Float_t *par, Float_t *res)
Float_t getPrecision() const
Float_t mapToInternal(Float_t x, Int_t d) const
Μaps x to [-1:1].
Float_t * getBoundaryMappingScale() const
void evaluateDerivative2(int dimd1, int dimd2, const Float_t *par, Float_t *res)
Double_t mapToExternal(Double_t x, Int_t d) const
void evaluateDerivative3D2(const Float_t *par, Float_t dbdrdr[3][3][3])
Returns the gradient matrix.
void shiftBound(int id, float dif)
Float_t getBoundMin(int i) const
Chebyshev3DCalc * getChebyshevCalc(int i) const
void setDimOut(const int d, const float *prec=nullptr)
void Print(const Option_t *opt="") const override
void Eval(const Float_t *par, Float_t *res)
Evaluates Chebyshev parameterization for 3d->DimOut function.
Float_t getBoundMax(int i) const
Chebyshev3D & operator=(const Chebyshev3D &rhs)
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint const GLchar * name
Definition glcorearb.h:781
GLuint GLuint stream
Definition glcorearb.h:1806
GLuint id
Definition glcorearb.h:650
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...