LHCb Physics Event Model Comments on the MathCore Vector and the Root Linear Algebra Classes

Introduction

The review of the physics event model is the right opportunity to also revise the usage of CLHEP. The merger of SEAL and ROOT is supposed to provide a new library of vectors and linear algebra (matrices) that overcome the known CLHEP problems (see below). There is a test version of the vector classes available, while the liear algebra matrices are part of the ROOT TObject classes for quite some time.

We have tried to use these classes in the new Physics Event Model but have found too many problems.

The contact person far all these issues is Juan Palacios.

CLHEP problems

A brief reminder of the problems with CLHEP:

  • No constructor from Point to Vector. A point minus a point is a point (!). The following code calculating an impact parameter does not compile anymore:

HepPoint3D P(0,0,0), B(1,2,3);
Hep3Vector V(0.8,0.6,0.0);
Hep3Vector D = B - A;                     // does not compile with CLHEP 1.9
double IP = (D.cross(V.unit()).mag();

One needs to:

HepPoint3D TMP = B - A ;                 // point - point is point (!?)
Hep3Vector D(TMP.x(),TMP.y(),TMP.z()) ;  // object-oriented programming ?

  • Because of a bug of the new CLHEP 1.9, whenever one includes HepSymMatrix.h after *Point*.h, one does not get the method HepSymMatrix sub(int min_row, int max_row); which results in the run-trime error
              relocation error: .../slc3_ia32_gcc323/lib*.so: undefined symbol: _ZN5CLHEP12HepSymMatrix3subEii
    
Conclusion: Include SymMatrix at the very beginning of the file.
  • The internal representation of a HepLorentzVector is (momentum, energy) which causes precision problems for photons for instance.

MathCore Vector Classes

Although they have a little complicated structure (many templates and typedefs) which makes it sometimes difficult to know which class one is actually using, the MathCore Vector Classes are quite well designed. Also the classes have sometimes silly names (XYZTVector for instance), which we hide behing an additional layer of typedefs.

There are a few small problems that can be easily fixed:

  • We found an inconsistency in the behaviour of the typedefs for Vector3Ds and LorentzVectors. If I MathCore/Vector3D.h in my code, this includes MathCore/Vector3Dfwd.h, so I get the typedefs XYZVector, XYZVectorF, etc. However, if I include MathCore/LorentzVector.h, I do not have access to the typedefs as this file does not include MathCore/LorentzVectorfwd.h.
  • A XYZTPoint is missing
  • The Vec() method in XYZTVector is not const

Root Linear Algebra Classes

  • All classes are TObjects, which pulls the whole of ROOT into our event model. Is that necessary?
  • Internally there are exported typedefs like Assert which overwrites the Assert method in GaudiTool.
  • We would like to be able to get a sub-matrix by reference. This is presently implemented, but the interface of the method is quite strange.
  • The linear algebra classes seem not to be compatible with the mathcore classes. There is no way to multiply a matrix and a vector. (?)

Links

-- PatrickKoppenburg - 09 Sep 2005

Edit | Attach | Watch | Print version | History: r7 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2005-09-09 - PatrickSKoppenburg
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LHCb All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback