REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestPhysics.h
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23#ifndef __RestCore_TRestPhysics_H__
24#define __RestCore_TRestPhysics_H__
25
26#include <TMatrixD.h>
27#include <TString.h>
28#include <TVector3.h>
29#include <TVectorD.h>
30
31#include <iostream>
32
34namespace REST_Physics {
35
37constexpr double vacuumPermitivity = 8.854E-12;
39constexpr double vacuumPermeability = 4E-7 * 3.141592653589793;
41constexpr double lightSpeed = 2.99792458E8;
43constexpr double qElectron = 1.602E-19;
45constexpr double mElectron = 9.107E-31;
47constexpr double kBoltzman = 1.380E-23;
49constexpr double hPlanck = 1.054E-34;
50
52constexpr double PhMeterIneV = 5067731.236453719;
54constexpr double secondIneV = 1519225802531030.2;
56constexpr double naturalElectron = 0.302822120214353;
58constexpr double kelvinToeV = 86.172809e-6;
59
61constexpr double AU = 1.49597870691E11;
62
63// Solar radius in m
64constexpr double solarRadius = 6.95700E8;
65
66TVector3 MoveToPlane(const TVector3& pos, const TVector3& dir, const TVector3& n, const TVector3& a);
67
68TVector3 MoveByDistance(const TVector3& pos, const TVector3& dir, Double_t d);
69TVector3 MoveByDistanceFast(const TVector3& pos, const TVector3& dir, Double_t d);
70
71TVector3 GetVectorReflection(const TVector3& dir, const TVector3& n);
72
73Double_t GetVectorsAngle(const TVector3& v1, const TVector3& v2);
74
75TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, TVector3 const& n,
76 TVector3 const& a);
77
78TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
79 const Double_t R3);
80
81TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta,
82 const Double_t R3, const Double_t focal);
83
84TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t R = 0);
85
86TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3);
87
88TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3,
89 const Double_t focal);
90
91TMatrixD GetConeMatrix(const TVector3& d, const Double_t cosTheta);
92
93Double_t GetConeVectorIntersection(const TVector3& pos, const TVector3& dir, const TVector3& d,
94 const TVector3& v, const Double_t cosTheta);
95Double_t GetConeVectorIntersection(const TVector3& pos, const TVector3& dir, const TMatrixD& M,
96 const TVector3& axis, const TVector3& v);
97
98Double_t DistanceToAxis(const TVector3& axisPoint, const TVector3& axisVector, const TVector3& point);
99
100Double_t GetDistance(const TVector3& v1, const TVector3& v2);
101Double_t GetDistance2(const TVector3& v1, const TVector3& v2);
102} // namespace REST_Physics
103
104#endif
This namespace serves to define physics constants and other basic physical operations.
Definition: TRestPhysics.h:34
constexpr double lightSpeed
Speed of light in m/s.
Definition: TRestPhysics.h:41
constexpr double mElectron
Electron mass in Kg.
Definition: TRestPhysics.h:45
TVector3 GetHyperbolicVectorIntersection(const TVector3 &pos, const TVector3 &dir, const Double_t beta, const Double_t R3, const Double_t focal)
TVector3 MoveByDistance(const TVector3 &pos, const TVector3 &dir, Double_t d)
This method transports a position pos by a distance d in the direction defined by dir.
TVector3 GetParabolicVectorIntersection(const TVector3 &pos, const TVector3 &dir, const Double_t alpha, const Double_t R3)
TVector3 GetParabolicNormal(const TVector3 &pos, const Double_t alpha, const Double_t R3)
This method returns the normal vector on a parabolic surface pointing towards the inside of the parab...
constexpr double PhMeterIneV
A meter in eV.
Definition: TRestPhysics.h:52
constexpr double vacuumPermeability
Vacuum permeability in H/m.
Definition: TRestPhysics.h:39
Double_t GetDistance(const TVector3 &v1, const TVector3 &v2)
This method returns the cartesian distance between vector v2 and v1.
TVector3 GetConeNormal(const TVector3 &pos, const Double_t alpha, const Double_t R=0)
This method will return a vector that is normal to the cone surface. The position pos should be at th...
constexpr double kBoltzman
Boltzman constant in J/K.
Definition: TRestPhysics.h:47
Double_t GetConeVectorIntersection(const TVector3 &pos, const TVector3 &dir, const TVector3 &d, const TVector3 &v, const Double_t cosTheta)
This method will find the intersection of the trajectory defined by the vector starting at pos and mo...
TVector3 GetPlaneVectorIntersection(const TVector3 &pos, const TVector3 &dir, TVector3 const &n, TVector3 const &a)
This method will find the intersection of the trajectory defined by the vector starting at pos and mo...
constexpr double qElectron
Electron charge in C.
Definition: TRestPhysics.h:43
Double_t DistanceToAxis(const TVector3 &axisPoint, const TVector3 &axisVector, const TVector3 &point)
This method will return the distance from point to the straight defined by axisPoint and axisVector.
constexpr double kelvinToeV
A kelvin in eV.
Definition: TRestPhysics.h:58
TMatrixD GetConeMatrix(const TVector3 &d, const Double_t cosTheta)
It returns the cone matrix M = d^T x d - cosTheta^2 x I, extracted from the document by "David Eberly...
TVector3 MoveToPlane(const TVector3 &pos, const TVector3 &dir, const TVector3 &n, const TVector3 &a)
This method will translate the vector with direction dir starting at position pos to the plane define...
Double_t GetDistance2(const TVector3 &v1, const TVector3 &v2)
This method returns the squared cartesian distance between vector v2 and v1.
TVector3 MoveByDistanceFast(const TVector3 &pos, const TVector3 &dir, Double_t d)
This method transports a position pos by a distance d in the direction defined by dir....
constexpr double naturalElectron
Electron charge in natural units.
Definition: TRestPhysics.h:56
constexpr double hPlanck
Planck constant in J*s.
Definition: TRestPhysics.h:49
constexpr double AU
Average Sun-Earth distance in m.
Definition: TRestPhysics.h:61
TVector3 GetHyperbolicNormal(const TVector3 &pos, const Double_t beta, const Double_t R3, const Double_t focal)
This method returns the normal vector on a hyperbolic surface pointing towards the inside of the hype...
TVector3 GetVectorReflection(const TVector3 &dir, const TVector3 &n)
This method will return the reflected vector respect to a plane defined by its normal vector n....
constexpr double vacuumPermitivity
Vacuum permitivity in F/m.
Definition: TRestPhysics.h:37
Double_t GetVectorsAngle(const TVector3 &v1, const TVector3 &v2)
This method will return the angle in radians between 2 vectors.
constexpr double secondIneV
A second in eV (using natural units)
Definition: TRestPhysics.h:54