StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Polarization.h
1 //--------------------------------------------------------------------------
2 #ifndef HEPMC_POLARIZATION_H
3 #define HEPMC_POLARIZATION_H
4 
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.
12 
13 #include "HepMC/SimpleVector.h"
14 #include <iostream>
15 #include <cmath>
16 
17 namespace HepMC {
18 
19  static const double HepMC_pi = 3.14159265358979323846; // copy of pi from CLHEP
20 
22 
29  class Polarization {
30 
32  friend std::ostream& operator<<( std::ostream&, const Polarization& );
33 
34  public:
36  Polarization( );
38  Polarization( double theta, double phi = 0 );
40  Polarization( const Polarization& inpolar );
42  Polarization( const ThreeVector& vec3in );
43  virtual ~Polarization() {}
44 
46  void swap( Polarization & other);
48  Polarization& operator=( const Polarization& inpolar );
50  bool operator==( const Polarization& ) const;
52  bool operator!=( const Polarization& ) const;
53 
55  void print( std::ostream& ostr = std::cout ) const;
56 
58  // access methods //
60  double theta() const;
61  double phi() const;
62  ThreeVector normal3d() const;
63  bool is_defined() const;
64 
66  double set_theta( double theta );
68  double set_phi( double phi );
70  void set_theta_phi( double theta, double phi );
72  ThreeVector set_normal3d( const ThreeVector& vec3in );
74  void set_undefined();
75 
76  private:
78  double valid_theta( double theta );
80  double valid_phi( double phi );
81 
82  private:
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
86  };
87 
89  // INLINE Access Methods //
91 
92  inline double Polarization::theta() const { return m_theta; }
93  inline double Polarization::phi() const { return m_phi; }
94 
96  // INLINE Operators //
98 
99  inline bool Polarization::operator==( const Polarization& a ) const
100  {
101  return ( a.theta() == this->theta() && a.phi() == this->phi() && a.is_defined() == this->is_defined() );
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 //--------------------------------------------------------------------------
void print(std::ostream &ostr=std::cout) const
print theta and phi
Definition: Polarization.cc:49
void set_undefined()
declares the Polarization as undefined and zeros the values
Definition: Polarization.cc:81
double set_theta(double theta)
set polar angle in radians
Definition: Polarization.cc:65
ThreeVector set_normal3d(const ThreeVector &vec3in)
sets polarization according to direction of 3 vec
Definition: Polarization.cc:93
ThreeVector is a simple representation of a position or displacement 3 vector.
Definition: SimpleVector.h:131
ThreeVector normal3d() const
unit 3 vector for easy manipulation
Definition: Polarization.cc:57
double theta() const
returns polar angle in radians
Definition: Polarization.h:92
Polarization()
default constructor
Definition: Polarization.cc:11
double set_phi(double phi)
set azimuthal angle in radians
Definition: Polarization.cc:71
The Polarization class stores theta and phi for a GenParticle.
Definition: Polarization.h:29
void swap(Polarization &other)
swap
Definition: Polarization.cc:35
Polarization & operator=(const Polarization &inpolar)
make a copy
Definition: Polarization.cc:42
bool operator==(const Polarization &) const
equality requires that theta and phi are equal
Definition: Polarization.h:99
void set_theta_phi(double theta, double phi)
set both polar and azimuthal angles in radians
Definition: Polarization.cc:87
friend std::ostream & operator<<(std::ostream &, const Polarization &)
print polarization information
bool is_defined() const
returns true if the Polarization has been defined
Definition: Polarization.cc:77
double phi() const
returns azimuthal angle in radians
Definition: Polarization.h:93
bool operator!=(const Polarization &) const
inequality results if either theta or phi differ
Definition: Polarization.h:104