16#define BOOST_TEST_MODULE Test TPC Fast Transformation
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19#include <boost/test/unit_test.hpp>
30#include <fairlogger/Logger.h>
59 double maxDx = 0, maxDy = 0;
61 for (
int row = 0;
row < geo.getNumberOfRows();
row++) {
63 int nPads = geo.getRowInfo(
row).maxPad + 1;
67 double x = geo.getRowInfo(
row).x;
71 for (
int pad = 0; pad < nPads; pad++) {
77 fastTransform.convPadTimeToLocal(sector,
row, pad,
time,
y,
z, 0.);
78 double dx =
x -
c.X();
79 double dy =
y - (-
c.Y());
82 if (fabs(dy) >= 1.e-5) {
83 std::cout <<
"row " <<
row <<
" pad " << pad <<
" y calc " <<
y <<
" y in map " << -
c.Y() <<
" dy " << dy << std::endl;
85 if (fabs(maxDx) < fabs(dx)) {
88 if (fabs(maxDy) < fabs(dy)) {
108 auto correctionUV = [&](
int sector,
int ,
const double u,
const double v,
double& dX,
double& dU,
double& dV) {
110 dX = 1. + 1 * u + 0.1 * u * u;
111 dU = 2. + 0.2 * u + 0.002 * u * u;
112 dV = 3. + 0.1 *
v + 0.01 *
v *
v;
115 auto correctionLocal = [&](
int sector,
int row,
double ly,
double lz,
116 double& dx,
double& dly,
double& dlz) {
118 geo.convLocalToUV(sector, ly, lz, u,
v);
120 correctionUV(sector,
row, u,
v, dx, du, dv);
122 geo.convUVtoLocal(sector, u + du,
v + dv, ly1, lz1);
128 int nRows = geo.getNumberOfRows();
130 scData.
init(nSectors, nRows);
133 for (
int iRow = 0; iRow <
nRows; iRow++) {
134 double dsu = 1. / (3 * 8 - 3);
135 double dsv = 1. / (3 * 20 - 3);
136 for (
double su = 0.f; su < 1.f + .5 * dsu; su += dsv) {
137 for (
double sv = 0.f; sv < 1.f + .5 * dsv; sv += dsv) {
138 float ly = 0.f, lz = 0.f;
139 geo.convScaledUVtoLocal(
iSector, iRow, su, sv, ly, lz);
141 correctionLocal(
iSector, iRow, ly, lz, dx, dy, dz);
151 int err = fastTransform->writeToFile(
"tmpTestTPCFastTransform.root");
159 double statDiff = 0., statN = 0.;
160 double statDiffFile = 0., statNFile = 0.;
167 float lastTimeBin = fastTransform->getMaxDriftTime(sector, 0.f);
169 for (
int row = 0;
row < geo.getNumberOfRows();
row++) {
171 int nPads = geo.getRowInfo(
row).maxPad + 1;
173 for (
int pad = 0; pad < nPads; pad += 10) {
178 fastTransform->setApplyCorrectionOff();
180 fastTransform->Transform(sector,
row, pad,
time,
x0,
y0, z0);
184 fastTransform->setApplyCorrectionOn();
186 fastTransform->Transform(sector,
row, pad,
time,
x1,
y1, z1);
189 float u0,
v0, u1,
v1;
190 geo.convLocalToUV(sector,
y0, z0, u0,
v0);
191 geo.convLocalToUV(sector,
y1, z1, u1,
v1);
193 correctionUV(sector,
row, u0,
v0, dx, du, dv);
194 statDiff += fabs((
x1 -
x0) - dx) + fabs((u1 - u0) - du) + fabs((
v1 -
v0) - dv);
200 fromFile->Transform(sector,
row, pad,
time, x1f, y1f, z1f);
201 statDiffFile += fabs(x1f -
x1) + fabs(y1f -
y1) + fabs(z1f - z1);
212 statDiffFile /= statNFile;
215 std::cout <<
"average difference in correction " << statDiff <<
" cm " << std::endl;
216 BOOST_CHECK_MESSAGE(fabs(statDiff) < 1.e-3,
"test of correction map failed, average difference " << statDiff <<
" cm is too large");
217 BOOST_CHECK_MESSAGE(fabs(statDiffFile) < 1.e-10,
"test of file streamer failed, average difference " << statDiffFile <<
" cm is too large");
219 double maxDeviation = fastTransform->getCorrection().testInverse();
220 std::cout <<
"max deviation for inverse correction " << maxDeviation <<
" cm " << std::endl;
221 BOOST_CHECK_MESSAGE(fabs(maxDeviation) < 1.e-2,
"test of inverse correction map failed, max difference " << maxDeviation <<
" cm is too large");
Definition of the parameter class for the detector.
Definition of the parameter class for the detector electronics.
Definition of the parameter class for the detector gas.
void init(int32_t nSectors, int32_t nRows)
(re-)init the map
void addCorrectionPoint(int32_t iSector, int32_t iRow, double y, double z, double dx, double dy, double dz, double weight)
Starts the construction procedure, reserves temporary memory.
int getNumberOfRows() const
int getNumberOfPadsInRowSector(int row) const
GlobalPadNumber globalPadNumber(const PadPos &globalPadPosition) const
static Mapper & instance(const std::string mappingDir="")
const PadCentre & padCentre(GlobalPadNumber padNumber) const
static constexpr int MAXSECTOR
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLuint GLfloat GLfloat y0
GLdouble GLdouble GLdouble z
ConcreteParserVariants< PageSize, BOUNDS_CHECKS > create(T const *buffer, size_t size)
create a raw parser depending on version of RAWDataHeader found at beginning of data
float float float float z1
BOOST_AUTO_TEST_CASE(ClusterHardware_test1)
constexpr std::array< int, nLayers > nRows
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())