hepmc - Blame information for rev 432

Subversion Repositories:
Rev:
Rev Author Line No. Line
2 garren 1 //--------------------------------------------------------------------------
2 #ifndef HEPMC_POLARIZATION_H
3 #define HEPMC_POLARIZATION_H
4  
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).
9 //
10 // Polarization object for a particle. All angles are in radians.
11 //////////////////////////////////////////////////////////////////////////
12  
43 garren 13 #include "HepMC/SimpleVector.h"
2 garren 14 #include <iostream>
15 #include <cmath>
16  
17 namespace HepMC {
18  
21 garren 19     static const double HepMC_pi = 3.14159265358979323846;  // copy of pi from CLHEP
2 garren 20  
65 garren 21     //! The Polarization class stores theta and phi for a GenParticle
22  
23     ///
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.
28     ///
2 garren 29     class Polarization {
30  
65 garren 31         /// print polarization information
2 garren 32         friend std::ostream& operator<<( std::ostream&, const Polarization& );
33  
34     public:
65 garren 35         /// default constructor
432 garren 36         Polarization( );
37         /// constructor requiring at least one value
38         Polarization( double theta, double phi = 0 );
65 garren 39         /// construct from another polarization object
2 garren 40         Polarization( const Polarization& inpolar );
65 garren 41         /// construct using the polar and azimuthal angles from a ThreeVector
43 garren 42         Polarization( const ThreeVector& vec3in );
2 garren 43         virtual       ~Polarization() {}
44  
147 garren 45         /// swap
46         void swap( Polarization & other);
65 garren 47         /// make a copy
2 garren 48         Polarization& operator=( const Polarization& inpolar );
65 garren 49         /// equality requires that theta and phi are equal
2 garren 50         bool          operator==( const Polarization& ) const;
65 garren 51         /// inequality results if either theta or phi differ
2 garren 52         bool          operator!=( const Polarization& ) const;
53  
65 garren 54         /// print theta and phi
2 garren 55         void          print( std::ostream& ostr = std::cout ) const;
56  
57         ////////////////////
58         // access methods //
59         ////////////////////
65 garren 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
432 garren 63         bool          is_defined() const;   //!< returns true if the Polarization has been defined
2 garren 64  
65 garren 65         /// set polar angle in radians
2 garren 66         double        set_theta( double theta );
65 garren 67         /// set azimuthal angle in radians
68         double        set_phi( double phi );
69         /// set both polar and azimuthal angles in radians
2 garren 70         void          set_theta_phi( double theta, double phi );
65 garren 71         /// sets polarization according to direction of 3 vec
43 garren 72         ThreeVector   set_normal3d( const ThreeVector& vec3in );
432 garren 73         /// declares the Polarization as undefined and zeros the values
74         void          set_undefined();
2 garren 75  
76     private:
147 garren 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 );
81  
82     private:
2 garren 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
432 garren 85         bool   m_defined; //used to flag if the Polarization has been defined
2 garren 86     };
87  
88     ///////////////////////////
89     // INLINE Access Methods //
90     ///////////////////////////
91  
92     inline double Polarization::theta() const { return m_theta; }
93     inline double Polarization::phi() const { return m_phi; }
94  
95     ///////////////////////////
96     // INLINE Operators      //
97     ///////////////////////////
98  
99     inline bool Polarization::operator==( const Polarization& a ) const
100     {
432 garren 101         return ( a.theta() == this->theta() && a.phi() == this->phi() && a.is_defined() == this->is_defined() );
2 garren 102     }
103  
104     inline bool Polarization::operator!=(const Polarization& a ) const
105     {
106         return !( a == *this );
107     }
108  
109 } // HepMC
110  
111 #endif  // HEPMC_POLARIZATION_H
112 //--------------------------------------------------------------------------