BOSS 7.1.1
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//
22#include <iostream>
23#include <math.h>
24#include <fstream>
25#include <stdio.h>
26#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 _Yaxis.set(i-1,Pyaxis.get(i));
41 _Zaxis.set(i-1,Pzaxis.get(i));
42 }
44}
45
48
50 return _alpha;
51}
52
54 return _beta;
55}
56
58 return _gamma;
59}
60
62 // to calculate Euler angles with y-convention, i.e. R=R(Z, alpha).R(Y,beta).R(Z,gamma)
63 double pi=3.1415926;
64 _ry=_Yaxis.d3mag();
65 _rz=_Zaxis.d3mag();
66
67 if(_ry==0 ||_rz==0) {
68 report(ERROR,"") << "Euler angle calculation specified by zero modules of the axis!"<<endl;
69 report(ERROR,"EvtGen") << "Will terminate execution!"<<endl;
70 ::abort();
71 }
72 double tolerance=1e-10;
73 bool Y1is0=fabs(_Yaxis.get(0))<tolerance;
74 bool Y2is0=fabs(_Yaxis.get(1))<tolerance;
75 bool Y3is0=fabs(_Yaxis.get(2))<tolerance;
76 bool Z1is0=fabs(_Zaxis.get(0))<tolerance;
77 bool Z2is0=fabs(_Zaxis.get(1))<tolerance;
78 bool Z3is0=fabs(_Zaxis.get(2))<tolerance;
79
80 if(Y1is0 && Y3is0 && Z1is0 && Z2is0 ){
81 _alpha=0; _beta=0; _gamma=0;
82 return;
83 }
84
85 if( Z1is0 && Z2is0 && !Y2is0){
86 _alpha=0; _beta=0;
87 _gamma=acos(_Yaxis.get(0)/_ry);
88 if(_Yaxis.get(1)<0) _gamma=2*pi - _gamma;
89 return;
90 }
91
92 // For general case to calculate Euler angles
93 // to calculate beta
94
95 if(Z1is0 && Z2is0) {
96 _beta=0;
97 } else{ _beta =acos(_Zaxis.get(2)/_rz);}
98
99 //to calculate alpha
100
101 if(_beta==0){
102 _alpha=0.0;
103 }else {
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 beta !=0 case left
111
112 double singamma=_Yaxis.get(2)/_ry/sin(_beta);
113 double cosgamma=(-_Yaxis.get(0)/_ry-cos(_alpha)*cos(_beta)*singamma)/sin(_alpha);
114 if(fabs(singamma)>1.0) singamma=singamma/fabs(singamma);
115 _gamma=asin(singamma);
116 if(singamma>0 && cosgamma<0 ) _gamma=pi - _gamma; // _gamma>0
117 if(singamma<0 && cosgamma<0 ) _gamma=pi - _gamma; //_gamma<0
118 if(singamma<0 && cosgamma>0 ) _gamma=2*pi + _gamma; //_gamma<0
119
120
121}
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:36
@ ERROR
Definition EvtReport.hh:49
virtual ~EvtEulerAngles()
double get(int i) const
double d3mag() const
void set(int i, double d)
double get(int i) const
const float pi
Definition vector3.h:133