-
Notifications
You must be signed in to change notification settings - Fork 242
refactor: Refactoring of string parsing code for Gbts LUT and connection table #4934
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
302d8f6
refactoring of LUT parser
jpreston-cern 16fe8ca
removed unessicary include
jpreston-cern b2b27b8
clang tidy
jpreston-cern 09255a7
add condition to pass empty array if clusterwidth is not used
jpreston-cern 25854d6
fixes based of andi and benjamins suggestions
jpreston-cern 17a22b0
clang tidy
jpreston-cern 9b4c5bb
next set of changes (minus Lutparser conversation)
jpreston-cern ca2fd45
reformatted lut parser to be a free function instead of a class
jpreston-cern 2fff28b
Merge branch 'main' into refactoring
andiwand 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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // This file is part of the ACTS project. | ||
| // | ||
| // Copyright (C) 2016 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/. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <array> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace Acts::Experimental { | ||
|
|
||
| class GbtsLutParser { | ||
| public: | ||
| explicit GbtsLutParser() = default; | ||
|
|
||
| void parseLutFile(std::string& lutInputFile, bool useML); | ||
|
|
||
| const std::vector<std::array<float, 5>>& getParsedLut() const { | ||
| return m_mlLUT; | ||
| } | ||
|
|
||
| private: | ||
| std::vector<std::array<float, 5>> m_mlLUT{}; | ||
andiwand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| } // namespace Acts::Experimental | ||
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
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,43 @@ | ||
| // This file is part of the ACTS project. | ||
| // | ||
| // Copyright (C) 2016 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 "Acts/Seeding/GbtsLutParser.hpp" | ||
|
|
||
| #include <fstream> | ||
|
|
||
| namespace Acts::Experimental { | ||
|
|
||
| void GbtsLutParser::parseLutFile(std::string& lutInputFile, bool useML) { | ||
| if (useML) { | ||
| if (lutInputFile.empty()) { | ||
| throw std::runtime_error("Cannot find ML predictor LUT file"); | ||
| } else { | ||
| m_mlLUT.reserve(100); | ||
| std::ifstream ifs(std::string(lutInputFile).c_str()); | ||
|
|
||
| if (!ifs.is_open()) { | ||
| throw std::runtime_error("Failed to open LUT file"); | ||
| } | ||
|
|
||
| float cl_width{}, min1{}, max1{}, min2{}, max2{}; | ||
|
|
||
| while (ifs >> cl_width >> min1 >> max1 >> min2 >> max2) { | ||
| std::array<float, 5> lut_line = {cl_width, min1, max1, min2, max2}; | ||
| m_mlLUT.emplace_back(lut_line); | ||
| } | ||
| if (!ifs.eof()) { | ||
| // ended if parse error present, not clean EOF | ||
|
|
||
| throw std::runtime_error("Stopped reading LUT file due to parse error"); | ||
| } | ||
|
|
||
| ifs.close(); | ||
| } | ||
| } | ||
| } | ||
| } // namespace Acts::Experimental |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.