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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/clhep/src/SpaceVectorP.cc (Version 11.3.0) and /externals/clhep/src/SpaceVectorP.cc (Version 1.1)


  1 // -*- C++ -*-                                      1 
  2 // -------------------------------------------    
  3 //                                                
  4 // This file is a part of the CLHEP - a Class     
  5 //                                                
  6 // SpaceVector                                    
  7 //                                                
  8 // This is the implementation of the subset of    
  9 // class which originated from the ZOOM SpaceV    
 10 // intrinsic properties or propeties relative     
 11 //                                                
 12                                                   
 13 #include "CLHEP/Vector/ThreeVector.h"             
 14                                                   
 15 #include <cmath>                                  
 16                                                   
 17 namespace CLHEP  {                                
 18                                                   
 19 //-********************************               
 20 //    - 5 -                                       
 21 // Intrinsic properties of a vector               
 22 // and properties relative to a direction         
 23 //                                                
 24 //-********************************               
 25                                                   
 26 double Hep3Vector::beta() const {                 
 27   double b = std::sqrt(mag2());                   
 28 //  if (b >= 1) {                                 
 29 //    std::cerr << "Hep3Vector::beta() - "        
 30 //      << "Beta taken for Hep3Vector of at le    
 31 //  }                                             
 32   return b;                                       
 33 }                                                 
 34                                                   
 35 double Hep3Vector::gamma() const {                
 36   double bbeta = std::sqrt(mag2());               
 37 //  if (bbeta == 1) {                             
 38 //    std::cerr << "Hep3Vector::gamma() - "       
 39 //      << "Gamma taken for Hep3Vector of unit    
 40 //      << std::endl;                             
 41 //  }                                             
 42 //  if (bbeta > 1) {                              
 43 //    std::cerr << "Hep3Vector::gamma() - "       
 44 //      << "Gamma taken for Hep3Vector of more    
 45 //      << "the sqrt function would return NAN    
 46 //  }                                             
 47   return 1/std::sqrt(1-bbeta*bbeta);              
 48 }                                                 
 49                                                   
 50 double Hep3Vector::rapidity() const {             
 51 //  if (std::fabs(z()) == 1) {                    
 52 //    std::cerr << "Hep3Vector::rapidity() - "    
 53 //      << "Rapidity in Z direction taken for     
 54 //      << "the log should return infinity" <,    
 55 //  }                                             
 56 //  if (std::fabs(z()) > 1) {                     
 57 //    std::cerr << "Hep3Vector::rapidity() - "    
 58 //      << "Rapidity in Z direction taken for     
 59 //      << "the log would return a NAN" << std    
 60 //  }                                             
 61   // Want inverse std::tanh(dz):                  
 62   return (.5 * std::log((1+z())/(1-z())) );       
 63 }                                                 
 64                                                   
 65 double Hep3Vector::coLinearRapidity() const {     
 66   double b = beta();                              
 67 //  if (b == 1) {                                 
 68 //    std::cerr << "Hep3Vector::coLinearRapidi    
 69 //      << "Co-linear Rapidity taken for Hep3V    
 70 //      << "the log should return infinity" <<    
 71 //  }                                             
 72 //  if (b > 1) {                                  
 73 //    std::cerr << "Hep3Vector::coLinearRapidi    
 74 //      << "Co-linear Rapidity taken for Hep3V    
 75 //      << "the log would return a NAN" << std    
 76 //  }                                             
 77   // Want inverse std::tanh(b):                   
 78   return (.5 * std::log((1+b)/(1-b)) );           
 79 }                                                 
 80                                                   
 81 //-*******************************************    
 82 // Other properties relative to a reference ve    
 83 //-*******************************************    
 84                                                   
 85 Hep3Vector Hep3Vector::project (const Hep3Vect    
 86   double mag2v2 = v2.mag2();                      
 87   if (mag2v2 == 0) {                              
 88     std::cerr << "Hep3Vector::project() - "       
 89       << "Attempt to take projection of vector    
 90       << std::endl;                               
 91     return project();                             
 92   }                                               
 93   return ( v2 * (dot(v2)/mag2v2) );               
 94 }                                                 
 95                                                   
 96 double Hep3Vector::rapidity(const Hep3Vector &    
 97   double vmag = v2.mag();                         
 98   if ( vmag == 0 ) {                              
 99     std::cerr << "Hep3Vector::rapidity() - "      
100       << "Rapidity taken with respect to zero     
101     return 0;                                     
102   }                                               
103   double z1 = dot(v2)/vmag;                       
104 //  if (std::fabs(z1) >= 1) {                     
105 //    std::cerr << "Hep3Vector::rapidity() - "    
106 //      << "Rapidity taken for too large a Hep    
107 //      << "-- would return infinity or NAN" <    
108 //  }                                             
109   // Want inverse std::tanh(z):                   
110   return (.5 * std::log((1+z1)/(1-z1)) );         
111 }                                                 
112                                                   
113 double Hep3Vector::eta(const Hep3Vector & v2)     
114   // Defined as    -std::log ( std::tan ( .5*     
115   //                                              
116   // Quicker is to use cosTheta:                  
117   // std::tan (theta/2) = std::sin(theta)/(1 +    
118                                                   
119   double r1   = getR();                           
120   double v2r = v2.mag();                          
121   if ( (r1 == 0) || (v2r == 0) ) {                
122     std::cerr << "Hep3Vector::eta() - "           
123       << "Cannot find pseudorapidity of a zero    
124       << std::endl;                               
125     return 0.;                                    
126   }                                               
127   double c  = dot(v2)/(r1*v2r);                   
128   if ( c >= 1 ) {                                 
129     c = 1;  //-| We don't want to return NAN b    
130     std::cerr << "Hep3Vector::eta() - "           
131       << "Pseudorapidity of vector relative to    
132       << "will give infinite result" << std::e    
133             // We can just go on; tangent will    
134           // std::log (tangent) will be -INFIN    
135           // will be +INFINITY.                   
136   }                                               
137   if ( c <= -1 ) {                                
138     std::cerr << "Hep3Vector::eta() - "           
139       << "Pseudorapidity of vector relative to    
140       << "will give negative infinite result"<    
141           //-| We don't want to return NAN bec    
142     return ( negativeInfinity() );                
143           //  If we just went on, the tangent     
144           //  so return would be NAN.  But the    
145           // of tan is +Infinity, so the retur    
146           // -INFINITY.                           
147   }                                               
148                                                   
149   double tangent = std::sqrt (1-c*c) / ( 1 + c    
150   return (- std::log (tangent));                  
151                                                   
152 } /* eta (u) */                                   
153                                                   
154                                                   
155 }  // namespace CLHEP                             
156