Project

General

Profile

Support #11257

recob::PCAxis uses nested vector to represent 3x3 matrix

Added by Gianluca Petrillo over 5 years ago. Updated over 3 years ago.

Status:
Assigned
Priority:
Normal
Assignee:
Category:
Architecture
Target version:
-
Start date:
12/18/2015
Due date:
% Done:

0%

Estimated time:
4.00 h
Experiment:
-
Co-Assignees:
Duration:

Description

recob::PCAxis uses a nested std::vector to represent the 3x3 matrix of eigenvalues.

If ROOT 6 supports std::array, we should probably use a nested std::array instead.
Otherwise, a simple double[9] structure is enough.
If the 2D interface is desired, it can be obtained replacing the current

const EigenVectors& getEigenVectors() const;

with
/// Returns all the eigenvectors (principal, second, third) in a row
double const* getEigenVectors() const { return &(fEigenVectors[0]); }
/// Returns the i-th eigenvector (array: { x, y, z } coordinates)
double const* getEigenVector(size_t i) const { return &(fEigenVectors[3 * i]); }

A breaking change by writing an input rule.


Related issues

Blocked by LArSoft - Task #14048: Provide a uniform recommendation for physic vector data structures in LArSoft data productsClosed10/04/2016

History

#1 Updated by Lynn Garren about 5 years ago

  • Status changed from New to Assigned

#3 Updated by Katherine Lato over 4 years ago

As part of data product review phase II, new representation of vectors is being sought. After that happens, this data product will have to be reshaped to use those.

#4 Updated by Gianluca Petrillo over 4 years ago

  • Blocked by Task #14048: Provide a uniform recommendation for physic vector data structures in LArSoft data products added

#5 Updated by Katherine Lato over 3 years ago

  • Assignee changed from Gianluca Petrillo to Tracy Usher

Assigned to Tracy.
From: "Usher, Tracy L." <>
Date: Wednesday, October 11, 2017 at 2:48 PM
To: Katherine Lato <>
Cc: Gianluca Petrillo <>, Erica Snider <>
Subject: Re: Can you take this redmine issue?

Sure.

Tracy

On Oct 11, 2017, at 12:45 PM, Katherine Lato <> wrote:

Tracy,
Would you be willing to take ownership of
https://cdcvs.fnal.gov/redmine/issues/11257

#6 Updated by Tracy Usher over 3 years ago

Gianluca Petrillo wrote:

recob::PCAxis uses a nested std::vector to represent the 3x3 matrix of eigenvalues.

If ROOT 6 supports std::array, we should probably use a nested std::array instead.
Otherwise, a simple double[9] structure is enough.
If the 2D interface is desired, it can be obtained replacing the current
[...]
with
[...]

A breaking change by writing an input rule.

Ok, I think I might be a little bit uncertain what is desired here... the 3x3 matrix in question contains the 3 eigenvectors which are unit vectors describing the directions of each of the 3 principal components axes that have been found. The advantage to the nested std::vector scheme is that it only takes one index to get the a) primary, b) secondary or 3) tertiary eigen vector. Its not obvious to me how to obtain the same behavior with, for example, a simple array.

any hints?

#7 Updated by Gianluca Petrillo over 3 years ago

The point is to avoid the use of std::vector for fixed-array data.
Using a nested array of arrays is fine, I think (I am told ROOT 6.8.6 is supposed to support std::array serialisation): std::array<std::array<double, 3U>, 3U>.
My recommendation is to have an array of 3D vectors, like std::array<geo::Vector_t, 3U> (see From ROOT vectors (TVector3) to ROOT GenVector, http://nusoft.fnal.gov/larsoft/doxsvn/html/namespacegeo.html#ac78157942b179c6abb41ed24ccb4560a and larcoreobj:source:larcoreobj/SimpleTypesAndConstants/geo_vectors.h). That is a breaking change, though, in that it will require the accessors to return a different data type. Totally worth, in my opinion (and I would help with the schema evolution in ROOT I/O).

#8 Updated by Gianluca Petrillo over 3 years ago

Correction: ROOT 6.8.6 was meant to support std::array, but for us the full support will come only with art 2.9 (which we hope to push through next week).

Also available in: Atom PDF