CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
ZMxpv.h
Go to the documentation of this file.
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 <exception>
125#include <iostream> // for std::cerr
126#include <string>
127
128#define ZMthrowA(A) do { std::cerr << A.name() << " thrown:\n" \
129 << A.what() << "\n" \
130 << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
131 throw A;} while (0)
132
133#define ZMthrowC(A) do { std::cerr << A.name() << ":\n" \
134 << A.what() << "\n" \
135 << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
136 } while (0)
137
138class CLHEP_vector_exception : public std::exception {
139public:
140 CLHEP_vector_exception ( const std::string & s1 ) throw();
141 virtual const char* what() const throw();
142 virtual const char* name() const throw() = 0;
143 virtual ~CLHEP_vector_exception() throw() {}
144 private:
145 std::string message;
146};
147
148#define CLHEP_vector_exception_header(NAME) \
149 class NAME : public CLHEP_vector_exception { \
150 public: \
151 NAME ( const std::string & s ) throw(); \
152 virtual const char* name() const throw(); \
153 virtual ~NAME() throw() {} \
154 };
155
156
157// The following exceptions might be encountered via ZMtrhowA
158
159CLHEP_vector_exception_header( ZMxPhysicsVectors )
160CLHEP_vector_exception_header( ZMxpvSpacelike )
161CLHEP_vector_exception_header( ZMxpvNegativeMass )
162CLHEP_vector_exception_header( ZMxpvVectorInputFails )
163CLHEP_vector_exception_header( ZMxpvIndexRange )
164CLHEP_vector_exception_header( ZMxpvFixedAxis )
165
166// The following are sometimes ZMthrowA and sometimes ZMthrowC
167
168CLHEP_vector_exception_header( ZMxpvTachyonic )
169CLHEP_vector_exception_header( ZMxpvZeroVector )
170CLHEP_vector_exception_header( ZMxpvImproperTransformation )
171CLHEP_vector_exception_header( ZMxpvInfiniteVector )
172CLHEP_vector_exception_header( ZMxpvInfinity )
173CLHEP_vector_exception_header( ZMxpvImproperRotation )
174CLHEP_vector_exception_header( ZMxpvAmbiguousAngle )
175
176// THe following won't throw; they are encountered via ZMthrowC
177
178CLHEP_vector_exception_header( ZMxpvNegativeR )
179CLHEP_vector_exception_header( ZMxpvUnusualTheta )
180CLHEP_vector_exception_header( ZMxpvParallelCols )
181CLHEP_vector_exception_header( ZMxpvNotOrthogonal )
182CLHEP_vector_exception_header( ZMxpvNotSymplectic )
183
184#endif // endif for ifndef ENABLE_ZOOM_EXCEPTIONS
185
186// =============================================================
187// =============================================================
188// =============================================================
189
190#ifdef ENABLE_ZOOM_EXCEPTIONS
191
192// This is the ZOOM version. When compiled for ZOOM, even the basic CLHEP
193// Vector classes will depend on ZOOM Exceptions.
194// Though in the CLHEP context methods use ZMthrowA and ZMthrowC, these
195// in the ZOOM context become ZMthrow.
196//
197// Either this file or ZMxpvCLHEP.h is copied to become ZMxpv.h, depending
198// on whether this is a ZOOM or a CLHEP build.
199//
200
201#ifndef ZMEXCEPTIONS_H
202 #include "Exceptions/ZMexception.h"
203 #include "Exceptions/ZMthrow.h"
204#endif
205using namespace zmex;
206
207namespace zmpv {
208
209ZMexStandardDefinition (ZMexception, ZMxPhysicsVectors);
210ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfiniteVector);
211ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvZeroVector);
212ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvTachyonic);
213ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvSpacelike);
214ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfinity);
215ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeMass);
216ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvAmbiguousAngle);
217ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeR);
218ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvUnusualTheta);
219ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvVectorInputFails);
220ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvParallelCols);
221ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperRotation);
222ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperTransformation);
223ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvIndexRange);
224ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotOrthogonal);
225ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotSymplectic);
226ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvFixedAxis);
227
228#define ZMthrowA(A) ZMthrow(A)
229#define ZMthrowC(A) ZMthrow(A)
230
231} // namespace zmpv
232
233#endif // ENABLE_ZOOM_EXCEPTIONS
234
235#endif // HEP_ZMXPV_H
#define ZMexStandardDefinition(Parent, Class)
Definition: ZMexception.h:523
#define CLHEP_vector_exception_header(NAME)
Definition: ZMxpv.h:148
virtual const char * what() const
Definition: ZMxpv.cc:32
virtual const char * name() const =0
Definition: ZMerrno.h:52