CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 #ifndef HEP_ZMXPV_H 00002 #define HEP_ZMXPV_H 00003 00004 // ---------------------------------------------------------------------- 00005 // 00006 // ZMxpv.h ZMexception's ZMthrown by classes in the PhysicsVectors 00007 // package. To avoid name clashes, these start with ZMxpv. 00008 // 00009 // THIS FILE CONTAINS TWO VERSIONS OF THE NECESSARY CODE: 00010 // 00011 // With no special defines, this file will produce code for pure CLHEP 00012 // building -- no ZOOM Exceptions are involved. 00013 // 00014 // To force a build using ZOOM Exceptions where the ZMthrow macros appear, 00015 // compile with ENABLE_ZOOM_EXCEPTIONS defined. 00016 // 00017 // ---------------------------------------------------------------------- 00018 00019 //#undef ENABLE_ZOOM_EXCEPTIONS // For CLHEP builds 00020 //#define ENABLE_ZOOM_EXCEPTIONS // For ZOOM builds 00021 00022 // There should be some external way to control this. We haven't found it yet. 00023 // Right now, this must be changed by hand when going between CLHEP and ZOOM. 00024 #undef ENABLE_ZOOM_EXCEPTIONS 00025 00026 // Member functions of the Vector classes are capable of ZMthrow-ing the 00027 // following ZMexception's: 00028 // 00029 // ZMxPhysicsVectors Severe Parent exception of all ZMexceptions 00030 // particular to classes in the package. 00031 // 00032 // ZMxpvInfiniteVector Error 00033 // Mathematical operation will lead 00034 // to infinity or NAN in a component 00035 // of a result vector. 00036 // ZMxpvZeroVector Error 00037 // A zero vector was used to specify 00038 // a direction based on vector.unit(). 00039 // ZMxpvTachyonic Error 00040 // A relativistic kinematic function was 00041 // taken, involving a vector representing 00042 // a speed at or beyond that of light (=1). 00043 // ZMxpvSpacelike Error 00044 // A spacelike 4-vector was used in a 00045 // context where its restMass or gamma 00046 // needs to be computed: The result is 00047 // formally imaginary (a zero result is 00048 // supplied). 00049 // ZMxpvInfinity Error 00050 // Mathematical operation will lead 00051 // to infinity as a Scalar result. 00052 // ZMxpvNegativeMass Error 00053 // Kinematic operation, e.g. invariant 00054 // mass, rendered meaningless by an input 00055 // with negative time component. 00056 // ZMxpvVectorInputFails Error 00057 // Input to a SpaceVector or Lorentz 00058 // Vector failed due to bad format or EOF. 00059 // ZMxpvParallelCols Error 00060 // Purportedly orthogonal col's supplied 00061 // to form a Rotation are exactly 00062 // parallel instead. 00063 // ZMxpvImproperRotation Error 00064 // Orthogonal col's supplied form a 00065 // refection (determinant -1) more 00066 // nearly than rather than a rotation. 00067 // ZMxpvImproperTransformation Error 00068 // Orthogonalized rows supplied form a 00069 // tachyonic boost, a reflection, or 00070 // a combination of those flaws, 00071 // more nearly than a proper Lorentz 00072 // transformation. 00073 // ZMxpvFixedAxis Error 00074 // Attempt to change a RotationX, 00075 // RotationY, or RotationZ in such a way 00076 // that the axis might no longer be X, 00077 // Y, or Z respectively. 00078 // ZMxpvIndexRange Error 00079 // When using the syntax of v(i) to get 00080 // a vector component, i is out of range. 00081 // ZMxpvNotOrthogonal Warning 00082 // Purportedly orthogonal col's supplied 00083 // to form a Rotation or LT are not 00084 // orthogonal within the tolerance. 00085 // ZMxpvNotSymplectic Warning 00086 // A row supplied to form a Lorentz 00087 // transformation has a value of restmass 00088 // incorrect by more than the tolerance: 00089 // It should be -1 for rows 1-3, 00090 // +1 for row 4. 00091 // ZMxpvAmbiguousAngle Warning 00092 // Method involves taking an angle against 00093 // a reference vector of zero length, or 00094 // phi in polar coordinates of a vector 00095 // along the Z axis. 00096 // ZMxpvNegativeR Warning 00097 // R of a supplied vector is negative. 00098 // The mathematical operation done is 00099 // still formally valid. 00100 // ZMxpvUnusualTheta Warning 00101 // Theta supplied to construct or set 00102 // a vector is outside the range [0,PI]. 00103 // The mathematical operation done is 00104 // still formally valid. But note that 00105 // when sin(theta) < 0, phi becomes an 00106 // angle against the -X axis. 00107 //______________________________________________________________________ 00108 00109 #ifndef ENABLE_ZOOM_EXCEPTIONS 00110 00111 // This is the CLHEP version. When compiled for CLHEP, the basic CLHEP 00112 // Vector classes will not (at least for now) depend on ZOOM Exceptions. 00113 // Though this header lists the various sorts of Exceptions that could be 00114 // thrown, ZMthrow.h in the pure CLHEP context will make ZMthrowC 00115 // do what CLHEP has always done: whine to cerr about the problem 00116 // and continue. 00117 // ZMthrowA will whine to cerr and throw an exception; by catching the 00118 // exception as a std::exception, the outside code can call e.what() to 00119 // find the message string. 00120 // 00121 // If CLHEP ever embraces the ZOOM Exceptions mechanism, we will simply 00122 // modify this file. 00123 00124 #include <string> 00125 #include <exception> 00126 00127 #define ZMthrowA(A) do { std::cerr << A.name() << " thrown:\n" \ 00128 << A.what() << "\n" \ 00129 << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \ 00130 throw A;} while (0) 00131 00132 #define ZMthrowC(A) do { std::cerr << A.name() << ":\n" \ 00133 << A.what() << "\n" \ 00134 << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \ 00135 } while (0) 00136 00137 class CLHEP_vector_exception : public std::exception { 00138 public: 00139 CLHEP_vector_exception ( const std::string & s ) throw(); 00140 virtual const char* what() const throw(); 00141 virtual const char* name() const throw() = 0; 00142 virtual ~CLHEP_vector_exception() throw() {} 00143 private: 00144 std::string message; 00145 }; 00146 00147 #define CLHEP_vector_exception_header(NAME) \ 00148 class NAME : public CLHEP_vector_exception { \ 00149 public: \ 00150 NAME ( const std::string & s ) throw(); \ 00151 virtual const char* name() const throw(); \ 00152 virtual ~NAME() throw() {} \ 00153 }; 00154 00155 00156 // The following exceptions might be encountered via ZMtrhowA 00157 00158 CLHEP_vector_exception_header( ZMxPhysicsVectors ) 00159 CLHEP_vector_exception_header( ZMxpvSpacelike ) 00160 CLHEP_vector_exception_header( ZMxpvNegativeMass ) 00161 CLHEP_vector_exception_header( ZMxpvVectorInputFails ) 00162 CLHEP_vector_exception_header( ZMxpvIndexRange ) 00163 CLHEP_vector_exception_header( ZMxpvFixedAxis ) 00164 00165 // The following are sometimes ZMthrowA and sometimes ZMthrowC 00166 00167 CLHEP_vector_exception_header( ZMxpvTachyonic ) 00168 CLHEP_vector_exception_header( ZMxpvZeroVector ) 00169 CLHEP_vector_exception_header( ZMxpvImproperTransformation ) 00170 CLHEP_vector_exception_header( ZMxpvInfiniteVector ) 00171 CLHEP_vector_exception_header( ZMxpvInfinity ) 00172 CLHEP_vector_exception_header( ZMxpvImproperRotation ) 00173 CLHEP_vector_exception_header( ZMxpvAmbiguousAngle ) 00174 00175 // THe following won't throw; they are encountered via ZMthrowC 00176 00177 CLHEP_vector_exception_header( ZMxpvNegativeR ) 00178 CLHEP_vector_exception_header( ZMxpvUnusualTheta ) 00179 CLHEP_vector_exception_header( ZMxpvParallelCols ) 00180 CLHEP_vector_exception_header( ZMxpvNotOrthogonal ) 00181 CLHEP_vector_exception_header( ZMxpvNotSymplectic ) 00182 00183 #endif // endif for ifndef ENABLE_ZOOM_EXCEPTIONS 00184 00185 // ============================================================= 00186 // ============================================================= 00187 // ============================================================= 00188 00189 #ifdef ENABLE_ZOOM_EXCEPTIONS 00190 00191 // This is the ZOOM version. When compiled for ZOOM, even the basic CLHEP 00192 // Vector classes will depend on ZOOM Exceptions. 00193 // Though in the CLHEP context methods use ZMthrowA and ZMthrowC, these 00194 // in the ZOOM context become ZMthrow. 00195 // 00196 // Either this file or ZMxpvCLHEP.h is copied to become ZMxpv.h, depending 00197 // on whether this is a ZOOM or a CLHEP build. 00198 // 00199 00200 #ifndef ZMEXCEPTIONS_H 00201 #include "Exceptions/ZMexception.h" 00202 #include "Exceptions/ZMthrow.h" 00203 #endif 00204 using namespace zmex; 00205 00206 namespace zmpv { 00207 00208 ZMexStandardDefinition (ZMexception, ZMxPhysicsVectors); 00209 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfiniteVector); 00210 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvZeroVector); 00211 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvTachyonic); 00212 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvSpacelike); 00213 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfinity); 00214 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeMass); 00215 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvAmbiguousAngle); 00216 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeR); 00217 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvUnusualTheta); 00218 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvVectorInputFails); 00219 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvParallelCols); 00220 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperRotation); 00221 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperTransformation); 00222 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvIndexRange); 00223 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotOrthogonal); 00224 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotSymplectic); 00225 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvFixedAxis); 00226 00227 #define ZMthrowA(A) ZMthrow(A) 00228 #define ZMthrowC(A) ZMthrow(A) 00229 00230 } // namespace zmpv 00231 00232 #endif // ENABLE_ZOOM_EXCEPTIONS 00233 00234 #endif // HEP_ZMXPV_H