Public Member Functions | Private Member Functions | List of all members
EDep::TMatrixElement Class Reference

#include <TMatrixElement.hxx>

Inheritance diagram for EDep::TMatrixElement:

Public Member Functions

 TMatrixElement (const char *name, const TVector3 &position, const TMatrixD &matrix, bool longAxis)
 
 TMatrixElement (const char *name, const TVector3 &position, const TMatrixF &matrix, bool longAxis)
 
virtual ~TMatrixElement ()
 

Private Member Functions

void Initialize (const TVector3 &position, const TMatrixD &matrix, bool longAxis)
 

Detailed Description

A Eve Element object to represent a 3x3 matrix (either the moments of a distribution, or the covariance) at a position. This can be used to represent clusters, or other objects, and handles some of the matrix algebra necessary. Since Eve can't draw a spheriod, the spheriod described by the matrix is drawn as an eliptical tube. If the longAxis variable is true, then the longest axis of the spheriod is used as the axis of the tube, but if it's false, the shortest axis of the spheriod is used as the axis of the tube.

Definition at line 21 of file TMatrixElement.hxx.

Constructor & Destructor Documentation

EDep::TMatrixElement::TMatrixElement ( const char *  name,
const TVector3 &  position,
const TMatrixD &  matrix,
bool  longAxis 
)

Definition at line 11 of file TMatrixElement.cxx.

15  : TEveGeoShape(name) {
16  Initialize(position,matrix,longAxis);
17 }
static QCString name
Definition: declinfo.cpp:673
void Initialize(const TVector3 &position, const TMatrixD &matrix, bool longAxis)
EDep::TMatrixElement::TMatrixElement ( const char *  name,
const TVector3 &  position,
const TMatrixF &  matrix,
bool  longAxis 
)

Definition at line 19 of file TMatrixElement.cxx.

23  : TEveGeoShape(name) {
24  TMatrixD mat(matrix);
25  Initialize(position,mat,longAxis);
26 }
static QCString name
Definition: declinfo.cpp:673
void Initialize(const TVector3 &position, const TMatrixD &matrix, bool longAxis)
EDep::TMatrixElement::~TMatrixElement ( )
virtual

Definition at line 9 of file TMatrixElement.cxx.

9 {}

Member Function Documentation

void EDep::TMatrixElement::Initialize ( const TVector3 &  position,
const TMatrixD &  matrix,
bool  longAxis 
)
private

Definition at line 28 of file TMatrixElement.cxx.

30  {
31  // Find the rotation of the object to be displayed. If longAxis is true,
32  // the the matrix is represented as a tube with the long axis along the
33  // local Z direction, and the major and minor in the XY plane. Otherwise,
34  // the matrix is represented as a tube with the short axis along the local
35  // Z direction.
36  TMatrixD tubeRot(3,3);
37  for (int i=0; i<3; ++i) {
38  for (int j=0; j<3; ++j) {
39  tubeRot(i,j) = matrix(i,j);
40  }
41  }
42 
43  double tubeAxis;
44  double tubeMajor;
45  double tubeMinor;
46  TVectorD values(3);
47  TMatrixD tubeEigen(tubeRot.EigenVectors(values));
48  if (longAxis) {
49  tubeAxis = std::sqrt(values(0));
50  tubeRot(0,2) = tubeEigen(0,0);
51  tubeRot(1,2) = tubeEigen(1,0);
52  tubeRot(2,2) = tubeEigen(2,0);
53  tubeMajor = std::sqrt(values(1));
54  tubeRot(0,0) = tubeEigen(0,1);
55  tubeRot(1,0) = tubeEigen(1,1);
56  tubeRot(2,0) = tubeEigen(2,1);
57  tubeMinor = std::sqrt(values(2));
58  tubeRot(0,1) = tubeEigen(0,2);
59  tubeRot(1,1) = tubeEigen(1,2);
60  tubeRot(2,1) = tubeEigen(2,2);
61  }
62  else {
63  tubeAxis = std::sqrt(values(2));
64  tubeRot(0,2) = tubeEigen(0,2);
65  tubeRot(1,2) = tubeEigen(1,2);
66  tubeRot(2,2) = tubeEigen(2,2);
67  tubeMajor = std::sqrt(values(0));
68  tubeRot(0,0) = tubeEigen(0,0);
69  tubeRot(1,0) = tubeEigen(1,0);
70  tubeRot(2,0) = tubeEigen(2,0);
71  tubeMinor = std::sqrt(values(1));
72  tubeRot(0,1) = tubeEigen(0,1);
73  tubeRot(1,1) = tubeEigen(1,1);
74  tubeRot(2,1) = tubeEigen(2,1);
75  }
76 
77  // Create the rotation matrix.
78  TGeoRotation rot;
79  rot.SetMatrix(tubeRot.GetMatrixArray());
80 
81  // Set the translation
82  TGeoTranslation trans(position.X(), position.Y(), position.Z());
83 
84  // Finally set the transform for the object.
85  TGeoCombiTrans rotTrans(trans,rot);
86  SetTransMatrix(rotTrans);
87 
88  // Make sure the tube size doesn't get too small.
89  tubeAxis = std::max(1.5, tubeAxis);
90  tubeMajor = std::max(1.5, tubeMajor);
91  tubeMinor = std::max(1.5, tubeMinor);
92 
93  // Create the shape to display. This has to play some fancy footsie to
94  // get the gGeoManager memory management right. It first saves the
95  // current manager, then gets an internal geometry manager used by
96  // TEveGeoShape, and then resets the old manager once the shape is
97  // created. You gotta love global variables...
98  TGeoManager* saveGeom = gGeoManager;
99  gGeoManager = GetGeoMangeur();
100  TGeoShape* geoShape = new TGeoEltu(tubeMajor,tubeMinor,tubeAxis);
101  SetShape(geoShape);
102  gGeoManager = saveGeom;
103 }
Q_UINT16 values[128]
static int max(int a, int b)

The documentation for this class was generated from the following files: