CLHEP/HepMC/Polarization.h

00001 //--------------------------------------------------------------------------
00002 #ifndef HEPMC_POLARIZATION_H
00003 #define HEPMC_POLARIZATION_H
00004 
00006 // Matt.Dobbs@Cern.CH, September 1999, refer to:
00007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
00008 // High Energy Physics", Computer Physics Communications (to be published).
00009 //
00010 // Polarization object for a particle. All angles are in radians.
00012 
00013 #include "CLHEP/Geometry/Normal3D.h"
00014 #include "CLHEP/Units/PhysicalConstants.h"
00015 #include "CLHEP/config/CLHEP.h"
00016 #include "CLHEP/config/iostream.h"
00017 
00018 namespace HepMC {
00019 
00020     static const double HepMC_pi = pi; // use pi from CLHEP
00021     
00026     class Polarization {
00027 
00028         friend std::ostream& operator<<( std::ostream&, const Polarization& );
00029 
00030     public:
00031         Polarization( double theta = 0, double phi = 0 );
00032         Polarization( const Polarization& inpolar );
00033         Polarization( const HepNormal3D& vec3in );
00034         virtual       ~Polarization() {}
00035 
00036         Polarization& operator=( const Polarization& inpolar );
00037         bool          operator==( const Polarization& ) const;
00038         bool          operator!=( const Polarization& ) const;
00039 
00040         void          print( std::ostream& ostr = std::cout ) const;
00041     
00043         // access methods //
00045         double        theta() const;    // returns polar angle in radians
00046         double        phi() const;      // returns azimuthal angle in radians
00047         HepNormal3D   normal3d() const; // unit 3 vector for easy manipulation
00048 
00049         double        set_theta( double theta );
00050         double        set_phi( double phi ); 
00051         void          set_theta_phi( double theta, double phi );
00052         // sets polarization according to direction of 3 vec
00053         HepNormal3D   set_normal3d( const HepNormal3D& vec3in ); 
00054 
00055     private:
00056         double m_theta; //polar angle of polarization in radians 0< theta <pi
00057         double m_phi;   //azimuthal angle of polarization in rad. 0< phi <2pi
00058     };
00059 
00061     // INLINE Access Methods //
00063 
00064     inline double Polarization::theta() const { return m_theta; }
00065     inline double Polarization::phi() const { return m_phi; }
00066 
00068     // INLINE Operators      //
00070 
00071     inline bool Polarization::operator==( const Polarization& a ) const 
00072     {
00073         return ( a.theta() == this->theta() && a.phi() == this->phi() );
00074     }
00075 
00076     inline bool Polarization::operator!=(const Polarization& a ) const 
00077     {
00078         return !( a == *this );
00079     }
00080 
00081 } // HepMC
00082 
00083 #endif  // HEPMC_POLARIZATION_H
00084 //--------------------------------------------------------------------------

Class Library for High Energy Physics (version 1.8)