BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtEulerAngles.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of models developed at BES collaboration
5// based on the EvtGen framework. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/BesCopyright
9// Copyright (A) 2006 Ping Rong-Gang @IHEP
10//
11// Module: EvtDIY.cc
12//
13// Description: Class to calculate the Euler angles to rotate a system
14//
15// Modification history:
16//
17// Ping R.-G. December, 2007 Module created
18//
19//------------------------------------------------------------------------
20//
21#include "EvtEulerAngles.hh"
22#include "EvtPatches.hh"
23#include "EvtReport.hh"
24#include <fstream>
25#include <iostream>
26#include <math.h>
27#include <stdio.h>
28#include <stdlib.h>
29using namespace std; //::endl;
30
33 _Yaxis = Yaxis;
34 _Zaxis = Zaxis;
36}
37
39 for ( int i = 1; i < 4; i++ )
40 {
41 _Yaxis.set( i - 1, Pyaxis.get( i ) );
42 _Zaxis.set( i - 1, Pzaxis.get( i ) );
43 }
45}
46
48
49double EvtEulerAngles::getAlpha() { return _alpha; }
50
51double EvtEulerAngles::getBeta() { return _beta; }
52
53double EvtEulerAngles::getGamma() { return _gamma; }
54
56 // to calculate Euler angles with y-convention, i.e. R=R(Z, alpha).R(Y,beta).R(Z,gamma)
57 double pi = 3.1415926;
58 _ry = _Yaxis.d3mag();
59 _rz = _Zaxis.d3mag();
60
61 if ( _ry == 0 || _rz == 0 )
62 {
63 report( ERROR, "" ) << "Euler angle calculation specified by zero modules of the axis!"
64 << endl;
65 report( ERROR, "EvtGen" ) << "Will terminate execution!" << endl;
66 ::abort();
67 }
68 double tolerance = 1e-10;
69 bool Y1is0 = fabs( _Yaxis.get( 0 ) ) < tolerance;
70 bool Y2is0 = fabs( _Yaxis.get( 1 ) ) < tolerance;
71 bool Y3is0 = fabs( _Yaxis.get( 2 ) ) < tolerance;
72 bool Z1is0 = fabs( _Zaxis.get( 0 ) ) < tolerance;
73 bool Z2is0 = fabs( _Zaxis.get( 1 ) ) < tolerance;
74 bool Z3is0 = fabs( _Zaxis.get( 2 ) ) < tolerance;
75
76 if ( Y1is0 && Y3is0 && Z1is0 && Z2is0 )
77 {
78 _alpha = 0;
79 _beta = 0;
80 _gamma = 0;
81 return;
82 }
83
84 if ( Z1is0 && Z2is0 && !Y2is0 )
85 {
86 _alpha = 0;
87 _beta = 0;
88 _gamma = acos( _Yaxis.get( 0 ) / _ry );
89 if ( _Yaxis.get( 1 ) < 0 ) _gamma = 2 * pi - _gamma;
90 return;
91 }
92
93 // For general case to calculate Euler angles
94 // to calculate beta
95
96 if ( Z1is0 && Z2is0 ) { _beta = 0; }
97 else { _beta = acos( _Zaxis.get( 2 ) / _rz ); }
98
99 // to calculate alpha
100
101 if ( _beta == 0 ) { _alpha = 0.0; }
102 else
103 {
104 double cosalpha = _Zaxis.get( 0 ) / _rz / sin( _beta );
105 if ( fabs( cosalpha ) > 1.0 ) cosalpha = cosalpha / fabs( cosalpha );
106 _alpha = acos( cosalpha );
107 if ( _Zaxis.get( 1 ) < 0.0 ) _alpha = 2 * pi - _alpha;
108 }
109
110 // to calculate gamma, alpha=0 and beta=0 case has been calculated, so only alpha !=0 and
111 // beta !=0 case left
112
113 double singamma = _Yaxis.get( 2 ) / _ry / sin( _beta );
114 double cosgamma =
115 ( -_Yaxis.get( 0 ) / _ry - cos( _alpha ) * cos( _beta ) * singamma ) / sin( _alpha );
116 if ( fabs( singamma ) > 1.0 ) singamma = singamma / fabs( singamma );
117 _gamma = asin( singamma );
118 if ( singamma > 0 && cosgamma < 0 ) _gamma = pi - _gamma; // _gamma>0
119 if ( singamma < 0 && cosgamma < 0 ) _gamma = pi - _gamma; //_gamma<0
120 if ( singamma < 0 && cosgamma > 0 ) _gamma = 2 * pi + _gamma; //_gamma<0
121}
double pi
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49
virtual ~EvtEulerAngles()
double get(int i) const