-
Notifications
You must be signed in to change notification settings - Fork 257
feat: Add the option of bin counting histograms for the surfaces material maps #5567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dimitra97
wants to merge
5
commits into
acts-project:main
Choose a base branch
from
dimitra97:binnedmaterial-bincounts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,10 +34,12 @@ class BinnedSurfaceMaterial : public ISurfaceMaterial { | |
| /// @param binUtility defines the binning structure on the surface (copied) | ||
| /// @param materialVector is the vector of material slabs as recorded (moved) | ||
| /// @param splitFactor is the pre/post splitting directive | ||
| /// @param binCounts is the vector of the bin counts recorded | ||
| /// @param mappingType is the type of surface mapping associated to the surface | ||
| BinnedSurfaceMaterial(const BinUtility& binUtility, | ||
| MaterialSlabVector materialVector, | ||
| double splitFactor = 0., | ||
| std::vector<unsigned int> binCounts = {}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for this to be non-breaking the parameter would have to be the last one |
||
| MappingType mappingType = MappingType::Default); | ||
|
|
||
| /// Explicit constructor with only full MaterialSlab, | ||
|
|
@@ -46,10 +48,12 @@ class BinnedSurfaceMaterial : public ISurfaceMaterial { | |
| /// @param binUtility defines the binning structure on the surface (copied) | ||
| /// @param materialMatrix is the matrix of material slabs as recorded (moved) | ||
| /// @param splitFactor is the pre/post splitting directive | ||
| /// @param binCounts is the matrix of the bin counts recorded | ||
| /// @param mappingType is the type of surface mapping associated to the surface | ||
| BinnedSurfaceMaterial(const BinUtility& binUtility, | ||
| MaterialSlabMatrix materialMatrix, | ||
| double splitFactor = 0., | ||
| std::vector<std::vector<unsigned int>> binCounts = {}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| MappingType mappingType = MappingType::Default); | ||
|
|
||
| /// Scale operation | ||
|
|
@@ -66,6 +70,12 @@ class BinnedSurfaceMaterial : public ISurfaceMaterial { | |
| /// @return Reference to the complete matrix of material slabs | ||
| const MaterialSlabMatrix& fullMaterial() const { return m_fullMaterial; } | ||
|
|
||
| /// @brief Retrieve the bin counts matrix of the mapped bins | ||
| /// @return Reference to the bin counts matrix of the map | ||
| const std::vector<std::vector<unsigned int>>& binCounts() const { | ||
| return m_binCounts; | ||
| } | ||
|
|
||
| /// @copydoc ISurfaceMaterial::materialSlab(const Vector2&) const | ||
| const MaterialSlab& materialSlab(const Vector2& lp) const final; | ||
|
|
||
|
|
@@ -91,6 +101,9 @@ class BinnedSurfaceMaterial : public ISurfaceMaterial { | |
|
|
||
| /// The five different MaterialSlab | ||
| MaterialSlabMatrix m_fullMaterial; | ||
|
|
||
| // The bin counts of the mapped bins | ||
| std::vector<std::vector<unsigned int>> m_binCounts; | ||
| }; | ||
|
|
||
| } // namespace Acts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
andiwand marked this conversation as resolved.
Outdated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // This file is part of the ACTS project. | ||
| // | ||
| // Copyright (C) 2026 CERN for the benefit of the ACTS project | ||
| // | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
|
|
||
| #include <TROOT.h> | ||
| #include <TFile.h> | ||
| #include <TKey.h> | ||
| #include <TDirectory.h> | ||
| #include <TH2F.h> | ||
| #include <TH1F.h> | ||
| #include <TCanvas.h> | ||
|
|
||
| #include <string> | ||
| #include <fstream> | ||
| #include <iostream> | ||
| #include <sstream> | ||
|
|
||
| void makeBinCountsDist(const char* filename = "material-maps.root") | ||
| { | ||
| TFile* f = TFile::Open(filename, "READ"); | ||
| if (!f || f->IsZombie()) return; | ||
|
|
||
| TIter nextDir(f->GetListOfKeys()); | ||
| TKey* key; | ||
|
|
||
| while ((key = (TKey*)nextDir())) { | ||
|
|
||
| TObject* obj = key->ReadObj(); | ||
|
|
||
| if (!obj->InheritsFrom(TDirectory::Class())){ | ||
| continue; | ||
| } | ||
|
|
||
| TDirectory* dir = (TDirectory*)obj; | ||
|
|
||
| TH2F* h2 = nullptr; | ||
| dir->GetObject("binCounts", h2); | ||
|
|
||
| if (!h2){ | ||
| std::cout<<"Histogram not found - continue"<<std::endl; | ||
| continue; | ||
| } | ||
|
|
||
| std::cout << "\nProcessing: " << dir->GetName() << std::endl; | ||
|
|
||
| TH1F hDist("binCountsDist", | ||
| "BinCounts distribution;count;bins", | ||
| 100, 0, h2->GetMaximum() + 1); | ||
|
|
||
| std::size_t nEmptyBins{0}; | ||
|
|
||
| for (int ix = 1; ix <= h2->GetNbinsX(); ++ix) { | ||
| for (int iy = 1; iy <= h2->GetNbinsY(); ++iy) { | ||
|
|
||
| double val = h2->GetBinContent(ix, iy); | ||
| if(val == 0){ | ||
| nEmptyBins+=1; | ||
| } | ||
| hDist.Fill(val); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| std::cout << "Mean = " << hDist.GetMean() | ||
| << " ,StdDev = " << hDist.GetStdDev() | ||
| <<" ,Empty bins counted = "<< nEmptyBins | ||
| << std::endl; | ||
|
|
||
| TCanvas* c = new TCanvas(); | ||
| hDist.Draw(); | ||
|
|
||
| c->SaveAs(Form("%s_binCounts.png", dir->GetName())); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we really want to pipe everything through the reconstruction abstraction. if these were two different interfaces we could leave the reco untouched
one way out might be to containerize the accumulated material with dynamic columns and trimming that for reconstruction purposes
but all of this is rather long term compared to this change here
cc @asalzburger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the GridSurfaceMaterial has already some sort of containerized option. I am sort of waiting until we have the axis work through to clean this one up - probably we wait for the binCounts to added at that stage then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sounds like an option. I draft it for now and go with the containerized option, once the axis refactoring is also done