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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/LorentzRotationC.cc (Version 11.3.0) and /externals/clhep/src/LorentzRotationC.cc (Version 7.0.p1)


  1 // -*- C++ -*-                                      1 
  2 // -------------------------------------------    
  3 //                                                
  4 // This file is a part of the CLHEP - a Class     
  5 //                                                
  6 // This is the implementation of that part of     
  7 // which is concerned with setting or construc    
  8 // on 4 supplied columns or rows.                 
  9                                                   
 10 #include "CLHEP/Vector/LorentzRotation.h"         
 11 #include "CLHEP/Vector/LorentzVector.h"           
 12                                                   
 13 #include <cmath>                                  
 14 #include <iostream>                               
 15                                                   
 16 namespace CLHEP  {                                
 17                                                   
 18 // ----------  Constructors and Assignment:       
 19                                                   
 20 HepLorentzRotation & HepLorentzRotation::set (    
 21                                   const HepLor    
 22                             const HepLorentzVe    
 23                             const HepLorentzVe    
 24   // First, test that the four cols do represe    
 25   // true LT:                                     
 26                                                   
 27   ZMpvMetric_t savedMetric = HepLorentzVector:    
 28                                                   
 29   if ( ccol4.getT() < 0 ) {                       
 30     std::cerr << "HepLorentzRotation::set() -     
 31       << "column 4 supplied to define transfor    
 32       << std::endl;                               
 33     *this = HepLorentzRotation();                 
 34     return *this;                                 
 35   }                                               
 36 /*                                                
 37   double u1u1 = ccol1.dot(ccol1);                 
 38   double f11  = std::fabs(u1u1 + 1.0);            
 39   if ( f11 > Hep4RotationInterface::tolerance     
 40     std::cerr << "HepLorentzRotation::set() -     
 41       << "column 1 supplied for HepLorentzRota    
 42   }                                               
 43   double u2u2 = ccol2.dot(ccol2);                 
 44   double f22  = std::fabs(u2u2 + 1.0);            
 45   if ( f22 > Hep4RotationInterface::tolerance     
 46     std::cerr << "HepLorentzRotation::set() -     
 47       << "column 2 supplied for HepLorentzRota    
 48   }                                               
 49   double u3u3 = ccol3.dot(ccol3);                 
 50   double f33  = std::fabs(u3u3 + 1.0);            
 51   if ( f33 > Hep4RotationInterface::tolerance     
 52     std::cerr << "HepLorentzRotation::set() -     
 53       << "column 3 supplied for HepLorentzRota    
 54   }                                               
 55   double u4u4 = ccol4.dot(ccol4);                 
 56   double f44  = std::fabs(u4u4 - 1.0);            
 57   if ( f44 > Hep4RotationInterface::tolerance     
 58     std::cerr << "HepLorentzRotation::set() -     
 59       << "column 4 supplied for HepLorentzRota    
 60   }                                               
 61                                                   
 62   double u1u2 = ccol1.dot(ccol2);                 
 63   double f12  = std::fabs(u1u2);                  
 64   if ( f12 > Hep4RotationInterface::tolerance     
 65     std::cerr << "HepLorentzRotation::set() -     
 66       << "columns 1 and 2 supplied for HepLore    
 67   }                                               
 68   double u1u3 = ccol1.dot(ccol3);                 
 69   double f13  = std::fabs(u1u3);                  
 70                                                   
 71   if ( f13 > Hep4RotationInterface::tolerance     
 72     std::cerr << "HepLorentzRotation::set() -     
 73       << "columns 1 and 3 supplied for HepLore    
 74   }                                               
 75   double u1u4 = ccol1.dot(ccol4);                 
 76   double f14  = std::fabs(u1u4);                  
 77   if ( f14 > Hep4RotationInterface::tolerance     
 78     std::cerr << "HepLorentzRotation::set() -     
 79       << "columns 1 and 4 supplied for HepLore    
 80   }                                               
 81   double u2u3 = ccol2.dot(ccol3);                 
 82   double f23  = std::fabs(u2u3);                  
 83   if ( f23 > Hep4RotationInterface::tolerance     
 84     std::cerr << "HepLorentzRotation::set() -     
 85       << "columns 2 and 3 supplied for HepLore    
 86   }                                               
 87   double u2u4 = ccol2.dot(ccol4);                 
 88   double f24  = std::fabs(u2u4);                  
 89   if ( f24 > Hep4RotationInterface::tolerance     
 90     std::cerr << "HepLorentzRotation::set() -     
 91       << "columns 2 and 4 supplied for HepLore    
 92   }                                               
 93   double u3u4 = ccol3.dot(ccol4);                 
 94   double f34  = std::fabs(u3u4);                  
 95   if ( f34 > Hep4RotationInterface::tolerance     
 96     std::cerr << "HepLorentzRotation::set() -     
 97       << "columns 3 and 4 supplied for HepLore    
 98   }                                               
 99 */                                                
100   // Our strategy will be to order the cols, t    
101   // (that is, remove the components of col d     
102   // col c, normalize that, then remove the co    
103   // non-orthogonal to d and to c, normalize t    
104                                                   
105   // Because col4, the time col, is most likel    
106   // will start from there and work left-ward.    
107                                                   
108   HepLorentzVector a, b, c, d;                    
109   bool isLorentzTransformation = true;            
110   double norm;                                    
111                                                   
112   d = ccol4;                                      
113   norm = d.dot(d);                                
114   if (norm <= 0.0) {                              
115     isLorentzTransformation = false;              
116     if (norm == 0.0) {                            
117       d = T_HAT4;       // Moot, but let's kee    
118       norm = 1.0;                                 
119     }                                             
120   }                                               
121   d /= norm;                                      
122                                                   
123   c = ccol3 - ccol3.dot(d) * d;                   
124   norm = -c.dot(c);                               
125   if (norm <= 0.0) {                              
126     isLorentzTransformation = false;              
127     if (norm == 0.0) {                            
128       c = Z_HAT4;       // Moot                   
129       norm = 1.0;                                 
130     }                                             
131   }                                               
132   c /= norm;                                      
133                                                   
134   b = ccol2 + ccol2.dot(c) * c - ccol2.dot(d)     
135   norm = -b.dot(b);                               
136   if (norm <= 0.0) {                              
137     isLorentzTransformation = false;              
138     if (norm == 0.0) {                            
139       b = Y_HAT4;       // Moot                   
140       norm = 1.0;                                 
141     }                                             
142   }                                               
143   b /= norm;                                      
144                                                   
145   a = ccol1 + ccol1.dot(b) * b + ccol1.dot(c)     
146   norm = -a.dot(a);                               
147   if (norm <= 0.0) {                              
148     isLorentzTransformation = false;              
149     if (norm == 0.0) {                            
150       a = X_HAT4;       // Moot                   
151       norm = 1.0;                                 
152     }                                             
153   }                                               
154   a /= norm;                                      
155                                                   
156   if ( !isLorentzTransformation ) {               
157       std::cerr << "HepLorentzRotation::set()     
158         << "cols 1-4 supplied to define transf    
159         << "       a boosted reflection or a t    
160         << "       transformation will be set     
161                                                   
162     *this = HepLorentzRotation();                 
163   }                                               
164                                                   
165   if ( isLorentzTransformation ) {                
166     mxx = a.x(); myx = a.y(); mzx = a.z(); mtx    
167     mxy = b.x(); myy = b.y(); mzy = b.z(); mty    
168     mxz = c.x(); myz = c.y(); mzz = c.z(); mtz    
169     mxt = d.x(); myt = d.y(); mzt = d.z(); mtt    
170   }                                               
171                                                   
172   HepLorentzVector::setMetric (savedMetric);      
173   return *this;                                   
174                                                   
175 } // set ( col1, col2, col3, col4 )               
176                                                   
177 HepLorentzRotation & HepLorentzRotation::setRo    
178    (const HepLorentzVector & rrow1,               
179           const HepLorentzVector & rrow2,         
180     const HepLorentzVector & rrow3,               
181     const HepLorentzVector & rrow4) {             
182   // Set based on using those rows as columns:    
183   set (rrow1, rrow2, rrow3, rrow4);               
184   // Now transpose in place:                      
185   double q1, q2, q3;                              
186   q1  = mxy;  q2  = mxz;  q3  = mxt;              
187   mxy = myx;  mxz = mzx;  mxt = mtx;              
188   myx = q1;   mzx = q2;   mtx = q3;               
189   q1  = myz;  q2  = myt;  q3  = mzt;              
190   myz = mzy;  myt = mty;  mzt = mtz;              
191   mzy = q1;   mty = q2;   mtz = q3;               
192   return *this;                                   
193 } // LorentzTransformation::setRows(row1 ... r    
194                                                   
195 HepLorentzRotation::HepLorentzRotation ( const    
196                              const HepLorentzV    
197                              const HepLorentzV    
198                              const HepLorentzV    
199 {                                                 
200   set ( ccol1, ccol2, ccol3, ccol4 );             
201 }                                                 
202                                                   
203 }  // namespace CLHEP                             
204                                                   
205