Skip to content
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

feat: use algorithms properties in CalorimeterClusterRecoCoG (2) #1165

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wdconinc
Copy link
Contributor

@wdconinc wdconinc commented Dec 1, 2023

Briefly, what does this PR introduce?

This PR converts CalorimeterClusterRecoCoG to using properties defined as algorithms::Property. This is the second attempt at #1154, now based on JOmniFactory and ParameterRef.

What kind of change does this PR introduce?

  • Bug fix (issue #__)
  • New feature (issue #__)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

@github-actions github-actions bot added topic: calorimetry relates to calorimetry topic: far-forward Far forward reconstruction topic: far-backward Reconstruction related to far backward detectors topic: barrel topic: forward topic: backward labels Dec 1, 2023
[this, key = key](auto&& val) {
using T = std::decay_t<decltype(val)>;
if constexpr (std::is_fundamental_v<T>
|| std::is_same_v<T, std::string>) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vector is now also ok, I think.

@wdconinc
Copy link
Contributor Author

wdconinc commented Dec 2, 2023

It is curious that this introduces the kind of diffs (e.g. https://github.com/eic/EICrecon/actions/runs/7072810354/job/19252231634#step:15:82) that are more typically assocated with double/float conversions. So either before or after there may be a conversion that shouldn't happen.

std::visit(
[this, key = key, &parameters](auto&& val) {
using T = std::decay_t<decltype(val)>;
if constexpr (std::is_fundamental_v<T> || std::is_same_v<T, std::string>) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incomplete because JParameterManager can parse the algorithms::Property of type T = std::vector<U> where U is a fundamental type or std::string. However, we can't use

Suggested change
if constexpr (std::is_fundamental_v<T> || std::is_same_v<T, std::string>) {
if constexpr (std::is_fundamental_v<T> || std::is_same_v<T, std::string>
|| std::is_same_v<std::vector<typename T::value_type, T> && std::is_fundamental_v<typename T::value_type>) {

because it tries to apply this to the fundamental types too, and fails due to T::value_type not existing for e.g. T = bool. I'm not sure yet how to solve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nathanwbrei @veprbl Maybe you have some insights on how to structure a type test here.

@wdconinc
Copy link
Contributor Author

wdconinc commented Dec 4, 2023

So either before or after there may be a conversion that shouldn't happen.

Actually, it's worse. Somewhere I am passing a reference to a copy of the property value in the algorithm, so the algorithm still operates with the original default... Back to the drawing board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: backward topic: barrel topic: calorimetry relates to calorimetry topic: far-backward Reconstruction related to far backward detectors topic: far-forward Far forward reconstruction topic: forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant