Fork me on GitHub

source: svn/trunk/Utilities/HepMC/interface/Polarization.h@ 491

Last change on this file since 491 was 349, checked in by severine ovyn, 16 years ago

first test

File size: 3.6 KB
RevLine 
[349]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
13#include "SimpleVector.h"
14#include <iostream>
15#include <cmath>
16
17namespace HepMC {
18
19 static const double HepMC_pi = 3.14159265358979323846; // copy of pi from CLHEP
20
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 ///
29 class Polarization {
30
31 /// print polarization information
32 friend std::ostream& operator<<( std::ostream&, const Polarization& );
33
34 public:
35 /// default constructor
36 Polarization( double theta = 0, double phi = 0 );
37 /// construct from another polarization object
38 Polarization( const Polarization& inpolar );
39 /// construct using the polar and azimuthal angles from a ThreeVector
40 Polarization( const ThreeVector& vec3in );
41 virtual ~Polarization() {}
42
43 /// swap
44 void swap( Polarization & other);
45 /// make a copy
46 Polarization& operator=( const Polarization& inpolar );
47 /// equality requires that theta and phi are equal
48 bool operator==( const Polarization& ) const;
49 /// inequality results if either theta or phi differ
50 bool operator!=( const Polarization& ) const;
51
52 /// print theta and phi
53 void print( std::ostream& ostr = std::cout ) const;
54
55 ////////////////////
56 // access methods //
57 ////////////////////
58 double theta() const; //!< returns polar angle in radians
59 double phi() const; //!< returns azimuthal angle in radians
60 ThreeVector normal3d() const; //!< unit 3 vector for easy manipulation
61
62 /// set polar angle in radians
63 double set_theta( double theta );
64 /// set azimuthal angle in radians
65 double set_phi( double phi );
66 /// set both polar and azimuthal angles in radians
67 void set_theta_phi( double theta, double phi );
68 /// sets polarization according to direction of 3 vec
69 ThreeVector set_normal3d( const ThreeVector& vec3in );
70
71 private:
72 /// private method to return a polar angle in the correct range
73 double valid_theta( double theta );
74 /// private method to return an azimuthal angle in the correct range
75 double valid_phi( double phi );
76
77 private:
78 double m_theta; //polar angle of polarization in radians 0< theta <pi
79 double m_phi; //azimuthal angle of polarization in rad. 0< phi <2pi
80 };
81
82 ///////////////////////////
83 // INLINE Access Methods //
84 ///////////////////////////
85
86 inline double Polarization::theta() const { return m_theta; }
87 inline double Polarization::phi() const { return m_phi; }
88
89 ///////////////////////////
90 // INLINE Operators //
91 ///////////////////////////
92
93 inline bool Polarization::operator==( const Polarization& a ) const
94 {
95 return ( a.theta() == this->theta() && a.phi() == this->phi() );
96 }
97
98 inline bool Polarization::operator!=(const Polarization& a ) const
99 {
100 return !( a == *this );
101 }
102
103} // HepMC
104
105#endif // HEPMC_POLARIZATION_H
106//--------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.