Skip to content

functor improvements

Olli Lupton requested to merge olupton_improve_functors into master

Improvements to the functors:

  • Adjust functor code to allow printing via the owning algorithm.
  • Provide a simple implementation of Warning that doesn't spam
    • @graven, @clemenci it doesn't seem like this is a thing that I should be doing...but it's also not clear what would be better. The use-case is wanting to print a warning that gets suppressed after a while, where the text of the warning is not predictable (there are a "large" number of possible texts), and the performance of the code is not a major concern (the warning exists to tell you that you are doing something suboptimal...)
  • Implement Gerhard's suggestion in #60 (closed) (remove apply_single, simplifying functor definitions slightly). Closes #60 (closed).
  • Support adapters, so you can write e.g. SUM(PT) as a CombinationCut
    • Try the implementation choice of CombinationCut acting on a special collection-of-tracks type -- this means that for something like MAXDOCACHI2 < 10. the functor can remain trivial (return combination.maxdocachi2();), with the work done in the track combination type. By defining begin and end functions the track-combination type is also iterable, so something like SUM(PT) (scalar sum of transverse momenta) can also work naturally.
  • Add some functors for acting on composite particles, e.g. "DIRA" angle between momentum and flight direction, and ipchi2 of a composite particle.
  • Make the detail::ComposedFunctor helper variadic and implement most/all operations and overloads more succinctly using it. Also add some missing operator overloads.
  • Add generic detail::FunctorWithDataDeps helper for functors that have external data dependencies
  • Make some functors into templates (e.g. functors using PVs are templated on the PV container type), expose this to Python but allow implicit/default behaviour in normal cases
  • Improvements in the Python wrapper:
    • Add missing operator overloads __r*__ for when the LHS is a basic type.
    • Allow functors with exactly one argument to have it specified as a positional argument.
  • Allow "prepared" functors to be accessed through the type-erasure layer.
  • Support variadic functor signatures and add some new functors.
    • Allows void functors for things like SIZE("Some/TES/Location") > 0.
    • Also permits functors that explicitly take two objects, e.g. DOCA.
  • Reduce the verbosity of the functor factory and try to enable cling optimisation.

Miscellaneous other improvements that risked getting lost:

  • Move the proxies used to iterate LHCb::Pr::Velo::Tracks out of the functor code (closes #72 (closed)), see LHCb MR.
  • Make Pr::Selection's iterators compatible with std::next()
  • In TracksFTConverter make all states get a consistent q/p error according to the algorithm property
  • Import commit from @pseyfert simplifying how we can write out SOA::Container skin/proxy types.

Other experiments, not finalised but also quite well-contained so may be fine to merge:

  • Import commit from @wouter including new vertex types (!1477 (closed)) -- thanks to merge conflicts it was easier to pick the contents in one commit than merge that other branch as-is.
  • Add a track combiner algorithm based on these new vertex classes, mainly as a way of testing that the relevant functor signatures work as expected
  • Add a "void filter" algorithm, which wraps a functor that takes no arguments
  • Add Phys/SelAlgorithms and Phys/SelKernel packages to hold new algorithms/types/utilities.

Goes with LHCb!2029 (merged) and Moore!204 (merged).

Edited by Marco Cattaneo

Merge request reports