Project
Loading...
Searching...
No Matches
TriCubic.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
16
17#ifndef ALICEO2_TPC_TRICUBIC_H_
18#define ALICEO2_TPC_TRICUBIC_H_
19
21
22// forward declare VC Memory
23template <typename DataT, size_t, size_t, bool>
24class Memory;
25
26namespace o2
27{
28namespace tpc
29{
30
31template <typename DataT>
32class DataContainer3D;
33
45
46template <typename DataT, size_t N>
47class Vector;
48
50template <typename DataT = double>
52{
55
56 public:
60 TriCubicInterpolator(const DataContainer& gridData, const Grid3D& gridProperties) : mGridData{&gridData}, mGridProperties{&gridProperties} {};
61
64
67
68 enum class ExtrapolationType {
69 Linear = 0,
70 Parabola = 1,
71 };
72
73 // interpolate value at given coordinate
79 DataT operator()(const DataT z, const DataT r, const DataT phi) const { return interpolateSparse(z, r, phi); }
80
83 void setExtrapolationType(const ExtrapolationType extrapolationType) { mExtrapolationType = extrapolationType; }
84
86 ExtrapolationType getExtrapolationType() const { return mExtrapolationType; }
87
89 void setExtrapolateValues(const bool extraPolate) { mExtraPolateValues = extraPolate; }
90
92 bool getExtrapolateValues() const { return mExtraPolateValues; }
93
94 private:
95 static constexpr unsigned int FDim = Grid3D::getDim();
96 static constexpr unsigned int FZ = Grid3D::getFZ();
97 static constexpr unsigned int FR = Grid3D::getFR();
98 static constexpr unsigned int FPHI = Grid3D::getFPhi();
99 const DataContainer* mGridData{};
100 const Grid3D* mGridProperties{};
102 bool mExtraPolateValues = true;
103
104 // DEFINITION OF enum GridPos
105 //========================================================
106 // r
107 // | 6------F---7
108 // | / | / |
109 // | K G YR L H
110 // | / | / |
111 // | 2---B------3 |
112 // | | | | |
113 // | | 4---|---E--5
114 // | C XL / D XR /
115 // | | I YL | J
116 // | | / | /
117 // | 0---A------1
118 // |------------------------------- z
119 // /
120 // /
121 // /
122 // phi
123 //========================================================
124
125 enum class GridPos {
126 None = 27,
127 InnerVolume = 26,
128 Edge0 = 0,
129 Edge1 = 1,
130 Edge2 = 2,
131 Edge3 = 3,
132 Edge4 = 4,
133 Edge5 = 5,
134 Edge6 = 6,
135 Edge7 = 7,
136 LineA = 8,
137 LineB = 9,
138 LineC = 10,
139 LineD = 11,
140 LineE = 12,
141 LineF = 13,
142 LineG = 14,
143 LineH = 15,
144 LineI = 16,
145 LineJ = 17,
146 LineK = 18,
147 LineL = 19,
148 SideXRight = 20,
149 SideXLeft = 21,
150 SideYRight = 22,
151 SideYLeft = 23,
152 SideZRight = 24,
153 SideZLeft = 25
154 };
155
156 void setValues(const int iz, const int ir, const int iphi, std::array<Vector<DataT, 4>, 16>& cVals) const;
157
158 // interpolate value at given coordinate - this method doesnt compute and stores the coefficients and is faster when quering only a few values per cube
163 DataT interpolateSparse(const DataT z, const DataT r, const DataT phi) const;
164
165 // for periodic boundary conditions
166 void getDataIndexCircularArray(const int index0, const int dim, int arr[]) const;
167
168 // this helps to get circular and non circular padding indices
169 int getRegulatedDelta(const int index0, const int delta, const unsigned int dim, const int offs) const { return mGridProperties->isIndexInGrid(index0 + delta, dim) ? delta : offs; }
170
171 DataT extrapolation(const DataT valk, const DataT valk1, const DataT valk2) const;
172
173 DataT linearExtrapolation(const DataT valk, const DataT valk1) const;
174
175 DataT parabolExtrapolation(const DataT valk, const DataT valk1, const DataT valk2) const;
176
177 GridPos findPos(const int iz, const int ir, const int iphi) const;
178
179 bool isInInnerVolume(const int iz, const int ir, const int iphi, GridPos& posType) const;
180
181 bool findEdge(const int iz, const int ir, const int iphi, GridPos& posType) const;
182
183 bool findLine(const int iz, const int ir, const int iphi, GridPos& posType) const;
184
185 bool findSide(const int iz, const int ir, const int iphi, GridPos& posType) const;
186
187 bool isSideRight(const int ind, const int dim) const;
188
189 bool isSideLeft(const int ind) const;
190};
191
192} // namespace tpc
193} // namespace o2
194
195#endif
Definition of RegularGrid3D class.
static constexpr unsigned int getFPhi()
static constexpr unsigned int getFZ()
static constexpr unsigned int getDim()
static constexpr unsigned int getFR()
bool isIndexInGrid(const int index, const unsigned int dim) const
void setExtrapolationType(const ExtrapolationType extrapolationType)
Definition TriCubic.h:83
bool getExtrapolateValues() const
Definition TriCubic.h:92
TriCubicInterpolator(const DataContainer &gridData, const Grid3D &gridProperties)
Definition TriCubic.h:60
ExtrapolationType getExtrapolationType() const
Definition TriCubic.h:86
void setExtrapolateValues(const bool extraPolate)
enable or disable extraolating values outside of the grid
Definition TriCubic.h:89
DataT operator()(const DataT z, const DataT r, const DataT phi) const
Definition TriCubic.h:79
@ Linear
assume linear dependency at the boundaries of the grid
@ Parabola
assume parabolic dependency at the boundaries of the grid
TriCubicInterpolator< DataT > & operator=(TriCubicInterpolator< DataT > &&)
move assignment
Definition TriCubic.cxx:36
GLboolean r
Definition glcorearb.h:1233
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
o2::InteractionRecord ir(0, 0)