ROOT logo
// @(#)root/eve:$Id: TEveVector.cxx 31517 2009-12-03 11:56:23Z matevz $
// Author: Matevz Tadel 2007

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TEveVector.h"
#include "TVector3.h"

//==============================================================================
// TEveVector
//==============================================================================

//______________________________________________________________________________
//
// Float three-vector; a inimal Float_t copy of TVector3 used to
// represent points and momenta (also used in VSD).

ClassImp(TEveVector);

//______________________________________________________________________________
void TEveVector::Set(const TVector3& v)
{
   // Set from TVector3.

   fX = v.x(); fY = v.y(); fZ = v.z();
}

//______________________________________________________________________________
void TEveVector::Dump() const
{
   // Dump to stdout as "(x, y, z)\n".

   printf("(%f, %f, %f)\n", fX, fY, fZ);
}

//______________________________________________________________________________
Float_t TEveVector::Eta() const
{
   // Calculate eta of the point, pretending it's a momentum vector.

   Float_t cosTheta = CosTheta();
   if (cosTheta*cosTheta < 1) return -0.5* TMath::Log( (1.0-cosTheta)/(1.0+cosTheta) );
   Warning("Eta","transverse momentum = 0, returning +/- 1e10");
   return (fZ >= 0) ? 1e10 : -1e10;
}

//______________________________________________________________________________
void TEveVector::Normalize(Float_t length)
{
   // Normalize the vector to length if current length is non-zero.

   Float_t m = Mag();
   if (m != 0)
   {
      m = length / m;
      fX *= m; fY *= m; fZ *= m;
   }
}

//______________________________________________________________________________
TEveVector TEveVector::Orthogonal() const
{
   // Returns an orthogonal vector (not normalized).

   Float_t xx = fX < 0 ? -fX : fX;
   Float_t yy = fY < 0 ? -fY : fY;
   Float_t zz = fZ < 0 ? -fZ : fZ;
   if (xx < yy) {
      return xx < zz ? TEveVector(0,fZ,-fY) : TEveVector(fY,-fX,0);
   } else {
      return yy < zz ? TEveVector(-fZ,0,fX) : TEveVector(fY,-fX,0);
   }
}

//______________________________________________________________________________
void TEveVector::OrthoNormBase(TEveVector& a, TEveVector& b) const
{
   // Set vectors a and b to be normal to this and among themselves,
   // both of length 1.

   a = Orthogonal();
   TMath::Cross(this->Arr(), a.Arr(), b.Arr());
   a.Normalize();
   b.Normalize();
}

//______________________________________________________________________________
TEveVector TEveVector::operator + (const TEveVector & b) const
{
   // Vector addition.

   return TEveVector(fX + b.fX, fY + b.fY, fZ + b.fZ);
}

//______________________________________________________________________________
TEveVector TEveVector::operator - (const TEveVector & b) const
{
   // Vector subtraction.

   return TEveVector(fX - b.fX, fY - b.fY, fZ - b.fZ);
}

//______________________________________________________________________________
TEveVector TEveVector::operator * (Float_t a) const
{
   // Multiplication with scalar.

   return TEveVector(a*fX, a*fY, a*fZ);
}


//==============================================================================
// TEveVector4
//==============================================================================

//______________________________________________________________________________
//
// Float four-vector.

ClassImp(TEveVector4);

//______________________________________________________________________________
void TEveVector4::Dump() const
{
   // Dump to stdout as "(x, y, z; t)\n".

   printf("(%f, %f, %f; %f)\n", fX, fY, fZ, fT);
}


//==============================================================================
// TEvePathMark
//==============================================================================

//______________________________________________________________________________
//
// Special-point on track:
//  kDaughter  - daughter creation; fP is momentum of the daughter, it is subtracted from
//               momentum of the track
//  kReference - position/momentum reference
//  kDecay     - decay point, fP not used
//  kCluster2D - measurement with large error in one direction (like strip detectors):
//               fP - normal to detector plane,
//               fE - large error direction, must be normalized.
//               Track is propagated to plane and correction in fE direction is discarded.

ClassImp(TEvePathMark);

