From d30563c6f9749555f1cb78b4a38e8c2c18de9f31 Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Mon, 18 Nov 2024 11:20:20 +0100 Subject: [PATCH] CA: migration from ca:: to kf::MaterialMap: removing ca::MaterialMap from CbmL1 and CbmGenerateMaterialMaps classes --- algo/kf/core/geo/KfMaterialMap.h | 8 +- reco/KF/ParticleFitter/CbmL1PFFitter.cxx | 13 +- reco/L1/CbmL1.cxx | 154 +++--------------- reco/L1/CbmL1.h | 21 +-- .../CbmGenerateMaterialMaps.cxx | 63 ++----- .../CbmGenerateMaterialMaps.h | 24 +-- reco/kfnew/tools/KfRootUtils.cxx | 36 ++++ reco/kfnew/tools/KfRootUtils.h | 34 ++++ 8 files changed, 134 insertions(+), 219 deletions(-) create mode 100644 reco/kfnew/tools/KfRootUtils.cxx create mode 100644 reco/kfnew/tools/KfRootUtils.h diff --git a/algo/kf/core/geo/KfMaterialMap.h b/algo/kf/core/geo/KfMaterialMap.h index af1e742588..e453f6bd9a 100644 --- a/algo/kf/core/geo/KfMaterialMap.h +++ b/algo/kf/core/geo/KfMaterialMap.h @@ -104,7 +104,8 @@ namespace cbm::algo::kf /// \tparam I Type of material thickness /// \param iGlob Global bin number: iGlob = iX + iY * fNbins template<typename I> - I GetBinThicknessX0(int iGlob) const { + I GetBinThicknessX0(int iGlob) const + { if constexpr (std::is_same_v<I, fvec>) { fvec res; for (size_t i = 0; i < utils::simd::Size<I>(); ++i) { @@ -122,7 +123,10 @@ namespace cbm::algo::kf /// \param iX Bin number along x axis /// \param iY Bin number along y axis template<typename I> - I GetBinThicknessX0(int iX, int iY) const { return GetBinThicknessX0<I>(iX + iY * fNbins); } + I GetBinThicknessX0(int iX, int iY) const + { + return GetBinThicknessX0<I>(iX + iY * fNbins); + } /// \brief Function to test the instance for NaN bool IsUndefined() const diff --git a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx index 3d653e0d95..eb29a057b9 100644 --- a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx +++ b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx @@ -172,7 +172,9 @@ void FilterFirst(kf::TrackKalmanFilter<fvec>& fit, kf::MeasurementXy<fvec>& mxy, void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmMvdHit>& vMvdHits, const std::vector<CbmStsHit>& vStsHits, const std::vector<int>& pidHypo) { - + // TODO: (!) replace CbmL1::Instance()->fpAlgo->GetParameters() with the cbm::ca::ParametersHandler::Instance()->Get() + // everywhere outside cbm::algo + const auto& activeTrackingSetup = CbmL1::Instance()->fpAlgo->GetParameters().GetActiveSetup(); Initialize(); kf::FieldValue<fvec> b0, b1, b2 _fvecalignment; @@ -374,7 +376,7 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM fit.SetMask(initialised); fit.Extrapolate(z[i], fld); - auto radThick = CbmL1::Instance()->fpAlgo->GetParameters().GetMaterialThickness(i, fit.Tr().X(), fit.Tr().Y()); + auto radThick = activeTrackingSetup.GetMaterial(i).GetThicknessX0(fit.Tr().X(), fit.Tr().Y()); fit.MultipleScattering(radThick); fit.EnergyLossCorrection(radThick, kf::FitDirection::kDownstream); @@ -435,7 +437,7 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM fit.SetMask(initialised); fit.Extrapolate(z[i], fld); - auto radThick = CbmL1::Instance()->fpAlgo->GetParameters().GetMaterialThickness(i, fit.Tr().X(), fit.Tr().Y()); + auto radThick = activeTrackingSetup.GetMaterial(i).GetThicknessX0(fit.Tr().X(), fit.Tr().Y()); fit.MultipleScattering(radThick); fit.EnergyLossCorrection(radThick, kf::FitDirection::kUpstream); @@ -499,6 +501,9 @@ void CbmL1PFFitter::Fit(vector<CbmStsTrack>& Tracks, const vector<int>& pidHypo) void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<PFFieldRegion>& field, vector<float>& chiToVtx, CbmKFVertex& primVtx, float chiPrim) { + // TODO: (!) replace CbmL1::Instance()->fpAlgo->GetParameters() with the cbm::ca::ParametersHandler::Instance()->Get() + // everywhere outside cbm::algo + const auto& activeTrackingSetup = CbmL1::Instance()->fpAlgo->GetParameters().GetActiveSetup(); Initialize(); chiToVtx.reserve(Tracks.size()); @@ -604,7 +609,7 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<PFFieldRe for (int iSt = nStations - 4; iSt >= 0; iSt--) { fit.SetMask(T.Z() > zSta[iSt] + fvec(2.5)); fit.Extrapolate(zSta[iSt], fld); - auto radThick = CbmL1::Instance()->fpAlgo->GetParameters().GetMaterialThickness(iSt, fit.Tr().X(), fit.Tr().Y()); + auto radThick = activeTrackingSetup.GetMaterial(iSt).GetThicknessX0(fit.Tr().X(), fit.Tr().Y()); fit.MultipleScattering(radThick); fit.EnergyLossCorrection(radThick, kf::FitDirection::kUpstream); } diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 185f303a27..fd3eff0f43 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -45,6 +45,7 @@ #include "CbmTrackingDetectorInterfaceInit.h" #include "FairField.h" #include "FairRunAna.h" +#include "KfRootUtils.h" #include "TGeoArb8.h" #include "TGeoBoolNode.h" #include "TGeoCompositeShape.h" @@ -254,8 +255,8 @@ try { // ** Target initialization ** // *************************** - GetTargetInfo(); - + { + } fInitManager.SetTargetPosition(fTargetX, fTargetY, fTargetZ); // ********************************* @@ -437,11 +438,6 @@ try { fInitManager.InitStationLayout(); fInitManager.ReadInputConfigs(); - // **************************************** - // ** Material maps initialization ** - // **************************************** - this->GenerateMaterialMaps(); - // ************************* // ** Initialize KF-setup ** // ************************* @@ -766,72 +762,6 @@ void CbmL1::writedir2current(TObject* obj) } } -// --------------------------------------------------------------------------------------------------------------------- -// -void CbmL1::GenerateMaterialMaps() -{ - LOG(info) << "Generating material maps..."; - auto timerStart = std::chrono::high_resolution_clock::now(); - - cbm::ca::tools::MaterialHelper matHelper; - matHelper.SetSafeMaterialInitialization(fDoSafeMaterialInitialization); - - if (!fMatBudgetParallelProjection) { - matHelper.SetDoRadialProjection(fTargetZ); - } - matHelper.SetNraysPerDim(fMatBudgetNrays); - - double zLast = fTargetZ + 1.; // some gap (+1cm) to skip the target material - - std::vector<ca::StationInitializer*> vpActiveStations; - vpActiveStations.reserve(fInitManager.GetNstationsActive()); - for (auto& station : fInitManager.GetStationInfo()) { // loop over active + inactive station - if (station.GetTrackingStatus()) { - vpActiveStations.push_back(&station); - } - } - - LOG(info) << "Generating material maps for stations: "; - for (const auto* pSta : vpActiveStations) { - LOG(info) << "\t- z = " << pSta->GetZref() << " cm"; - } - - for (unsigned int ist = 0; ist < vpActiveStations.size(); ++ist) { - auto* pStation = vpActiveStations[ist]; - double z1 = pStation->GetZmax(); - double z2 = z1; - if (ist < vpActiveStations.size() - 1) { - // split materials between the stations at the middle - auto* pStationNext = vpActiveStations[ist + 1]; - z2 = pStationNext->GetZmin(); - } - double zNew = 0.5 * (z1 + z2); - - double maxXY = 1.3 * std::max(std::fabs(pStation->GetXmax()), std::fabs(pStation->GetYmax())); - //double maxXY = 80; - // calculate n bins from the minimal pitch - int nBins = static_cast<int>(std::ceil(2. * maxXY / fMatBudgetPitch)); - if (nBins < 1) { - LOG(fatal) << " material nBins " << nBins << " is not positive, something is wrong"; - } - if (nBins > fMatBudgetNbins) { - nBins = fMatBudgetNbins; - } - - ca::MaterialMap matBudget = matHelper.GenerateMaterialMap(pStation->GetZref(), zLast, zNew, maxXY, nBins); - - - LOG(info) << "Generated material map for tracking station " << ist << " at z = " << pStation->GetZref() << " cm." - << " Material is collected between z = " << zLast << " and z = " << zNew; - - zLast = zNew; - } - - auto timerEnd = std::chrono::high_resolution_clock::now(); - double materialGenerationTime = (double) (std::chrono::duration<double>(timerEnd - timerStart).count()); - LOG(info) << "Generating material maps... done! (it took " << materialGenerationTime << " s)"; -} - // --------------------------------------------------------------------------------------------------------------------- // void CbmL1::IdealTrackFinder() @@ -994,63 +924,29 @@ void CbmL1::ReadSTAPPerfInputData() // --------------------------------------------------------------------------------------------------------------------- // -void CbmL1::GetTargetInfo() -{ - // Loop over all nodes till a node with name "target" is found - // Extract the required infrmation from the node and store it in the - // proper structure - // The complete logic depends on the naming convention of the target. - // If the node doesn't contain the string target the procedure will fail - - fTargetX = 1.e10; - fTargetY = 1.e10; - fTargetZ = 1.e10; - - TString targetPath; - TGeoNode* targetNode{nullptr}; - FindTargetNode(targetPath, targetNode); - - if (!targetNode) { - LOG(fatal) << "L1: can not find the target!"; - } - - Double_t local[3] = {0., 0., 0.}; // target centre, local c.s. - Double_t global[3]; // target centre, global c.s. - gGeoManager->cd(targetPath); - gGeoManager->GetCurrentMatrix()->LocalToMaster(local, global); - fTargetX = global[0]; - fTargetY = global[1]; - fTargetZ = global[2]; - - LOG(info) << " Target found: \"" << targetPath << "\" at ( " << fTargetX << " " << fTargetY << " " << fTargetZ - << " ) "; -} - -// --------------------------------------------------------------------------------------------------------------------- -// Target finder - recursive routine -// - -void CbmL1::FindTargetNode(TString& targetPath, TGeoNode*& targetNode) +void CbmL1::DumpMaterialToFile(TString fileName) { - if (!targetNode) { // init at the top of the tree - targetNode = gGeoManager->GetTopNode(); - targetPath = "/" + TString(targetNode->GetName()); - } - - if (TString(targetNode->GetName()).Contains("target")) { - return; - } - - for (Int_t iNode = 0; iNode < targetNode->GetNdaughters(); iNode++) { - TGeoNode* newNode = targetNode->GetDaughter(iNode); - TString newPath = targetPath + "/" + newNode->GetName(); - FindTargetNode(newPath, newNode); - if (newNode) { - targetPath = newPath; - targetNode = newNode; - return; + auto* currentFile = gFile; + TFile f = TFile{fileName, "RECREATE"}; + f.cd(); + // TODO: (!) replace CbmL1::Instance()->fpAlgo->GetParameters() with the cbm::ca::ParametersHandler::Instance()->Get() + // everywhere outside cbm::algo + const auto& activeTrackingSetup = CbmL1::Instance()->fpAlgo->GetParameters().GetActiveSetup(); + for (int iSt = 0; iSt < activeTrackingSetup.GetNofLayers(); ++iSt) { + const auto& material = activeTrackingSetup.GetMaterial(iSt); + TString name = Form("tracking_station%d", iSt); + TString title = Form("Tracking station %d: Rad. thickness in %%. Z region [%.2f, %.2f] cm.", iSt, + material.GetZmin(), material.GetZmax()); + if (fMatBudgetParallelProjection) { + title += " Horizontal projection."; + } + else { + title += " Radial projection."; } + auto* h = ::kf::tools::RootUtils::ToHistogram(material, name, title); + h->SetStats(kFALSE); + h->SetDirectory(&f); } - targetPath = ""; - targetNode = nullptr; + f.Write(); + currentFile->cd(); } diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index bdd688efa3..e7d4cd7629 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -309,9 +309,6 @@ class CbmL1 : public FairTask { << " ! The material budget files are not used anymore !"; } - /// A helper for GetTargetInfo() - static void FindTargetNode(TString& targetPath, TGeoNode*& targetNode); - private: struct TH1FParameters { TString name, title; @@ -319,23 +316,17 @@ class CbmL1 : public FairTask { float xMin, xMax; }; - /// @brief Generates material maps - void GenerateMaterialMaps(); - - /// @brief Runs ideal track finder: copies all MC-tracks into reconstructed tracks + /// \brief Runs ideal track finder: copies all MC-tracks into reconstructed tracks void IdealTrackFinder(); - // static bool compareZ(const int &a, const int &b ); - // bool compareZ(const int &a, const int &b ); - - /// Fills the fvMCTracks vector and the fmMCTracksMap + /// \brief Fills the fvMCTracks vector and the fmMCTracksMap void Fill_vMCTracks(); /* * Input Performance */ - /// Matches hit with MC point + /// \brief Matches hit with MC point /// \tparam DetId Detector ID /// \param iHit External index of hit /// \return MC-point index in fvMCPoints array @@ -406,10 +397,6 @@ class CbmL1 : public FairTask { /// Gets a pointer to L1InitManager (for an access in run_reco.C) ca::InitManager* GetInitManager() { return &fInitManager; } - /// Get the target information - void GetTargetInfo(); - - void WriteHistosCurFile(TObject* obj); static std::istream& eatwhite(std::istream& is); // skip spaces @@ -534,7 +521,7 @@ class CbmL1 : public FairTask { bool fExtrapolateToTheEndOfSTS{false}; - std::vector<kf::MaterialMonitor> fMaterialMonitor{}; ///< Material monitors for each material budget map + std::vector<cbm::algo::kf::MaterialMonitor> fMaterialMonitor{}; ///< Material monitors for each material budget map ClassDef(CbmL1, 0); }; diff --git a/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.cxx b/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.cxx index d8d125cb0f..74edc181d3 100644 --- a/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.cxx +++ b/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.cxx @@ -9,9 +9,10 @@ #include "CbmGenerateMaterialMaps.h" -#include "CbmL1.h" // for FindTargetNode +#include "CbmKfTarget.h" #include "CbmTrackingDetectorInterfaceBase.h" #include "CbmTrackingDetectorInterfaceInit.h" +#include "KfRootUtils.h" #include "TFile.h" #include "TH2F.h" @@ -39,14 +40,14 @@ InitStatus CbmGenerateMaterialMaps::Init() LOG(info) << fName << ": configuration file was not provided. Using default settings"; } - InitTarget(); + fTargetZ = cbm::kf::Target::Instance()->GetZ(); - fpMaterialHelper = std::make_unique<cbm::ca::tools::MaterialHelper>(); + fpMaterialFactory = std::make_unique<::kf::tools::MaterialMapFactory>(); if (!fConfig.fbParallelRays) { - fpMaterialHelper->SetDoRadialProjection(fTargetZ); + fpMaterialFactory->SetDoRadialProjection(fTargetZ); } - fpMaterialHelper->SetSafeMaterialInitialization(true); - fpMaterialHelper->SetNraysPerDim(fConfig.fNofRays); + fpMaterialFactory->SetSafeMaterialInitialization(true); + fpMaterialFactory->SetNraysPerDim(fConfig.fNofRays); if (fConfig.fbTrackingStations) { std::set<MaterialSlice> mSlice; @@ -87,7 +88,7 @@ InitStatus CbmGenerateMaterialMaps::Init() if (nBins > fConfig.fMaxNofBins) { nBins = fConfig.fMaxNofBins; } - fmMaterial[it->fName] = fpMaterialHelper->GenerateMaterialMap(zRef, zLast, zNew, xyMax, nBins); + fmMaterial[it->fName] = std::move(fpMaterialFactory->GenerateMaterialMap(zRef, zLast, zNew, xyMax, nBins)); zLast = zNew; } } @@ -118,7 +119,7 @@ InitStatus CbmGenerateMaterialMaps::Init() if (nBins > fConfig.fMaxNofBins) { nBins = fConfig.fMaxNofBins; } - fmMaterial[slice.fName] = fpMaterialHelper->GenerateMaterialMap(zRef, zMin, zMax, xyMax, nBins); + fmMaterial[slice.fName] = fpMaterialFactory->GenerateMaterialMap(zRef, zMin, zMax, xyMax, nBins); } WriteMaterialMaps(); @@ -129,40 +130,6 @@ InitStatus CbmGenerateMaterialMaps::Init() // InitStatus CbmGenerateMaterialMaps::ReInit() { return kSUCCESS; } -// --------------------------------------------------------------------------------------------------------------------- -// -void CbmGenerateMaterialMaps::InitTarget() -{ - // Loop over all nodes till a node with name "target" is found - // Extract the required infrmation from the node and store it in the - // proper structure - // The complete logic depends on the naming convention of the target. - // If the node doesn't contain the string target the procedure will fail - - fTargetX = 1.e10; - fTargetY = 1.e10; - fTargetZ = 1.e10; - - TString targetPath; - TGeoNode* targetNode{nullptr}; - CbmL1::FindTargetNode(targetPath, targetNode); - - if (!targetNode) { - LOG(fatal) << fName << ": target node is not found"; - } - - Double_t local[3] = {0., 0., 0.}; // target centre, local c.s. - Double_t global[3]; // target centre, global c.s. - gGeoManager->cd(targetPath); - gGeoManager->GetCurrentMatrix()->LocalToMaster(local, global); - fTargetX = global[0]; - fTargetY = global[1]; - fTargetZ = global[2]; - - LOG(info) << fName << ": target found: \"" << targetPath << "\" at ( " << fTargetX << " " << fTargetY << " " - << fTargetZ << " ) [cm] "; -} - // --------------------------------------------------------------------------------------------------------------------- // void CbmGenerateMaterialMaps::WriteMaterialMaps() @@ -179,16 +146,8 @@ void CbmGenerateMaterialMaps::WriteMaterialMaps() else { title += Form("; radial projection from z=%f cm", fTargetZ); } - double nBins = material.GetNbins(); - double xyMax = material.GetXYmax(); - auto* h = new TH2F(name.c_str(), title.c_str(), nBins, -xyMax, xyMax, nBins, -xyMax, xyMax); - h->GetXaxis()->SetTitle("x [cm]"); - h->GetYaxis()->SetTitle("y [cm]"); - for (int iBinX = 0; iBinX < nBins; ++iBinX) { - for (int iBinY = 0; iBinY < nBins; ++iBinY) { - h->SetBinContent(iBinX + 1, iBinY + 1, material.GetRadThickBin(iBinX, iBinY)); - } - } + auto* h = ::kf::tools::RootUtils::ToHistogram(material, name.c_str(), title.c_str()); + h->SetDirectory(&f); } f.Write(); } diff --git a/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.h b/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.h index 830470bcc7..1bb05bfc71 100644 --- a/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.h +++ b/reco/L1/OffLineInterface/CbmGenerateMaterialMaps.h @@ -9,9 +9,9 @@ #pragma once -#include "CaMaterialMap.h" -#include "CaToolsMaterialHelper.h" #include "FairTask.h" +#include "KfMaterialMap.h" +#include "KfMaterialMapFactory.h" #include "yaml/Yaml.h" #include <map> @@ -23,8 +23,7 @@ /// \class CbmGenerateMaterialMaps /// \brief Steer class for executing the material budget maps generator independently from tracking class CbmGenerateMaterialMaps : public FairTask { - using MaterialMap = cbm::algo::ca::MaterialMap; - using MaterialHelper = cbm::ca::tools::MaterialHelper; + using MaterialMap = cbm::algo::kf::MaterialMap; /// \struct MaterialSlice /// \brief Input parameters for the material map generation @@ -108,9 +107,6 @@ class CbmGenerateMaterialMaps : public FairTask { const std::map<std::string, MaterialMap>& GetMaterial() const { return fmMaterial; } private: - /// \brief Gets target - void InitTarget(); - /// \brief Writes material budget maps to file /// /// The material maps are represented with ROOT histograms. The value of the material thickness @@ -120,15 +116,13 @@ class CbmGenerateMaterialMaps : public FairTask { static constexpr double kXYoffset = 1.3; /// Offset from station boarders [scale] static constexpr double kTargetOffset = 1.; /// Offset from target to start generating mat. maps [cm] - Config fConfig; ///< Configuration for the task - std::string fsUserConfig = ""; ///< User configuration file - std::string fsOutputFile = "matBudget.root"; ///< Output file name - std::map<std::string, MaterialMap> fmMaterial; ///< Material budget maps - std::unique_ptr<MaterialHelper> fpMaterialHelper = nullptr; ///< Material helper instance + Config fConfig; ///< Configuration for the task + std::string fsUserConfig = ""; ///< User configuration file + std::string fsOutputFile = "matBudget.root"; ///< Output file name + std::map<std::string, MaterialMap> fmMaterial; ///< Material budget maps + std::unique_ptr<::kf::tools::MaterialMapFactory> fpMaterialFactory{nullptr}; ///< Material factory instance - double fTargetX; - double fTargetY; - double fTargetZ; + double fTargetZ; ///< z-coordinate of the target center ClassDef(CbmGenerateMaterialMaps, 0); }; diff --git a/reco/kfnew/tools/KfRootUtils.cxx b/reco/kfnew/tools/KfRootUtils.cxx new file mode 100644 index 0000000000..2952a0f461 --- /dev/null +++ b/reco/kfnew/tools/KfRootUtils.cxx @@ -0,0 +1,36 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file KfRootUtils.cxx +/// \brief Different ROOT utility functions for the KF-framework (header) +/// \author Sergei Zharko <s.zharko@gsi.de> +/// \date 01.11.2024 + +#include "KfRootUtils.h" + +#include "KfMaterialMap.h" +#include "TH2F.h" +#include "TString.h" + +namespace kf::tools +{ + // ------------------------------------------------------------------------------------------------------------------- + // + TH2F* RootUtils::ToHistogram(const cbm::algo::kf::MaterialMap& material, const TString& name, const TString& title) + { + int nBins = material.GetNbins(); + int xMin = -material.GetXYmax(); + int xMax = +material.GetXYmax(); + auto* h = new TH2F(name, title, nBins, xMin, xMax, nBins, xMin, xMax); + h->GetXaxis()->SetTitle("X [cm]"); + h->GetYaxis()->SetTitle("Y [cm]"); + h->GetZaxis()->SetTitle("thickness [% of X0]"); + for (int iX = 0; iX < material.GetNbins(); iX++) { + for (int iY = 0; iY < material.GetNbins(); iY++) { + h->SetBinContent(iX + 1, iY + 1, 100. * material.GetBinThicknessX0<float>(iX, iY)); + } + } + return h; + } +} // namespace kf::tools diff --git a/reco/kfnew/tools/KfRootUtils.h b/reco/kfnew/tools/KfRootUtils.h new file mode 100644 index 0000000000..18afa92e64 --- /dev/null +++ b/reco/kfnew/tools/KfRootUtils.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file KfRootUtils.h +/// \brief Different ROOT utility functions for the KF-framework (header) +/// \author Sergei Zharko <s.zharko@gsi.de> +/// \date 01.11.2024 + +#pragma once + +namespace cbm::algo::kf +{ + class MaterialMap; +} + +class TH2F; +class TString; + +namespace kf::tools +{ + /// \struct KfRootUtils + /// \brief A structure to keep all the utilities together + struct RootUtils { + /// \brief Converts a material budget map into a TH2D histogram + /// \param material A material map + /// \param name Name for the histogram + /// \param title Title for the histogram (note: axis title are set automatically) + static TH2F* ToHistogram(const cbm::algo::kf::MaterialMap& material, const TString& name, const TString& title); + + // TODO: similar methods for fields etc. go here as well + // static TH2D* ToHistogram(const FieldSlice<T>& fieldSlice); + }; +}; // namespace kf::tools -- GitLab