Skip to content
Snippets Groups Projects
Commit a3afbc4e authored by Sergei Zharko's avatar Sergei Zharko Committed by Sergey Gorbunov
Browse files

bugfix: kf::MaterialMap::Add() function

parent d3e0d6e0
No related branches found
No related tags found
1 merge request!1952KF: material budget maps caching
......@@ -59,20 +59,20 @@ void MaterialMap::Add(const MaterialMap& other, float zTarg)
const auto stepSize{binSize / static_cast<float>(nRays)}; // Step between two neighboring rays [cm]
// The coordinates of the first ray intersection with the other material layer [cm]
float xBinOther{-this->fXYmax * scaleFactor + stepSize * 0.5F};
float yBinOther{xBinOther};
float yBinOther{-this->fXYmax * scaleFactor + stepSize * 0.5F};
// Loop over bins of the active (this)
for (int iBinY{0}; iBinY < this->fNbins; ++iBinY) {
float xBinOther{-this->fXYmax * scaleFactor + stepSize * 0.5F};
for (int iBinX{0}; iBinX < this->fNbins; ++iBinX) {
// Collect material using ray shooting
float avgThickness{0}; // Collected average thickness
for (int iRayY{0}; iRayY < nRays; ++iRayY) {
for (int iRayX{0}; iRayX < nRays; ++iRayX) {
avgThickness += other.GetThickness(xBinOther + iBinX * stepSize, yBinOther + iBinY * stepSize);
avgThickness += other.GetThicknessX0(xBinOther + iRayX * stepSize, yBinOther + iRayY * stepSize);
}
}
this->fTable[iBinX + this->fNbins * iBinY] += avgThickness / (nRays * nRays);
this->fTable[iBinX + this->fNbins * iBinY] += (avgThickness / (nRays * nRays));
xBinOther += binSize;
}
yBinOther += binSize;
......
......@@ -147,7 +147,7 @@ namespace cbm::algo::kf
}
auto& iGlbDsbl = fvLocToGlb[fvDetLocOffset[iDetIntDsbl] + locIdDisable];
if (iGlbDsbl == -1) {
if (iGlbDsbl < 0) {
return; // Nothing to disable, component is already inactive
}
......
......@@ -132,14 +132,12 @@ namespace cbm::algo::kf
void Setup<T>::DisableLayer(EDetID iDet, int iLoc)
{
int iLayer{fModuleIndexMap.LocalToGlobal(iDet, iLoc)};
std::cout << "Disabling layer: iDet = " << static_cast<int>(iDet) << ", iLoc = " << iLoc << ", iLayer = " << iLayer << '\n';
if (iLayer == -1) {
return;
}
// Remove material layer and add it to the next one
if (iLayer < static_cast<int>(fvMaterialLayers.size() - 1)) {
std::cout << " -- adding layer " << iLayer << " to layer " << iLayer + 1 << " with z = " << fvMaterialLayers[iLayer + 1].GetZref() << '\n';
fvMaterialLayers[iLayer + 1].Add(fvMaterialLayers[iLayer], utils::simd::Cast<T, float>(fTarget.GetZ()));
}
fvMaterialLayers.erase(fvMaterialLayers.begin() + iLayer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment