13#include "CLHEP/Vector/defs.h"
14#include "CLHEP/Vector/ThreeVector.h"
15#include "CLHEP/Vector/ZMxpv.h"
16#include "CLHEP/Units/PhysicalConstants.h"
24 double factor =
mag();
27 "Hep3Vector::setMag : zero vector can't be stretched"));
39 double u1 = NewUzVector.
x();
40 double u2 = NewUzVector.
y();
41 double u3 = NewUzVector.
z();
42 double up = u1*u1 + u2*u2;
46 double px = (u1 * u3 *
x() - u2 *
y()) / up + u1 *
z();
47 double py = (u2 * u3 *
x() + u1 *
y()) / up + u2 *
z();
48 double pz = -up *
x() + u3 *
z();
60 if ( m1== 0 )
return 0.0;
61 if ( m1==
z() )
return 1.0E72;
62 if ( m1== -
z() )
return -1.0E72;
63 return 0.5*std::log( (m1+
z())/(m1-
z()) );
67 return os <<
"(" << v.
x() <<
"," << v.
y() <<
"," << v.
z() <<
")";
71 double & x,
double & y,
double & z );
80const Hep3Vector
HepXHat(1.0, 0.0, 0.0);
81const Hep3Vector
HepYHat(0.0, 1.0, 0.0);
82const Hep3Vector
HepZHat(0.0, 0.0, 1.0);
91 double sinphi = std::sin(phi1);
92 double cosphi = std::cos(phi1);
93 double ty =
y() * cosphi -
z() * sinphi;
94 double tz =
z() * cosphi +
y() * sinphi;
101 double sinphi = std::sin(phi1);
102 double cosphi = std::cos(phi1);
103 double tx =
x() * cosphi +
z() * sinphi;
104 double tz =
z() * cosphi -
x() * sinphi;
111 double sinphi = std::sin(phi1);
112 double cosphi = std::cos(phi1);
113 double tx =
x() * cosphi -
y() * sinphi;
114 double ty =
y() * cosphi +
x() * sinphi;
121 double limit =
dot(v)*epsilon*epsilon;
122 return ( (*
this - v).
mag2() <= limit );
127 double d = (*
this - v).
mag2();
129 if ( (vdv > 0) && (d < vdv) ) {
130 return std::sqrt (d/vdv);
131 }
else if ( (vdv == 0) && (d == 0) ) {
140 if ( dphi > CLHEP::pi ) {
141 dphi -= CLHEP::twopi;
142 }
else if ( dphi <= -CLHEP::pi ) {
143 dphi += CLHEP::twopi;
149 double a =
eta() - v.
eta();
151 return std::sqrt ( a*a + b*b );
160 arg =
dot(q)/std::sqrt(ptot2);
161 if(arg > 1.0) arg = 1.0;
162 if(arg < -1.0) arg = -1.0;
169 double ptot2 =
mag2();
170 double qtot2 = q.
mag2();
171 if ( ptot2 == 0 || qtot2 == 0 ) {
175 arg = (pdq/ptot2) * (pdq/qtot2);
178 if(arg > 1.0) arg = 1.0;
186 if ( (
x() == 0) && (
y() == 0) ) {
189 "Attempt to set eta of zero vector -- vector is unchanged"));
193 "Attempt to set eta of vector along Z axis -- will use phi = 0"));
199 double tanHalfTheta = std::exp ( -eta1 );
201 (1 - tanHalfTheta*tanHalfTheta) / (1 + tanHalfTheta*tanHalfTheta);
202 double rho1 = r1*std::sqrt(1 - cosTheta1*cosTheta1);
203 setZ(r1 * cosTheta1);
204 setY(rho1 * std::sin (phi1));
205 setX(rho1 * std::cos (phi1));
213 if ( (
x() == 0) && (
y() == 0) ) {
216 "Attempt to set cylTheta of zero vector -- vector is unchanged"));
220 setZ(std::fabs(
z()));
223 if (theta1 == CLHEP::pi) {
224 setZ(-std::fabs(
z()));
228 "Attempt set cylindrical theta of vector along Z axis "
229 "to a non-trivial value, while keeping rho fixed -- "
230 "will return zero vector"));
234 if ( (theta1 < 0) || (theta1 > CLHEP::pi) ) {
236 "Setting Cyl theta of a vector based on a value not in [0, PI]"));
241 if ( (theta1 == 0) || (theta1 == CLHEP::pi) ) {
243 "Attempt to set cylindrical theta to 0 or PI "
244 "while keeping rho fixed -- infinite Z will be computed"));
245 setZ((theta1==0) ? 1.0E72 : -1.0E72);
248 setZ(rho1 / std::tan (theta1));
249 setY(rho1 * std::sin (phi1));
250 setX(rho1 * std::cos (phi1));
258 double theta1 = 2 * std::atan ( std::exp (-eta1) );
265 if ( (
x() == 0) && (
y() == 0) ) {
268 "Attempt to set cylEta of zero vector -- vector is unchanged"));
272 setZ(std::fabs(
z()));
275 if (theta1 == CLHEP::pi) {
276 setZ(-std::fabs(
z()));
280 "Attempt set cylindrical eta of vector along Z axis "
281 "to a non-trivial value, while keeping rho fixed -- "
282 "will return zero vector"));
288 setZ(rho1 / std::tan (theta1));
289 setY(rho1 * std::sin (phi1));
290 setX(rho1 * std::cos (phi1));
298 "Attempt to divide vector by 0 -- "
299 "will produce infinities and/or NANs"));
307 "Attempt to do vector /= 0 -- "
308 "division by zero would produce infinite or NAN components"));
Hep3Vector & rotateY(double)
Hep3Vector & rotateX(double)
Hep3Vector & rotateZ(double)
static const int ToleranceTicks
Hep3Vector & operator/=(double)
double howNear(const Hep3Vector &v) const
double dot(const Hep3Vector &) const
bool isNear(const Hep3Vector &, double epsilon=tolerance) const
double pseudoRapidity() const
double deltaPhi(const Hep3Vector &v2) const
void set(double x, double y, double z)
double deltaR(const Hep3Vector &v) const
Hep3Vector & rotateUz(const Hep3Vector &)
std::istream & operator>>(std::istream &is, HepRandom &dist)
std::ostream & operator<<(std::ostream &s, const HepDiagMatrix &q)
void ZMinput3doubles(std::istream &is, const char *type, double &x, double &y, double &z)
const Hep3Vector HepYHat(0.0, 1.0, 0.0)
const Hep3Vector HepXHat(1.0, 0.0, 0.0)
HepDiagMatrix operator/(const HepDiagMatrix &hm1, double t)
const Hep3Vector HepZHat(0.0, 0.0, 1.0)