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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/LorentzRotation.cc (Version 11.3.0) and /externals/clhep/src/LorentzRotation.cc (Version 9.4.p4)


  1 // -*- C++ -*-                                      1 
  2 // -------------------------------------------    
  3 //                                                
  4 // This file is a part of the CLHEP - a Class     
  5 //                                                
  6 // This is the implementation basic parts of t    
  7 //                                                
  8 // Some ZOOM methods involving construction fr    
  9 // into boost*rotation are split off into Lore    
 10                                                   
 11 #include "CLHEP/Vector/LorentzRotation.h"         
 12                                                   
 13 #include <cmath>                                  
 14 #include <iomanip>                                
 15 #include <iostream>                               
 16                                                   
 17 namespace CLHEP  {                                
 18                                                   
 19 // ----------  Constructors and Assignment:       
 20                                                   
 21                                                   
 22 HepLorentzRotation & HepLorentzRotation::set      
 23         (double bx, double by, double bz) {       
 24   double bp2 = bx*bx + by*by + bz*bz;             
 25 //  if (bp2 >= 1) {                               
 26 //    std::cerr << "HepLorentzRotation::set()     
 27 //      << "Boost Vector supplied to set HepLo    
 28 //      << std::endl;                             
 29 //  }                                             
 30   double gamma = 1.0 / std::sqrt(1.0 - bp2);      
 31   double bgamma = gamma * gamma / (1.0 + gamma    
 32   mxx = 1.0 + bgamma * bx * bx;                   
 33   myy = 1.0 + bgamma * by * by;                   
 34   mzz = 1.0 + bgamma * bz * bz;                   
 35   mxy = myx = bgamma * bx * by;                   
 36   mxz = mzx = bgamma * bx * bz;                   
 37   myz = mzy = bgamma * by * bz;                   
 38   mxt = mtx = gamma * bx;                         
 39   myt = mty = gamma * by;                         
 40   mzt = mtz = gamma * bz;                         
 41   mtt = gamma;                                    
 42   return *this;                                   
 43 }                                                 
 44                                                   
 45 HepLorentzRotation & HepLorentzRotation::set      
 46     (const HepBoost & B, const HepRotation & R    
 47   set (B.rep4x4());                               
 48   *this = matrixMultiplication ( R.rep4x4() );    
 49   return *this;                                   
 50 }                                                 
 51                                                   
 52 HepLorentzRotation & HepLorentzRotation::set      
 53     (const HepRotation & R, const HepBoost & B    
 54   set (R.rep4x4());                               
 55   *this = matrixMultiplication ( B.rep4x4() );    
 56   return *this;                                   
 57 }                                                 
 58                                                   
 59 // ----------  Accessors:                         
 60                                                   
 61 // ------------  Subscripting:                    
 62                                                   
 63 double HepLorentzRotation::operator () (int i,    
 64   if (i == 0) {                                   
 65     if (j == 0) { return xx(); }                  
 66     if (j == 1) { return xy(); }                  
 67     if (j == 2) { return xz(); }                  
 68     if (j == 3) { return xt(); }                  
 69   } else if (i == 1) {                            
 70     if (j == 0) { return yx(); }                  
 71     if (j == 1) { return yy(); }                  
 72     if (j == 2) { return yz(); }                  
 73     if (j == 3) { return yt(); }                  
 74   } else if (i == 2) {                            
 75     if (j == 0) { return zx(); }                  
 76     if (j == 1) { return zy(); }                  
 77     if (j == 2) { return zz(); }                  
 78     if (j == 3) { return zt(); }                  
 79   } else if (i == 3) {                            
 80     if (j == 0) { return tx(); }                  
 81     if (j == 1) { return ty(); }                  
 82     if (j == 2) { return tz(); }                  
 83     if (j == 3) { return tt(); }                  
 84   }                                               
 85   std::cerr << "HepLorentzRotation subscriptin    
 86       << "(" << i << "," << j << ")\n";           
 87   return 0.0;                                     
 88 }                                                 
 89                                                   
 90 // ---------- Application:                        
 91                                                   
 92                                                   
 93 // ---------- Comparison:                         
 94                                                   
 95 int HepLorentzRotation::compare( const HepLore    
 96        if (mtt<m1.mtt) return -1; else if (mtt    
 97   else if (mtz<m1.mtz) return -1; else if (mtz    
 98   else if (mty<m1.mty) return -1; else if (mty    
 99   else if (mtx<m1.mtx) return -1; else if (mtx    
100                                                   
101   else if (mzt<m1.mzt) return -1; else if (mzt    
102   else if (mzz<m1.mzz) return -1; else if (mzz    
103   else if (mzy<m1.mzy) return -1; else if (mzy    
104   else if (mzx<m1.mzx) return -1; else if (mzx    
105                                                   
106   else if (myt<m1.myt) return -1; else if (myt    
107   else if (myz<m1.myz) return -1; else if (myz    
108   else if (myy<m1.myy) return -1; else if (myy    
109   else if (myx<m1.myx) return -1; else if (myx    
110                                                   
111   else if (mxt<m1.mxt) return -1; else if (mxt    
112   else if (mxz<m1.mxz) return -1; else if (mxz    
113   else if (mxy<m1.mxy) return -1; else if (mxy    
114   else if (mxx<m1.mxx) return -1; else if (mxx    
115                                                   
116   else return 0;                                  
117 }                                                 
118                                                   
119                                                   
120 // ---------- Operations in the group of 4-Rot    
121                                                   
122 HepLorentzRotation                                
123 HepLorentzRotation::matrixMultiplication(const    
124   return HepLorentzRotation(                      
125     mxx*m1.xx_ + mxy*m1.yx_ + mxz*m1.zx_ + mxt    
126     mxx*m1.xy_ + mxy*m1.yy_ + mxz*m1.zy_ + mxt    
127     mxx*m1.xz_ + mxy*m1.yz_ + mxz*m1.zz_ + mxt    
128     mxx*m1.xt_ + mxy*m1.yt_ + mxz*m1.zt_ + mxt    
129                                                   
130     myx*m1.xx_ + myy*m1.yx_ + myz*m1.zx_ + myt    
131     myx*m1.xy_ + myy*m1.yy_ + myz*m1.zy_ + myt    
132     myx*m1.xz_ + myy*m1.yz_ + myz*m1.zz_ + myt    
133     myx*m1.xt_ + myy*m1.yt_ + myz*m1.zt_ + myt    
134                                                   
135     mzx*m1.xx_ + mzy*m1.yx_ + mzz*m1.zx_ + mzt    
136     mzx*m1.xy_ + mzy*m1.yy_ + mzz*m1.zy_ + mzt    
137     mzx*m1.xz_ + mzy*m1.yz_ + mzz*m1.zz_ + mzt    
138     mzx*m1.xt_ + mzy*m1.yt_ + mzz*m1.zt_ + mzt    
139                                                   
140     mtx*m1.xx_ + mty*m1.yx_ + mtz*m1.zx_ + mtt    
141     mtx*m1.xy_ + mty*m1.yy_ + mtz*m1.zy_ + mtt    
142     mtx*m1.xz_ + mty*m1.yz_ + mtz*m1.zz_ + mtt    
143     mtx*m1.xt_ + mty*m1.yt_ + mtz*m1.zt_ + mtt    
144 }                                                 
145                                                   
146 HepLorentzRotation & HepLorentzRotation::rotat    
147   double c1 = std::cos (delta);                   
148   double s1 = std::sin (delta);                   
149   HepLorentzVector rowy = row2();                 
150   HepLorentzVector rowz = row3();                 
151   HepLorentzVector r2 = c1 * rowy - s1 * rowz;    
152   HepLorentzVector r3 = s1 * rowy + c1 * rowz;    
153   myx = r2.x();   myy = r2.y();   myz = r2.z()    
154   mzx = r3.x();   mzy = r3.y();   mzz = r3.z()    
155   return *this;                                   
156 }                                                 
157                                                   
158 HepLorentzRotation & HepLorentzRotation::rotat    
159   double c1 = std::cos (delta);                   
160   double s1 = std::sin (delta);                   
161   HepLorentzVector rowx = row1();                 
162   HepLorentzVector rowz = row3();                 
163   HepLorentzVector r1 =  c1 * rowx + s1 * rowz    
164   HepLorentzVector r3 = -s1 * rowx + c1 * rowz    
165   mxx = r1.x();   mxy = r1.y();   mxz = r1.z()    
166   mzx = r3.x();   mzy = r3.y();   mzz = r3.z()    
167   return *this;                                   
168 }                                                 
169                                                   
170 HepLorentzRotation & HepLorentzRotation::rotat    
171   double c1 = std::cos (delta);                   
172   double s1 = std::sin (delta);                   
173   HepLorentzVector rowx = row1();                 
174   HepLorentzVector rowy = row2();                 
175   HepLorentzVector r1 = c1 * rowx - s1 * rowy;    
176   HepLorentzVector r2 = s1 * rowx + c1 * rowy;    
177   mxx = r1.x();   mxy = r1.y();   mxz = r1.z()    
178   myx = r2.x();   myy = r2.y();   myz = r2.z()    
179   return *this;                                   
180 }                                                 
181                                                   
182 HepLorentzRotation & HepLorentzRotation::boost    
183   double b2 = beta*beta;                          
184 //  if (b2 >= 1) {                                
185 //    std::cerr << "HepLorentzRotation::boostX    
186 //      << "Beta supplied to HepLorentzRotatio    
187 //      << std::endl;                             
188 //  }                                             
189   double g1  = 1.0/std::sqrt(1.0-b2);             
190   double bg = beta*g1;                            
191   HepLorentzVector rowx = row1();                 
192   HepLorentzVector rowt = row4();                 
193   HepLorentzVector r1 =  g1 * rowx + bg * rowt    
194   HepLorentzVector r4 = bg * rowx +  g1 * rowt    
195   mxx = r1.x();   mxy = r1.y();   mxz = r1.z()    
196   mtx = r4.x();   mty = r4.y();   mtz = r4.z()    
197   return *this;                                   
198 }                                                 
199                                                   
200 HepLorentzRotation & HepLorentzRotation::boost    
201   double b2 = beta*beta;                          
202 //  if (b2 >= 1) {                                
203 //    std::cerr << "HepLorentzRotation::boostY    
204 //      << "Beta supplied to HepLorentzRotatio    
205 //      << std::endl;                             
206 //  }                                             
207   double g1  = 1.0/std::sqrt(1.0-b2);             
208   double bg = beta*g1;                            
209   HepLorentzVector rowy = row2();                 
210   HepLorentzVector rowt = row4();                 
211   HepLorentzVector r2 =  g1 * rowy + bg * rowt    
212   HepLorentzVector r4 = bg * rowy +  g1 * rowt    
213   myx = r2.x();   myy = r2.y();   myz = r2.z()    
214   mtx = r4.x();   mty = r4.y();   mtz = r4.z()    
215   return *this;                                   
216 }                                                 
217                                                   
218 HepLorentzRotation & HepLorentzRotation::boost    
219   double b2 = beta*beta;                          
220 //  if (b2 >= 1) {                                
221 //    std::cerr << "HepLorentzRotation::boostZ    
222 //      << "Beta supplied to HepLorentzRotatio    
223 //      << std::endl;                             
224 //  }                                             
225   double g1  = 1.0/std::sqrt(1.0-b2);             
226   double bg = beta*g1;                            
227   HepLorentzVector rowz = row3();                 
228   HepLorentzVector rowt = row4();                 
229   HepLorentzVector r3 =  g1 * rowz + bg * rowt    
230   HepLorentzVector r4 = bg * rowz +  g1 * rowt    
231   mtx = r4.x();   mty = r4.y();   mtz = r4.z()    
232   mzx = r3.x();   mzy = r3.y();   mzz = r3.z()    
233   return *this;                                   
234 }                                                 
235                                                   
236 std::ostream & HepLorentzRotation::print( std:    
237   os << "\n   [ ( " <<                            
238         std::setw(11) << std::setprecision(6)     
239         std::setw(11) << std::setprecision(6)     
240         std::setw(11) << std::setprecision(6)     
241         std::setw(11) << std::setprecision(6)     
242      << "     ( " <<                              
243         std::setw(11) << std::setprecision(6)     
244         std::setw(11) << std::setprecision(6)     
245         std::setw(11) << std::setprecision(6)     
246         std::setw(11) << std::setprecision(6)     
247      << "     ( " <<                              
248         std::setw(11) << std::setprecision(6)     
249         std::setw(11) << std::setprecision(6)     
250         std::setw(11) << std::setprecision(6)     
251         std::setw(11) << std::setprecision(6)     
252      << "     ( " <<                              
253         std::setw(11) << std::setprecision(6)     
254         std::setw(11) << std::setprecision(6)     
255         std::setw(11) << std::setprecision(6)     
256         std::setw(11) << std::setprecision(6)     
257   return os;                                      
258 }                                                 
259                                                   
260 HepLorentzRotation operator* ( const HepRotati    
261                                const HepLorent    
262   r.rep4x4();                                     
263   lt.rep4x4();                                    
264   return HepLorentzRotation( HepRep4x4(           
265          r.xx()*lt.xx() + r.xy()*lt.yx() + r.x    
266    r.xx()*lt.xy() + r.xy()*lt.yy() + r.xz()*lt    
267    r.xx()*lt.xz() + r.xy()*lt.yz() + r.xz()*lt    
268    r.xx()*lt.xt() + r.xy()*lt.yt() + r.xz()*lt    
269                                                   
270          r.yx()*lt.xx() + r.yy()*lt.yx() + r.y    
271          r.yx()*lt.xy() + r.yy()*lt.yy() + r.y    
272          r.yx()*lt.xz() + r.yy()*lt.yz() + r.y    
273          r.yx()*lt.xt() + r.yy()*lt.yt() + r.y    
274                                                   
275          r.zx()*lt.xx() + r.zy()*lt.yx() + r.z    
276          r.zx()*lt.xy() + r.zy()*lt.yy() + r.z    
277          r.zx()*lt.xz() + r.zy()*lt.yz() + r.z    
278          r.zx()*lt.xt() + r.zy()*lt.yt() + r.z    
279                                                   
280          r.tx()*lt.xx() + r.ty()*lt.yx() + r.t    
281          r.tx()*lt.xy() + r.ty()*lt.yy() + r.t    
282          r.tx()*lt.xz() + r.ty()*lt.yz() + r.t    
283          r.tx()*lt.xt() + r.ty()*lt.yt() + r.t    
284 }                                                 
285                                                   
286                                                   
287 const HepLorentzRotation HepLorentzRotation::I    
288                                                   
289 }  // namespace CLHEP                             
290