7 #include "HepMC/Polarization.h"
18 : m_theta( valid_theta(theta) ),
19 m_phi ( valid_phi(phi) ),
24 : m_theta( valid_theta( inpolar.theta() ) ),
25 m_phi ( valid_phi( inpolar.phi() ) ),
26 m_defined( inpolar.is_defined() )
30 : m_theta( valid_theta( vec3in.theta() ) ),
31 m_phi ( valid_phi( vec3in.phi() ) ),
37 std::swap( m_theta, other.m_theta );
38 std::swap( m_phi, other.m_phi );
39 std::swap( m_defined, other.m_defined );
50 ostr <<
"Polarization: " << *
this << std::endl;
68 return m_theta = valid_theta( theta );
74 return m_phi = valid_phi( phi );
104 double Polarization::valid_theta(
double theta ) {
106 theta = ( theta>0 ? theta : -
theta );
108 theta = ( theta/(2*HepMC_pi) -
int(theta/(2*HepMC_pi)) )
111 if ( theta > HepMC_pi ) theta = 2*HepMC_pi -
theta;
115 double Polarization::valid_phi(
double phi ) {
118 phi = ( phi/(2*HepMC_pi) -
int(phi/(2*HepMC_pi)) ) * 2*HepMC_pi;
120 if ( phi < 0 ) phi = 2*HepMC_pi +
phi;
129 std::ostream& operator<<( std::ostream& ostr,
const Polarization& polar ) {
130 return ostr <<
"(" << polar.
theta()
131 <<
"," << polar.
phi() <<
")";
void print(std::ostream &ostr=std::cout) const
print theta and phi
double theta() const
The polar angle.
void set_undefined()
declares the Polarization as undefined and zeros the values
double set_theta(double theta)
set polar angle in radians
ThreeVector set_normal3d(const ThreeVector &vec3in)
sets polarization according to direction of 3 vec
void setPhi(double)
Set phi keeping magnitude and theta constant (BaBar).
ThreeVector is a simple representation of a position or displacement 3 vector.
ThreeVector normal3d() const
unit 3 vector for easy manipulation
double theta() const
returns polar angle in radians
Polarization()
default constructor
double phi() const
The azimuth angle.
double set_phi(double phi)
set azimuthal angle in radians
The Polarization class stores theta and phi for a GenParticle.
void swap(Polarization &other)
swap
Polarization & operator=(const Polarization &inpolar)
make a copy
void set_theta_phi(double theta, double phi)
set both polar and azimuthal angles in radians
bool is_defined() const
returns true if the Polarization has been defined
void setTheta(double)
Set theta keeping magnitude and phi constant (BaBar).
double phi() const
returns azimuthal angle in radians