Geant4 Cross Reference |
1 // -*- C++ -*- 1 // -*- C++ -*- 2 // CLASSDOC OFF 2 // CLASSDOC OFF 3 // ------------------------------------------- 3 // --------------------------------------------------------------------------- 4 // CLASSDOC ON 4 // CLASSDOC ON 5 // 5 // 6 // This file is a part of the CLHEP - a Class 6 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 7 // 7 // 8 // This contains the definition of two abstrac 8 // This contains the definition of two abstract interface classes: 9 // Hep4RotationInterface 9 // Hep4RotationInterface 10 // Hep3RotationInterface. 10 // Hep3RotationInterface. 11 // However, these are mostly for defining meth 11 // However, these are mostly for defining methods which should be present in 12 // any 4- or 3-rotation class, however special 12 // any 4- or 3-rotation class, however specialized. The actual classes do 13 // not inherit from these. The virtual functi 13 // not inherit from these. The virtual function overhead turns out 14 // to be too steep for that to be practical. 14 // to be too steep for that to be practical. 15 // 15 // 16 // It may be desirable in the future to turn t 16 // It may be desirable in the future to turn these classes into constraints 17 // in the Stroustrup sense, so as to enforce t 17 // in the Stroustrup sense, so as to enforce this interface, still without 18 // inheritance. However, they do contain an i 18 // inheritance. However, they do contain an important static: 19 // static double tolerance to set criteria for 19 // static double tolerance to set criteria for relative nearness. 20 // 20 // 21 // This file also defines structs 21 // This file also defines structs 22 // HepRep3x3; 22 // HepRep3x3; 23 // HepRep4x4; 23 // HepRep4x4; 24 // HepRep4x4Symmetric; 24 // HepRep4x4Symmetric; 25 // which are used by various Rotation classes. 25 // which are used by various Rotation classes. 26 // 26 // 27 // Hep4RotationInterface 27 // Hep4RotationInterface 28 // contains all the methods to get attributes 28 // contains all the methods to get attributes of either a 29 // HepLorentzRotation or a HepRotation -- any 29 // HepLorentzRotation or a HepRotation -- any information 30 // that pertains to a LorentzRotation can als 30 // that pertains to a LorentzRotation can also be defined 31 // for a HepRotation.(For example, the 4x4 re 31 // for a HepRotation.(For example, the 4x4 representation 32 // would just have 0's in the space-time entr 32 // would just have 0's in the space-time entries and 1 in 33 // the time-time entry.) 33 // the time-time entry.) 34 // 34 // 35 // Hep3RotationInterface 35 // Hep3RotationInterface 36 // inherits from Hep4RotationInterface, and 36 // inherits from Hep4RotationInterface, and adds methods 37 // which are well-defined only in the case of 37 // which are well-defined only in the case of a Rotation. 38 // For example, a 3x3 representation is an at 38 // For example, a 3x3 representation is an attribute only 39 // if the generic LorentzRotation involves no 39 // if the generic LorentzRotation involves no boost. 40 // 40 // 41 // In terms of classes in the ZOOM PhysicsVect 41 // In terms of classes in the ZOOM PhysicsVectors package, 42 // Hep4RotationInterface <--> LorentzTransfor 42 // Hep4RotationInterface <--> LorentzTransformationInterface 43 // Hep3RotationInterface <--> RotationInterfa 43 // Hep3RotationInterface <--> RotationInterface 44 // 44 // 45 // Hep4RotationInterface defines the required 45 // Hep4RotationInterface defines the required methods for: 46 // HepLorentzRotation 46 // HepLorentzRotation 47 // HepBoost 47 // HepBoost 48 // HepBoostX 48 // HepBoostX 49 // HepBoostY 49 // HepBoostY 50 // HepBoostZ 50 // HepBoostZ 51 // 51 // 52 // Hep3RotationInterface defines the required 52 // Hep3RotationInterface defines the required methods for: 53 // HepRotation 53 // HepRotation 54 // HepRotationX 54 // HepRotationX 55 // HepRotationY 55 // HepRotationY 56 // HepRotationZ 56 // HepRotationZ 57 // 57 // 58 // .SS See Also 58 // .SS See Also 59 // Rotation.h, LorentzRotation.h 59 // Rotation.h, LorentzRotation.h 60 // 60 // 61 // .SS Author 61 // .SS Author 62 // Mark Fischler 62 // Mark Fischler 63 // 63 // 64 64 65 #ifndef HEP_ROTATION_INTERFACES_H 65 #ifndef HEP_ROTATION_INTERFACES_H 66 #define HEP_ROTATION_INTERFACES_H 66 #define HEP_ROTATION_INTERFACES_H 67 67 68 #include "CLHEP/Vector/ThreeVector.h" 68 #include "CLHEP/Vector/ThreeVector.h" 69 #include "CLHEP/Vector/LorentzVector.h" 69 #include "CLHEP/Vector/LorentzVector.h" 70 #include "CLHEP/Vector/AxisAngle.h" 70 #include "CLHEP/Vector/AxisAngle.h" 71 71 72 namespace CLHEP { 72 namespace CLHEP { 73 73 74 struct HepRep3x3; 74 struct HepRep3x3; 75 struct HepRep4x4; 75 struct HepRep4x4; 76 struct HepRep4x4Symmetric; 76 struct HepRep4x4Symmetric; 77 77 78 class HepRotation; 78 class HepRotation; 79 class HepRotationX; 79 class HepRotationX; 80 class HepRotationY; 80 class HepRotationY; 81 class HepRotationZ; 81 class HepRotationZ; 82 class HepLorentzRotation; 82 class HepLorentzRotation; 83 class HepBoost; 83 class HepBoost; 84 class HepBoostX; 84 class HepBoostX; 85 class HepBoostY; 85 class HepBoostY; 86 class HepBoostZ; 86 class HepBoostZ; 87 87 88 //-****************************** 88 //-****************************** 89 // 89 // 90 // Hep4RotationInterface 90 // Hep4RotationInterface 91 // 91 // 92 //-****************************** 92 //-****************************** 93 93 94 /** 94 /** 95 * @author 95 * @author 96 * @ingroup vector 96 * @ingroup vector 97 */ 97 */ 98 class Hep4RotationInterface { 98 class Hep4RotationInterface { 99 99 100 // All attributes of shared by HepLorentzRot 100 // All attributes of shared by HepLorentzRotation, HepBoost, 101 // HepBoostX, HepBoostY, HepBoostZ. HepRota 101 // HepBoostX, HepBoostY, HepBoostZ. HepRotation, HepRotationX, 102 // HepRotationY, HepRotationZ also share thi 102 // HepRotationY, HepRotationZ also share this attribute interface. 103 103 104 friend class HepRotation; 104 friend class HepRotation; 105 friend class HepRotationX; 105 friend class HepRotationX; 106 friend class HepRotationY; 106 friend class HepRotationY; 107 friend class HepRotationZ; 107 friend class HepRotationZ; 108 friend class HepLorentzRotation; 108 friend class HepLorentzRotation; 109 friend class HepBoost; 109 friend class HepBoost; 110 friend class HepBoostX; 110 friend class HepBoostX; 111 friend class HepBoostY; 111 friend class HepBoostY; 112 friend class HepBoostZ; 112 friend class HepBoostZ; 113 113 114 public: 114 public: 115 115 116 DLL_API static double tolerance; // t 116 DLL_API static double tolerance; // to determine relative nearness 117 117 118 // ---------- Accessors: 118 // ---------- Accessors: 119 119 120 #ifdef ONLY_IN_CONCRETE_CLASSES 120 #ifdef ONLY_IN_CONCRETE_CLASSES 121 // orthosymplectic 4-vectors: 121 // orthosymplectic 4-vectors: 122 HepLorentzVector col1() const; 122 HepLorentzVector col1() const; 123 HepLorentzVector col2() const; 123 HepLorentzVector col2() const; 124 HepLorentzVector col3() const; 124 HepLorentzVector col3() const; 125 HepLorentzVector col4() const; 125 HepLorentzVector col4() const; 126 HepLorentzVector row1() const; 126 HepLorentzVector row1() const; 127 HepLorentzVector row2() const; 127 HepLorentzVector row2() const; 128 HepLorentzVector row3() const; 128 HepLorentzVector row3() const; 129 HepLorentzVector row4() const; 129 HepLorentzVector row4() const; 130 130 131 // individual elements: 131 // individual elements: 132 double xx() const ; 132 double xx() const ; 133 double xy() const ; 133 double xy() const ; 134 double xz() const ; 134 double xz() const ; 135 double xt() const ; 135 double xt() const ; 136 double yx() const ; 136 double yx() const ; 137 double yy() const ; 137 double yy() const ; 138 double yz() const ; 138 double yz() const ; 139 double yt() const ; 139 double yt() const ; 140 double zx() const ; 140 double zx() const ; 141 double zy() const ; 141 double zy() const ; 142 double zz() const ; 142 double zz() const ; 143 double zt() const ; 143 double zt() const ; 144 double tx() const ; 144 double tx() const ; 145 double ty() const ; 145 double ty() const ; 146 double tz() const ; 146 double tz() const ; 147 double tt() const ; 147 double tt() const ; 148 148 149 // 4x4 representation: 149 // 4x4 representation: 150 //HepRep4x4 rep4x4() const; JMM Declared here 150 //HepRep4x4 rep4x4() const; JMM Declared here but not defined anywhere! 151 151 152 // ---------- Operations: 152 // ---------- Operations: 153 // comparisons: 153 // comparisons: 154 154 155 inline int compare( const Hep4RotationInterf 155 inline int compare( const Hep4RotationInterface & lt ) const; 156 // Dictionary-order comparisons, utilizing t 156 // Dictionary-order comparisons, utilizing the decompose(b,r) method 157 157 158 // decomposition: 158 // decomposition: 159 159 160 void decompose (HepAxisAngle & rotation, Hep 160 void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const; 161 // Decompose as T= R * B, where R is pure ro 161 // Decompose as T= R * B, where R is pure rotation, B is pure boost. 162 162 163 void decompose (Hep3Vector & boost, HepAxisA 163 void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const; 164 // Decompose as T= B * R, where R is pure ro 164 // Decompose as T= B * R, where R is pure rotation, B is pure boost. 165 165 166 bool operator == (const Hep4RotationInterfac 166 bool operator == (const Hep4RotationInterface & r) const; 167 bool operator != (const Hep4RotationInterfac 167 bool operator != (const Hep4RotationInterface & r) const; 168 168 169 // relative comparison: 169 // relative comparison: 170 170 171 double norm2() const ; 171 double norm2() const ; 172 double distance2( const Hep4RotationInterfa 172 double distance2( const Hep4RotationInterface & lt ) const ; 173 double howNear( const Hep4RotationInterface 173 double howNear( const Hep4RotationInterface & lt ) const ; 174 bool isNear (const Hep4RotationInterface & l 174 bool isNear (const Hep4RotationInterface & lt, 175 double epsilon=tolerance) const ; 175 double epsilon=tolerance) const ; 176 176 177 void rectify() ; 177 void rectify() ; 178 // non-const but logically const correction 178 // non-const but logically const correction for accumulated roundoff errors 179 179 180 // ---------- Apply LorentzTransformations: 180 // ---------- Apply LorentzTransformations: 181 181 182 HepLorentzVector operator* ( const HepLorent 182 HepLorentzVector operator* ( const HepLorentzVector & w ) const ; 183 HepLorentzVector operator()( const HepLorent 183 HepLorentzVector operator()( const HepLorentzVector & w ) const ; 184 // Apply to a 4-vector 184 // Apply to a 4-vector 185 185 186 // ---------- I/O: 186 // ---------- I/O: 187 187 188 std::ostream & print( std::ostream & os ) co 188 std::ostream & print( std::ostream & os ) const; 189 189 190 #endif /* ONLY_IN_CONCRETE_CLASSES */ 190 #endif /* ONLY_IN_CONCRETE_CLASSES */ 191 191 192 static double getTolerance(); 192 static double getTolerance(); 193 static double setTolerance( double tol ); 193 static double setTolerance( double tol ); 194 194 195 static const int ToleranceTicks = 100; << 195 enum { ToleranceTicks = 100 }; 196 196 197 protected: 197 protected: 198 198 199 ~Hep4RotationInterface() {} // protect destr 199 ~Hep4RotationInterface() {} // protect destructor to forbid instatiation 200 200 201 }; // Hep4RotationInterface 201 }; // Hep4RotationInterface 202 202 203 203 204 //-****************************** 204 //-****************************** 205 // 205 // 206 // Hep3RotationInterface 206 // Hep3RotationInterface 207 // 207 // 208 //-****************************** 208 //-****************************** 209 209 210 /** 210 /** 211 * @author 211 * @author 212 * @ingroup vector 212 * @ingroup vector 213 */ 213 */ 214 class Hep3RotationInterface : public Hep4Rotat 214 class Hep3RotationInterface : public Hep4RotationInterface { 215 215 216 // All attributes of HepRotation, HepRotatio 216 // All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ 217 // beyond those available by virtue of being 217 // beyond those available by virtue of being a Hep3RotationInterface. 218 218 219 friend class HepRotation; 219 friend class HepRotation; 220 friend class HepRotationX; 220 friend class HepRotationX; 221 friend class HepRotationY; 221 friend class HepRotationY; 222 friend class HepRotationZ; 222 friend class HepRotationZ; 223 223 224 public: 224 public: 225 225 226 #ifdef ONLY_IN_CONCRETE_CLASSES 226 #ifdef ONLY_IN_CONCRETE_CLASSES 227 227 228 // Euler angles: 228 // Euler angles: 229 double getPhi () const ; 229 double getPhi () const ; 230 double getTheta() const ; 230 double getTheta() const ; 231 double getPsi () const ; 231 double getPsi () const ; 232 double phi () const ; 232 double phi () const ; 233 double theta() const ; 233 double theta() const ; 234 double psi () const ; 234 double psi () const ; 235 HepEulerAngles eulerAngles() const ; 235 HepEulerAngles eulerAngles() const ; 236 236 237 // axis & angle of rotation: 237 // axis & angle of rotation: 238 double getDelta() const ; 238 double getDelta() const ; 239 Hep3Vector getAxis () const ; 239 Hep3Vector getAxis () const ; 240 double delta() const ; 240 double delta() const ; 241 Hep3Vector axis () const ; 241 Hep3Vector axis () const ; 242 HepAxisAngle axisAngle() const ; 242 HepAxisAngle axisAngle() const ; 243 243 244 // orthogonal unit-length vectors: 244 // orthogonal unit-length vectors: 245 Hep3Vector rowX() const; 245 Hep3Vector rowX() const; 246 Hep3Vector rowY() const; 246 Hep3Vector rowY() const; 247 Hep3Vector rowZ() const; 247 Hep3Vector rowZ() const; 248 248 249 Hep3Vector colX() const; 249 Hep3Vector colX() const; 250 Hep3Vector colY() const; 250 Hep3Vector colY() const; 251 Hep3Vector colZ() const; 251 Hep3Vector colZ() const; 252 252 253 //HepRep3x3 rep3x3() const; JMM Declared here 253 //HepRep3x3 rep3x3() const; JMM Declared here but not defined anywhere! 254 // 3x3 representation 254 // 3x3 representation 255 255 256 // orthosymplectic 4-vectors treating this 256 // orthosymplectic 4-vectors treating this as a 4-rotation: 257 HepLorentzVector col1() const; 257 HepLorentzVector col1() const; 258 HepLorentzVector col2() const; 258 HepLorentzVector col2() const; 259 HepLorentzVector col3() const; 259 HepLorentzVector col3() const; 260 HepLorentzVector col4() const; 260 HepLorentzVector col4() const; 261 HepLorentzVector row1() const; 261 HepLorentzVector row1() const; 262 HepLorentzVector row2() const; 262 HepLorentzVector row2() const; 263 HepLorentzVector row3() const; 263 HepLorentzVector row3() const; 264 HepLorentzVector row4() const; 264 HepLorentzVector row4() const; 265 265 266 // individual elements treating this as a 4 266 // individual elements treating this as a 4-rotation: 267 double xt() const; 267 double xt() const; 268 double yt() const; 268 double yt() const; 269 double zt() const; 269 double zt() const; 270 double tx() const; 270 double tx() const; 271 double ty() const; 271 double ty() const; 272 double tz() const; 272 double tz() const; 273 double tt() const; 273 double tt() const; 274 274 275 // ---------- Operations in the Rotation gro 275 // ---------- Operations in the Rotation group 276 276 277 HepRotation operator * ( const Hep3RotationI 277 HepRotation operator * ( const Hep3RotationInterface & r ) const ; 278 278 279 // ---------- Application 279 // ---------- Application 280 280 281 HepLorentzVector operator* ( const HepLorent 281 HepLorentzVector operator* ( const HepLorentzVector & w ) const ; 282 HepLorentzVector operator()( const HepLorent 282 HepLorentzVector operator()( const HepLorentzVector & w ) const ; 283 // apply to HepLorentzVector 283 // apply to HepLorentzVector 284 284 285 Hep3Vector operator* ( const Hep3Vector & v 285 Hep3Vector operator* ( const Hep3Vector & v ) const ; 286 Hep3Vector operator()( const Hep3Vector & v 286 Hep3Vector operator()( const Hep3Vector & v ) const ; 287 // apply to Hep3Vector 287 // apply to Hep3Vector 288 288 289 // ---------- I/O and a helper method 289 // ---------- I/O and a helper method 290 290 291 std::ostream & print( std::ostream & os ) co 291 std::ostream & print( std::ostream & os ) const; 292 292 293 #endif /* ONLY_IN_CONCRETE_CLASSES */ 293 #endif /* ONLY_IN_CONCRETE_CLASSES */ 294 294 295 private: 295 private: 296 296 297 ~Hep3RotationInterface() {} // private destr 297 ~Hep3RotationInterface() {} // private destructor to forbid instatiation 298 298 299 }; // Hep3RotationInterface 299 }; // Hep3RotationInterface 300 300 301 //-*************************** 301 //-*************************** 302 // 3x3 and 4x4 representations 302 // 3x3 and 4x4 representations 303 //-*************************** 303 //-*************************** 304 304 305 struct HepRep3x3 { 305 struct HepRep3x3 { 306 306 307 // ----- Constructors: 307 // ----- Constructors: 308 308 309 inline HepRep3x3(); 309 inline HepRep3x3(); 310 310 311 inline HepRep3x3( double xx, double xy, dou 311 inline HepRep3x3( double xx, double xy, double xz 312 , double yx, double yy, dou 312 , double yx, double yy, double yz 313 , double zx, double zy, dou 313 , double zx, double zy, double zz 314 ); 314 ); 315 315 316 inline HepRep3x3( const double * array ); 316 inline HepRep3x3( const double * array ); 317 // construct from an array of doubles, holdi 317 // construct from an array of doubles, holding the rotation matrix 318 // in ROW order (xx, xy, ...) 318 // in ROW order (xx, xy, ...) 319 319 320 inline void setToIdentity(); 320 inline void setToIdentity(); 321 321 322 // ----- The data members are public: 322 // ----- The data members are public: 323 double xx_, xy_, xz_, 323 double xx_, xy_, xz_, 324 yx_, yy_, yz_, 324 yx_, yy_, yz_, 325 zx_, zy_, zz_; 325 zx_, zy_, zz_; 326 326 327 inline void getArray ( double * array ) cons 327 inline void getArray ( double * array ) const; 328 // fill array with the NINE doubles xx, xy, 328 // fill array with the NINE doubles xx, xy, xz ... zz 329 329 330 }; // HepRep3x3 330 }; // HepRep3x3 331 331 332 struct HepRep4x4 { 332 struct HepRep4x4 { 333 333 334 // ----- Constructors: 334 // ----- Constructors: 335 inline HepRep4x4(); 335 inline HepRep4x4(); 336 336 337 inline HepRep4x4( double xx, double xy, dou 337 inline HepRep4x4( double xx, double xy, double xz, double xt 338 , double yx, double yy, dou 338 , double yx, double yy, double yz, double yt 339 , double zx, double zy, dou 339 , double zx, double zy, double zz, double zt 340 , double tx, double ty, dou 340 , double tx, double ty, double tz, double tt 341 ); 341 ); 342 342 343 inline HepRep4x4( const HepRep4x4Symmetric & 343 inline HepRep4x4( const HepRep4x4Symmetric & rep ); 344 344 345 inline HepRep4x4( const double * array ); 345 inline HepRep4x4( const double * array ); 346 // construct from an array of doubles, holdi 346 // construct from an array of doubles, holding the transformation matrix 347 // in ROW order xx, xy, ... 347 // in ROW order xx, xy, ... 348 348 349 inline void setToIdentity(); 349 inline void setToIdentity(); 350 350 351 // ----- The data members are public: 351 // ----- The data members are public: 352 double xx_, xy_, xz_, xt_, 352 double xx_, xy_, xz_, xt_, 353 yx_, yy_, yz_, yt_, 353 yx_, yy_, yz_, yt_, 354 zx_, zy_, zz_, zt_, 354 zx_, zy_, zz_, zt_, 355 tx_, ty_, tz_, tt_; 355 tx_, ty_, tz_, tt_; 356 356 357 inline void getArray ( double * array ) cons 357 inline void getArray ( double * array ) const; 358 // fill array with the SIXTEEN doubles xx, x 358 // fill array with the SIXTEEN doubles xx, xy, xz ... tz, tt 359 359 360 inline bool operator==(HepRep4x4 const & r) 360 inline bool operator==(HepRep4x4 const & r) const; 361 inline bool operator!=(HepRep4x4 const & r) 361 inline bool operator!=(HepRep4x4 const & r) const; 362 362 363 363 364 }; // HepRep4x4 364 }; // HepRep4x4 365 365 366 struct HepRep4x4Symmetric { 366 struct HepRep4x4Symmetric { 367 367 368 // ----- Constructors: 368 // ----- Constructors: 369 369 370 inline HepRep4x4Symmetric(); 370 inline HepRep4x4Symmetric(); 371 371 372 inline HepRep4x4Symmetric 372 inline HepRep4x4Symmetric 373 ( double xx, double xy, double xz, double xt 373 ( double xx, double xy, double xz, double xt 374 , double yy, double yz, 374 , double yy, double yz, double yt 375 , double z 375 , double zz, double zt 376 376 , double tt ); 377 377 378 inline HepRep4x4Symmetric( const double * ar 378 inline HepRep4x4Symmetric( const double * array ); 379 // construct from an array of doubles, holdi 379 // construct from an array of doubles, holding the transformation matrix 380 // elements in this order: xx, xy, xz, xt, 380 // elements in this order: xx, xy, xz, xt, yy, yz, yt, zz, zt, tt 381 381 382 inline void setToIdentity(); 382 inline void setToIdentity(); 383 383 384 // ----- The data members are public: 384 // ----- The data members are public: 385 double xx_, xy_, xz_, xt_, 385 double xx_, xy_, xz_, xt_, 386 yy_, yz_, yt_, 386 yy_, yz_, yt_, 387 zz_, zt_, 387 zz_, zt_, 388 tt_; 388 tt_; 389 389 390 inline void getArray ( double * array ) cons 390 inline void getArray ( double * array ) const; 391 // fill array with the TEN doubles xx, xy, x 391 // fill array with the TEN doubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt 392 392 393 }; 393 }; 394 394 395 } // namespace CLHEP 395 } // namespace CLHEP 396 396 397 #include "CLHEP/Vector/RotationInterfaces.icc" 397 #include "CLHEP/Vector/RotationInterfaces.icc" 398 398 399 #endif // ROTATION_INTERFACES_H 399 #endif // ROTATION_INTERFACES_H 400 400