1 | #ifndef HEP_ZMXPV_H
|
---|
2 | #define HEP_ZMXPV_H
|
---|
3 |
|
---|
4 | // ----------------------------------------------------------------------
|
---|
5 | //
|
---|
6 | // ZMxpv.h ZMexception's ZMthrown by classes in the PhysicsVectors
|
---|
7 | // package. To avoid name clashes, these start with ZMxpv.
|
---|
8 | //
|
---|
9 | // THIS FILE CONTAINS TWO VERSIONS OF THE NECESSARY CODE:
|
---|
10 | //
|
---|
11 | // With no special defines, this file will produce code for pure CLHEP
|
---|
12 | // building -- no ZOOM Exceptions are involved.
|
---|
13 | //
|
---|
14 | // To force a build using ZOOM Exceptions where the ZMthrow macros appear,
|
---|
15 | // compile with ENABLE_ZOOM_EXCEPTIONS defined.
|
---|
16 | //
|
---|
17 | // ----------------------------------------------------------------------
|
---|
18 |
|
---|
19 | //#undef ENABLE_ZOOM_EXCEPTIONS // For CLHEP builds
|
---|
20 | //#define ENABLE_ZOOM_EXCEPTIONS // For ZOOM builds
|
---|
21 |
|
---|
22 | // There should be some external way to control this. We haven't found it yet.
|
---|
23 | // Right now, this must be changed by hand when going between CLHEP and ZOOM.
|
---|
24 | #undef ENABLE_ZOOM_EXCEPTIONS
|
---|
25 |
|
---|
26 | // Member functions of the Vector classes are capable of ZMthrow-ing the
|
---|
27 | // following ZMexception's:
|
---|
28 | //
|
---|
29 | // ZMxPhysicsVectors Severe Parent exception of all ZMexceptions
|
---|
30 | // particular to classes in the package.
|
---|
31 | //
|
---|
32 | // ZMxpvInfiniteVector Error
|
---|
33 | // Mathematical operation will lead
|
---|
34 | // to infinity or NAN in a component
|
---|
35 | // of a result vector.
|
---|
36 | // ZMxpvZeroVector Error
|
---|
37 | // A zero vector was used to specify
|
---|
38 | // a direction based on vector.unit().
|
---|
39 | // ZMxpvTachyonic Error
|
---|
40 | // A relativistic kinematic function was
|
---|
41 | // taken, involving a vector representing
|
---|
42 | // a speed at or beyond that of light (=1).
|
---|
43 | // ZMxpvSpacelike Error
|
---|
44 | // A spacelike 4-vector was used in a
|
---|
45 | // context where its restMass or gamma
|
---|
46 | // needs to be computed: The result is
|
---|
47 | // formally imaginary (a zero result is
|
---|
48 | // supplied).
|
---|
49 | // ZMxpvInfinity Error
|
---|
50 | // Mathematical operation will lead
|
---|
51 | // to infinity as a Scalar result.
|
---|
52 | // ZMxpvNegativeMass Error
|
---|
53 | // Kinematic operation, e.g. invariant
|
---|
54 | // mass, rendered meaningless by an input
|
---|
55 | // with negative time component.
|
---|
56 | // ZMxpvVectorInputFails Error
|
---|
57 | // Input to a SpaceVector or Lorentz
|
---|
58 | // Vector failed due to bad format or EOF.
|
---|
59 | // ZMxpvParallelCols Error
|
---|
60 | // Purportedly orthogonal col's supplied
|
---|
61 | // to form a Rotation are exactly
|
---|
62 | // parallel instead.
|
---|
63 | // ZMxpvImproperRotation Error
|
---|
64 | // Orthogonal col's supplied form a
|
---|
65 | // refection (determinant -1) more
|
---|
66 | // nearly than rather than a rotation.
|
---|
67 | // ZMxpvImproperTransformation Error
|
---|
68 | // Orthogonalized rows supplied form a
|
---|
69 | // tachyonic boost, a reflection, or
|
---|
70 | // a combination of those flaws,
|
---|
71 | // more nearly than a proper Lorentz
|
---|
72 | // transformation.
|
---|
73 | // ZMxpvFixedAxis Error
|
---|
74 | // Attempt to change a RotationX,
|
---|
75 | // RotationY, or RotationZ in such a way
|
---|
76 | // that the axis might no longer be X,
|
---|
77 | // Y, or Z respectively.
|
---|
78 | // ZMxpvIndexRange Error
|
---|
79 | // When using the syntax of v(i) to get
|
---|
80 | // a vector component, i is out of range.
|
---|
81 | // ZMxpvNotOrthogonal Warning
|
---|
82 | // Purportedly orthogonal col's supplied
|
---|
83 | // to form a Rotation or LT are not
|
---|
84 | // orthogonal within the tolerance.
|
---|
85 | // ZMxpvNotSymplectic Warning
|
---|
86 | // A row supplied to form a Lorentz
|
---|
87 | // transformation has a value of restmass
|
---|
88 | // incorrect by more than the tolerance:
|
---|
89 | // It should be -1 for rows 1-3,
|
---|
90 | // +1 for row 4.
|
---|
91 | // ZMxpvAmbiguousAngle Warning
|
---|
92 | // Method involves taking an angle against
|
---|
93 | // a reference vector of zero length, or
|
---|
94 | // phi in polar coordinates of a vector
|
---|
95 | // along the Z axis.
|
---|
96 | // ZMxpvNegativeR Warning
|
---|
97 | // R of a supplied vector is negative.
|
---|
98 | // The mathematical operation done is
|
---|
99 | // still formally valid.
|
---|
100 | // ZMxpvUnusualTheta Warning
|
---|
101 | // Theta supplied to construct or set
|
---|
102 | // a vector is outside the range [0,PI].
|
---|
103 | // The mathematical operation done is
|
---|
104 | // still formally valid. But note that
|
---|
105 | // when sin(theta) < 0, phi becomes an
|
---|
106 | // angle against the -X axis.
|
---|
107 | //______________________________________________________________________
|
---|
108 |
|
---|
109 | #ifndef ENABLE_ZOOM_EXCEPTIONS
|
---|
110 |
|
---|
111 | // This is the CLHEP version. When compiled for CLHEP, the basic CLHEP
|
---|
112 | // Vector classes will not (at least for now) depend on ZOOM Exceptions.
|
---|
113 | // Though this header lists the various sorts of Exceptions that could be
|
---|
114 | // thrown, ZMthrow.h in the pure CLHEP context will make ZMthrowC
|
---|
115 | // do what CLHEP has always done: whine to cerr about the problem
|
---|
116 | // and continue.
|
---|
117 | // ZMthrowA will whine to cerr and throw an exception; by catching the
|
---|
118 | // exception as a std::exception, the outside code can call e.what() to
|
---|
119 | // find the message string.
|
---|
120 | //
|
---|
121 | // If CLHEP ever embraces the ZOOM Exceptions mechanism, we will simply
|
---|
122 | // modify this file.
|
---|
123 |
|
---|
124 | #include <string>
|
---|
125 | #include <exception>
|
---|
126 |
|
---|
127 | #define ZMthrowA(A) do { std::cerr << A.name() << " thrown:\n" \
|
---|
128 | << A.what() << "\n" \
|
---|
129 | << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
|
---|
130 | throw A;} while (0)
|
---|
131 |
|
---|
132 | #define ZMthrowC(A) do { std::cerr << A.name() << ":\n" \
|
---|
133 | << A.what() << "\n" \
|
---|
134 | << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
|
---|
135 | } while (0)
|
---|
136 |
|
---|
137 | class CLHEP_vector_exception : public std::exception {
|
---|
138 | public:
|
---|
139 | CLHEP_vector_exception ( const std::string & s ) throw();
|
---|
140 | virtual const char* what() const throw();
|
---|
141 | virtual const char* name() const throw() = 0;
|
---|
142 | virtual ~CLHEP_vector_exception() throw() {}
|
---|
143 | private:
|
---|
144 | std::string message;
|
---|
145 | };
|
---|
146 |
|
---|
147 | #define CLHEP_vector_exception_header(NAME) \
|
---|
148 | class NAME : public CLHEP_vector_exception { \
|
---|
149 | public: \
|
---|
150 | NAME ( const std::string & s ) throw(); \
|
---|
151 | virtual const char* name() const throw(); \
|
---|
152 | virtual ~NAME() throw() {} \
|
---|
153 | };
|
---|
154 |
|
---|
155 |
|
---|
156 | // The following exceptions might be encountered via ZMtrhowA
|
---|
157 |
|
---|
158 | CLHEP_vector_exception_header( ZMxPhysicsVectors )
|
---|
159 | CLHEP_vector_exception_header( ZMxpvSpacelike )
|
---|
160 | CLHEP_vector_exception_header( ZMxpvNegativeMass )
|
---|
161 | CLHEP_vector_exception_header( ZMxpvVectorInputFails )
|
---|
162 | CLHEP_vector_exception_header( ZMxpvIndexRange )
|
---|
163 | CLHEP_vector_exception_header( ZMxpvFixedAxis )
|
---|
164 |
|
---|
165 | // The following are sometimes ZMthrowA and sometimes ZMthrowC
|
---|
166 |
|
---|
167 | CLHEP_vector_exception_header( ZMxpvTachyonic )
|
---|
168 | CLHEP_vector_exception_header( ZMxpvZeroVector )
|
---|
169 | CLHEP_vector_exception_header( ZMxpvImproperTransformation )
|
---|
170 | CLHEP_vector_exception_header( ZMxpvInfiniteVector )
|
---|
171 | CLHEP_vector_exception_header( ZMxpvInfinity )
|
---|
172 | CLHEP_vector_exception_header( ZMxpvImproperRotation )
|
---|
173 | CLHEP_vector_exception_header( ZMxpvAmbiguousAngle )
|
---|
174 |
|
---|
175 | // THe following won't throw; they are encountered via ZMthrowC
|
---|
176 |
|
---|
177 | CLHEP_vector_exception_header( ZMxpvNegativeR )
|
---|
178 | CLHEP_vector_exception_header( ZMxpvUnusualTheta )
|
---|
179 | CLHEP_vector_exception_header( ZMxpvParallelCols )
|
---|
180 | CLHEP_vector_exception_header( ZMxpvNotOrthogonal )
|
---|
181 | CLHEP_vector_exception_header( ZMxpvNotSymplectic )
|
---|
182 |
|
---|
183 | #endif // endif for ifndef ENABLE_ZOOM_EXCEPTIONS
|
---|
184 |
|
---|
185 | // =============================================================
|
---|
186 | // =============================================================
|
---|
187 | // =============================================================
|
---|
188 |
|
---|
189 | #ifdef ENABLE_ZOOM_EXCEPTIONS
|
---|
190 |
|
---|
191 | // This is the ZOOM version. When compiled for ZOOM, even the basic CLHEP
|
---|
192 | // Vector classes will depend on ZOOM Exceptions.
|
---|
193 | // Though in the CLHEP context methods use ZMthrowA and ZMthrowC, these
|
---|
194 | // in the ZOOM context become ZMthrow.
|
---|
195 | //
|
---|
196 | // Either this file or ZMxpvCLHEP.h is copied to become ZMxpv.h, depending
|
---|
197 | // on whether this is a ZOOM or a CLHEP build.
|
---|
198 | //
|
---|
199 |
|
---|
200 | #ifndef ZMEXCEPTIONS_H
|
---|
201 | #include "Exceptions/ZMexception.h"
|
---|
202 | #include "Exceptions/ZMthrow.h"
|
---|
203 | #endif
|
---|
204 | using namespace zmex;
|
---|
205 |
|
---|
206 | namespace zmpv {
|
---|
207 |
|
---|
208 | ZMexStandardDefinition (ZMexception, ZMxPhysicsVectors);
|
---|
209 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfiniteVector);
|
---|
210 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvZeroVector);
|
---|
211 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvTachyonic);
|
---|
212 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvSpacelike);
|
---|
213 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfinity);
|
---|
214 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeMass);
|
---|
215 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvAmbiguousAngle);
|
---|
216 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeR);
|
---|
217 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvUnusualTheta);
|
---|
218 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvVectorInputFails);
|
---|
219 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvParallelCols);
|
---|
220 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperRotation);
|
---|
221 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperTransformation);
|
---|
222 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvIndexRange);
|
---|
223 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotOrthogonal);
|
---|
224 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotSymplectic);
|
---|
225 | ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvFixedAxis);
|
---|
226 |
|
---|
227 | #define ZMthrowA(A) ZMthrow(A)
|
---|
228 | #define ZMthrowC(A) ZMthrow(A)
|
---|
229 |
|
---|
230 | } // namespace zmpv
|
---|
231 |
|
---|
232 | #endif // ENABLE_ZOOM_EXCEPTIONS
|
---|
233 |
|
---|
234 | #endif // HEP_ZMXPV_H
|
---|