|
23 | 23 | //#define _DBG_LOC_ // for local debugging only |
24 | 24 |
|
25 | 25 | #endif // !GPUCA_ALIGPUCODE |
26 | | - |
| 26 | +#undef NDEBUG |
27 | 27 | using namespace o2::base; |
28 | 28 |
|
29 | 29 | using flatObject = o2::gpu::FlatObject; |
@@ -90,7 +90,15 @@ void MatLayerCylSet::populateFromTGeo(int ntrPerCell) |
90 | 90 | get()->mLayers[i].print(); |
91 | 91 | get()->mLayers[i].populateFromTGeo(ntrPerCell); |
92 | 92 | } |
| 93 | + finalizeStructures(); |
| 94 | +} |
| 95 | + |
| 96 | +//________________________________________________________________________________ |
| 97 | +void MatLayerCylSet::finalizeStructures() |
| 98 | +{ |
93 | 99 | // build layer search structures |
| 100 | + assert(mConstructionMask == InProgress); |
| 101 | + int nlr = getNLayers(); |
94 | 102 | int nR2Int = 2 * (nlr + 1); |
95 | 103 | o2::gpu::resizeArray(get()->mR2Intervals, 0, nR2Int); |
96 | 104 | o2::gpu::resizeArray(get()->mInterval2LrID, 0, nR2Int); |
@@ -525,3 +533,37 @@ void MatLayerCylSet::fixPointers(char* oldPtr, char* newPtr, bool newPtrValid) |
525 | 533 | } |
526 | 534 | } |
527 | 535 | #endif // !GPUCA_GPUCODE |
| 536 | + |
| 537 | +#ifndef GPUCA_ALIGPUCODE // this part is unvisible on GPU version |
| 538 | + |
| 539 | +MatLayerCylSet* MatLayerCylSet::extractCopy(float rmin, float rmax, float tolerance) const |
| 540 | +{ |
| 541 | + Ray ray(std::max(getRMin(), rmin), 0., 0., std::min(getRMax(), rmax), 0., 0.); |
| 542 | + short lmin, lmax; |
| 543 | + if (!getLayersRange(ray, lmin, lmax)) { |
| 544 | + LOGP(warn, "No layers found for {} < r < {}", rmin, rmax); |
| 545 | + return nullptr; |
| 546 | + } |
| 547 | + LOGP(info, "Will extract layers {}:{} (out of {} layers) for {} < r < {}", lmin, lmax, getNLayers(), rmin, rmax); |
| 548 | + MatLayerCylSet* copy = new MatLayerCylSet(); |
| 549 | + int lrCount = 0; |
| 550 | + for (int il = lmin; il <= lmax; il++) { |
| 551 | + const auto& lr = getLayer(il); |
| 552 | + float drphi = lr.getDPhi() * (lr.getRMin() + lr.getRMax()) / 2. * 0.999; |
| 553 | + copy->addLayer(lr.getRMin(), lr.getRMax(), lr.getZMax(), lr.getDZ(), drphi); |
| 554 | + auto& lrNew = copy->getLayer(lrCount); |
| 555 | + for (int iz = 0; iz < lrNew.getNZBins(); iz++) { |
| 556 | + for (int ip = 0; ip < lrNew.getNPhiBins(); ip++) { |
| 557 | + lrNew.getCellPhiBin(ip, iz).set(lr.getCellPhiBin(ip, iz)); |
| 558 | + } |
| 559 | + } |
| 560 | + lrCount++; |
| 561 | + } |
| 562 | + |
| 563 | + copy->finalizeStructures(); |
| 564 | + copy->optimizePhiSlices(tolerance); |
| 565 | + copy->flatten(); |
| 566 | + return copy; |
| 567 | +} |
| 568 | + |
| 569 | +#endif |
0 commit comments