1 //--------------------------------------------------------------------------
2 #ifndef HEPMC_POLARIZATION_H
3 #define HEPMC_POLARIZATION_H
5 //////////////////////////////////////////////////////////////////////////
6 // Matt.Dobbs@Cern.CH, September 1999, refer to:
7 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
8 // High Energy Physics", Computer Physics Communications (to be published).
10 // Polarization object for a particle. All angles are in radians.
11 //////////////////////////////////////////////////////////////////////////
13 #include "HepMC/SimpleVector.h"
19 static const double HepMC_pi = 3.14159265358979323846; // copy of pi from CLHEP
21 //! The Polarization class stores theta and phi for a GenParticle
24 /// \class Polarization
25 /// HepMC::Polarization stores a particle's theta and phi in radians.
26 /// Use of this information is optional.
27 /// By default, the polarization is set to zero.
31 /// print polarization information
32 friend std::ostream& operator<<( std::ostream&, const Polarization& );
35 /// default constructor
37 /// constructor requiring at least one value
38 Polarization( double theta, double phi = 0 );
39 /// construct from another polarization object
40 Polarization( const Polarization& inpolar );
41 /// construct using the polar and azimuthal angles from a ThreeVector
42 Polarization( const ThreeVector& vec3in );
43 virtual ~Polarization() {}
46 void swap( Polarization & other);
48 Polarization& operator=( const Polarization& inpolar );
49 /// equality requires that theta and phi are equal
50 bool operator==( const Polarization& ) const;
51 /// inequality results if either theta or phi differ
52 bool operator!=( const Polarization& ) const;
54 /// print theta and phi
55 void print( std::ostream& ostr = std::cout ) const;
60 double theta() const; //!< returns polar angle in radians
61 double phi() const; //!< returns azimuthal angle in radians
62 ThreeVector normal3d() const; //!< unit 3 vector for easy manipulation
63 bool is_defined() const; //!< returns true if the Polarization has been defined
65 /// set polar angle in radians
66 double set_theta( double theta );
67 /// set azimuthal angle in radians
68 double set_phi( double phi );
69 /// set both polar and azimuthal angles in radians
70 void set_theta_phi( double theta, double phi );
71 /// sets polarization according to direction of 3 vec
72 ThreeVector set_normal3d( const ThreeVector& vec3in );
73 /// declares the Polarization as undefined and zeros the values
77 /// private method to return a polar angle in the correct range
78 double valid_theta( double theta );
79 /// private method to return an azimuthal angle in the correct range
80 double valid_phi( double phi );
83 double m_theta; //polar angle of polarization in radians 0< theta <pi
84 double m_phi; //azimuthal angle of polarization in rad. 0< phi <2pi
85 bool m_defined; //used to flag if the Polarization has been defined
88 ///////////////////////////
89 // INLINE Access Methods //
90 ///////////////////////////
92 inline double Polarization::theta() const { return m_theta; }
93 inline double Polarization::phi() const { return m_phi; }
95 ///////////////////////////
96 // INLINE Operators //
97 ///////////////////////////
99 inline bool Polarization::operator==( const Polarization& a ) const
101 return ( a.theta() == this->theta() && a.phi() == this->phi() && a.is_defined() == this->is_defined() );
104 inline bool Polarization::operator!=(const Polarization& a ) const
106 return !( a == *this );
111 #endif // HEPMC_POLARIZATION_H
112 //--------------------------------------------------------------------------