diff --git a/algo/ca/core/pars/CaInitManager.cxx b/algo/ca/core/pars/CaInitManager.cxx index 14117a2d88f642af743b30f8b651ae076e2e2347..8edfa2a2c5f9e37a6fa217ba0ead02419fcad6ac 100644 --- a/algo/ca/core/pars/CaInitManager.cxx +++ b/algo/ca/core/pars/CaInitManager.cxx @@ -47,7 +47,6 @@ void InitManager::ClearSetupInfo() { // Clear stations set and a thickness map fvStationInfo.clear(); - fParameters.fThickMap.fill(ca::MaterialMap()); fInitController.SetFlag(EInitKey::kStationsInfo, false); // Set number of stations do default values @@ -133,17 +132,6 @@ bool InitManager::FormParametersContainer() } } - { // Form array of material map - auto destIt = fParameters.fThickMap.begin(); - for (auto& station : fvStationInfo) { - if (!station.GetTrackingStatus()) { - continue; - } - *destIt = std::move(station.TakeMaterialMap()); - ++destIt; - } - } - // Check the consistency of the parameters object. If object inconsistent, it throws std::logic_error try { fParameters.CheckConsistency(); diff --git a/algo/ca/core/pars/CaInitManager.h b/algo/ca/core/pars/CaInitManager.h index 84c7e5248d2ff66080e400f78758ae479046b515..b1dc5118f102aae2d8682a4b5aca126ec619fd54 100644 --- a/algo/ca/core/pars/CaInitManager.h +++ b/algo/ca/core/pars/CaInitManager.h @@ -237,6 +237,7 @@ namespace cbm::algo::ca /// \note The default seed is 1 void SetRandomSeed(unsigned int seed); + // TODO: Use kf::Setup instead /// \brief Sets target position /// \param x Position X component [cm] /// \param y Position Y component [cm] @@ -326,10 +327,6 @@ namespace cbm::algo::ca /// \param false the Kalman filter is be used in track finder void DevSetIsParSearchWUsed(bool value = true) { fParameters.fDevIsParSearchWUsed = value; } - /// \brief Prints parameters log to string - /// \param verbose Verbosity level - std::string PrintParameters(int verbose = 1) const { return fParameters.ToString(verbose); } - private: /// \brief Checker for Iteration container initialization (sets EInitKey::kCAIterations) /// \return true If all Iteration objects were initialized properly diff --git a/algo/ca/core/pars/CaParameters.cxx b/algo/ca/core/pars/CaParameters.cxx index 610dbc181c232d86fec2d3a7988b3fed3b0412ff..3561da863e5e5f78adfccd006e18d3b071bb36bb 100644 --- a/algo/ca/core/pars/CaParameters.cxx +++ b/algo/ca/core/pars/CaParameters.cxx @@ -137,10 +137,10 @@ void Parameters<DataT>::CheckConsistency() const * there are uninitialized elements possible (with id > NstationsActiveTotal), thus one should NOT run the loop above over * all the stations in array but only until *(fNstationsActive.cend() - 1) (== NstationsActiveTotal). */ - - for (int iSt = 0; iSt < fNstationsActiveTotal; ++iSt) { - fThickMap[iSt].CheckConsistency(); - } + // TODO: Provide these checks in the kf::Setup + //for (int iSt = 0; iSt < fNstationsActiveTotal; ++iSt) { + // fThickMap[iSt].CheckConsistency(); + //} /* * Check equality of station indices in setups: @@ -374,24 +374,6 @@ std::string Parameters<DataT>::ToString(int verbosity, int indentLevel) const msg << fStations[iStAct].ToString(verbosity, 0) << '\n'; } - msg << indent << indentCh << clrs::CLb << "STATION MATERIAL MAPS:\n" << clrs::CL; - msg << indent << indentCh; - msg << setw(9) << "Active ID" << ' '; - msg << setw(9) << "N bins" << ' '; - msg << setw(11) << "xy max.[cm]" << ' '; - msg << setw(10) << "z min.[cm]" << ' '; - msg << setw(10) << "z max.[cm]" << ' '; - msg << setw(10) << "z ref.[cm]" << '\n'; - for (int iStAct = 0; iStAct < this->GetNstationsActive(); ++iStAct) { - const auto& matMap = fThickMap[iStAct]; - msg << indent << indentCh << setw(9) << iStAct << ' '; - msg << setw(9) << matMap.GetNbins() << ' '; - msg << setw(11) << matMap.GetXYmax() << ' '; - msg << setw(10) << matMap.GetZmin() << ' '; - msg << setw(10) << matMap.GetZmax() << ' '; - msg << setw(10) << matMap.GetZref() << '\n'; - } - msg << indent << indentCh << clrs::CLb << "MISALIGNMENT TOLERANCES:\n" << clrs::CL; msg << indent << indentCh; msg << setw(9) << "Active ID"; diff --git a/algo/ca/core/pars/CaParameters.h b/algo/ca/core/pars/CaParameters.h index a3386d9753bd08c8d22691cff96804ef9a02761c..e2f145c0ed4affe124b7c8b4f940d18808be3c3d 100644 --- a/algo/ca/core/pars/CaParameters.h +++ b/algo/ca/core/pars/CaParameters.h @@ -81,7 +81,6 @@ namespace cbm::algo::ca , fCAIterations(other.GetCAIterations()) , fVertexFieldValue(other.GetVertexFieldValue()) , fVertexFieldRegion(other.GetVertexFieldRegion()) - , fThickMap(other.GetThicknessMaps()) , fvFirstGeoId(other.GetFirstGeoId()) , fvLocalToGeoIdMap(other.GetLocalToGeoIdMap()) , fvGeoToLocalIdMap(other.GetGeoToLocalIdMap()) @@ -225,39 +224,6 @@ namespace cbm::algo::ca return fSearchWindows; } - /// \brief Gets reference to the array of station thickness map - const MaterialContainer_t& GetThicknessMaps() const { return fThickMap; } - - /// \brief Gets material thickness in units of radiation length in a point on the XY plane for a selected station - /// \param iStActive Global index of an active station - /// \param xPos Position of the point in X dimension [cm] - /// \param yPos Position of the point in Y dimension [cm] - float GetMaterialThicknessScal(int iStActive, float xPos, float yPos) const - { - return fThickMap[iStActive].GetRadThickScal(xPos, yPos); - } - - /// \brief Gets material thickness in units of radiation length in a point on the XY plane for a selected station - /// Common implementation for non-SIMD operations - /// \param iStActive Global index of an active station - /// \param xPos Position of the point in X dimension [cm] (SIMDized vector) - /// \param yPos Position of the point in Y dimension [cm] (SIMDized vector) - template<typename T> - T GetMaterialThickness(int iStActive, T xPos, T yPos) const - { - return fThickMap[iStActive].GetRadThickScal(xPos, yPos); - } - - /// \brief Gets material thickness in units of radiation length in a point on the XY plane for a selected station - /// Specific implementation for SIMD operations - /// \param iStActive Global index of an active station - /// \param xPos Position of the point in X dimension [cm] (SIMDized vector) - /// \param yPos Position of the point in Y dimension [cm] (SIMDized vector) - fvec GetMaterialThickness(int iStActive, fvec xPos, fvec yPos) const - { - return fThickMap[iStActive].GetRadThickVec(xPos, yPos); - } - /// \brief Gets X component of target position DataT GetTargetPositionX() const { return fTargetPos[0]; } @@ -379,9 +345,6 @@ namespace cbm::algo::ca /// Array of stations alignas(constants::misc::Alignment) StationsContainer_t<DataT> fStations{}; - /// Array of station thickness map - alignas(constants::misc::Alignment) MaterialContainer_t fThickMap{}; - // ** Station layout arrays ** /// \brief First index of the station on the particular detector /// @@ -463,7 +426,6 @@ namespace cbm::algo::ca ar& fVertexFieldRegion; ar& fStations; - ar& fThickMap; ar& fvFirstGeoId; ar& fvLocalToGeoIdMap; diff --git a/algo/ca/core/pars/CaStationInitializer.cxx b/algo/ca/core/pars/CaStationInitializer.cxx index 3e179cb3eae209597ab2a5849d52d5764c435e19..6c48c65c1781a26c171c7d53294f820043a43f8b 100644 --- a/algo/ca/core/pars/CaStationInitializer.cxx +++ b/algo/ca/core/pars/CaStationInitializer.cxx @@ -54,26 +54,6 @@ const Station<fvec>& StationInitializer::GetStation() const return fStation; } -// --------------------------------------------------------------------------------------------------------------------- -// -const MaterialMap& StationInitializer::GetMaterialMap() const -{ - if (!fInitController.IsFinalized()) { - LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of getting the material map object from uninitialized " - "L1BaseStation class (detectorID = " - << static_cast<int>(fDetectorID) << ", stationID = " << fStationID << ")"; - } - - if (fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)]) { - LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of getting the material map, which has been moved. The " - "thickness map instance have been " - << "already took from the StationInitializer object (detectorID = " << static_cast<int>(fDetectorID) - << ", stationID = " << fStationID << ")"; - } - - return fThicknessMap; -} - // --------------------------------------------------------------------------------------------------------------------- // void StationInitializer::SetDetectorID(EDetectorID inID) @@ -139,32 +119,6 @@ void StationInitializer::SetGeoLayerID(int geoLayerID) fInitController.SetFlag(EInitKey::kGeoLayerID); } -// --------------------------------------------------------------------------------------------------------------------- -// -void StationInitializer::SetMaterialMap(const MaterialMap& thicknessMap) -{ - if (!fInitController.GetFlag(EInitKey::kThicknessMap)) { - fThicknessMap = thicknessMap; - fInitController.SetFlag(EInitKey::kThicknessMap); - } - else { - LOG(warn) << "StationInitializer::SetMaterialMap: attempt to reinitialize the material map"; - } -} - -// --------------------------------------------------------------------------------------------------------------------- -// -void StationInitializer::SetMaterialMap(MaterialMap&& thicknessMap) noexcept -{ - if (!fInitController.GetFlag(EInitKey::kThicknessMap)) { - fThicknessMap = std::move(thicknessMap); - fInitController.SetFlag(EInitKey::kThicknessMap); - } - else { - LOG(warn) << "StationInitializer::SetMaterialMap: attempt to reinitialize the material map"; - } -} - // --------------------------------------------------------------------------------------------------------------------- // void StationInitializer::SetStationID(int inID) @@ -223,11 +177,6 @@ void StationInitializer::SetTrackingStatus(bool flag) { fTrackingStatus = flag; fInitController.SetFlag(EInitKey::kTrackingStatus); - if (!fTrackingStatus && !fInitController.GetFlag(EInitKey::kThicknessMap)) { - // Set initialized status for the material map, if the station is not active, since its material is accounted in the - // previous tracking station. - fInitController.SetFlag(EInitKey::kThicknessMap); - } } // --------------------------------------------------------------------------------------------------------------------- @@ -268,33 +217,9 @@ void StationInitializer::Swap(StationInitializer& other) noexcept std::swap(fZmin, other.fZmin); std::swap(fZmax, other.fZmax); std::swap(fStation, other.fStation); - std::swap(fThicknessMap, other.fThicknessMap); std::swap(fInitController, other.fInitController); } -// --------------------------------------------------------------------------------------------------------------------- -// -MaterialMap&& StationInitializer::TakeMaterialMap() -{ - if (!fInitController.IsFinalized()) { - LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of getting the material map object from uninitialized " - "L1BaseStation class (detectorID = " - << static_cast<int>(fDetectorID) << ", stationID = " << fStationID << ")"; - } - - if (fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)]) { - LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of taking the material map, which has been moved. The " - "thickness map instance have been " - << "already took from the StationInitializer object (detectorID = " << static_cast<int>(fDetectorID) - << ", stationID = " << fStationID << ")"; - } - else { - fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)] = true; - } - - return std::move(fThicknessMap); -} - // --------------------------------------------------------------------------------------------------------------------- // std::string StationInitializer::ToString(int verbosityLevel, int indentLevel) const diff --git a/algo/ca/core/pars/CaStationInitializer.h b/algo/ca/core/pars/CaStationInitializer.h index ceefb2abd41a908c6156c312e2cb6e9887e93f33..7347cee1300ddcb2df15374312248ed1005f3ad1 100644 --- a/algo/ca/core/pars/CaStationInitializer.h +++ b/algo/ca/core/pars/CaStationInitializer.h @@ -50,7 +50,6 @@ namespace cbm::algo::ca kZref, ///< reference z of the station kZmin, ///< min z of the station kZmax, ///< max z of the station - kThicknessMap, ///< thickness map of the station (optional?) kFieldSlice, ///< ca::Station.ca::FieldSlice object initialization kGeoLayerID, ///< index of geo layer in geometrical setup (including possibly inactive stations) // The last item is equal to the number of bits in fInitFlags @@ -85,9 +84,6 @@ namespace cbm::algo::ca /// \brief Gets a reference to ca::Station info field of the L1BaseStation info const Station<fvec>& GetStation() const; - /// \brief Gets a reference to ca::MaterialMap map - const MaterialMap& GetMaterialMap() const; - /// \brief Gets station ID int GetStationID() const { return fStationID; } @@ -132,14 +128,6 @@ namespace cbm::algo::ca /// \brief Sets geometry ID (index of the layer in the geometrical setup) void SetGeoLayerID(int geoLayerID); - /// \brief Sets station thickness in units of radiation length mapped vs. position in XY plane (copy semantics) - /// \param thicknessMap Map of station thickness in units of radiation length - void SetMaterialMap(const MaterialMap& thicknessMap); - - /// \brief Sets station thickness in units of radiation length mapped vs. position in XY plane (move semantics) - /// \param thicknessMap Map of station thickness in units of radiation length - void SetMaterialMap(MaterialMap&& thicknessMap) noexcept; - /// \brief Sets station ID [[deprecated("Please, use constructor to set station ID")]] void SetStationID(int inID); @@ -171,13 +159,6 @@ namespace cbm::algo::ca /// \brief Swap method for easy implementation of move constructor and copy and move assignment operator void Swap(StationInitializer& other) noexcept; - /// \brief Takes an instance of ca::MaterialMap map - /// - /// \note This method can be called only once. It will catch the content of ca::MaterialMap map (using move - /// semantics), and after the warning will be generated both for the GetMaterialMap and the TakeMaterialMap - /// functions. - ca::MaterialMap&& TakeMaterialMap(); - /// \brief String representation of class contents /// \param indentLevel Number of indent characters in the output std::string ToString(int verbosityLevel = 0, int indentLevel = 0) const; @@ -192,7 +173,6 @@ namespace cbm::algo::ca double fZmin{0}; ///< min z double fZmax{0}; ///< max z Station<fvec> fStation{}; ///< ca::Station structure, describes a station in L1Algo - MaterialMap fThicknessMap{}; ///< Map of station thickness in units of radiation length InitController_t fInitController{}; ///< Class fileds initialization flags ManagementFlags_t fManagementFlags{}; ///< bitset flags to manage internal behaviour of the class }; diff --git a/algo/kf/core/geo/KfMaterialMonitor.cxx b/algo/kf/core/geo/KfMaterialMonitor.cxx index 57e41cdbec1ad48ed13a052d4bfe3832dd503837..bd741e267ddb9231bf10377a5df78902b2c3336e 100644 --- a/algo/kf/core/geo/KfMaterialMonitor.cxx +++ b/algo/kf/core/geo/KfMaterialMonitor.cxx @@ -135,9 +135,9 @@ namespace cbm::algo::kf { /// print statistics to a string - EvaluateStatistics(); - // FIXME: a ToString method should not change data of its class, but only represent their current state. I would - // call EvaluateStatistics explicitly and provide a const ToString method inside it. + EvaluateStatistics(); + // FIXME: a ToString method should not change data of its class, but only represent their current state. I would + // call EvaluateStatistics explicitly and provide a const ToString method inside it. std::stringstream ss; ss << std::setprecision(2) << std::fixed; @@ -179,4 +179,4 @@ namespace cbm::algo::kf return ss.str(); } -} // namespace cbm::algo::ca +} // namespace cbm::algo::kf diff --git a/algo/kf/core/geo/KfMaterialMonitor.h b/algo/kf/core/geo/KfMaterialMonitor.h index 13d1f351d8146235e9f94af85b01ef8d14faf08d..08222c3850bcd87c3b54075a5c14f0afd0d9a53f 100644 --- a/algo/kf/core/geo/KfMaterialMonitor.h +++ b/algo/kf/core/geo/KfMaterialMonitor.h @@ -8,12 +8,12 @@ #pragma once -#include "KfMaterialMap.h" #include "KfDefs.h" +#include "KfMaterialMap.h" +#include <algorithm> #include <string> #include <vector> -#include <algorithm> namespace cbm::algo::kf { @@ -42,10 +42,7 @@ namespace cbm::algo::kf void SetName(const std::string& name) { fName = name; } /// \brief Reset the map of active bins - void ResetActiveBins() - { - std::fill(fActiveBinMap.begin(), fActiveBinMap.end(), 0); - } + void ResetActiveBins() { std::fill(fActiveBinMap.begin(), fActiveBinMap.end(), 0); } /// \brief Mark a bin as active /// \param x X-coordinate of the bin @@ -93,7 +90,7 @@ namespace cbm::algo::kf std::vector<char> fActiveBinMap{}; ///< Map of active bins in the material map (bins where hits appear) const MaterialMap* fMaterial{nullptr}; ///< Pointer to the material map - + double fActiveRadThickMin{defs::Undef<double>}; ///< Active material: minimal thickness double fActiveRadThickMax{defs::Undef<double>}; ///< Active material: maximal thickness double fActiveRadThickMean{defs::Undef<double>}; ///< Active material: average thickness @@ -104,9 +101,9 @@ namespace cbm::algo::kf unsigned long fNhitsTotal{0}; ///< number of hits in statistics unsigned long fNhitsOutside{0}; ///< number of hits outside the material map - - int fActiveNbins{defs::Undef<int>}; ///< Active material: number of bins - int fPassiveNbins{defs::Undef<int>}; ///< Passive material: number of bins + + int fActiveNbins{defs::Undef<int>}; ///< Active material: number of bins + int fPassiveNbins{defs::Undef<int>}; ///< Passive material: number of bins }; -} // namespace cbm::algo::ca +} // namespace cbm::algo::kf diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index e106cd4881b630b6f36b36eb974a49a2b05795ee..185f303a270d481f4138c608a022426b219e74a5 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -686,7 +686,7 @@ void CbmL1::Finish() { // monitor the material - std::stringstream msg; + std::stringstream msg; msg << '\n'; msg << "\033[31;1m ***************************\033[0m\n"; msg << "\033[31;1m ** CA Tracking monitor **\033[0m\n"; @@ -696,7 +696,7 @@ void CbmL1::Finish() { msg << '\n'; msg << " ----- Material budget map monitoring: active setup -----\n"; - for (auto& monitor: fMaterialMonitor) { + for (auto& monitor : fMaterialMonitor) { msg << monitor.ToString() << '\n'; } msg << " --------------------------------------------------------\n"; @@ -820,7 +820,6 @@ void CbmL1::GenerateMaterialMaps() ca::MaterialMap matBudget = matHelper.GenerateMaterialMap(pStation->GetZref(), zLast, zNew, maxXY, nBins); - pStation->SetMaterialMap(matBudget); LOG(info) << "Generated material map for tracking station " << ist << " at z = " << pStation->GetZref() << " cm." << " Material is collected between z = " << zLast << " and z = " << zNew; @@ -993,43 +992,6 @@ void CbmL1::ReadSTAPPerfInputData() LOG(fatal) << "CbmL1: Running in standalone mode is not available at the moment. It will be updated soon..."; } -// --------------------------------------------------------------------------------------------------------------------- -// -void CbmL1::DumpMaterialToFile(TString fileName) -{ - TFile* f = new TFile(fileName, "RECREATE"); - f->cd(); - const auto& param = fpAlgo->GetParameters(); - const auto& map = param.GetThicknessMaps(); - for (int ist = 0; ist < param.GetNstationsActive(); ist++) { - //const ca::Station& st = param.GetStation(ist); - const auto& mat = map[ist]; - - TString name = Form("tracking_station%d", ist); - TString title = Form("Tracking station %d: Rad. thickness in [%s]. Z region [%.2f,%.2f] cm.", ist, "%", - mat.GetZmin(), mat.GetZmax()); - - if (fMatBudgetParallelProjection) { - title += " Horisontal projection."; - } - else { - title += " Radial projection."; - } - - TH2F* h = new TH2F(name.Data(), title.Data(), mat.GetNbins(), -mat.GetXYmax(), mat.GetXYmax(), mat.GetNbins(), - -mat.GetXYmax(), mat.GetXYmax()); - h->GetXaxis()->SetTitle("X [cm]"); - h->GetYaxis()->SetTitle("Y [cm]"); - - for (int ix = 0; ix < mat.GetNbins(); ix++) { - for (int iy = 0; iy < mat.GetNbins(); iy++) { - h->SetBinContent(ix + 1, iy + 1, 100. * mat.GetRadThickBin(ix, iy)); - } - } - } - f->Write(); -} - // --------------------------------------------------------------------------------------------------------------------- // void CbmL1::GetTargetInfo() diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index fccff6814b80f980ff61310728dca41b262ef74b..bdd688efa3ce795062eed47e504997957a9865d1 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -24,7 +24,6 @@ #include "CaDataManager.h" #include "CaFramework.h" #include "CaInitManager.h" -#include "KfMaterialMonitor.h" #include "CaMonitor.h" #include "CaVector.h" #include "CbmCaMCModule.h" @@ -37,6 +36,7 @@ #include "FairDetector.h" #include "FairRootManager.h" #include "FairTask.h" +#include "KfMaterialMonitor.h" #include "KfTrackParam.h" #include "TClonesArray.h" #include "TH1.h" diff --git a/reco/kfnew/tools/CMakeLists.txt b/reco/kfnew/tools/CMakeLists.txt index 2f4a9baf529bfe4c1276a5fa24b2ec3f885d0027..0ce306e15bff65ef9c7c39c3415a4252e53e8bad 100644 --- a/reco/kfnew/tools/CMakeLists.txt +++ b/reco/kfnew/tools/CMakeLists.txt @@ -4,6 +4,7 @@ set(INCLUDE_DIRECTORIES set(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/KfMaterialMapFactory.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/KfRootUtils.cxx ) SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS "-O3") @@ -56,6 +57,7 @@ install(TARGETS KfTools DESTINATION lib) install( FILES KfMaterialMapFactory.h + KfRootUtils.h DESTINATION include/ )