38static double K1x[2], K1y[2];
39static double K2x[2], K2y[2];
42static double K3x[2], K3y[2];
43static double K4x[2], K4y[2];
45static double invPitch[2];
50static double splineXYStep = 1.0e-3;
51static double splineXYLimit = 3.0;
52static int nSplineSampling = 0;
78 for (
int i = 0;
i < 2;
i++) {
79 K3x[
i] = sqrtK3x[
i] * sqrtK3x[
i];
80 K3y[
i] = sqrtK3y[
i] * sqrtK3y[
i];
81 K2x[
i] = M_PI * 0.5 * (1.0 - sqrtK3x[
i] * 0.5);
82 K2y[
i] = M_PI * 0.5 * (1.0 - sqrtK3y[
i] * 0.5);
83 K1x[
i] = K2x[
i] * sqrtK3x[
i] * 0.25 / (atan(sqrtK3x[
i]));
84 K1y[
i] = K2y[
i] * sqrtK3y[
i] * 0.25 / (atan(sqrtK3y[
i]));
85 K4x[
i] = K1x[
i] / K2x[
i] / sqrtK3x[
i];
86 K4y[
i] = K1y[
i] / K2y[
i] / sqrtK3y[
i];
87 invPitch[
i] = 1.0 / pitch[
i];
97 double xyStep = splineXYStep;
98 double xyLimit = splineXYLimit;
100 nSplineSampling =
int(xyLimit / xyStep) + 1;
101 int N = nSplineSampling;
104 for (
int i = 0;
i < N;
i++) {
116 double mathPrimitive[N];
117 double rightDerivative(0.0), leftDerivative;
161 alpha[0] = 3.0 /
h * (
f[1] -
f[0]) - 3 * leftDerivative;
162 alpha[N - 1] = 3 * rightDerivative - 3.0 /
h * (
f[N - 1] -
f[N - 2]);
163 for (
int i = 1;
i < N - 1;
i++) {
171 double l[N], mu[N],
z[N];
177 for (
int i = 1;
i < N - 1;
i++) {
178 l[
i] = 2.0 * (xy[
i + 1] - xy[
i - 1]) -
h * mu[
i - 1];
184 l[N - 1] =
h * (2.0 - mu[N - 2]);
185 z[N - 1] = (
alpha[N - 1] -
h *
z[N - 2]) / l[N - 1];
189 for (
int j = N - 2;
j >= 0;
j--) {
190 c[
j] =
z[
j] - mu[
j] *
c[
j + 1];
191 b[
j] = (
f[
j + 1] -
f[
j]) /
h -
h / 3.0 * (
c[
j + 1] + 2 *
c[
j]);
192 d[
j] = (
c[
j + 1] -
c[
j]) / (3 *
h);
203 double dx = splineXYStep;
208 for (
int i = 0;
i < N;
i++) {
209 signX[
i] = (
x[
i] >= 0) ? 1 : -1;
210 uX[
i] = signX[
i] *
x[
i];
220 double cst = 1.0 / dx;
224 for (
int i = 0;
i < N;
i++) {
227 if (uX[
i] < splineXYLimit) {
228 idx =
int(uX[
i] * cst + dx * 0.1);
229 h = uX[
i] - idx * dx;
231 idx = nSplineSampling - 1;
234 mPrimitive[
i] = signX[
i] * (
a[idx] +
h * (
b[idx] +
h * (
c[idx] +
h * (d[idx]))));
246 int axe,
int chamberId,
double mPrimitive[])
254 double cst2xy = curK2xy * curInvPitch;
257 for (
int i = 0;
i < N;
i++) {
258 double u = curSqrtK3xy * tanh(cst2xy * xy[
i]);
259 mPrimitive[
i] = 2 * curK4xy * atan(u);
264 int axe,
int chamberId,
double mathieson[])
277 double cst2xy = curK2xy * curInvPitch;
279 for (
int i = 0;
i < N;
i++) {
281 double xTanh = tanh(cst2xy * xy[
i]);
282 double xTanh2 = xTanh * xTanh;
283 mathieson[
i] = curK1xy * (1.0 - xTanh2) / (1.0 + curK3xy * xTanh2);
288 double xy0,
int axe,
int chamberId,
double* integrals)
290 double zInf[N], zSup[N];
291 vectorAddScalar(xyInf, -xy0, N, zInf);
292 vectorAddScalar(xySup, -xy0, N, zSup);
297 int axe,
int chamberId,
double* Integrals)
309 double cst2 = curK2 * curInvPitch;
310 double cst4 = 2.0 * curK4;
313 for (
int i = 0;
i < N;
i++) {
315 uInf = curSqrtK3 * tanh(cst2 * xyInf[
i]);
316 uSup = curSqrtK3 * tanh(cst2 * xySup[
i]);
318 Integrals[
i] = cst4 * (atan(uSup) - atan(uInf));
337 const double*
x[2] = {
x1, x2};
338 int* xCode =
new int[2 * N];
339 for (
int i = 0;
i < N;
i++) {
340 for (
int b = 0;
b < 2;
b++) {
343 xCode[
i +
b * N] = (
int)(
x[
b][
i] * 1000 + 0.5);
348 for (
int k = 0; k < 2 * N; k++) {
351 std::sort(sIdx, &sIdx[2 * N], [=](
int a,
int b) {
352 return (xCode[
a] < xCode[
b]);
361 int prevCode = std::numeric_limits<int>::max();
364 for (
int i = 0;
i < 2 * N;
i++) {
366 if (xCode[idx] != prevCode) {
369 xCompress[nCompress] =
x1[idx];
370 map1[idx] = nCompress;
374 xCompress[nCompress] = x2[idx - N];
375 map2[idx - N] = nCompress;
382 map1[idx] = nCompress - 1;
385 map2[idx - N] = nCompress - 1;
389 prevCode = xCode[idx];
402 const double* yInf,
const double* ySup,
int N)
407 compressedPads->
mapXInf =
new int[N];
408 compressedPads->
mapXSup =
new int[N];
411 compressedPads->
mapYInf =
new int[N];
412 compressedPads->
mapYSup =
new int[N];
414 return compressedPads;
419 delete[] compressedPads->
mapXInf;
420 delete[] compressedPads->
mapXSup;
421 delete[] compressedPads->
mapYInf;
422 delete[] compressedPads->
mapYSup;
432 int chamberId,
double Integrals[])
435 int nXc = compressedPads->
nXc;
436 int nYc = compressedPads->
nYc;
439 double xPrimitives[nXc];
440 double yPrimitives[nYc];
444 vectorAddScalar(compressedPads->
xCompressed, -xShift, nXc, xy);
450 vectorAddScalar(compressedPads->
yCompressed, -yShift, nYc, xy);
455 int* mapXInf = compressedPads->
mapXInf;
456 int* mapXSup = compressedPads->
mapXSup;
457 int* mapYInf = compressedPads->
mapYInf;
458 int* mapYSup = compressedPads->
mapYSup;
459 for (
int i = 0;
i < N;
i++) {
460 Integrals[
i] = (xPrimitives[mapXSup[
i]] - xPrimitives[mapXInf[
i]]) * (yPrimitives[mapYSup[
i]] - yPrimitives[mapYInf[
i]]);
471 const double* yInf,
const double* ySup,
int N,
472 int chamberId,
double Integrals[])
475 int mapXInf[N], mapXSup[N];
476 int mapYInf[N], mapYSup[N];
482 double xPrimitives[nXc];
487 double yPrimitives[nYc];
491 for (
int i = 0;
i < N;
i++) {
492 Integrals[
i] = (xPrimitives[mapXSup[
i]] - xPrimitives[mapXInf[
i]]) * (yPrimitives[mapYSup[
i]] - yPrimitives[mapYInf[
i]]);
504 double lBoundPrim[N], uBoundPrim[N], xIntegrals[N], yIntegrals[N];
510 vectorAddVector(uBoundPrim, -1.0, lBoundPrim, N, xIntegrals);
512 for (
int i = 0;
i < N;
i++) {
513 if (xIntegrals[
i] < 0.0) {
514 printf(
"??? %d x (%f %f) lInt=%f uInt%f xInt=%f\n",
i, xInf[
i], xSup[
i], lBoundPrim[
i], uBoundPrim[
i], xIntegrals[
i]);
515 throw std::out_of_range(
516 "[findLocalMaxWithPEM] ????");
524 vectorAddVector(uBoundPrim, -1.0, lBoundPrim, N, yIntegrals);
526 vectorMultVector(xIntegrals, yIntegrals, N, Integrals);
529 for (
int i = 0;
i < N;
i++) {
530 if (yIntegrals[
i] < 0.0) {
531 printf(
"??? %d y (%f %f) lInt=%f uInt%f yInt=%f\n",
i, yInf[
i], ySup[
i], lBoundPrim[
i], uBoundPrim[
i], yIntegrals[
i]);
532 throw std::out_of_range(
533 "[findLocalMaxWithPEM] ????");
552 vectorMultVector(xIntegrals, yIntegrals, N, Integrals);
558 if (chamberId <= 2) {
572 double cst2x = curK2x * curInvPitch;
573 double cst2y = curK2y * curInvPitch;
574 double cst4 = 4.0 * curK4x * curK4y;
575 double uInf, uSup, vInf, vSup;
577 for (
int i = 0;
i < N;
i++) {
579 uInf = curSqrtK3x * tanh(cst2x * xInf[
i]);
580 uSup = curSqrtK3x * tanh(cst2x * xSup[
i]);
582 vInf = curSqrtK3y * tanh(cst2y * yInf[
i]);
583 vSup = curSqrtK3y * tanh(cst2y * ySup[
i]);
585 Integrals[
i] = cst4 * (atan(uSup) - atan(uInf)) * (atan(vSup) - atan(vInf));
601 const double* theta,
int N,
int K,
602 int chamberId,
double Integrals[])
608 vectorSetZero(Integrals, N);
619 double xyInfSup[4 * N];
620 double* xInf =
getXInf(xyInfSup, N);
621 double* yInf =
getYInf(xyInfSup, N);
622 double* xSup =
getXSup(xyInfSup, N);
623 double* ySup =
getYSup(xyInfSup, N);
624 for (
int k = 0; k < K; k++) {
625 vectorAddScalar(xInf0, -muX[k], N, xInf);
626 vectorAddScalar(xSup0, -muX[k], N, xSup);
627 vectorAddScalar(yInf0, -muY[k], N, yInf);
628 vectorAddScalar(ySup0, -muY[k], N, ySup);
631 vectorAddVector(Integrals,
w[k],
z, N, Integrals);
635bool checkIntegrals(
const double* xInf,
const double* xSup,
const double* yInf,
const double* ySup,
636 const double* integralsToCheck,
int chId,
int N)
638 double lBoundPrim[N], uBoundPrim[N];
639 double xIntegrals[N], yIntegrals[N], Integrals[N];
645 vectorAddVector(uBoundPrim, -1.0, lBoundPrim, N, xIntegrals);
657 vectorAddVector(uBoundPrim, -1.0, lBoundPrim, N, yIntegrals);
659 vectorMultVector(xIntegrals, yIntegrals, N, Integrals);
661 for (
int i = 0;
i < N;
i++) {
662 if (std::fabs(integralsToCheck[
i] - Integrals[
i]) >
precision) {
663 printf(
"i=%d xInf=%f xSup=%f, yInf=%f ySup=%f, reference=%f check value=%f\n",
i,
664 xInf[
i], xSup[
i], yInf[
i], ySup[
i], Integrals[
i], integralsToCheck[
i]);
666 throw std::out_of_range(
"[checkIntegral] bad integral value");
690 "[computeFastCij] exception: bad representation (mode) of pads in "
691 "computeCij (padMode=%d, pixelMode=%d)\n",
693 throw std::overflow_error(
"Bad mode");
700 const double* xInf0 = pads.
getXInf();
701 const double* yInf0 = pads.
getYInf();
702 const double* xSup0 = pads.
getXSup();
703 const double* ySup0 = pads.
getYSup();
705 const double* muX = pixel.
getX();
706 const double* muY = pixel.
getY();
713 std::map<int, double*> xMap;
714 std::map<int, double*> yMap;
715 for (
int k = 0; k < K; k++) {
718 int xCode = (
int)(muX[k] * 1000 + 0.5);
719 int yCode = (
int)(muY[k] * 1000 + 0.5);
720 if (xMap.find(xCode) == xMap.end()) {
722 vectorAddScalar(xInf0, -muX[k], N, zInf);
723 vectorAddScalar(xSup0, -muX[k], N, zSup);
725 double* xIntegrals =
new double[N];
727 xMap[xCode] = xIntegrals;
729 if (yMap.find(yCode) == yMap.end()) {
731 vectorAddScalar(yInf0, -muY[k], N, zInf);
732 vectorAddScalar(ySup0, -muY[k], N, zSup);
734 double* yIntegrals =
new double[N];
736 yMap[yCode] = yIntegrals;
739 vectorMultVector(xMap[xCode], yMap[yCode], N, &Cij[N * k]);
743 double xInf[N], xSup[N];
744 double yInf[N], ySup[N];
745 double lBoundPrim[N], uBoundPrim[N];
746 double xIntegrals[N], yIntegrals[N], Integrals[N];
750 vectorAddScalar(xInf0, -muX[k], N, xInf);
751 vectorAddScalar(xSup0, -muX[k], N, xSup);
752 vectorAddScalar(yInf0, -muY[k], N, yInf);
753 vectorAddScalar(ySup0, -muY[k], N, ySup);
758 for (
auto it = xMap.begin(); it != xMap.end(); ++it) {
761 for (
auto it = yMap.begin(); it != yMap.end(); ++it) {
783 "[computeFastCij] exception: bad representation (mode) of pads in "
784 "computeCij (padMode=%d, pixelMode=%d)\n",
786 throw std::overflow_error(
"Bad mode");
793 const double* xInf0 = pads.
getXInf();
794 const double* yInf0 = pads.
getYInf();
795 const double* xSup0 = pads.
getXSup();
796 const double* ySup0 = pads.
getYSup();
798 const double* muX = pixel.
getX();
799 const double* muY = pixel.
getY();
801 double xPixMin = vectorMin(muX, K);
802 double xPixMax = vectorMax(muX, K);
803 double yPixMin = vectorMin(muY, K);
804 double yPixMax = vectorMax(muY, K);
805 double dxMinPix = vectorMin(pixel.
getDX(), K);
806 double dyMinPix = vectorMin(pixel.
getDY(), K);
808 int nXPixels = (
int)((xPixMax - xPixMin) / dxMinPix + 0.5) + 1;
809 int nYPixels = (
int)((yPixMax - yPixMin) / dyMinPix + 0.5) + 1;
814 double* PadIntegralX =
new double[nXPixels * N];
815 double* PadIntegralY =
new double[nYPixels * N];
818 vectorSet((
double*)PadIntegralX, -1.0, nXPixels * N);
819 vectorSet((
double*)PadIntegralY, -1.0, nYPixels * N);
840 for (
int k = 0; k < K; k++) {
843 int xIdx = (
int)((muX[k] - xPixMin) / dxMinPix + 0.5);
844 int yIdx = (
int)((muY[k] - yPixMin) / dyMinPix + 0.5);
849 if (PadIntegralX[xIdx * N + 0] == -1) {
851 vectorAddScalar(xInf0, -muX[k], N, zInf);
852 vectorAddScalar(xSup0, -muX[k], N, zSup);
856 if (PadIntegralY[yIdx * N + 0] == -1) {
858 vectorAddScalar(yInf0, -muY[k], N, zInf);
859 vectorAddScalar(ySup0, -muY[k], N, zSup);
864 vectorMultVector(&PadIntegralX[xIdx * N + 0], &PadIntegralY[yIdx * N + 0], N, &Cij[N * k]);
866 double xInf[N], xSup[N];
867 double yInf[N], ySup[N];
868 double lBoundPrim[N], uBoundPrim[N];
869 double xIntegrals[N], yIntegrals[N], Integrals[N];
871 vectorAddScalar(xInf0, -muX[k], N, xInf);
872 vectorAddScalar(xSup0, -muX[k], N, xSup);
873 vectorAddScalar(yInf0, -muY[k], N, yInf);
874 vectorAddScalar(ySup0, -muY[k], N, ySup);
879 vectorAddVector(uBoundPrim, -1.0, lBoundPrim, N, xIntegrals);
883 vectorAddVector(uBoundPrim, -1.0, lBoundPrim, N, yIntegrals);
885 vectorMultVector(xIntegrals, yIntegrals, N, Integrals);
886 for (
int i = 0;
i < N;
i++) {
888 if (std::fabs(Cij[N * k +
i] - Integrals[
i]) > 1.0e-6) {
889 printf(
"i(pixel)=%d j(pad)=%d cij=%f xInt=%f yInt=%f fastcij=%f xFast=%f yFast=%f\n", k,
i,
890 Integrals[
i], xIntegrals[
i], yIntegrals[
i], Cij[N * k +
i], PadIntegralX[xIdx * N +
i], PadIntegralY[yIdx * N +
i]);
894 delete[] PadIntegralX;
895 delete[] PadIntegralY;
907 "computeFastCij] exception: bad representation (mode) of pads in "
908 "computeCij (padMode=%d, pixelMode=%d)\n",
910 throw std::overflow_error(
"Bad mode");
916 const double* xInf0 = pads.
getXInf();
917 const double* yInf0 = pads.
getYInf();
918 const double* xSup0 = pads.
getXSup();
919 const double* ySup0 = pads.
getYSup();
922 const double* muX = pixel.
getX();
923 const double* muY = pixel.
getY();
930 for (
int k = 0; k < K; k++) {
931 vectorAddScalar(xInf0, -muX[k], N, xInf);
932 vectorAddScalar(xSup0, -muX[k], N, xSup);
933 vectorAddScalar(yInf0, -muY[k], N, yInf);
934 vectorAddScalar(ySup0, -muY[k], N, ySup);
945 int nPixels =
pixels.getNbrOfPads();
946 double* Cij =
new double[nPads * nPixels];
947 double* diffCij =
new double[nPads * nPixels];
950 vectorAddVector(Cij, -1,
checkCij, nPads * nPixels, diffCij);
951 vectorAbs(diffCij, nPads * nPixels, diffCij);
952 double minDiff = vectorMin(diffCij, nPads * nPixels);
953 double maxDiff = vectorMax(diffCij, nPads * nPixels);
954 int argMax = vectorArgMax(diffCij, nPads * nPixels);
956 int iIdx = argMax / nPads;
957 int jIdx = argMax % nPads;
959 printf(
"\n\n[checkCij] min/max(checkCij-Cij)=(%f, %f) argmin/max=(i=%d, j=%d)\n",
960 minDiff, maxDiff, iIdx, jIdx);
961 printf(
"\n checkCij=%f differ from Cij=%f\n",
checkCij[iIdx * nPads + jIdx], Cij[iIdx * nPads + jIdx]);
965 for (
int k = 0; k < nPixels; k++) {
966 for (
int l = 0; l < nPads; l++) {
967 if (diffCij[k * nPads + l] >
precision) {
968 printf(
"pad=%d pixel=%d checkCij=%f Cij=%f diff=%f\n", l, k,
checkCij[k * nPads + l], Cij[k * nPads + l], diffCij[k * nPads + l]);
975 throw std::out_of_range(
"[checkCij] bad Cij value");
982double*
getVarX(
double* theta,
int K) {
return &theta[0 * K]; };
983double*
getVarY(
double* theta,
int K) {
return &theta[1 * K]; };
984double*
getMuX(
double* theta,
int K) {
return &theta[2 * K]; };
985double*
getMuY(
double* theta,
int K) {
return &theta[3 * K]; };
986double*
getW(
double* theta,
int K) {
return &theta[4 * K]; };
987double*
getMuAndW(
double* theta,
int K) {
return &theta[2 * K]; };
991 return &theta[0 * K];
995 return &theta[1 * K];
997const double*
getConstMuX(
const double* theta,
int K) {
return &theta[2 * K]; };
998const double*
getConstMuY(
const double* theta,
int K) {
return &theta[3 * K]; };
999const double*
getConstW(
const double* theta,
int K) {
return &theta[4 * K]; };
1002 return &theta[2 * K];
1006double*
getX(
double* xyDxy,
int N) {
return &xyDxy[0 * N]; };
1007double*
getY(
double* xyDxy,
int N) {
return &xyDxy[1 * N]; };
1008double*
getDX(
double* xyDxy,
int N) {
return &xyDxy[2 * N]; };
1009double*
getDY(
double* xyDxy,
int N) {
return &xyDxy[3 * N]; };
1011const double*
getConstX(
const double* xyDxy,
int N) {
return &xyDxy[0 * N]; };
1012const double*
getConstY(
const double* xyDxy,
int N) {
return &xyDxy[1 * N]; };
1013const double*
getConstDX(
const double* xyDxy,
int N) {
return &xyDxy[2 * N]; };
1014const double*
getConstDY(
const double* xyDxy,
int N) {
return &xyDxy[3 * N]; };
1017double*
getXInf(
double* xyInfSup,
int N) {
return &xyInfSup[0 * N]; };
1018double*
getYInf(
double* xyInfSup,
int N) {
return &xyInfSup[1 * N]; };
1019double*
getXSup(
double* xyInfSup,
int N) {
return &xyInfSup[2 * N]; };
1020double*
getYSup(
double* xyInfSup,
int N) {
return &xyInfSup[3 * N]; };
1023 return &xyInfSup[0 * N];
1027 return &xyInfSup[1 * N];
1031 return &xyInfSup[2 * N];
1035 return &xyInfSup[3 * N];
1038void copyTheta(
const double* theta0,
int K0,
double* theta,
int K1,
int K)
1045 double* wm =
getW(theta, K1);
1046 double* muXm =
getMuX(theta, K1);
1047 double* muYm =
getMuY(theta, K1);
1048 double* varXm =
getVarX(theta, K1);
1049 double* varYm =
getVarY(theta, K1);
1050 vectorCopy(
w, K, wm);
1051 vectorCopy(muX, K, muXm);
1052 vectorCopy(muY, K, muYm);
1053 vectorCopy(varX, K, varXm);
1054 vectorCopy(varY, K, varYm);
1057void copyXYdXY(
const double* xyDxy0,
int N0,
double* xyDxy,
int N1,
int N)
1059 const double* X0 =
getConstX(xyDxy0, N0);
1060 const double* Y0 =
getConstY(xyDxy0, N0);
1064 double* X =
getX(xyDxy, N1);
1065 double* Y =
getY(xyDxy, N1);
1066 double* DX =
getDX(xyDxy, N1);
1067 double* DY =
getDY(xyDxy, N1);
1069 vectorCopy(X0, N, X);
1070 vectorCopy(Y0, N, Y);
1071 vectorCopy(DX0, N, DX);
1072 vectorCopy(DY0, N, DY);
1083 printf(
"%s \n",
str);
1084 printf(
" k charge w muX muY sigX sigY\n");
1085 for (
int k = 0; k < K; k++) {
1086 printf(
" %.2d-th: %8.2g %6.3g %8.3g %8.3g %8.3g %8.3g\n", k,
w[k] * meanCharge,
w[k], muX[k],
1087 muY[k], sqrt(varX[k]), sqrt(varY[k]));
1092 const double* X =
getConstX(xyDxy, nxyDxy);
1093 const double* Y =
getConstY(xyDxy, nxyDxy);
1094 const double* DX =
getConstDX(xyDxy, nxyDxy);
1095 const double* DY =
getConstDY(xyDxy, nxyDxy);
1096 double* XInf =
getXInf(xyInfSup, nxyDxy);
1097 double* XSup =
getXSup(xyInfSup, nxyDxy);
1098 double* YInf =
getYInf(xyInfSup, nxyDxy);
1099 double* YSup =
getYSup(xyInfSup, nxyDxy);
1100 for (
int k = 0; k < nxyDxy; k++) {
1102 double xInf = X[k] - DX[k];
1103 double xSup = X[k] + DX[k];
1104 double yInf = Y[k] - DY[k];
1105 double ySup = Y[k] + DY[k];
1116 int nMask,
double* xyDxyMasked,
int nxyDxyMasked)
1118 const double* X =
getConstX(xyDxy, nxyDxy);
1119 const double* Y =
getConstY(xyDxy, nxyDxy);
1120 const double* DX =
getConstDX(xyDxy, nxyDxy);
1121 const double* DY =
getConstDY(xyDxy, nxyDxy);
1122 double* Xm =
getX(xyDxyMasked, nxyDxyMasked);
1123 double* Ym =
getY(xyDxyMasked, nxyDxyMasked);
1124 double* DXm =
getDX(xyDxyMasked, nxyDxyMasked);
1125 double* DYm =
getDY(xyDxyMasked, nxyDxyMasked);
1126 vectorGather(X,
mask, nMask, Xm);
1127 vectorGather(Y,
mask, nMask, Ym);
1128 vectorGather(DX,
mask, nMask, DXm);
1129 vectorGather(DY,
mask, nMask, DYm);
1133 int nMask,
double* xyDxyMasked,
int ndxyDxyMasked)
1135 const double* X =
getConstX(xyDxy, ndxyDxy);
1136 const double* Y =
getConstY(xyDxy, ndxyDxy);
1137 const double* DX =
getConstDX(xyDxy, ndxyDxy);
1138 const double* DY =
getConstDY(xyDxy, ndxyDxy);
1139 double* Xm =
getX(xyDxyMasked, ndxyDxyMasked);
1140 double* Ym =
getY(xyDxyMasked, ndxyDxyMasked);
1141 double* DXm =
getDX(xyDxyMasked, ndxyDxyMasked);
1142 double* DYm =
getDY(xyDxyMasked, ndxyDxyMasked);
1143 double* XmInf =
getXInf(xyDxyMasked, ndxyDxyMasked);
1144 double* XmSup =
getXSup(xyDxyMasked, ndxyDxyMasked);
1145 double* YmInf =
getYInf(xyDxyMasked, ndxyDxyMasked);
1146 double* YmSup =
getYSup(xyDxyMasked, ndxyDxyMasked);
1147 vectorGather(X,
mask, nMask, Xm);
1148 vectorGather(Y,
mask, nMask, Ym);
1149 vectorGather(DX,
mask, nMask, DXm);
1150 vectorGather(DY,
mask, nMask, DYm);
1151 for (
int k = 0; k < nMask; k++) {
1153 double xInf = Xm[k] - DXm[k];
1154 double xSup = Xm[k] + DXm[k];
1155 double yInf = Ym[k] - DYm[k];
1156 double ySup = Ym[k] + DYm[k];
1166 double* maskedTheta,
int maskedK)
1173 double* wm =
getW(maskedTheta, maskedK);
1174 double* muXm =
getMuX(maskedTheta, maskedK);
1175 double* muYm =
getMuY(maskedTheta, maskedK);
1176 double* varXm =
getVarX(maskedTheta, maskedK);
1177 double* varYm =
getVarY(maskedTheta, maskedK);
1178 vectorGather(
w,
mask, nMask, wm);
1179 vectorGather(muX,
mask, nMask, muXm);
1180 vectorGather(muY,
mask, nMask, muYm);
1181 vectorGather(varX,
mask, nMask, varXm);
1182 vectorGather(varY,
mask, nMask, varYm);
1186 const double* val1,
const double* val2)
1188 const double* X =
getConstX(xyDxy, NMax);
1189 const double* Y =
getConstY(xyDxy, NMax);
1193 printf(
"%s\n",
str);
1195 if (val1 !=
nullptr) {
1198 if (val2 !=
nullptr) {
1201 if ((nPrint == 1) && (val2 !=
nullptr)) {
1207 printf(
" pad %2d: %9.3g %9.3g %9.3g %9.3g \n",
i, X[
i], Y[
i], DX[
i],
1210 }
else if (nPrint == 1) {
1212 printf(
" pad %2d: %9.3g %9.3g %9.3g %9.3g - %9.3g \n",
i, X[
i], Y[
i],
1213 DX[
i], DY[
i], val1[
i]);
1217 printf(
" pad %d: %9.3g %9.3g %9.3g %9.3g - %9.3g %9.3g \n",
i, X[
i],
1218 Y[
i], DX[
i], DY[
i], val1[
i], val2[
i]);
1233 const double* yInf,
const double* ySup,
int N,
1234 int chamberId,
double Integrals[])
1241 int K,
int chamberId,
double Cij[])
1257 double xyInfSup[4 * N];
1262 for (
int k = 0; k < K; k++) {
1263 o2::mch::vectorAddScalar(xInf0, -muX[k], N, xInf);
1264 o2::mch::vectorAddScalar(xSup0, -muX[k], N, xSup);
1265 o2::mch::vectorAddScalar(yInf0, -muY[k], N, yInf);
1266 o2::mch::vectorAddScalar(ySup0, -muY[k], N, ySup);
1274 const double* theta,
int N,
1275 int K,
int chamberId,
1279 chamberId, Integrals);
Clustering and fifting parameters.
Class for time synchronization of RawReader instances.
const double * getX() const
const double * getXSup() const
@ xydxdyMode
x, y, dx, dy pad coordinates
@ xyInfSupMode
xInf=x, xSup=dx, yInf=y, ySup=dy pad coordinates
static int getNbrOfPads(const Pads *pads)
const double * getDY() const
const double * getYInf() const
const double * getY() const
const double * getXInf() const
const double * getYSup() const
const double * getDX() const
GLfloat GLfloat GLfloat alpha
GLuint GLfloat GLfloat GLfloat x1
GLboolean GLboolean GLboolean b
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
GLboolean GLboolean GLboolean GLboolean a
GLubyte GLubyte GLubyte GLubyte w
GLenum GLint GLint * precision
GLdouble GLdouble GLdouble z
void o2_mch_compute2DMathiesonMixturePadIntegrals(const double *xyInfSup0, const double *theta, int N, int K, int chamberId, double Integrals[])
void o2_mch_computeCij(const double *xyInfSup0, const double *pixel, int N, int K, int chamberId, double Cij[])
void o2_mch_initMathieson()
void o2_mch_compute2DPadIntegrals(const double *xInf, const double *xSup, const double *yInf, const double *ySup, int N, int chamberId, double Integrals[])
void initMathieson(int useSpline_, int useCache_)
const double * getConstXInf(const double *xyInfSup, int N)
void maskedCopyToXYInfSup(const double *xyDxy, int ndxyDxy, const Mask_t *mask, int nMask, double *xyDxyMasked, int ndxyDxyMasked)
void maskedCopyTheta(const double *theta, int K, const Mask_t *mask, int nMask, double *maskedTheta, int maskedK)
double * getMuY(double *theta, int K)
const double * getConstMuAndW(const double *theta, int K)
void printTheta(const char *str, double meanCharge, const double *theta, int K)
void compute2DPadIntegrals(const double *xInf, const double *xSup, const double *yInf, const double *ySup, int N, int chamberId, double Integrals[])
void printXYdXY(const char *str, const double *xyDxy, int NMax, int N, const double *val1, const double *val2)
double * getDX(double *xyDxy, int N)
bool checkIntegrals(const double *xInf, const double *xSup, const double *yInf, const double *ySup, const double *integralsToCheck, int chId, int N)
CompressedPads_t * compressPads(const double *xInf, const double *xSup, const double *yInf, const double *ySup, int N)
void computeFastCij(const Pads &pads, const Pads &pixel, double Cij[])
const double * getConstDX(const double *xyDxy, int N)
void splineMathiesonPrimitive(const double *x, int N, int axe, int chamberId, double *mPrimitive)
double * getX(double *xyDxy, int N)
double * getY(double *xyDxy, int N)
void compute1DPadIntegrals(const double *xyInf, const double *xySup, int N, double xy0, int axe, int chamberId, double *integrals)
double * getYSup(double *xyInfSup, int N)
void maskedCopyXYdXY(const double *xyDxy, int nxyDxy, const Mask_t *mask, int nMask, double *xyDxyMasked, int nxyDxyMasked)
double * getYInf(double *xyInfSup, int N)
const double * getConstVarY(const double *theta, int K)
void computeCij(const Pads &pads, const Pads &pixel, double Cij[])
void copyTheta(const double *theta0, int K0, double *theta, int K1, int K)
double * getMuAndW(double *theta, int K)
void initSplineMathiesonPrimitive()
SplineCoef * splineCoef[2][2]
const double * getConstW(const double *theta, int K)
double * getVarX(double *theta, int K)
void compute2DMathiesonMixturePadIntegrals(const double *xyInfSup0, const double *theta, int N, int K, int chamberId, double Integrals[])
void computeCompressed2DPadIntegrals(CompressedPads_t *compressedPads, double xShift, double yShift, int N, int chamberId, double Integrals[])
void checkCij(const Pads &pads, const Pads &pixels, const double *checkCij, int mode)
void xyDxyToxyInfSup(const double *xyDxy, int nxyDxy, double *xyInfSup)
const double * getConstDY(const double *xyDxy, int N)
double * getMuX(double *theta, int K)
void copyXYdXY(const double *xyDxy0, int N0, double *xyDxy, int N1, int N)
double * getXSup(double *xyInfSup, int N)
double * getW(double *theta, int K)
const double * getConstYInf(const double *xyInfSup, int N)
const double * getConstY(const double *xyDxy, int N)
const double * getConstX(const double *xyDxy, int N)
const double * getConstMuX(const double *theta, int K)
void deleteCompressedPads(CompressedPads_t *compressedPads)
double * getVarY(double *theta, int K)
double * getDY(double *xyDxy, int N)
const double * getConstXSup(const double *xyInfSup, int N)
const double * getConstMuY(const double *theta, int K)
ClusterConfig clusterConfig
int compressSameValues(const double *x1, const double *x2, int *map1, int *map2, int N, double *xCompress)
void compute1DMathieson(const double *xy, int N, int axe, int chamberId, double mathieson[])
const double * getConstVarX(const double *theta, int K)
void computeFastCijV0(const Pads &pads, const Pads &pixel, double Cij[])
void mathiesonPrimitive(const double *xy, int N, int axe, int chamberId, double mPrimitive[])
void computeSplineCoef(const double *xy, double xyStep, const double *f, int N, double leftDerivative, double rightDerivative, SplineCoef *splineCoef)
double * getXInf(double *xyInfSup, int N)
const double * getConstYSup(const double *xyInfSup, int N)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...