Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/HepMC/Polarization.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //--------------------------------------------------------------------------
0002 #ifndef HEPMC_POLARIZATION_H
0003 #define HEPMC_POLARIZATION_H
0004 
0005 //////////////////////////////////////////////////////////////////////////
0006 // Matt.Dobbs@Cern.CH, September 1999, refer to:
0007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
0008 // High Energy Physics", Computer Physics Communications (to be published).
0009 //
0010 // Polarization object for a particle. All angles are in radians.
0011 //////////////////////////////////////////////////////////////////////////
0012 
0013 #include "HepMC/SimpleVector.h"
0014 #include <iostream>
0015 #include <cmath>
0016 
0017 namespace HepMC {
0018 
0019     static const double HepMC_pi = 3.14159265358979323846;  // copy of pi from CLHEP
0020     
0021     //! The Polarization class stores theta and phi for a GenParticle
0022 
0023     ///
0024     /// \class  Polarization
0025     /// HepMC::Polarization stores a particle's theta and phi in radians.
0026     /// Use of this information is optional. 
0027     /// By default, the polarization is set to zero.
0028     ///
0029     class Polarization {
0030 
0031         /// print polarization information
0032     friend std::ostream& operator<<( std::ostream&, const Polarization& );
0033 
0034     public:
0035         /// default constructor
0036     Polarization( );
0037     /// constructor requiring at least one value
0038     Polarization( double theta, double phi = 0 );
0039     /// construct from another polarization object
0040     Polarization( const Polarization& inpolar );
0041     /// construct using the polar and azimuthal angles from a ThreeVector
0042     Polarization( const ThreeVector& vec3in );
0043     virtual       ~Polarization() {}
0044 
0045         /// swap
0046         void swap( Polarization & other);
0047     /// make a copy
0048     Polarization& operator=( const Polarization& inpolar );
0049     /// equality requires that theta and phi are equal
0050     bool          operator==( const Polarization& ) const;
0051     /// inequality results if either theta or phi differ
0052     bool          operator!=( const Polarization& ) const;
0053 
0054         /// print theta and phi
0055     void          print( std::ostream& ostr = std::cout ) const;
0056     
0057     ////////////////////
0058     // access methods //
0059     ////////////////////
0060     double        theta() const;    //!< returns polar angle in radians
0061     double        phi() const;      //!< returns azimuthal angle in radians
0062     ThreeVector   normal3d() const; //!< unit 3 vector for easy manipulation
0063     bool          is_defined() const;   //!< returns true if the Polarization has been defined
0064 
0065         /// set polar angle in radians 
0066     double        set_theta( double theta );
0067         /// set azimuthal angle in radians 
0068     double        set_phi( double phi );
0069     /// set both polar and azimuthal angles in radians
0070     void          set_theta_phi( double theta, double phi );
0071     /// sets polarization according to direction of 3 vec
0072     ThreeVector   set_normal3d( const ThreeVector& vec3in ); 
0073     /// declares the Polarization as undefined and zeros the values
0074     void          set_undefined();
0075 
0076     private:
0077         /// private method to return a polar angle in the correct range
0078     double valid_theta( double theta );
0079         /// private method to return an azimuthal angle in the correct range
0080     double valid_phi( double phi );
0081 
0082     private:
0083     double m_theta; //polar angle of polarization in radians 0< theta <pi
0084     double m_phi;   //azimuthal angle of polarization in rad. 0< phi <2pi
0085     bool   m_defined; //used to flag if the Polarization has been defined
0086     };
0087 
0088     ///////////////////////////
0089     // INLINE Access Methods //
0090     ///////////////////////////
0091 
0092     inline double Polarization::theta() const { return m_theta; }
0093     inline double Polarization::phi() const { return m_phi; }
0094 
0095     ///////////////////////////
0096     // INLINE Operators      //
0097     ///////////////////////////
0098 
0099     inline bool Polarization::operator==( const Polarization& a ) const 
0100     {
0101     return ( a.theta() == this->theta() && a.phi() == this->phi() && a.is_defined() == this->is_defined() );
0102     }
0103 
0104     inline bool Polarization::operator!=(const Polarization& a ) const 
0105     {
0106     return !( a == *this );
0107     }
0108 
0109 } // HepMC
0110 
0111 #endif  // HEPMC_POLARIZATION_H
0112 //--------------------------------------------------------------------------