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

Remove excess selector code #1587

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Remove excess selector code #1587

wants to merge 24 commits into from

Conversation

simonge
Copy link
Contributor

@simonge simonge commented Aug 20, 2024

Briefly, what does this PR introduce?

Removes remaining selector algorithms and factories reducing the code base.

Functionality to simply select a subset collection based on not matching was missing from the simple sub-divide functors (selecting all charged particles). This PR extends the ValueSplit to allow the output to each collection where the filter does not match.

Working the same in the case of selecting charged particles, the option to select outside of a range in RangeSplit has been added but this is slightly less intuitive and probably less optimal (charge<0||charge>0)

Alternative approaches would be to have a dedicated separate functors for these cases or just create the lambda function in the factory definition itself.

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

@@ -90,23 +105,33 @@ template <auto... MemberFunctionPtrs>
class ValueSplit {
public:

ValueSplit(std::vector<std::vector<int>> ids) : m_ids(ids) {};
ValueSplit( std::vector<std::vector<int>> ids, bool matching = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also const ref the ids arg here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, optionally, I've wondered about a TrueFalseSplit functor a number of times. That's really just a ValueSplit (which is how this gets implemented in plugins), but it could have the benefit of accepting a function that returns a bool, which is semantically cleaner than relying on bool to integer conversions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You would have to move away from the simple std::find implementation for anything other than ==. I'll have another think, as changing the functors already there is making them less clear. It should be possible to pass an array of boolean operators along with values and member functions to a functor.

After the vertexing discussion, access to min/max might be nice too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BooleanSplit (name can still be changed) should be able to perform the jobs of RangeSplit and ValueSplit where an array of functions which return a bool from two inputs is passed alongside the array of values to compare. The bools are all reduced by and rather than trying to mix in some more complexity.

What is missing the the ability to compare types other than float, I'm not sure how to approach for instance asking for e.g. ReconstructedParticles with PDG "equal_to" and a goodnessOfPID "greater_than". Maybe it's not important, could be done in a few steps, or this sort of thing is not what we'll want to do in eicrecon.

@wdconinc wdconinc force-pushed the Remove-Excess-Selector-Code branch from 20cb0b4 to 9786e24 Compare August 28, 2024 14:04
@wdconinc
Copy link
Contributor

Rebased to pick up #1591.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants