NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
Nc3Vector Class Reference

Handling of 3-vectors in various reference frames. More...

#include "Nc3Vector.h"

Inheritance diagram for Nc3Vector:
Nc3VectorObj NcPosition NcPositionObj NcSignal NcVertex NcCalcluster NcCalmodule NcDevice NcEvent IceGOM NcCalorimeter NcDetectorUnit NcTagger NcVeto RnoGANT IceEvent RnoEvent

Detailed Description

Handling of 3-vectors in various reference frames.


Copyright(c) 1999 NCFS/IIHE, All Rights Reserved. *
*
Authors: The Netherlands Center for Fundamental Studies (NCFS). *
The Inter-university Institute for High Energies (IIHE). *
Website : http://www.iihe.ac.be *
Contact : Nick van Eijndhoven (nickve.nl@gmail.com) *
*
Contributors are mentioned in the code where appropriate. *
*
No part of this software may be used, copied, modified or distributed *
by any means nor transmitted or translated into machine language for *
commercial purposes without written permission by the IIHE representative. *
Permission to use the software strictly for non-commercial purposes *
is hereby granted without fee, provided that the above copyright notice *
appears in all copies and that both the copyright notice and this *
permission notice appear in the supporting documentation. *
This software is provided "as is" without express or implied warranty. *
The authors make no claims that this software is free of error, or is *
consistent with any particular standard of merchantability, or that it *
will meet your requirements for any particular application, other than *
indicated in the corresponding documentation. *
This software should not be relied on for solving a problem whose *
incorrect solution could result in injury to a person or loss of property. *
If you do use this software in such a manner, it is at your own risk. *
The authors disclaim all liability for direct or consequential damage *
resulting from your use of this software. *

// Class Nc3Vector
// Handling of 3-vectors in various reference frames.
//
// This class is meant to serve as a base class for NCFS (derived) objects
// that have 3-dimensional vector characteristics.
// Error propagation is performed automatically.
//
// Note :
// ------
// Vectors (v), Errors (e), reference frames (f) and angular units (u)
// are specified via
// SetVector(Float_t* v,TString f,TString u)
// SetErrors(Float_t* e,TString f,TString u)
// under the following conventions :
//
// f="car" ==> v in Cartesian coordinates (x,y,z)
// f="sph" ==> v in Spherical coordinates (r,theta,phi)
// f="cyl" ==> v in Cylindrical coordinates (rho,phi,z)
//
// u="rad" ==> angles in radians
// u="deg" ==> angles in degrees
//
// The "f" and "u" facilities only serve as a convenient user interface.
// Internally the actual storage of the various components is performed
// in a unique way. This allows setting/retrieval of vector components in a
// user selected frame/unit convention at any time.
//
// Example :
// ---------
//
// Nc3Vector a;
// Float_t v[3]={-1,25,7};
// Float_t e[3]={0.03,0.5,0.21};
// a.SetVector(v,"car");
// a.SetErrors(e,"car");
// a.Data();
//
// Float_t vec[3];
// Float_t err[3];
// a.GetVector(vec,"sph","deg");
// a.GetErrors(vec,"sph","deg");
//
// Nc3Vector b;
// Float_t v2[3]={6,-18,33};
// Float_t e2[3]={0.19,0.45,0.93};
// b.SetVector(v2,"car");
// b.SetErrors(e2,"car");
//
// Float_t dotpro=a.Dot(b);
// Float_t doterror=a.GetResultError();
//
// Nc3Vector c=a.Cross(b);
// c.Data("sph");
// c.GetVector(vec,"cyl");
// c.GetErrors(err,"cyl");
//
// Float_t norm=c.GetNorm();
// Float_t normerror=c.GetResultError();
//
// c=a+b;
// c=a-b;
// c=a*5;
//
//--- Author: Nick van Eijndhoven 30-mar-1999 Utrecht University
//- Modified: Nick van Eijndhoven, IIHE-VUB, Brussel, July 16, 2023 02:29Z

Definition at line 14 of file Nc3Vector.h.

Public Member Functions

 Nc3Vector ()
 
 Nc3Vector (const Nc3Vector &v)
 
virtual ~Nc3Vector ()
 
Double_t ConvertAngle (Double_t a, TString in, TString out) const
 
Nc3Vector Cross (Nc3Vector &q) const
 
virtual void Data (TString f="car", TString u="rad") const
 
Double_t Dot (Nc3Vector &q)
 
void GetErrors (Double_t *e, TString f, TString u="rad") const
 
void GetErrors (Float_t *e, TString f, TString u="rad") const
 
Double_t GetNorm ()
 
virtual Double_t GetOpeningAngle (Nc3Vector &q, TString u="rad")
 
Nc3Vector GetPrimed (TRotMatrix *m) const
 
Double_t GetPseudoRapidity ()
 
Double_t GetResultError () const
 
Nc3Vector GetUnprimed (TRotMatrix *m) const
 
Nc3Vector GetVecLong () const
 
void GetVector (Double_t *v, TString f, TString u="rad") const
 
void GetVector (Float_t *v, TString f, TString u="rad") const
 
Nc3Vector GetVecTrans () const
 
Double_t GetX (Int_t i, TString f, TString u="rad")
 
Int_t HasErrors () const
 
Int_t HasVector () const
 
virtual void Load (Nc3Vector &q)
 
Nc3Vector operator* (Double_t s) const
 
Nc3Vectoroperator*= (Double_t s)
 
Nc3Vector operator+ (Nc3Vector &q) const
 
Nc3Vectoroperator+= (Nc3Vector &q)
 
Nc3Vector operator- (Nc3Vector &q) const
 
Nc3Vectoroperator-= (Nc3Vector &q)
 
Nc3Vector operator/ (Double_t s) const
 
Nc3Vectoroperator/= (Double_t s)
 
Nc3Vectoroperator= (const Nc3Vector &q)
 
void PrintAngle (Double_t a, TString in, TString out, Int_t ndig=1, Bool_t align=kFALSE) const
 
void SetErrors (Double_t *e, TString f, TString u="rad")
 
void SetErrors (Double_t e1, Double_t e2, Double_t e3, TString f, TString u="rad")
 
void SetErrors (Float_t *e, TString f, TString u="rad")
 
void SetVector (Double_t *v, TString f, TString u="rad")
 
void SetVector (Double_t v1, Double_t v2, Double_t v3, TString f, TString u="rad")
 
void SetVector (Float_t *v, TString f, TString u="rad")
 
virtual void SetZero ()
 

Protected Attributes

Double32_t fDresult
 ! Error on scalar result (e.g. norm or dotproduct)
 
Int_t fNv
 
Double32_t * fV
 

Constructor & Destructor Documentation

◆ Nc3Vector() [1/2]

Nc3Vector::Nc3Vector ( )
// Creation of an Nc3Vector object and initialisation of parameters
// All attributes initialised to 0

Definition at line 110 of file Nc3Vector.cxx.

◆ ~Nc3Vector()

Nc3Vector::~Nc3Vector ( )
virtual
// Destructor to delete dynamically allocated memory

Definition at line 124 of file Nc3Vector.cxx.

◆ Nc3Vector() [2/2]

Nc3Vector::Nc3Vector ( const Nc3Vector & v)
// Copy constructor

Definition at line 139 of file Nc3Vector.cxx.

Member Function Documentation

◆ ConvertAngle()

Double_t Nc3Vector::ConvertAngle ( Double_t a,
TString in,
TString out ) const
// Conversion of various angular formats.
//
// The input argument "a" denotes the angle to be converted.
// The string arguments "in" and "out" specify the angular I/O formats.
//
// in = "rad" : input angle provided in radians
// "deg" : input angle provided in degrees
// "dms" : input angle provided in dddmmss.sss
// "hms" : input angle provided in hhmmss.sss
// "hrs" : input angle provided in fractional hours
//
// out = "rad" : output angle provided in radians
// "deg" : output angle provided in degrees
// "dms" : output angle provided in dddmmss.sss
// "hms" : output angle provided in hhmmss.sss
// "hrs" : output angle provided in fractional hours

Definition at line 1616 of file Nc3Vector.cxx.

◆ Cross()

Nc3Vector Nc3Vector::Cross ( Nc3Vector & q) const
// Provide the cross product of the current vector with vector q.
// Error propagation is performed automatically

Definition at line 1016 of file Nc3Vector.cxx.

◆ Data()

void Nc3Vector::Data ( TString f = "car",
TString u = "rad" ) const
virtual
// Print vector components according to reference frame f
//
// f = "car" : Cartesian coordinates
// "sph" : Spherical coordinates
// "cyl" : Cylindrical coordinates
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
//
// u = "rad" : angle provided in radians
// "deg" : angle provided in degrees
// "dms" : angle provided in dddmmss.sss
// "hms" : angle provided in hhmmss.sss
//
// The defaults are f="car" and u="rad".

Reimplemented in NcDetectorUnit, NcDevice, NcPosition, NcSignal, and NcVertex.

Definition at line 803 of file Nc3Vector.cxx.

◆ Dot()

Double_t Nc3Vector::Dot ( Nc3Vector & q)
// Provide the dot product of the current vector with vector q.
// The error on the scalar result (dotproduct) is updated accordingly

Definition at line 965 of file Nc3Vector.cxx.

◆ GetErrors() [1/2]

void Nc3Vector::GetErrors ( Double_t * e,
TString f,
TString u = "rad" ) const
// Provide errors according to reference frame f.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".

Definition at line 621 of file Nc3Vector.cxx.

◆ GetErrors() [2/2]

void Nc3Vector::GetErrors ( Float_t * e,
TString f,
TString u = "rad" ) const
// Provide errors according to reference frame f
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".

Definition at line 780 of file Nc3Vector.cxx.

◆ GetNorm()

Double_t Nc3Vector::GetNorm ( )
// Provide the norm of the current vector.
// The error on the scalar result (norm) is updated accordingly

Definition at line 910 of file Nc3Vector.cxx.

◆ GetOpeningAngle()

Double_t Nc3Vector::GetOpeningAngle ( Nc3Vector & q,
TString u = "rad" )
virtual
// Provide the opening angle with vector q.
// The string argument "u" allows to choose between different output units.
// u = "rad" : opening angle provided in radians
// "deg" : opening angle provided in degrees
//
// The default is u="rad".

Definition at line 1554 of file Nc3Vector.cxx.

◆ GetPrimed()

Nc3Vector Nc3Vector::GetPrimed ( TRotMatrix * m) const
// Provide vector components (and errors) in a rotated frame.
// The orientation of the rotated frame is described by the TRotMatrix
// input argument.

Definition at line 1438 of file Nc3Vector.cxx.

◆ GetPseudoRapidity()

Double_t Nc3Vector::GetPseudoRapidity ( )
// Provide the pseudo-rapidity w.r.t. the z-axis.
// In other words : eta=-log(tan(theta/2))
// The error on the scalar result (pseudo-rap.) is updated accordingly

Definition at line 933 of file Nc3Vector.cxx.

◆ GetResultError()

Double_t Nc3Vector::GetResultError ( ) const
// Provide the error on the result of an operation yielding a scalar.
// E.g. GetNorm() or Dot()

Definition at line 1004 of file Nc3Vector.cxx.

◆ GetUnprimed()

Nc3Vector Nc3Vector::GetUnprimed ( TRotMatrix * m) const
// Provide original vector components (and errors) from the rotated ones.
// The orientation of the rotated frame is described by the TRotMatrix
// input argument.
// So, this is the inverse of the GetPrimed() memberfunction.
// This memberfunction makes use of the fact that the inverse of a certain
// TRotMatrix is given by its transposed matrix.

Definition at line 1476 of file Nc3Vector.cxx.

◆ GetVecLong()

Nc3Vector Nc3Vector::GetVecLong ( ) const
// Provide the longitudinal vector w.r.t. z-axis.
// Error propagation is performed automatically

Definition at line 1401 of file Nc3Vector.cxx.

◆ GetVector() [1/2]

void Nc3Vector::GetVector ( Double_t * v,
TString f,
TString u = "rad" ) const
// Provide vector according to reference frame f
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".

Definition at line 394 of file Nc3Vector.cxx.

◆ GetVector() [2/2]

void Nc3Vector::GetVector ( Float_t * v,
TString f,
TString u = "rad" ) const
// Provide vector according to reference frame f
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".

Definition at line 486 of file Nc3Vector.cxx.

◆ GetVecTrans()

Nc3Vector Nc3Vector::GetVecTrans ( ) const
// Provide the transverse vector w.r.t. z-axis.
// Error propagation is performed automatically

Definition at line 1367 of file Nc3Vector.cxx.

◆ GetX()

Double_t Nc3Vector::GetX ( Int_t i,
TString f,
TString u = "rad" )
// Provide i-th vector component according to reference frame f.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".
//
// The vector components are addressed via the generic x1,x2,x3 notation.
// So, i=1 denotes the first vector component.
// The error on the selected component can be obtained via the
// usual GetResultError() facility.

Definition at line 1517 of file Nc3Vector.cxx.

◆ HasErrors()

Int_t Nc3Vector::HasErrors ( ) const
// Check whether the errors on the vector components have been set.
// In case the errors have been set, the value 1 is returned.
// Otherwise, the value 0 is returned.

Definition at line 895 of file Nc3Vector.cxx.

◆ HasVector()

Int_t Nc3Vector::HasVector ( ) const
// Check whether the vector components have been set.
// In case the vector components have been set, the value 1 is returned.
// Otherwise, the value 0 is returned.

Definition at line 880 of file Nc3Vector.cxx.

◆ Load()

void Nc3Vector::Load ( Nc3Vector & q)
virtual
// Load all attributes of the input Nc3Vector into this Nc3Vector object.

Definition at line 191 of file Nc3Vector.cxx.

◆ operator*()

Nc3Vector Nc3Vector::operator* ( Double_t s) const
// Multiply the current vector with a scalar s.
// Error propagation is performed automatically.

Definition at line 1139 of file Nc3Vector.cxx.

◆ operator*=()

Nc3Vector & Nc3Vector::operator*= ( Double_t s)
// Multiply the current vector with a scalar s.
// Error propagation is performed automatically

Definition at line 1291 of file Nc3Vector.cxx.

◆ operator+()

Nc3Vector Nc3Vector::operator+ ( Nc3Vector & q) const
// Add vector q to the current vector.
// Error propagation is performed automatically

Definition at line 1061 of file Nc3Vector.cxx.

◆ operator+=()

Nc3Vector & Nc3Vector::operator+= ( Nc3Vector & q)
// Add vector q to the current vector.
// Error propagation is performed automatically

Definition at line 1219 of file Nc3Vector.cxx.

◆ operator-()

Nc3Vector Nc3Vector::operator- ( Nc3Vector & q) const
// Subtract vector q from the current vector.
// Error propagation is performed automatically

Definition at line 1100 of file Nc3Vector.cxx.

◆ operator-=()

Nc3Vector & Nc3Vector::operator-= ( Nc3Vector & q)
// Subtract vector q from the current vector.
// Error propagation is performed automatically

Definition at line 1255 of file Nc3Vector.cxx.

◆ operator/()

Nc3Vector Nc3Vector::operator/ ( Double_t s) const
// Divide the current vector by a scalar s.
// Error propagation is performed automatically

Definition at line 1175 of file Nc3Vector.cxx.

◆ operator/=()

Nc3Vector & Nc3Vector::operator/= ( Double_t s)
// Divide the current vector by a scalar s.
// Error propagation is performed automatically

Definition at line 1325 of file Nc3Vector.cxx.

◆ operator=()

Nc3Vector & Nc3Vector::operator= ( const Nc3Vector & q)
// Set the current vector equal to vector q.

Definition at line 157 of file Nc3Vector.cxx.

◆ PrintAngle()

