36 assert(rmin < rmax && zmax > 0 && dz > 0 && drphi > 0);
38 int nlr = getNLayers();
50 for (
int il = 0; il < nlr; il++) {
52 if (lr.getRMax() > rmin && rmax > lr.getRMin()) {
53 LOG(fatal) <<
"new layer overlaps with layer " << il;
58 for (
int i = nlr;
i--;) {
59 oldLayers[
i].clearInternalBufferPtr();
62 get()->mLayers[nlr].initSegmentation(rmin, rmax, zmax, dz, drphi);
64 get()->mRMin = get()->mRMin > rmin ? rmin : get()->mRMin;
65 get()->mRMax = get()->mRMax < rmax ? rmax : get()->mRMax;
66 get()->mZMax = get()->mZMax < zmax ? zmax : get()->mZMax;
67 get()->mRMin2 = get()->mRMin * get()->mRMin;
68 get()->mRMax2 = get()->mRMax * get()->mRMax;
99 int nlr = getNLayers();
100 int nR2Int = 2 * (nlr + 1);
103 get()->mR2Intervals[0] = get()->mRMin2;
104 get()->mR2Intervals[1] = get()->mRMax2;
105 get()->mInterval2LrID[0] = 0;
106 auto& nRIntervals = get()->mNRIntervals;
109 for (
int i = 1;
i < nlr;
i++) {
111 if (o2::math_utils::sqrt(lr.getRMin2()) > o2::math_utils::sqrt(get()->mR2Intervals[nRIntervals] +
Ray::Tiny)) {
113 get()->mInterval2LrID[nRIntervals] = -1;
114 get()->mR2Intervals[++nRIntervals] = lr.getRMin2();
116 get()->mInterval2LrID[nRIntervals] =
i;
117 get()->mR2Intervals[++nRIntervals] = lr.getRMax2();
130 for (
int i = 0;
i < getNLayers();
i++) {
132 float r = 0.5 * (lr.getRMin() + lr.getRMax());
134 int nphib = lr.getNPhiBins();
135 for (
int ip = 0; ip < nphib; ip++) {
136 float phi = 0.5 * (lr.getPhiBinMin(ip) + lr.getPhiBinMax(ip));
138 int ips = lr.phiBin2Slice(ip);
140 if (ip + 1 < nphib) {
141 int ips1 = lr.phiBin2Slice(ip + 1);
142 merge = ips == ips1 ? -1 : lr.canMergePhiSlices(ips, ips1);
146 o2::math_utils::sincos(phi, sn, cs);
147 float x =
r * cs,
y =
r * sn;
148 for (
int iz = 0; iz < lr.getNZBins(); iz++) {
149 float z = 0.5 * (lr.getZBinMin(iz) + lr.getZBinMax(iz));
150 auto cell = lr.getCellPhiBin(ip, iz);
152 <<
"ilr=" <<
i <<
"r=" <<
r <<
"phi=" << phi <<
"x=" <<
x <<
"y=" <<
y <<
"z=" <<
z <<
"ip=" << ip <<
"ips=" << ips <<
"iz=" << iz
153 <<
"mrgnxt=" <<
merge <<
"val=" << cell <<
"\n";
159 lr.getMeanRMS(mean, rms);
161 <<
"ilr=" <<
i <<
"r=" <<
r <<
"mean=" << mean <<
"rms=" << rms <<
"\n";
312 if (ray.isTooShort() || !getLayersRange(ray, lmin, lmax)) {
313 rval.
length = ray.getDist();
317 while (lrID >= lmin) {
318 const auto& lr = getLayer(lrID);
319 int nphiSlices = lr.getNPhiSlices();
320 int nc = ray.crossLayer(lr);
321 for (
int ic = nc; ic--;) {
322 float cross1, cross2;
323 ray.getCrossParams(ic, cross1, cross2);
325 auto phi0 = ray.getPhi(cross1), phi1 = ray.getPhi(cross2), dPhi = phi0 - phi1;
326 auto phiID = lr.getPhiSliceID(phi0), phiIDLast = lr.getPhiSliceID(phi1);
330 phiIDLast += nphiSlices;
338 int stepPhiID = phiID > phiIDLast ? -1 : 1;
339 bool checkMorePhi =
true;
340 auto tStartPhi = cross1, tEndPhi = 0.f;
343 if (phiID == phiIDLast) {
345 checkMorePhi =
false;
347 tEndPhi = ray.crossRadial(lr, (stepPhiID > 0 ? phiID + 1 : phiID) % nphiSlices);
352 auto zID = lr.getZBinID(ray.getZ(tStartPhi));
353 auto zIDLast = lr.getZBinID(ray.getZ(tEndPhi));
357 printf(
"-- Zdiff (%3d : %3d) mode: t: %+e %+e\n", zID, zIDLast, tStartPhi, tEndPhi);
360 if (zID != zIDLast) {
361 auto stepZID = zID < zIDLast ? 1 : -1;
362 bool checkMoreZ =
true;
363 auto tStartZ = tStartPhi, tEndZ = 0.f;
365 if (zID == zIDLast) {
369 tEndZ = ray.crossZ(lr.getZBinMin(stepZID > 0 ? zID + 1 : zID));
375 float step = tEndZ > tStartZ ? tEndZ - tStartZ : tStartZ - tEndZ;
376 const auto& cell = lr.getCell(phiID % nphiSlices, zID);
377 rval.
meanRho += cell.meanRho * step;
378 rval.
meanX2X0 += cell.meanX2X0 * step;
382 float pos0[3] = {ray.getPos(tStartZ, 0), ray.getPos(tStartZ, 1), ray.getPos(tStartZ, 2)};
383 float pos1[3] = {ray.getPos(tEndZ, 0), ray.getPos(tEndZ, 1), ray.getPos(tEndZ, 2)};
385 "Lr#%3d / cross#%d : account %f<t<%f at phiSlice %d | Zbin: %3d (%3d) |[%+e %+e +%e]:[%+e %+e %+e] "
386 "Step: %.3e StrpCor: %.3e\n",
387 lrID, ic, tEndZ, tStartZ, phiID % nphiSlices, zID, zIDLast,
388 pos0[0], pos0[1], pos0[2], pos1[0], pos1[1], pos1[2], step, ray.getDist(step));
393 }
while (checkMoreZ);
395 float step = tEndPhi > tStartPhi ? tEndPhi - tStartPhi : tStartPhi - tEndPhi;
396 const auto& cell = lr.getCell(phiID % nphiSlices, zID);
397 rval.
meanRho += cell.meanRho * step;
398 rval.
meanX2X0 += cell.meanX2X0 * step;
402 float pos0[3] = {ray.getPos(tStartPhi, 0), ray.getPos(tStartPhi, 1), ray.getPos(tStartPhi, 2)};
403 float pos1[3] = {ray.getPos(tEndPhi, 0), ray.getPos(tEndPhi, 1), ray.getPos(tEndPhi, 2)};
405 "Lr#%3d / cross#%d : account %f<t<%f at phiSlice %d | Zbin: %3d ----- |[%+e %+e +%e]:[%+e %+e %+e]"
406 "Step: %.3e StrpCor: %.3e\n",
407 lrID, ic, tEndPhi, tStartPhi, phiID % nphiSlices, zID,
408 pos0[0], pos0[1], pos0[2], pos1[0], pos1[1], pos1[2], step, ray.getDist(step));
415 }
while (checkMorePhi);
424 rval.
length = ray.getDist();
439 ray.getMinMaxR2(rmin2, rmax2);
441 if (rmin2 >= getRMax2() || rmax2 <= getRMin2()) {
445 if (!mInitializedLayerVoxelLU) {
446 lmxInt = rmax2 < getRMax2() ? searchSegment(rmax2, 0) :
get()->mNRIntervals - 2;
447 lmnInt = rmin2 >= getRMin2() ? searchSegment(rmin2, 0, lmxInt + 1) : 0;
449 lmxInt = rmax2 < getRMax2() ? searchLayerFast(rmax2, 0) :
get()->mNRIntervals - 2;
450 lmnInt = rmin2 >= getRMin2() ? searchLayerFast(rmin2, 0, lmxInt + 1) : 0;
453 const auto* interval2LrID =
get()->mInterval2LrID;
454 lmax = interval2LrID[lmxInt];
455 lmin = interval2LrID[lmnInt];
458 lmax = interval2LrID[lmxInt - 1];
461 lmin = interval2LrID[lmnInt + 1];
469 const auto index = 2 *
int(o2::gpu::CAMath::Sqrt(r2) * InvVoxelRDelta);
470 const auto layersfirst = mLayerVoxelLU[
index];
471 const auto layerslast = mLayerVoxelLU[
index + 1];
472 if (layersfirst != layerslast) {
474 return searchSegment(r2, layersfirst, layerslast + 1);
486 high =
get()->mNRIntervals;
488 int mid = (low + high) >> 1;
489 const auto* r2Intervals =
get()->mR2Intervals;
491 if (
val < r2Intervals[mid]) {
496 mid = (low + high) >> 1;
502#ifndef GPUCA_ALIGPUCODE
514 int nLr = getNLayers();
520 for (
int i = nLr;
i--;) {
521 oldLayers[
i].clearInternalBufferPtr();
534 for (
int il = 0; il < nLr; il++) {