// @(#)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. * *************************************************************************/ #include "TEveVector.h" #include "TVector3.h" /** \class TEveVectorT \ingroup TEve Minimal, templated three-vector. No TObject inheritance and virtual functions. Also used in VSD. */ ClassImp(TEveVectorT); ClassImp(TEveVectorT); //////////////////////////////////////////////////////////////////////////////// /// Dump to stdout as "(x, y, z)\n". template void TEveVectorT::Dump() const { printf("(%f, %f, %f)\n", fX, fY, fZ); } //////////////////////////////////////////////////////////////////////////////// /// Set from TVector3. template void TEveVectorT::Set(const TVector3& v) { fX = v.x(); fY = v.y(); fZ = v.z(); } //////////////////////////////////////////////////////////////////////////////// /// Calculate eta of the point, pretending it's a momentum vector. template TT TEveVectorT::Eta() const { TT 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; } //////////////////////////////////////////////////////////////////////////////// /// Normalize the vector to length if current length is non-zero. /// Returns the old magnitude. template TT TEveVectorT::Normalize(TT length) { TT m = Mag(); if (m != 0) { length /= m; fX *= length; fY *= length; fZ *= length; } return m; } //////////////////////////////////////////////////////////////////////////////// /// Returns an orthogonal vector (not normalized). template TEveVectorT TEveVectorT::Orthogonal() const { 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 ? TEveVectorT(0,fZ,-fY) : TEveVectorT(fY,-fX,0); } else { return yy < zz ? TEveVectorT(-fZ,0,fX) : TEveVectorT(fY,-fX,0); } } //////////////////////////////////////////////////////////////////////////////// /// Set vectors a and b to be normal to this and among themselves, /// both of length 1. template void TEveVectorT::OrthoNormBase(TEveVectorT& a, TEveVectorT& b) const { a = Orthogonal(); TMath::Cross(this->Arr(), a.Arr(), b.Arr()); a.Normalize(); b.Normalize(); } template class TEveVectorT; template class TEveVectorT; /** \class TEveVector4T \ingroup TEve Minimal, templated four-vector. No TObject inheritance and virtual functions. Also used in VSD. */ ClassImp(TEveVector4T); ClassImp(TEveVector4T); //////////////////////////////////////////////////////////////////////////////// /// Dump to stdout as "(x, y, z; t)\n". template void TEveVector4T::Dump() const { printf("(%f, %f, %f; %f)\n", TP::fX, TP::fY, TP::fZ, fT); } template class TEveVector4T; template class TEveVector4T; /** \class TEveVector2T \ingroup TEve Minimal, templated two-vector. No TObject inheritance and virtual functions. Also used in VSD. */ ClassImp(TEveVector2T); ClassImp(TEveVector2T); //////////////////////////////////////////////////////////////////////////////// /// Normalize the vector to length if current length is non-zero. template void TEveVector2T::Normalize(TT length) { Float_t m = Mag(); if (m != 0) { m = length / m; fX *= m; fY *= m; } } //////////////////////////////////////////////////////////////////////////////// /// Dump to stdout as "(x, y)\n". template void TEveVector2T::Dump() const { printf("(%f, %f)\n", fX, fY); } template class TEveVector2T; template class TEveVector2T;