8 #include "CLHEP/Geometry/BasicVector3D.h" 
   13   float BasicVector3D<float>::pseudoRapidity()
 const {
 
   14     float ma = mag(), dz = 
z();
 
   15     if (ma ==  0)  
return  0;
 
   18     return 0.5*std::log((ma+dz)/(ma-dz));
 
   23   void BasicVector3D<float>::setEta(
float a) {
 
   26     double tanHalfTheta  = std::exp(-a);
 
   27     double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
 
   28     double cosTheta1      = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
 
   29     double rh            = ma * std::sqrt(1 - cosTheta1*cosTheta1);
 
   31     set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
 
   36   float BasicVector3D<float>::angle(
const BasicVector3D<float> & v)
 const {
 
   38     double ptot = mag()*v.mag();
 
   41       if(cosa >  1) cosa =  1;
 
   42       if(cosa < -1) cosa = -1;
 
   44     return std::acos(cosa);
 
   49   BasicVector3D<float> & BasicVector3D<float>::rotateX(
float a) {
 
   50     double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = 
z();
 
   51     setY(dy*cosa-dz*sina);
 
   52     setZ(dz*cosa+dy*sina);
 
   58   BasicVector3D<float> & BasicVector3D<float>::rotateY(
float a) {
 
   59     double sina = std::sin(a), cosa = std::cos(a), dz = 
z(), dx = x();
 
   60     setZ(dz*cosa-dx*sina);
 
   61     setX(dx*cosa+dz*sina);
 
   67   BasicVector3D<float> & BasicVector3D<float>::rotateZ(
float a) {
 
   68     double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
 
   69     setX(dx*cosa-dy*sina);
 
   70     setY(dy*cosa+dx*sina);
 
   76   BasicVector3D<float> &
 
   77   BasicVector3D<float>::rotate(
float a, 
const BasicVector3D<float> & v) {
 
   78     if (a  == 0) 
return *
this;
 
   79     double cx = v.x(), cy = v.y(), cz = v.z();
 
   80     double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
 
   82       std::cerr << 
"BasicVector<float>::rotate() : zero axis" << std::endl;
 
   85     double cosa = std::cos(a), sina = std::sin(a);
 
   86     cx /= ll; cy /= ll; cz /= ll;   
 
   88     double xx = cosa + (1-cosa)*cx*cx;
 
   89     double xy =        (1-cosa)*cx*cy - sina*cz;
 
   90     double xz =        (1-cosa)*cx*cz + sina*cy;
 
   92     double yx =        (1-cosa)*cy*cx + sina*cz;
 
   93     double yy = cosa + (1-cosa)*cy*cy; 
 
   94     double yz =        (1-cosa)*cy*cz - sina*cx;
 
   96     double zx =        (1-cosa)*cz*cx - sina*cy;
 
   97     double zy =        (1-cosa)*cz*cy + sina*cx;
 
   98     double zz = cosa + (1-cosa)*cz*cz;
 
  100     cx = x(); cy = y(); cz = 
z();   
 
  101     set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
 
  107   operator<<(std::ostream & os, const BasicVector3D<float> & 
a)
 
  109     return os << 
"(" << a.x() << 
"," << a.y() << 
"," << a.z() << 
")";
 
  126     if (is.fail() || c != 
'(' ) {
 
  128         << 
"Could not find required opening parenthesis " 
  129         << 
"in input of a BasicVector3D<float>" 
  134     is >> x >> std::ws >> c;
 
  135     if (is.fail() || c != 
',' ) {
 
  137         << 
"Could not find x value and required trailing comma " 
  138         << 
"in input of a BasicVector3D<float>" 
  143     is >> y >> std::ws >> c;
 
  144     if (is.fail() || c != 
',' ) {
 
  146         << 
"Could not find y value and required trailing comma " 
  147         <<  
"in input of a BasicVector3D<float>" 
  152     is >> z >> std::ws >> c;
 
  153     if (is.fail() || c != 
')' ) {
 
  155         << 
"Could not find z value and required close parenthesis " 
  156         << 
"in input of a BasicVector3D<float>" 
  169   double BasicVector3D<double>::pseudoRapidity()
 const {
 
  170     double ma = mag(), dz = 
z();
 
  171     if (ma ==  0)  
return  0;
 
  173     if (ma == -dz) 
return -
DBL_MAX;
 
  174     return 0.5*std::log((ma+dz)/(ma-dz));
 
  179   void BasicVector3D<double>::setEta(
double a) {
 
  182     double tanHalfTheta  = std::exp(-a);
 
  183     double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
 
  184     double cosTheta1      = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
 
  185     double rh            = ma * std::sqrt(1 - cosTheta1*cosTheta1);
 
  187     set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
 
  192   double BasicVector3D<double>::angle(
const BasicVector3D<double> & v)
 const {
 
  194     double ptot = mag()*v.mag();
 
  197       if(cosa >  1) cosa =  1;
 
  198       if(cosa < -1) cosa = -1;
 
  200     return std::acos(cosa);
 
  205   BasicVector3D<double> & BasicVector3D<double>::rotateX(
double a) {
 
  206     double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = 
z();
 
  207     setY(dy*cosa-dz*sina);
 
  208     setZ(dz*cosa+dy*sina);
 
  214   BasicVector3D<double> & BasicVector3D<double>::rotateY(
double a) {
 
  215     double sina = std::sin(a), cosa = std::cos(a), dz = 
z(), dx = x();
 
  216     setZ(dz*cosa-dx*sina);
 
  217     setX(dx*cosa+dz*sina);
 
  223   BasicVector3D<double> & BasicVector3D<double>::rotateZ(
double a) {
 
  224     double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
 
  225     setX(dx*cosa-dy*sina);
 
  226     setY(dy*cosa+dx*sina);
 
  232   BasicVector3D<double> &
 
  233   BasicVector3D<double>::rotate(
double a, 
const BasicVector3D<double> & v) {
 
  234     if (a  == 0) 
return *
this;
 
  235     double cx = v.x(), cy = v.y(), cz = v.z();
 
  236     double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
 
  238       std::cerr << 
"BasicVector<double>::rotate() : zero axis" << std::endl;
 
  241     double cosa = std::cos(a), sina = std::sin(a);
 
  242     cx /= ll; cy /= ll; cz /= ll;   
 
  244     double xx = cosa + (1-cosa)*cx*cx;
 
  245     double xy =        (1-cosa)*cx*cy - sina*cz;
 
  246     double xz =        (1-cosa)*cx*cz + sina*cy;
 
  248     double yx =        (1-cosa)*cy*cx + sina*cz;
 
  249     double yy = cosa + (1-cosa)*cy*cy; 
 
  250     double yz =        (1-cosa)*cy*cz - sina*cx;
 
  252     double zx =        (1-cosa)*cz*cx - sina*cy;
 
  253     double zy =        (1-cosa)*cz*cy + sina*cx;
 
  254     double zz = cosa + (1-cosa)*cz*cz;
 
  256     cx = x(); cy = y(); cz = 
z();   
 
  257     set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
 
  263   operator<< (std::ostream & os, const BasicVector3D<double> & 
a)
 
  265     return os << 
"(" << a.x() << 
"," << a.y() << 
"," << a.z() << 
")";
 
  282     if (is.fail() || c != 
'(' ) {
 
  284         << 
"Could not find required opening parenthesis " 
  285         << 
"in input of a BasicVector3D<double>" 
  290     is >> x >> std::ws >> c;
 
  291     if (is.fail() || c != 
',' ) {
 
  293         << 
"Could not find x value and required trailing comma " 
  294         << 
"in input of a BasicVector3D<double>" 
  299     is >> y >> std::ws >> c;
 
  300     if (is.fail() || c != 
',' ) {
 
  302         << 
"Could not find y value and required trailing comma " 
  303         <<  
"in input of a BasicVector3D<double>" 
  308     is >> z >> std::ws >> c;
 
  309     if (is.fail() || c != 
')' ) {
 
  311         << 
"Could not find z value and required close parenthesis " 
  312         << 
"in input of a BasicVector3D<double>" 
std::istream & operator>>(std::istream &is, BasicVector3D< float > &a)