//______________________________________________________________________________
const char* TEvePathMark::TypeName()
{
   // Return the name of path-mark type.

   switch (fType)
   {
      case kDaughter:  return "Daughter";
      case kReference: return "Reference";
      case kDecay:     return "Decay";
      case kCluster2D: return "Cluster2D";
      default:         return "Unknown";
   }
}
 TEveVector.cxx:1
 TEveVector.cxx:2
 TEveVector.cxx:3
 TEveVector.cxx:4
 TEveVector.cxx:5
 TEveVector.cxx:6
 TEveVector.cxx:7
 TEveVector.cxx:8
 TEveVector.cxx:9
 TEveVector.cxx:10
 TEveVector.cxx:11
 TEveVector.cxx:12
 TEveVector.cxx:13
 TEveVector.cxx:14
 TEveVector.cxx:15
 TEveVector.cxx:16
 TEveVector.cxx:17
 TEveVector.cxx:18
 TEveVector.cxx:19
 TEveVector.cxx:20
 TEveVector.cxx:21
 TEveVector.cxx:22
 TEveVector.cxx:23
 TEveVector.cxx:24
 TEveVector.cxx:25
 TEveVector.cxx:26
 TEveVector.cxx:27
 TEveVector.cxx:28
 TEveVector.cxx:29
 TEveVector.cxx:30
 TEveVector.cxx:31
 TEveVector.cxx:32
 TEveVector.cxx:33
 TEveVector.cxx:34
 TEveVector.cxx:35
 TEveVector.cxx:36
 TEveVector.cxx:37
 TEveVector.cxx:38
 TEveVector.cxx:39
 TEveVector.cxx:40
 TEveVector.cxx:41
 TEveVector.cxx:42
 TEveVector.cxx:43
 TEveVector.cxx:44
 TEveVector.cxx:45
 TEveVector.cxx:46
 TEveVector.cxx:47
 TEveVector.cxx:48
 TEveVector.cxx:49
 TEveVector.cxx:50
 TEveVector.cxx:51
 TEveVector.cxx:52
 TEveVector.cxx:53
 TEveVector.cxx:54
 TEveVector.cxx:55
 TEveVector.cxx:56
 TEveVector.cxx:57
 TEveVector.cxx:58
 TEveVector.cxx:59
 TEveVector.cxx:60
 TEveVector.cxx:61
 TEveVector.cxx:62
 TEveVector.cxx:63
 TEveVector.cxx:64
 TEveVector.cxx:65
 TEveVector.cxx:66
 TEveVector.cxx:67
 TEveVector.cxx:68
 TEveVector.cxx:69
 TEveVector.cxx:70
 TEveVector.cxx:71
 TEveVector.cxx:72
 TEveVector.cxx:73
 TEveVector.cxx:74
 TEveVector.cxx:75
 TEveVector.cxx:76
 TEveVector.cxx:77
 TEveVector.cxx:78
 TEveVector.cxx:79
 TEveVector.cxx:80
 TEveVector.cxx:81
 TEveVector.cxx:82
 TEveVector.cxx:83
 TEveVector.cxx:84
 TEveVector.cxx:85
 TEveVector.cxx:86
 TEveVector.cxx:87
 TEveVector.cxx:88
 TEveVector.cxx:89
 TEveVector.cxx:90
 TEveVector.cxx:91
 TEveVector.cxx:92
 TEveVector.cxx:93
 TEveVector.cxx:94
 TEveVector.cxx:95
 TEveVector.cxx:96
 TEveVector.cxx:97
 TEveVector.cxx:98
 TEveVector.cxx:99
 TEveVector.cxx:100
 TEveVector.cxx:101
 TEveVector.cxx:102
 TEveVector.cxx:103
 TEveVector.cxx:104
 TEveVector.cxx:105
 TEveVector.cxx:106
 TEveVector.cxx:107
 TEveVector.cxx:108
 TEveVector.cxx:109
 TEveVector.cxx:110
 TEveVector.cxx:111
 TEveVector.cxx:112
 TEveVector.cxx:113
 TEveVector.cxx:114
 TEveVector.cxx:115
 TEveVector.cxx:116
 TEveVector.cxx:117
 TEveVector.cxx:118
 TEveVector.cxx:119
 TEveVector.cxx:120
 TEveVector.cxx:121
 TEveVector.cxx:122
 TEveVector.cxx:123
 TEveVector.cxx:124
 TEveVector.cxx:125
 TEveVector.cxx:126
 TEveVector.cxx:127
 TEveVector.cxx:128
 TEveVector.cxx:129
 TEveVector.cxx:130
 TEveVector.cxx:131
 TEveVector.cxx:132
 TEveVector.cxx:133
 TEveVector.cxx:134
 TEveVector.cxx:135
 TEveVector.cxx:136
 TEveVector.cxx:137
 TEveVector.cxx:138
 TEveVector.cxx:139
 TEveVector.cxx:140
 TEveVector.cxx:141
 TEveVector.cxx:142
 TEveVector.cxx:143
 TEveVector.cxx:144
 TEveVector.cxx:145
 TEveVector.cxx:146
 TEveVector.cxx:147
 TEveVector.cxx:148
 TEveVector.cxx:149
 TEveVector.cxx:150
 TEveVector.cxx:151
 TEveVector.cxx:152
 TEveVector.cxx:153
 TEveVector.cxx:154
 TEveVector.cxx:155
 TEveVector.cxx:156
 TEveVector.cxx:157
 TEveVector.cxx:158
 TEveVector.cxx:159
 TEveVector.cxx:160
 TEveVector.cxx:161
 TEveVector.cxx:162
 TEveVector.cxx:163
 TEveVector.cxx:164
 TEveVector.cxx:165
 TEveVector.cxx:166
 TEveVector.cxx:167
 TEveVector.cxx:168