All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SRVector3D.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file SRVector3D.h
3 // \author Christopher Backhouse - bckhouse@caltech.edu
4 ////////////////////////////////////////////////////////////////////////
5 
6 #ifndef SRVECTOR3D_H
7 #define SRVECTOR3D_H
8 
9 #ifndef __castxml__
10 #include "TVector3.h"
11 #endif
12 
13 namespace caf
14 {
15  /// A 3-vector with more efficient storage than TVector3
16  class SRVector3D
17  {
18  public:
19  SRVector3D();
20  virtual ~SRVector3D();
21 
22 #ifndef __castxml__
23  SRVector3D(float x, float y, float z);
24  /// Easy conversion from TVector3
25  SRVector3D(const TVector3& v);
26 
27  void SetXYZ(float x, float y, float z);
28 
29  /// Easy conversion back to TVector3
30  operator TVector3() const;
31 
32  void SetX(float _x){x = _x;}
33  void SetY(float _y){y = _y;}
34  void SetZ(float _z){z = _z;}
35 
36  float X() const {return x;}
37  float Y() const {return y;}
38  float Z() const {return z;}
39 
40  // The more common TVector3 operations, mostly for use with TTree::Draw
41  //
42  // NB: you need to specify the initial "rec." when using these
43  float Mag2() const {return x*x+y*y+z*z;}
44  float Mag() const {return sqrt(Mag2());}
45  float Dot(const SRVector3D& v) const {return x*v.x + y*v.y + z*v.z;}
46  SRVector3D Unit() const
47  {
48  const float m = Mag();
49  return SRVector3D(x/m, y/m, z/m);
50  }
51 #endif
52 
53  float x;
54  float y;
55  float z;
56  };
57 
58 } // end namespace
59 
60 #endif // SRVECTOR3D_H
61 //////////////////////////////////////////////////////////////////////////////
62 
A 3-vector with more efficient storage than TVector3.
Definition: SRVector3D.h:16
void SetXYZ(float x, float y, float z)
Definition: SRVector3D.cxx:33
void SetX(float _x)
Definition: SRVector3D.h:32
float Mag2() const
Definition: SRVector3D.h:43
float Y() const
Definition: SRVector3D.h:37
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
void SetZ(float _z)
Definition: SRVector3D.h:34
float X() const
Definition: SRVector3D.h:36
SRVector3D Unit() const
Definition: SRVector3D.h:46
virtual ~SRVector3D()
Definition: SRVector3D.cxx:29
float Z() const
Definition: SRVector3D.h:38
float Dot(const SRVector3D &v) const
Definition: SRVector3D.h:45
float Mag() const
Definition: SRVector3D.h:44
void SetY(float _y)
Definition: SRVector3D.h:33