]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/Ali3Vector.h
3970430cffced7cf496e58c3959a47ffcaf6e143
[u/mrichter/AliRoot.git] / RALICE / Ali3Vector.h
1 #ifndef ALI3VECTOR_H
2 #define ALI3VECTOR_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////////
9 // Class Ali3Vector
10 // Handling of 3-vectors in various reference frames.
11 //
12 // This class is meant to serve as a base class for ALICE objects
13 // that have 3-dimensional vector characteristics.
14 //
15 // Note :
16 // ------
17 // Vectors (v) and reference frames (f) are specified via
18 // SetVector(Float_t* v,TString f) under the following conventions :
19 //
20 // f="car" ==> v in Cartesian coordinates   (x,y,z)
21 // f="sph" ==> v in Spherical coordinates   (r,theta,phi)
22 // f="cyl" ==> v in Cylindrical coordinates (rho,phi,z)
23 //
24 // All angles are in radians.
25 //
26 // Example :
27 // ---------
28 //
29 // Ali3Vector a;
30 // Float_t v[3]={-1,25,7};
31 // a.SetVector(v,"car");
32 // a.Info();
33 //
34 // Float_t vec[3];
35 // a.GetVector(vec,"sph");
36 //
37 // Ali3Vector b;
38 // Float_t v2[3]={6,-18,33};
39 // b.SetVector(v2,"car");
40 //
41 // Float_t dotpro=a.Dot(b);
42 //
43 // Ali3Vector c=a.Cross(b);
44 // c.Info("sph");
45 // c.GetVector(vec,"cyl");
46 // Float_t norm=c.GetNorm();
47 // c=a+b;
48 // c=a-b;
49 // c=a*5;
50 //
51 //--- NvE 30-mar-1999 UU-SAP Utrecht
52 ///////////////////////////////////////////////////////////////////////////
53
54 #include <iostream.h>
55 #include <math.h>
56  
57 #include "TObject.h"
58 #include "TString.h"
59  
60 class Ali3Vector
61 {
62  public:
63   Ali3Vector();                                  // Default constructor
64   virtual ~Ali3Vector();                         // Destructor
65   virtual void SetVector(Double_t* v,TString f); // Store vector v in frame f
66   virtual void GetVector(Double_t* v,TString f); // Provide vector v in frame f
67   virtual void SetVector(Float_t*  v,TString f); // Store vector v in frame f
68   virtual void GetVector(Float_t*  v,TString f); // Provide vector v in frame f
69   virtual void Info(TString f="car");            // Print vector components in frame f
70   Double_t GetNorm();                            // Provide norm of the vector
71   Double_t Dot(Ali3Vector& q);                   // Provide dot product with q
72   Ali3Vector Cross(Ali3Vector& q);               // Provide cross product with q
73   Ali3Vector operator+(Ali3Vector& q);           // Add vector q
74   Ali3Vector operator-(Ali3Vector& q);           // Subtract vector q
75   Ali3Vector operator*(Double_t s);              // Multiply vector with scalar s
76   Ali3Vector operator/(Double_t s);              // Divide vector by scalar s
77   Ali3Vector& operator+=(Ali3Vector& q);         // Add vector q
78   Ali3Vector& operator-=(Ali3Vector& q);         // Subtract vector q
79   Ali3Vector& operator*=(Double_t s);            // Multiply with scalar s
80   Ali3Vector& operator/=(Double_t s);            // Divide by scalar s
81
82  protected:
83   Double_t fV,fTheta,fPhi; // Vector in spherical coordinates
84
85  ClassDef(Ali3Vector,1) // Class definition to enable ROOT I/O
86 };
87 #endif