void Nc3Vector::PrintAngle ( Double_t a,
TString in,
TString out,
Int_t ndig = 1,
Bool_t align = kFALSE ) const
// Printing of angles in various formats.
//
// The input argument "a" denotes the angle to be printed.
// The string arguments "in" and "out" specify the angular I/O formats.
//
// in = "rad" : input angle provided in radians
// "deg" : input angle provided in degrees
// "dms" : input angle provided in dddmmss.sss
// "hms" : input angle provided in hhmmss.sss
//
// out = "rad" : output angle provided in radians
// "deg" : output angle provided in degrees
// "dms" : output angle provided in dddmmss.sss
// "hms" : output angle provided in hhmmss.sss
//
// The argument "ndig" specifies the number of digits for the fractional
// part (e.g. ndig=6 for "dms" corresponds to micro-arcsecond precision).
// Rounding will be performed, so an arcsecond count of 3.473 with ndig=1
// will appear as 03.5 on the output, but with ndig=2 it will show 03.47.
// Due to computer accuracy, precision on the pico-arcsecond level may get lost.
//
// The argument "align", when set to kTRUE, ensures that for a certain selected
// output format, all provided output strings will have the same length.
// This will allow the user to provide data in an aligned tabular format.
// When "align" is set to kFALSE, the produced output will be in the most
// compact format.
//
// The defaults are ndig=1 and align=kFALSE.
//
// Note : The angle info is printed without additional spaces or "endline".
// This allows the print to be included in various composite output formats.

Definition at line 1754 of file Nc3Vector.cxx.

◆ SetErrors() [1/3]

void Nc3Vector::SetErrors ( Double_t * e,
TString f,
TString u = "rad" )
// Store errors according to reference frame f.
//
// Note : The errors can only be set after the vector components have
// been specified via the SetVector memberfunction.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".
//
// The error on scalar results is reset to 0.

Definition at line 509 of file Nc3Vector.cxx.

◆ SetErrors() [2/3]

void Nc3Vector::SetErrors ( Double_t e1,
Double_t e2,
Double_t e3,
TString f,
TString u = "rad" )
// Store errors according to reference frame f.
//
// Note : The errors can only be set after the vector components have
// been specified via the SetVector memberfunction.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".
//
// The error on scalar results is reset to 0

Definition at line 594 of file Nc3Vector.cxx.

◆ SetErrors() [3/3]

void Nc3Vector::SetErrors ( Float_t * e,
TString f,
TString u = "rad" )
// Store errors according to reference frame f.
//
// Note : The errors can only be set after the vector components have
// been specified via the SetVector memberfunction.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".
//
// The error on scalar results is reset to 0

Definition at line 752 of file Nc3Vector.cxx.

◆ SetVector() [1/3]

void Nc3Vector::SetVector ( Double_t * v,
TString f,
TString u = "rad" )
// Store vector according to reference frame f.
// Only vector components will be stored, no errors.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".

Definition at line 230 of file Nc3Vector.cxx.

◆ SetVector() [2/3]

void Nc3Vector::SetVector ( Double_t v1,
Double_t v2,
Double_t v3,
TString f,
TString u = "rad" )
// Store vector according to reference frame f.
// Only vector components will be stored, no errors.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".

Definition at line 371 of file Nc3Vector.cxx.

◆ SetVector() [3/3]

void Nc3Vector::SetVector ( Float_t * v,
TString f,
TString u = "rad" )
// Store vector according to reference frame f.
// Only vector components will be stored, no errors.
//
// The string argument "u" allows to choose between different angular units
// in case e.g. a spherical frame is selected.
// u = "rad" : angles provided in radians
// "deg" : angles provided in degrees
//
// The default is u="rad".

Definition at line 462 of file Nc3Vector.cxx.

◆ SetZero()

void Nc3Vector::SetZero ( )
virtual
// (Re)set all attributes to zero.

Definition at line 213 of file Nc3Vector.cxx.

Member Data Documentation

◆ fDresult

Double32_t Nc3Vector::fDresult
protected

! Error on scalar result (e.g. norm or dotproduct)

Definition at line 61 of file Nc3Vector.h.

◆ fNv

Int_t Nc3Vector::fNv
protected

Definition at line 59 of file Nc3Vector.h.

◆ fV

Double32_t* Nc3Vector::fV
protected

Definition at line 60 of file Nc3Vector.h.


The documentation for this class was generated from the following files: