14 #pragma implementation 17 #include "CLHEP/Vector/defs.h" 18 #include "CLHEP/Vector/ThreeVector.h" 19 #include "CLHEP/Vector/ZMxpv.h" 20 #include "CLHEP/Units/PhysicalConstants.h" 28 double factor =
mag();
31 "Hep3Vector::setMag : zero vector can't be stretched"));
49 std::cerr <<
"Hep3Vector subscripting: bad index (" << i <<
")" 66 <<
"Hep3Vector subscripting: bad index (" << i <<
")" 75 double u1 = NewUzVector.
x();
76 double u2 = NewUzVector.
y();
77 double u3 = NewUzVector.
z();
78 double up = u1*u1 + u2*u2;
82 double px =
dx, py =
dy, pz =
dz;
83 dx = (u1*u3*px - u2*py)/up + u1*pz;
84 dy = (u2*u3*px + u1*py)/up + u2*pz;
87 else if (u3 < 0.) {
dx = -
dx;
dz = -
dz; }
94 if ( m1== 0 )
return 0.0;
95 if ( m1==
z() )
return 1.0E72;
96 if ( m1== -
z() )
return -1.0E72;
97 return 0.5*std::log( (m1+
z())/(m1-
z()) );
101 return os <<
"(" << v.
x() <<
"," << v.
y() <<
"," << v.
z() <<
")";
105 double &
x,
double &
y,
double &
z );
125 double sinphi = std::sin(phi1);
126 double cosphi = std::cos(phi1);
128 ty =
dy * cosphi -
dz * sinphi;
129 dz =
dz * cosphi +
dy * sinphi;
135 double sinphi = std::sin(phi1);
136 double cosphi = std::cos(phi1);
138 tz =
dz * cosphi -
dx * sinphi;
139 dx =
dx * cosphi +
dz * sinphi;
145 double sinphi = std::sin(phi1);
146 double cosphi = std::cos(phi1);
148 tx =
dx * cosphi -
dy * sinphi;
149 dy =
dy * cosphi +
dx * sinphi;
155 double limit =
dot(v)*epsilon*epsilon;
156 return ( (*
this - v).
mag2() <= limit );
161 double d = (*
this - v).
mag2();
163 if ( (vdv > 0) && (d < vdv) ) {
164 return std::sqrt (d/vdv);
165 }
else if ( (vdv == 0) && (d == 0) ) {
174 if ( dphi > CLHEP::pi ) {
175 dphi -= CLHEP::twopi;
176 }
else if ( dphi <= -CLHEP::pi ) {
177 dphi += CLHEP::twopi;
185 return std::sqrt ( a*a + b*b );
194 arg =
dot(q)/std::sqrt(ptot2);
195 if(arg > 1.0) arg = 1.0;
196 if(arg < -1.0) arg = -1.0;
203 double ptot2 =
mag2();
204 double qtot2 = q.
mag2();
205 if ( ptot2 == 0 || qtot2 == 0 ) {
209 arg = (pdq/ptot2) * (pdq/qtot2);
212 if(arg > 1.0) arg = 1.0;
220 if ( (
dx == 0) && (
dy == 0) ) {
223 "Attempt to set eta of zero vector -- vector is unchanged"));
227 "Attempt to set eta of vector along Z axis -- will use phi = 0"));
233 double tanHalfTheta = std::exp ( -eta1 );
235 (1 - tanHalfTheta*tanHalfTheta) / (1 + tanHalfTheta*tanHalfTheta);
237 double rho1 = r1*std::sqrt(1 - cosTheta1*cosTheta1);
238 dy = rho1 * std::sin (phi1);
239 dx = rho1 * std::cos (phi1);
247 if ( (
dx == 0) && (
dy == 0) ) {
250 "Attempt to set cylTheta of zero vector -- vector is unchanged"));
257 if (theta1 == CLHEP::pi) {
262 "Attempt set cylindrical theta of vector along Z axis " 263 "to a non-trivial value, while keeping rho fixed -- " 264 "will return zero vector"));
268 if ( (theta1 < 0) || (theta1 > CLHEP::pi) ) {
270 "Setting Cyl theta of a vector based on a value not in [0, PI]"));
275 if ( (theta1 == 0) || (theta1 == CLHEP::pi) ) {
277 "Attempt to set cylindrical theta to 0 or PI " 278 "while keeping rho fixed -- infinite Z will be computed"));
279 dz = (theta1==0) ? 1.0E72 : -1.0E72;
282 dz = rho1 / std::tan (theta1);
283 dy = rho1 * std::sin (phi1);
284 dx = rho1 * std::cos (phi1);
292 double theta1 = 2 * std::atan ( std::exp (-eta1) );
299 if ( (
dx == 0) && (
dy == 0) ) {
302 "Attempt to set cylEta of zero vector -- vector is unchanged"));
309 if (theta1 == CLHEP::pi) {
314 "Attempt set cylindrical eta of vector along Z axis " 315 "to a non-trivial value, while keeping rho fixed -- " 316 "will return zero vector"));
322 dz = rho1 / std::tan (theta1);
323 dy = rho1 * std::sin (phi1);
324 dx = rho1 * std::cos (phi1);
332 "Attempt to divide vector by 0 -- " 333 "will produce infinities and/or NANs"));
335 double oneOverC = 1.0/c;
344 "Attempt to do vector /= 0 -- " 345 "division by zero would produce infinite or NAN components"));
347 double oneOverC = 1.0/c;
void ZMinput3doubles(std::istream &is, const char *type, double &x, double &y, double &z)
void set(double x, double y, double z)
double deltaPhi(const Hep3Vector &v2) const
HepLorentzVector operator/(const HepLorentzVector &, double a)
Hep3Vector & rotateX(double)
Hep3Vector & rotateUz(const Hep3Vector &)
bool isNear(const Hep3Vector &, double epsilon=tolerance) const
double pseudoRapidity() const
std::istream & operator>>(std::istream &is, HepAxisAngle &aa)
Hep3Vector & rotateZ(double)
double howNear(const Hep3Vector &v) const
double deltaR(const Hep3Vector &v) const
double dot(const Hep3Vector &) const
Hep3Vector & rotateY(double)
double operator()(int) const
std::ostream & operator<<(std::ostream &os, const HepAxisAngle &aa)
Hep3Vector & operator/=(double)