support index-based selection#502
Conversation
|
Hi @goblirsc, nice to see these :) I believe quickest way to fix the tests would be to rebase on the latest master. |
9be047e to
4591373
Compare
Thanks, missed the latest commits by a tiny bit :) |
|
PRs up to 500 should be sufficient for the pipeline, the later PRs do not affect analyzers. |
900ab16 to
24fc851
Compare
|
after running Or is this genuine and the entire codebase was violating the formatting rules? |
|
Dear @kjvbrt, can we retry the |
|
Hi @goblirsc, the test tries to do a selective format, only of the edited lines. One can do it with the help of git You can get the |
This reverts commit 24fc851.
Thank you! The number of format changes looks a lot more reasonable now :) |
|
Hm, the CI seems to expect a different format to the one I get when I run |
|
Dear @kjvbrt, I now applied the diff printed by the formatter by hand, after To avoid this overhead in the future, is there a recipe for either reproducibly applying the formatter locally with changes consistent to what the CI expects, or for automatically applying the suggested patch from the CI to my branch? Cheers, Max |
|
Dear @kjvbrt, in addition to the above, it seems the pipeline is set to only run when you manually trigger it. Could you please do so? Cheers, |
|
next format update, please re-run the CI. |
|
Dear @kjvbrt, I think I finally figured out how to run the CI formatter stage locally :) May I make another suggestion? Could the formatter check
Cheers, Max |
| ``` | ||
| git clang-format --style=file $(git merge-base upstream/master HEAD) | ||
| ``` | ||
| to only format the lines you changed (otherwise you will reformat the entire file). |
There was a problem hiding this comment.
Thanks for figuring this out :)
Maybe (otherwise you will reformat the entire file) is a bit redundant, as the same information is a few lines above.
There was a problem hiding this comment.
In any case, at some point we need to run formatter across the whole repository.
There was a problem hiding this comment.
Fixed (caught a long-term gitlab user :) )
| bool operator() (ROOT::VecOps::RVec<edm4hep::MCParticleData> in); | ||
| }; | ||
|
|
||
| /// @brief Helper struct to select entries matching a certain predicate. |
There was a problem hiding this comment.
Could you also provide an example of usage?
There was a problem hiding this comment.
Hi, sure - would you prefer this in the doxygen doc or on the PR?
The replacements for the selectors below this definition can serve as "inline" examples to refer to.
The general pattern is
struct mySelection: selByPredicate{
mySelection(): selByPredicate(some_selection_function){}
};
Where some_selection_function is a function returning a "keep" decision for a given input object. Using lambda captures, the function can be configured with constructor arguments - for example, a configurable cut threshold.
This object can then be used to obtain a copy-vector of passed objects from an input object list, or a set of passing indices, or a set of passing element for each of a list of input index vectors.
The main motivation is that we save a lot of common boilerplate code when implementing selection functions (loop over containers, output allocation, copy operations, ...). The pattern also ensures that deep-copies are avoided where possible. We also gain the ability to apply the same selection functor transparently on index-based or copy-based selection logic, avoiding a need to duplicate logic if both are to be supported.
It would actually be more elegant to generalise this to a template consuming an arbitrary input object type, rather than being restricted to the MCParticleData class.
There was a problem hiding this comment.
Nice explanation, I think having it in Doxygen would be the best. Would you also add an example how to use this when working with the dataframe in Python? I mean a snipped a user might write.
There was a problem hiding this comment.
Added explanation for doxygen, including snippets. Also moved the selByPredicate to Utils, making it available more generally than before.
Add a few features to help with index-based object selection and truth-reco matching studies within FCCAnalyses:
MCParticleselection structs now support both element-based and index-based selectionsselByPredicatebase struct is introduced to simplify adding future selection criteria without copy-pasting boilerplate codeget_lists_of_stable_particles_from_decaysfunction extending the existingget_list_of_stable_particles_from_decayto check multiple decaying particles in one callselRP_matched_to_listand add an index-based version. Add optional flag to also match metastable particlesindex_rangehelper function to obtainrange(coll.size())for any RVec collection.count_valid_indiceshelper function to count valid entries in a list of (selected) indices.sel_byIndexhelper function to move from index list to particle listgetVertex_matching_recoParticlesfunction to VertexingUtils - find vertices that contain a user-specified list of recoparticlesThe changes in this PR are designed to be transparent to all existing code - should require no adaptation by users.