/usr/include/root/TEveVector.h is in libroot-graf3d-eve-dev 5.34.19+dfsg-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | // @(#)root/eve:$Id$
// 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. *
*************************************************************************/
#ifndef ROOT_TEveVector
#define ROOT_TEveVector
#include "TMath.h"
class TVector3;
//==============================================================================
// TEveVectorT
//==============================================================================
template <typename TT>
class TEveVectorT
{
public:
TT fX, fY, fZ; // Components of the vector.
TEveVectorT() : fX(0), fY(0), fZ(0) {}
template <typename OO>
TEveVectorT(const TEveVectorT<OO>& v) : fX(v.fX), fY(v.fY), fZ(v.fZ) {}
TEveVectorT(const Float_t* v) : fX(v[0]), fY(v[1]), fZ(v[2]) {}
TEveVectorT(const Double_t* v) : fX(v[0]), fY(v[1]), fZ(v[2]) {}
TEveVectorT(TT x, TT y, TT z) : fX(x), fY(y), fZ(z) {}
void Dump() const;
operator const TT*() const { return &fX; }
operator TT*() { return &fX; }
TT operator [] (Int_t idx) const { return (&fX)[idx]; }
TT& operator [] (Int_t idx) { return (&fX)[idx]; }
const TT* Arr() const { return &fX; }
TT* Arr() { return &fX; }
TEveVectorT& operator*=(TT s) { fX *= s; fY *= s; fZ *= s; return *this; }
TEveVectorT& operator+=(const TEveVectorT& v) { fX += v.fX; fY += v.fY; fZ += v.fZ; return *this; }
TEveVectorT& operator-=(const TEveVectorT& v) { fX -= v.fX; fY -= v.fY; fZ -= v.fZ; return *this; }
void Set(const Float_t* v) { fX = v[0]; fY = v[1]; fZ = v[2]; }
void Set(const Double_t* v) { fX = v[0]; fY = v[1]; fZ = v[2]; }
void Set(TT x, TT y, TT z) { fX = x; fY = y; fZ = z; }
void Set(const TVector3& v);
template <typename OO>
void Set(const TEveVectorT<OO>& v) { fX = v.fX; fY = v.fY; fZ = v.fZ; }
void NegateXYZ() { fX = - fX; fY = -fY; fZ = -fZ; }
TT Normalize(TT length=1);
TT Phi() const;
TT Theta() const;
TT CosTheta() const;
TT Eta() const;
TT Mag2() const { return fX*fX + fY*fY + fZ*fZ; }
TT Mag() const { return TMath::Sqrt(Mag2()); }
TT Perp2() const { return fX*fX + fY*fY; }
TT Perp() const { return TMath::Sqrt(Perp2()); }
TT R() const { return Perp(); }
TT Distance(const TEveVectorT& v) const;
TT SquareDistance(const TEveVectorT& v) const;
TT Dot(const TEveVectorT& a) const;
TEveVectorT Cross(const TEveVectorT& a) const;
TEveVectorT& Sub(const TEveVectorT& a, const TEveVectorT& b);
TEveVectorT& Mult(const TEveVectorT& a, TT af);
TEveVectorT Orthogonal() const;
void OrthoNormBase(TEveVectorT& a, TEveVectorT& b) const;
Bool_t IsZero() const { return fX == 0 && fY == 0 && fZ == 0; }
ClassDefNV(TEveVectorT, 2); // A three-vector template without TObject inheritance and virtual functions.
};
typedef TEveVectorT<Float_t> TEveVector;
typedef TEveVectorT<Float_t> TEveVectorF;
typedef TEveVectorT<Double_t> TEveVectorD;
//______________________________________________________________________________
template<typename TT>
inline TT TEveVectorT<TT>::Phi() const
{
return fX == 0 && fY == 0 ? 0 : TMath::ATan2(fY, fX);
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVectorT<TT>::Theta() const
{
return fX == 0 && fY == 0 && fZ == 0 ? 0 : TMath::ATan2(Perp(), fZ);
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVectorT<TT>::CosTheta() const
{
Float_t ptot = Mag(); return ptot == 0 ? 1 : fZ/ptot;
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVectorT<TT>::Distance(const TEveVectorT& b) const
{
return TMath::Sqrt((fX - b.fX)*(fX - b.fX) +
(fY - b.fY)*(fY - b.fY) +
(fZ - b.fZ)*(fZ - b.fZ));
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVectorT<TT>::SquareDistance(const TEveVectorT& b) const
{
return ((fX - b.fX) * (fX - b.fX) +
(fY - b.fY) * (fY - b.fY) +
(fZ - b.fZ) * (fZ - b.fZ));
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVectorT<TT>::Dot(const TEveVectorT& a) const
{
return a.fX*fX + a.fY*fY + a.fZ*fZ;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVectorT<TT> TEveVectorT<TT>::Cross(const TEveVectorT<TT>& a) const
{
TEveVectorT<TT> r;
r.fX = fY * a.fZ - fZ * a.fY;
r.fY = fZ * a.fX - fX * a.fZ;
r.fZ = fX * a.fY - fY * a.fX;
return r;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVectorT<TT>& TEveVectorT<TT>::Sub(const TEveVectorT<TT>& a, const TEveVectorT<TT>& b)
{
fX = a.fX - b.fX;
fY = a.fY - b.fY;
fZ = a.fZ - b.fZ;
return *this;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVectorT<TT>& TEveVectorT<TT>::Mult(const TEveVectorT<TT>& a, TT af)
{
fX = a.fX * af;
fY = a.fY * af;
fZ = a.fZ * af;
return *this;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVectorT<TT> operator+(const TEveVectorT<TT>& a, const TEveVectorT<TT>& b)
{
TEveVectorT<TT> r(a);
return r += b;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVectorT<TT> operator-(const TEveVectorT<TT>& a, const TEveVectorT<TT>& b)
{
TEveVectorT<TT> r(a);
return r -= b;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVectorT<TT> operator*(const TEveVectorT<TT>& a, TT b)
{
TEveVectorT<TT> r(a);
return r *= b;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVectorT<TT> operator*(TT b, const TEveVectorT<TT>& a)
{
TEveVectorT<TT> r(a);
return r *= b;
}
//==============================================================================
// TEveVector4T
//==============================================================================
template <typename TT>
class TEveVector4T : public TEveVectorT<TT>
{
typedef TEveVectorT<TT> TP;
public:
TT fT;
TEveVector4T() : TP(), fT(0) {}
template <typename OO>
TEveVector4T(const TEveVectorT<OO>& v) : TP(v.fX, v.fY, v.fZ), fT(0) {}
template <typename OO>
TEveVector4T(const TEveVectorT<OO>& v, Float_t t) : TP(v.fX, v.fY, v.fZ), fT(t) {}
template <typename OO>
TEveVector4T(const TEveVector4T<OO>& v) : TP(v.fX, v.fY, v.fZ), fT(v.fT) {}
TEveVector4T(const Float_t* v) : TP(v), fT(v[3]) {}
TEveVector4T(const Double_t* v) : TP(v), fT(v[3]) {}
TEveVector4T(TT x, TT y, TT z, TT t=0) : TP(x, y, z), fT(t) {}
void Dump() const;
TEveVector4T& operator*=(TT s) { TP::operator*=(s); fT *= s; return *this; }
TEveVector4T& operator+=(const TEveVector4T& v) { TP::operator+=(v); fT += v.fT; return *this; }
TEveVector4T& operator-=(const TEveVector4T& v) { TP::operator-=(v); fT -= v.fT; return *this; }
using TP::operator+=;
using TP::operator-=;
ClassDefNV(TEveVector4T, 1); // A four-vector template without TObject inheritance and virtual functions.
};
typedef TEveVector4T<Float_t> TEveVector4;
typedef TEveVector4T<Float_t> TEveVector4F;
typedef TEveVector4T<Double_t> TEveVector4D;
//______________________________________________________________________________
template<typename TT>
inline TEveVector4T<TT> operator+(const TEveVector4T<TT>& a, const TEveVector4T<TT>& b)
{
return TEveVector4T<TT>(a.fX + b.fX, a.fY + b.fY, a.fZ + b.fZ, a.fT + b.fT);
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector4T<TT> operator-(const TEveVector4T<TT>& a, const TEveVector4T<TT>& b)
{
return TEveVector4T<TT>(a.fX - b.fX, a.fY - b.fY, a.fZ - b.fZ, a.fT - b.fT);
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector4T<TT> operator*(const TEveVector4T<TT>& a, TT b)
{
return TEveVector4T<TT>(a.fX*b, a.fY*b, a.fZ*b, a.fT*b);
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector4T<TT> operator*(TT b, const TEveVector4T<TT>& a)
{
return TEveVector4T<TT>(a.fX*b, a.fY*b, a.fZ*b, a.fT*b);
}
//==============================================================================
// TEveVector2T
//==============================================================================
template <typename TT>
class TEveVector2T
{
public:
TT fX, fY; // Components of the point.
TEveVector2T() : fX(0), fY(0) {}
template <typename OO>
TEveVector2T(const TEveVector2T<OO>& v) : fX(v.fX), fY(v.fY) {}
TEveVector2T(const Float_t* v) : fX(v[0]), fY(v[1]) {}
TEveVector2T(const Double_t* v) : fX(v[0]), fY(v[1]) {}
TEveVector2T(TT x, TT y) : fX(x), fY(y) {}
void Dump() const;
operator const TT*() const { return &fX; }
operator TT*() { return &fX; }
TEveVector2T& operator*=(TT s) { fX *= s; fY *= s; return *this; }
TEveVector2T& operator+=(const TEveVector2T& v) { fX += v.fX; fY += v.fY; return *this; }
TEveVector2T& operator-=(const TEveVector2T& v) { fX -= v.fX; fY -= v.fY; return *this; }
TT& operator[](Int_t idx) { return (&fX)[idx]; }
TT operator[](Int_t idx) const { return (&fX)[idx]; }
const TT* Arr() const { return &fX; }
TT* Arr() { return &fX; }
void Set(const Float_t* v) { fX = v[0]; fY = v[1]; }
void Set(const Double_t* v) { fX = v[0]; fY = v[1]; }
void Set(TT x, TT y) { fX = x; fY = y; }
template <typename OO>
void Set(const TEveVector2T<OO>& v) { fX = v.fX; fY = v.fY; }
void NegateXY() { fX = - fX; fY = -fY; }
void Normalize(TT length=1);
TT Phi() const;
TT Mag2() const { return fX*fX + fY*fY;}
TT Mag() const { return TMath::Sqrt(Mag2());}
TT Distance(const TEveVector2T& v) const;
TT SquareDistance(const TEveVector2T& v) const;
TT Dot(const TEveVector2T& a) const;
TT Cross(const TEveVector2T& a) const;
TEveVector2T& Sub(const TEveVector2T& p, const TEveVector2T& q);
TEveVector2T& Mult(const TEveVector2T& a, TT af);
ClassDefNV(TEveVector2T, 1); // // A two-vector template without TObject inheritance and virtual functions.
};
typedef TEveVector2T<Float_t> TEveVector2;
typedef TEveVector2T<Float_t> TEveVector2F;
typedef TEveVector2T<Double_t> TEveVector2D;
//______________________________________________________________________________
template<typename TT>
inline TT TEveVector2T<TT>::Phi() const
{
return fX == 0.0 && fY == 0.0 ? 0.0 : TMath::ATan2(fY, fX);
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVector2T<TT>::Distance( const TEveVector2T<TT>& b) const
{
return TMath::Sqrt((fX - b.fX)*(fX - b.fX) +
(fY - b.fY)*(fY - b.fY));
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVector2T<TT>::SquareDistance(const TEveVector2T<TT>& b) const
{
return ((fX - b.fX) * (fX - b.fX) +
(fY - b.fY) * (fY - b.fY));
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVector2T<TT>::Dot(const TEveVector2T<TT>& a) const
{
return a.fX*fX + a.fY*fY;
}
//______________________________________________________________________________
template<typename TT>
inline TT TEveVector2T<TT>::Cross(const TEveVector2T<TT>& a) const
{
return fX * a.fY - fY * a.fX;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector2T<TT>& TEveVector2T<TT>::Sub(const TEveVector2T<TT>& p, const TEveVector2T<TT>& q)
{
fX = p.fX - q.fX;
fY = p.fY - q.fY;
return *this;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector2T<TT>& TEveVector2T<TT>::Mult(const TEveVector2T<TT>& a, TT af)
{
fX = a.fX * af;
fY = a.fY * af;
return *this;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector2T<TT> operator+(const TEveVector2T<TT>& a, const TEveVector2T<TT>& b)
{
TEveVector2T<TT> r(a);
return r += b;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector2T<TT> operator-(const TEveVector2T<TT>& a, const TEveVector2T<TT>& b)
{
TEveVector2T<TT> r(a);
return r -= b;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector2T<TT> operator*(const TEveVector2T<TT>& a, TT b)
{
TEveVector2T<TT> r(a);
return r *= b;
}
//______________________________________________________________________________
template<typename TT>
inline TEveVector2T<TT> operator*(TT b, const TEveVector2T<TT>& a)
{
TEveVector2T<TT> r(a);
return r *= b;
}
#endif
|