Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:42

0001 #ifndef HEP_ZMXPV_H
0002 #define HEP_ZMXPV_H
0003 
0004 // ----------------------------------------------------------------------
0005 //
0006 //  ZMxpv.h     ZMexception's ZMthrown by classes in the PhysicsVectors
0007 //      package.  To avoid name clashes, these start with ZMxpv.
0008 //
0009 //  THIS FILE CONTAINS TWO VERSIONS OF THE NECESSARY CODE:
0010 //
0011 //  With no special defines, this file will produce code for pure CLHEP 
0012 //  building -- no ZOOM Exceptions are involved.
0013 //
0014 //  To force a build using ZOOM Exceptions where the ZMthrow macros appear,
0015 //  compile with ENABLE_ZOOM_EXCEPTIONS defined.
0016 //
0017 // ----------------------------------------------------------------------
0018 
0019 //#undef  ENABLE_ZOOM_EXCEPTIONS    // For CLHEP builds 
0020 //#define ENABLE_ZOOM_EXCEPTIONS        // For ZOOM  builds
0021 
0022 // There should be some external way to control this.  We haven't found it yet.
0023 // Right now, this must be changed by hand when going between CLHEP and ZOOM.
0024 #undef  ENABLE_ZOOM_EXCEPTIONS  
0025 
0026   // Member functions of the Vector classes are capable of ZMthrow-ing the
0027   // following ZMexception's:
0028   //
0029   //    ZMxPhysicsVectors   Severe  Parent exception of all ZMexceptions
0030   //                    particular to classes in the package.
0031   //
0032   //    ZMxpvInfiniteVector     Error
0033   //                                    Mathematical operation will lead
0034   //                                    to infinity or NAN in a component
0035   //                                    of a result vector.
0036   //    ZMxpvZeroVector         Error
0037   //                                    A zero vector was used to specify
0038   //                                    a direction based on vector.unit().
0039   //    ZMxpvTachyonic          Error
0040   //                                    A relativistic kinematic function was
0041   //                                    taken, involving a vector representing
0042   //                                    a speed at or beyond that of light (=1).
0043   //    ZMxpvSpacelike      Error
0044   //                    A spacelike 4-vector was used in a
0045   //                    context where its restMass or gamma
0046   //                    needs to be computed:  The result is
0047   //                    formally imaginary (a zero result is
0048   //                    supplied).
0049   //    ZMxpvInfinity       Error
0050   //                                    Mathematical operation will lead
0051   //                                    to infinity as a Scalar result.
0052   //    ZMxpvNegativeMass   Error
0053   //                                    Kinematic operation, e.g. invariant
0054   //                    mass, rendered meaningless by an input
0055   //                    with negative time component.
0056   //    ZMxpvVectorInputFails   Error
0057   //                    Input to a SpaceVector or Lorentz
0058   //                    Vector failed due to bad format or EOF.
0059   //    ZMxpvParallelCols   Error
0060   //                    Purportedly orthogonal col's supplied
0061   //                    to form a Rotation are exactly
0062   //                    parallel instead.
0063   //    ZMxpvImproperRotation   Error
0064   //                    Orthogonal col's supplied form a
0065   //                    refection (determinant -1) more
0066   //                    nearly than rather than a rotation.
0067   //    ZMxpvImproperTransformation Error
0068   //                                    Orthogonalized rows supplied form a
0069   //                                    tachyonic boost, a reflection, or
0070   //                                    a combination of those flaws,
0071   //                                    more nearly than a proper Lorentz
0072   //                                    transformation.
0073   //    ZMxpvFixedAxis      Error
0074   //                    Attempt to change a RotationX,
0075   //                    RotationY, or RotationZ in such a way
0076   //                    that the axis might no longer be X,
0077   //                    Y, or Z respectively.
0078   //    ZMxpvIndexRange     Error
0079   //                    When using the syntax of v(i) to get
0080   //                    a vector component, i is out of range.
0081   //    ZMxpvNotOrthogonal  Warning
0082   //                    Purportedly orthogonal col's supplied
0083   //                    to form a Rotation or LT are not
0084   //                    orthogonal within the tolerance.
0085   //    ZMxpvNotSymplectic  Warning
0086   //                    A row supplied to form a Lorentz
0087   //                    transformation has a value of restmass
0088   //                    incorrect by more than the tolerance:
0089   //                    It should be -1 for rows 1-3,
0090   //                    +1 for row 4.
0091   //    ZMxpvAmbiguousAngle     Warning
0092   //                                    Method involves taking an angle against
0093   //                                    a reference vector of zero length, or
0094   //                                    phi in polar coordinates of a vector
0095   //                                    along the Z axis.
0096   //    ZMxpvNegativeR          Warning
0097   //                                    R of a supplied vector is negative.
0098   //                                    The mathematical operation done is
0099   //                                    still formally valid.
0100   //    ZMxpvUnusualTheta       Warning
0101   //                                    Theta supplied to construct or set
0102   //                                    a vector is outside the range [0,PI].
0103   //                                    The mathematical operation done is
0104   //                                    still formally valid.  But note that
0105   //                                    when sin(theta) < 0, phi becomes an
0106   //                                    angle against the -X axis.
0107   //______________________________________________________________________
0108 
0109 #ifndef ENABLE_ZOOM_EXCEPTIONS 
0110 
0111 //  This is the CLHEP version.  When compiled for CLHEP, the basic CLHEP 
0112 //  Vector classes will not (at least for now) depend on ZOOM Exceptions.  
0113 //  Though this header lists the various sorts of Exceptions that could be 
0114 //  thrown, ZMthrow.h in the pure CLHEP context will make ZMthrowC  
0115 //  do what CLHEP has always done:  whine to cerr about the problem 
0116 //  and continue.
0117 //  ZMthrowA will whine to cerr and throw an exception; by catching the
0118 //  exception as a std::exception, the outside code can call e.what() to 
0119 //  find the message string.
0120 //
0121 //  If CLHEP ever embraces the ZOOM Exceptions mechanism, we will simply
0122 //  modify this file.
0123 
0124 #include <exception>
0125 #include <iostream> // for std::cerr
0126 #include <string>
0127 
0128 #define ZMthrowA(A) do { std::cerr << A.name() << " thrown:\n"     \
0129              <<   A.what() << "\n"                     \
0130          << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
0131   throw A;} while (0)
0132 
0133 #define ZMthrowC(A) do { std::cerr << A.name() << ":\n"            \
0134              <<   A.what() << "\n"                     \
0135          << "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
0136   } while (0)
0137 
0138 class CLHEP_vector_exception : public std::exception {
0139 public:
0140     CLHEP_vector_exception ( const std::string & s1 ) throw();
0141     virtual const char* what() const throw();
0142     virtual const char* name() const throw() = 0; 
0143     virtual ~CLHEP_vector_exception() throw() {} 
0144   private:                              
0145     std::string message;  
0146 };
0147 
0148 #define CLHEP_vector_exception_header(NAME)                 \
0149   class NAME : public CLHEP_vector_exception {              \
0150   public:                               \
0151     NAME ( const std::string & s ) throw();             \
0152     virtual const char* name() const throw();               \
0153     virtual ~NAME() throw() {}                      \
0154   };
0155 
0156 
0157 // The following exceptions might be encountered via ZMtrhowA
0158 
0159 CLHEP_vector_exception_header( ZMxPhysicsVectors )
0160 CLHEP_vector_exception_header( ZMxpvSpacelike )
0161 CLHEP_vector_exception_header( ZMxpvNegativeMass )
0162 CLHEP_vector_exception_header( ZMxpvVectorInputFails )
0163 CLHEP_vector_exception_header( ZMxpvIndexRange )
0164 CLHEP_vector_exception_header( ZMxpvFixedAxis )
0165 
0166 // The following are sometimes ZMthrowA and sometimes ZMthrowC
0167 
0168 CLHEP_vector_exception_header( ZMxpvTachyonic )
0169 CLHEP_vector_exception_header( ZMxpvZeroVector )
0170 CLHEP_vector_exception_header( ZMxpvImproperTransformation )
0171 CLHEP_vector_exception_header( ZMxpvInfiniteVector )
0172 CLHEP_vector_exception_header( ZMxpvInfinity )
0173 CLHEP_vector_exception_header( ZMxpvImproperRotation )
0174 CLHEP_vector_exception_header( ZMxpvAmbiguousAngle )
0175 
0176 // THe following won't throw; they are encountered via ZMthrowC
0177 
0178 CLHEP_vector_exception_header( ZMxpvNegativeR )
0179 CLHEP_vector_exception_header( ZMxpvUnusualTheta )
0180 CLHEP_vector_exception_header( ZMxpvParallelCols )
0181 CLHEP_vector_exception_header( ZMxpvNotOrthogonal )
0182 CLHEP_vector_exception_header( ZMxpvNotSymplectic )
0183 
0184 #endif // endif for ifndef ENABLE_ZOOM_EXCEPTIONS 
0185 
0186 // =============================================================
0187 // =============================================================
0188 // =============================================================
0189 
0190 #ifdef ENABLE_ZOOM_EXCEPTIONS 
0191 
0192 //  This is the ZOOM version.  When compiled for ZOOM, even the basic CLHEP 
0193 //  Vector classes will depend on ZOOM Exceptions.  
0194 //  Though in the CLHEP context methods use ZMthrowA and ZMthrowC, these
0195 //  in the ZOOM context become ZMthrow.
0196 //
0197 //  Either this file or ZMxpvCLHEP.h is copied to become ZMxpv.h, depending 
0198 //  on whether this is a ZOOM or a CLHEP build.  
0199 //
0200 
0201 #ifndef ZMEXCEPTIONS_H
0202   #include "Exceptions/ZMexception.h"
0203   #include "Exceptions/ZMthrow.h"
0204 #endif
0205 using namespace zmex;
0206 
0207 namespace zmpv  {
0208 
0209 ZMexStandardDefinition (ZMexception, ZMxPhysicsVectors);
0210 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfiniteVector);
0211 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvZeroVector);
0212 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvTachyonic);
0213 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvSpacelike);
0214 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvInfinity);
0215 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeMass);
0216 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvAmbiguousAngle);
0217 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNegativeR);
0218 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvUnusualTheta);
0219 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvVectorInputFails);
0220 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvParallelCols);
0221 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperRotation);
0222 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvImproperTransformation);
0223 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvIndexRange);
0224 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotOrthogonal);
0225 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvNotSymplectic);
0226 ZMexStandardDefinition (ZMxPhysicsVectors, ZMxpvFixedAxis);
0227 
0228 #define ZMthrowA(A) ZMthrow(A)
0229 #define ZMthrowC(A) ZMthrow(A)
0230 
0231 }  // namespace zmpv
0232 
0233 #endif // ENABLE_ZOOM_EXCEPTIONS
0234 
0235 #endif // HEP_ZMXPV_H