Skip to content

wrong implementation of gdml matrices? #245

@ManuelHu

Description

@ManuelHu

I think I found a quite serious mis-implementation of GDML matrices. Luckily, this does not affect all use cases (that is why we never have seen this in our optical use case)

see this short notebook example, in which I would expect a different result:


from pyg4ometry import gdml, geant4
import numpy as np
reg = geant4.Registry()
mv = gdml.MatrixFromVectors([1, 2, 3], [100, 200, 300], "testmatrix", reg)
mv.values
[Expression : matrix_expr_idx0_val_testmatrix = expr_matrix_expr_idx0_val_testmatrix : 1*eV,
 Expression : matrix_expr_idx1_val_testmatrix = expr_matrix_expr_idx1_val_testmatrix : 100,
 Expression : matrix_expr_idx2_val_testmatrix = expr_matrix_expr_idx2_val_testmatrix : 2*eV,
 Expression : matrix_expr_idx3_val_testmatrix = expr_matrix_expr_idx3_val_testmatrix : 200,
 Expression : matrix_expr_idx4_val_testmatrix = expr_matrix_expr_idx4_val_testmatrix : 3*eV,
 Expression : matrix_expr_idx5_val_testmatrix = expr_matrix_expr_idx5_val_testmatrix : 300]

--> this has the right order

mv.eval()
array([[9.99999566e-07, 1.00000000e+02, 1.99999913e-06],
       [2.00000000e+02, 2.99999870e-06, 3.00000000e+02]])

--> this does not have the right structure at all? It is just the values array arbitrarily folded in half?

mv.eval().reshape(-1).reshape(3, 2)
array([[9.99999566e-07, 1.00000000e+02],
       [1.99999913e-06, 2.00000000e+02],
       [2.99999870e-06, 3.00000000e+02]])

--> this would be the right result, with the two columns in GDML organized in columns of the evaled matrix?

this is not just the transposition of the "wrong" matrix above, but a complete re-ordering of all values. (if eval() returns a matrix like this, or the transposed value, could still be discussed; especially for 1D "matrices")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions