DUNE StandardRecord
Base object for DUNE analysis files (CAFs)
Loading...
Searching...
No Matches
SRVector3D.h
Go to the documentation of this file.
1
8
9#ifndef DUNEANAOBJ_SRVECTOR3D_H
10#define DUNEANAOBJ_SRVECTOR3D_H
11
12#if !defined(__GCCXML__) && !defined(__castxml__)
13
14#include <cmath>
15#include <iostream>
16
17#include "TVector3.h"
18
19#endif
20
21
22namespace caf
23{
26 {
27 public:
28 SRVector3D();
29 SRVector3D(float x, float y, float z);
30
31#if !defined(__GCCXML__) && !defined(__castxml__)
33 explicit SRVector3D(const TVector3& v);
34#endif
35
36 virtual ~SRVector3D() = default;
37
38 void SetXYZ(float x, float y, float z);
39
40#if !defined(__GCCXML__) && !defined(__castxml__)
42 operator TVector3() const;
43 SRVector3D & operator=(const TVector3& vec);
44
45 void SetX(float _x){x = _x;}
46 void SetY(float _y){y = _y;}
47 void SetZ(float _z){z = _z;}
48
49 float X() const {return x;}
50 float Y() const {return y;}
51 float Z() const {return z;}
52
53 // The more common TVector3 operations, mostly for use with TTree::Draw
54 //
55 // NB: you need to specify the initial "rec." when using these
56 float Mag2() const {return x*x+y*y+z*z;}
57 float Mag() const {return sqrt(Mag2());}
58 float Dot(const SRVector3D& v) const {return x*v.x + y*v.y + z*v.z;}
59 SRVector3D Unit() const
60 {
61 const float m = Mag();
62 return SRVector3D(x/m, y/m, z/m);
63 }
64
65 // a few more of them...
66 SRVector3D operator+(const SRVector3D & other) const { return SRVector3D(x + other.x, y + other.y, z + other.z); }
67 SRVector3D operator-(const SRVector3D & other) const {return SRVector3D(x - other.x, y - other.y, z - other.z); }
68#endif
69
70 // -----------------------------
71
72 float x;
73 float y;
74 float z;
75 };
76
77}
78
79#if !defined(__GCCXML__) && !defined(__castxml__)
80// make writing these out easier
81std::ostream & operator<<(std::ostream & stream, const caf::SRVector3D & vec);
82#endif
83
84#endif //DUNEANAOBJ_SRVECTOR3D_H
A 3-vector with more efficient storage than TVector3.
Definition SRVector3D.h:26
Common Analysis Files.
Definition Navigate.cxx:8