Project

General

Profile

Feature #19043

Bug #18972: Track length based only on ValidPoints (i.e. !NoPoint flag), ignores flags ExcludedByFit and RejectedByFit

need a more generic version of the methods NextValidPoint and PreviousValidPoint, taking as an argument a list of allowed (or forbidden) flags

Added by Giuseppe Cerati almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Data products
Target version:
-
Start date:
02/19/2018
Due date:
% Done:

100%

Estimated time:
Spent time:
Experiment:
-
Co-Assignees:
Duration:

Description

need a more generic version of the methods NextValidPoint and PreviousValidPoint, taking as an argument a list of allowed (or forbidden) flags

Associated revisions

Revision b287771e (diff)
Added by Gianluca Petrillo over 1 year ago

Added TrajectoryPointFlags::match().

This is in support of resolution of issue #19043.

Revision 00f7c810 (diff)
Added by Gianluca Petrillo over 1 year ago

Added interface to filter trajectory points in a iteration.

This solves issue #19043.

History

#1 Updated by Lynn Garren almost 2 years ago

  • Status changed from New to Assigned

#2 Updated by Gianluca Petrillo over 1 year ago

The solution implemented here is at proxy level.
A method has been added to proxy::Tracks proxy element interface: TrackCollectionProxyElement<CollProxy>::pointsWithFlags() can be used in a for-range loop to iterate through the points which match the flags specified as an argument. As a reminder, the mask type allows to request for each of the flags to be set, unset or ignored independently, in any combination.
An example of usage is provided in the Doxygen documentation of that method.

An additional method is provided, selectPoints(), which will apply a user-defined requirement to determine whether to skip each point. pointsWithFlags() is a specific use of this more generic method.

Although this is not documented, both methods are required to answer to begin() and end() free functions to return two iterators: this requirement comes from C++ support for range-for loops.
Therefore these methods can be used also to obtain the specific iterators. The iterators are not standard iterators, but they support most of the standard input iterator interface (except operator->()) and some of the forward iterator interface (except that reference is not even a reference type), but they do not support backward iteration. An example (untested) of how to get and use those iterators is:

auto tracks = proxy::getCollection<proxy::Tracks>(event, tracksTag);
for (auto const& track: tracks) {
  auto const& pointRange = track.selectPoints([](auto const& point){ return point.isPointValid(); });
  double length = 0.0;
  unsigned int nValidPoints = 0U;
  auto iPoint = pointRange.begin();
  auto pend = pointRange.end();
  while (iPoint != pend) {
    ++nValidPoints;
    auto prevPoint = iPoint++; // go to next valid point, leave the current one as `prevPoint`
    if (iPoint == pend) break; // if prevPoint was the last one, we are done
    length += (iPoint->position() - prevPoint->position()).R();
  } // while
  mf::LogVerbatim("ProxyExample") << "Track #" << track.index() << " has " << nValidPoints << " points and length " << length << " cm";
} // for tracks

The implementation relies on Boost's filter iterators (there are probably more things in the proxy implementation which could rely on Boost).

#3 Updated by Gianluca Petrillo over 1 year ago

  • Category set to Data products
  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

The resolution is published in branch feature/gp_Issue19043 of repositories lardata (main implementation), larcorealg and lardataobj (little instrumental improvements).

#4 Updated by Gianluca Petrillo over 1 year ago

  • Status changed from Resolved to Closed

#5 Updated by Lynn Garren over 1 year ago

  • Status changed from Closed to Assigned

#6 Updated by Lynn Garren over 1 year ago

  • Status changed from Assigned to Closed

Branches merged successfully for the upcoming release.



Also available in: Atom PDF