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++) {
75 fastTransform.convPadTimeToUV(0,
row, pad, 0, u,
v, 0.);
77 double dx =
x -
c.X();
78 double dy = u - (-
c.Y());
81 if (fabs(dy) >= 1.e-5) {
82 std::cout <<
"row " <<
row <<
" pad " << pad <<
" y calc " << u <<
" y in map " << -
c.Y() <<
" dy " << dy << std::endl;
84 if (fabs(maxDx) < fabs(dx)) {
87 if (fabs(maxDy) < fabs(dy)) {
107 auto correctionUV = [&](
int roc,
int ,
const double u,
const double v,
double& dX,
double& dU,
double& dV) {
109 dX = 1. + 1 * u + 0.1 * u * u;
110 dU = 2. + 0.2 * u + 0.002 * u * u;
111 dV = 3. + 0.1 *
v + 0.01 *
v *
v;
114 auto correctionLocal = [&](
int roc,
int row,
double ly,
double lz,
115 double& dx,
double& dly,
double& dlz) {
117 geo.convLocalToUV(
roc, ly, lz, u,
v);
119 correctionUV(
roc,
row, u,
v, dx, du, dv);
121 geo.convUVtoLocal(
roc, u + du,
v + dv, ly1, lz1);
126 int nRocs = geo.getNumberOfSlices();
127 int nRows = geo.getNumberOfRows();
129 scData.
init(nRocs, nRows);
131 for (
int iRoc = 0; iRoc < nRocs; iRoc++) {
132 for (
int iRow = 0; iRow <
nRows; iRow++) {
133 double dsu = 1. / (3 * 8 - 3);
134 double dsv = 1. / (3 * 20 - 3);
135 for (
double su = 0.f; su < 1.f + .5 * dsu; su += dsv) {
136 for (
double sv = 0.f; sv < 1.f + .5 * dsv; sv += dsv) {
137 float ly = 0.f, lz = 0.f;
138 geo.convScaledUVtoLocal(iRoc, iRow, su, sv, ly, lz);
140 correctionLocal(iRoc, iRow, ly, lz, dx, dy, dz);
150 int err = fastTransform->writeToFile(
"tmpTestTPCFastTransform.root");
158 double statDiff = 0., statN = 0.;
159 double statDiffFile = 0., statNFile = 0.;
161 for (
int slice = 0; slice < geo.getNumberOfSlices(); slice += 1) {
166 float lastTimeBin = fastTransform->getMaxDriftTime(slice, 0.f);
168 for (
int row = 0;
row < geo.getNumberOfRows();
row++) {
170 int nPads = geo.getRowInfo(
row).maxPad + 1;
172 for (
int pad = 0; pad < nPads; pad += 10) {
177 fastTransform->setApplyCorrectionOff();
179 fastTransform->Transform(slice,
row, pad,
time,
x0,
y0, z0);
183 fastTransform->setApplyCorrectionOn();
185 fastTransform->Transform(slice,
row, pad,
time,
x1,
y1, z1);
188 float u0,
v0, u1,
v1;
189 geo.convLocalToUV(slice,
y0, z0, u0,
v0);
190 geo.convLocalToUV(slice,
y1, z1, u1,
v1);
192 correctionUV(slice,
row, u0,
v0, dx, du, dv);
193 statDiff += fabs((
x1 -
x0) - dx) + fabs((u1 - u0) - du) + fabs((
v1 -
v0) - dv);
199 fromFile->Transform(slice,
row, pad,
time, x1f, y1f, z1f);
200 statDiffFile += fabs(x1f -
x1) + fabs(y1f -
y1) + fabs(z1f - z1);
211 statDiffFile /= statNFile;
214 std::cout <<
"average difference in correction " << statDiff <<
" cm " << std::endl;
215 BOOST_CHECK_MESSAGE(fabs(statDiff) < 1.e-3,
"test of correction map failed, average difference " << statDiff <<
" cm is too large");
216 BOOST_CHECK_MESSAGE(fabs(statDiffFile) < 1.e-10,
"test of file streamer failed, average difference " << statDiffFile <<
" cm is too large");
218 double maxDeviation = fastTransform->getCorrection().testInverse();
219 std::cout <<
"max deviation for inverse correction " << maxDeviation <<
" cm " << std::endl;
220 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 addCorrectionPoint(int32_t iRoc, int32_t iRow, double y, double z, double dx, double dy, double dz)
Starts the construction procedure, reserves temporary memory.
void init(int32_t nRocs, int32_t nRows)
(re-)init the map
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
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)
unsigned short GlobalPadNumber
global pad number
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())