Project
Loading...
Searching...
No Matches
testO2TPCTricubic.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#define BOOST_TEST_MODULE Test TPC O2TPCTricubic class
18#define BOOST_TEST_MAIN
19#define BOOST_TEST_DYN_LINK
20#include <boost/test/unit_test.hpp>
25
26namespace o2
27{
28namespace tpc
29{
30
31using DataT = double;
32static constexpr DataT TOLERANCE = 0.15; // relative tolerance
33static constexpr DataT ABSTOLERANCE = 0.003; // absolute tolerance is taken at small values near 0
34static constexpr unsigned short NR = 65; // grid in r
35static constexpr unsigned short NZ = 65; // grid in z
36static constexpr unsigned short NPHI = 90; // grid in phi
37
38BOOST_AUTO_TEST_CASE(PoissonSolver3D_test)
39{
40 const ParamSpaceCharge params{NR, NZ, NPHI};
41
42 // define min range
46
50
51 // create grid and datacontainer object
52 o2::tpc::RegularGrid3D<DataT> grid3D(zmin, rmin, phimin, zSpacing, rSpacing, phiSpacing, params);
53 o2::tpc::DataContainer3D<DataT> data3D(NZ, NR, NPHI);
54
55 // function to approximate
57
58 // fill the DataContainer3D with some values
59 for (int iz = 0; iz < NZ; ++iz) {
60 for (int ir = 0; ir < NR; ++ir) {
61 for (int iphi = 0; iphi < NPHI; ++iphi) {
62 const DataT z = zSpacing * iz + zmin;
63 const DataT r = rSpacing * ir + rmin;
64 const DataT phi = phiSpacing * iphi + phimin;
65 data3D(iz, ir, iphi) = field.evalPotential(z, r, phi);
66 }
67 }
68 }
69
70 // create tricubic interpolator
71 o2::tpc::TriCubicInterpolator<DataT> interpolator(data3D, grid3D);
72
73 const float nFacLoop = 1.4;
74 const int nrPointsLoop = NR * nFacLoop;
75 const int nzPointsLoop = NZ * nFacLoop;
76 const int nphiPointsLoop = NPHI * nFacLoop;
77 const DataT rSpacingLoop = GridProperties<DataT>::getGridSpacingR(nrPointsLoop);
78 const DataT zSpacingLoop = GridProperties<DataT>::getGridSpacingZ(nzPointsLoop);
79 const DataT phiSpacingLoop = GridProperties<DataT>::getGridSpacingZ(nphiPointsLoop);
80
81 for (int iR = -2; iR < nrPointsLoop + 2; ++iR) {
82 const DataT r = rmin + iR * rSpacingLoop;
83 for (int iZ = 0; iZ < nzPointsLoop; ++iZ) {
84 const DataT z = zmin + iZ * zSpacingLoop;
85 for (int iPhi = -2; iPhi < nphiPointsLoop + 2; ++iPhi) {
86 DataT phi = phimin + iPhi * phiSpacingLoop;
87 const DataT interpolatedSparse = interpolator(z, r, phi);
88 const DataT trueValue = field.evalPotential(z, r, phi);
89
90 // use larger tolerances at the edges of the grid
91 const int facTol = ((iR < nFacLoop) || (iZ < nFacLoop) || (iR >= nrPointsLoop - 1 - nFacLoop) || (iZ >= nzPointsLoop - 1 - nFacLoop)) ? 10 : 1;
92 if (std::abs(trueValue) < 0.1) {
93 BOOST_CHECK_SMALL(trueValue - interpolatedSparse, facTol * ABSTOLERANCE);
94 } else {
95 BOOST_CHECK_CLOSE(interpolatedSparse, trueValue, facTol * TOLERANCE);
96 }
97 }
98 }
99 }
100}
101
102} // namespace tpc
103} // namespace o2
This class provides a simple method to store values on a large 3-Dim grid with ROOT io functionality.
This file provides all necesseray classes which are used during the calcution of the distortions and ...
Definition of TriCubic class.
DataT evalPotential(DataT z, DataT r, DataT phi) const
GLenum const GLfloat * params
Definition glcorearb.h:272
GLboolean r
Definition glcorearb.h:1233
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
BOOST_AUTO_TEST_CASE(ClusterHardware_test1)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static constexpr DataT getGridSpacingR(const unsigned int nR)
static constexpr DataT getGridSpacingZ(const unsigned int nZ)
static constexpr DataT getGridSpacingPhi(const unsigned int nPhi)
o2::InteractionRecord ir(0, 0)