diff --git a/algo/kf/core/geo/KfField.cxx b/algo/kf/core/geo/KfField.cxx index 74172f541c1864ed0f3c855074a27ff8df8ce21a..a1c6632af73e8be960216f9a6fd241f39f04cd47 100644 --- a/algo/kf/core/geo/KfField.cxx +++ b/algo/kf/core/geo/KfField.cxx @@ -50,6 +50,19 @@ std::string FieldBase<T, EFieldMode::Orig>::ToString(int indentLevel, int /*verb return msg.str(); } +// --------------------------------------------------------------------------------------------------------------------- +// +template<typename T> +void Field<T>::RemoveSlice(int iLayer) +{ + if (fFieldMode == EFieldMode::Orig) { + foFldOrig->RemoveSlice(iLayer); + } + else if (fFieldMode == EFieldMode::Intrpl) { + foFldIntrpl->RemoveSlice(iLayer); + } +} + // --------------------------------------------------------------------------------------------------------------------- // template<typename T> diff --git a/algo/kf/core/geo/KfField.h b/algo/kf/core/geo/KfField.h index 218c7ed1ea06ba752e10ba07c2b23fe230440e76..d35db8d3e96bdf37ed0c3d0b4ca5ba67bf00c443 100644 --- a/algo/kf/core/geo/KfField.h +++ b/algo/kf/core/geo/KfField.h @@ -87,6 +87,10 @@ namespace cbm::algo::kf /// \brief Makes field region FieldRegion<T> MakeFieldRegion(EFieldType fldType) const { return FieldRegion(fldType, fFieldFn); } + /// \brief Removes a field slice + /// \param iLayer Index of field slice + void RemoveSlice(int iLayer) { fvFieldSliceZ.erase(fvFieldSliceZ.begin() + iLayer); } + /// \brief Sets magnetic field function /// \param fieldFn Magnetic field function (KF-format) void SetFieldFunction(const FieldFn_t& fieldFn) { fFieldFn = fieldFn; } @@ -171,6 +175,10 @@ namespace cbm::algo::kf return FieldRegion<T>(fldType, b0, z0, b1, z1, b2, z2); } + /// \brief Removes a field slice + /// \param iLayer Index of field slice + void RemoveSlice(int iLayer) { fvFieldSlices.erase(fvFieldSlices.begin() + iLayer); } + /// \brief String representation of the class /// \param indentLevel Indent level of the string output /// \param verbose Verbosity level @@ -277,6 +285,10 @@ namespace cbm::algo::kf : FieldRegion<T>(fFieldType, foFldOrig->GetFieldFunction())); } + /// \brief Removes a field slice + /// \param iLayer Index of field slice + void RemoveSlice(int iLayer); + /// \brief String representation of the class /// \param indentLevel Indent level of the string output /// \param verbose Verbosity level diff --git a/algo/kf/core/geo/KfMaterialMap.cxx b/algo/kf/core/geo/KfMaterialMap.cxx index 5708155e66ef5d3d1ad01b096ccfa021b7bb73da..c4024ef5823c0fd43fae21953b99a2e0a6441c8d 100644 --- a/algo/kf/core/geo/KfMaterialMap.cxx +++ b/algo/kf/core/geo/KfMaterialMap.cxx @@ -52,7 +52,7 @@ void MaterialMap::Add(const MaterialMap& other, float zTarg) { // The function allows to add a material layer either from the left or from the right to the station // NOTE: A symmetry of x-y is assumed - constexpr int nRays{100}; // Number of rays in a bin in a dimension + constexpr int nRays{3}; // Number of rays in a bin in a dimension const bool bRadialRays{!std::isnan(zTarg)}; // Are rays radial (true, coming from target) or parallel (false)? const auto scaleFactor{bRadialRays ? ((other.fZref - zTarg) / (this->fZref - zTarg)) : 1.F}; const auto binSize{2.F * scaleFactor * this->fXYmax / this->fNbins}; // Size of each bin dimension [cm] diff --git a/algo/kf/core/geo/KfMaterialMap.h b/algo/kf/core/geo/KfMaterialMap.h index 46e40f00922f9b6ce8e409bbb51f895c8cc463a1..7c25dca012a8f82f73e63c106ea98e3f5d3505d3 100644 --- a/algo/kf/core/geo/KfMaterialMap.h +++ b/algo/kf/core/geo/KfMaterialMap.h @@ -77,12 +77,12 @@ namespace cbm::algo::kf /// \param x X coordinate of the point [cm] /// \param y Y coordinate of the point [cm] template<typename I> - I GetThickness(const I& x, const I& y) const + I GetThicknessX0(const I& x, const I& y) const { if constexpr (std::is_same_v<I, fvec>) { fvec res; for (size_t i = 0; i < utils::simd::Size<I>(); ++i) { - res[i] = GetThickness(x[i], y[i]); + res[i] = GetThicknessX0(x[i], y[i]); } return res; } diff --git a/algo/kf/core/geo/KfModuleIndexMap.h b/algo/kf/core/geo/KfModuleIndexMap.h index 78c186de40ecc2489a46445a4013870690e2f897..4e4ff0696b08bfd4700e9fb18c3273a86e10afe7 100644 --- a/algo/kf/core/geo/KfModuleIndexMap.h +++ b/algo/kf/core/geo/KfModuleIndexMap.h @@ -160,7 +160,19 @@ namespace cbm::algo::kf return; // Nothing to disable, detector is already not in the map } - //auto iGeoDsbl{LocalToGeo(locIdDisable, detIdDisable)}; + auto iDetIntDsbl{fvDetExtToInt[iDetExtDsbl]}; + if (fvDetLocOffset[iDetIntDsbl + 1] <= locIdDisable) { + return; // Nothing to disable, component is already not in the map + } + + auto& iGlbDsbl = fvLocToGlb[fvDetLocOffset[iDetIntDsbl] + locIdDisable]; + if (iGlbDsbl == -1) { + return; // Nothing to disable, component is already inactive + } + + fvGlbToLoc.erase(fvGlbToLoc.begin() + iGlbDsbl); // Removing component from glob->(det, loc) map + iGlbDsbl = -1; + // NOTE: information on disabled detectors stays there, probably we should remove it } // ------------------------------------------------------------------------------------------------------------------- diff --git a/algo/kf/core/geo/KfSetup.h b/algo/kf/core/geo/KfSetup.h index 39ce0ca7756c979600efb577ad414dc3ffde3b1b..a147f0b9778e299dbd23c3e746011d46fc746346 100644 --- a/algo/kf/core/geo/KfSetup.h +++ b/algo/kf/core/geo/KfSetup.h @@ -69,6 +69,13 @@ namespace cbm::algo::kf /// \brief Move assignment operator //Setup& operator=(Setup&&) noexcept; + /// \brief Disables geo layer + /// \tparam EDetID Index of the detector subsystem + /// \param iDet DetectorID + /// \param iLoc Local index of the module + template<class EDetID> + void DisableLayer(EDetID iDet, int iLoc); + /// \brief Makes an instance of the field depending on the template parameter /// \throw std::logic_error If the particular field member is undefined (nullopt) const Field<T>& GetField() const { return fField; } @@ -117,4 +124,30 @@ namespace cbm::algo::kf Target<T> fTarget; ///< Target layer }; + + // ------------------------------------------------------------------------------------------------------------------- + // + template<typename T> + template<class EDetID> + void Setup<T>::DisableLayer(EDetID iDet, int iLoc) + { + int iLayer{fModuleIndexMap.LocalToGlobal(iDet, iLoc)}; + if (iLayer == -1) { + return; + } + + // Remove material layer and add it to the next one + if (iLayer < static_cast<int>(fvMaterialLayers.size() - 1)) { + fvMaterialLayers[iLayer + 1].Add(fvMaterialLayers[iLayer], utils::simd::Cast<T, float>(fTarget.GetZ())); + } + fvMaterialLayers.erase(fvMaterialLayers.begin() + iLayer); + + // Remove field slice + fField.RemoveSlice(iLayer); + + // Disable layer in the index map + fModuleIndexMap.Disable(iDet, iLoc); + } + + } // namespace cbm::algo::kf diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 55488de21295ac3ff8f8b233113ff821d0790dd0..a66a0741ff37da11bfb4d062e4f8d0a49adb7b67 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -610,27 +610,27 @@ try { // TEST: material maps { Node n{.iSt = 1, .x = 2.3, .y = 1.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThickness(n.x, n.y) << " -- " + LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); } { Node n{.iSt = 1, .x = -2.3, .y = -1.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThickness(n.x, n.y) << " -- " + LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); } { Node n{.iSt = 1, .x = 2.5, .y = 0.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThickness(n.x, n.y) << " -- " + LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); } { Node n{.iSt = 4, .x = 5.3, .y = -2.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThickness(n.x, n.y) << " -- " + LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); } { Node n{.iSt = 4, .x = 0, .y = -1.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThickness(n.x, n.y) << " -- " + LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); } }