ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSimEulerTransformation.cc
Go to the documentation of this file.
1 // - AUTHOR: M.S. Golovkov 02/2008
2 /******************************************************************
3  * Copyright (C) 2005-2016, Hector Alvarez-Pol *
4  * All rights reserved. *
5  * *
6  * License according to GNU LESSER GPL (see lgpl-3.0.txt). *
7  * For the list of contributors see CREDITS. *
8  ******************************************************************/
9 //////////////////////////////////////////////////////////////////
10 /// \class ActarSimEulerTransformation
11 /// Euler transformation between beam system and lab system
12 //////////////////////////////////////////////////////////////////
13 
15 
16 #include "globals.hh"
17 #include "math.h"
18 
19 using namespace std;
20 
21 //////////////////////////////////////////////////////////////////
22 /// Constructor
23 /// *** Transformation coordinate system (Euler angles) : ***
24 ///
25 /// DEFINITIONS:
26 /// - from beam to lab system
27 /// (alpha = phi,
28 /// beta = theta,
29 /// gamma = 0)
30 /// *** inputs: theta_beam, phi_beam, alpha, beta, gamma
31 /// *** calculate: theta_lab, phi_lab (from beam to lab)
32 ///
33 /// - or from lab to beam system
34 /// (alpha = pi,
35 /// beta = theta_beam,
36 /// gamma = pi - phi_beam)
38  ThetaInBeamSystem= 0.0;
39  PhiInBeamSystem = 0.0;
40  BeamDirectionAtVertexTheta=0.0;
41  BeamDirectionAtVertexPhi=0.0;
42  ThetaInLabSystem = 0.0;
43  PhiInLabSystem = 0.0;
44 }
45 
46 //////////////////////////////////////////////////////////////////
47 /// Destructor
49 }
50 
51 //////////////////////////////////////////////////////////////////
52 /// *** Transformation coordinate system (Euler angles) : ***
53 ///
54 /// DEFINITIONS:
55 /// - from beam to lab system
56 /// (alpha = phi,
57 /// beta = theta,
58 /// gamma = 0)
59 /// *** inputs: theta_beam, phi_beam, alpha, beta, gamma
60 /// *** calculate: theta_lab, phi_lab (from beam to lab)
61 ///
62 /// - or from lab to beam system
63 /// (alpha = pi,
64 /// beta = theta_beam,
65 /// gamma = pi - phi_beam)
66 ///
67 /// BE CAREFUL of the units! Here the angles are not in degrees!
69 
70  const G4double PI=3.14159265358979323846;
71  // const G4double rad=180.0/PI;
72 
73  G4double Theta0 = ThetaInBeamSystem;
74  G4double Phi0 = PhiInBeamSystem;
75 
76  G4double alpha = BeamDirectionAtVertexPhi; // alpha=phi
77  G4double beta = BeamDirectionAtVertexTheta; // beta =theta
78  G4double gamma = 0.0;
79 
80  G4double px = sin(Theta0)*cos(Phi0);
81  G4double py = sin(Theta0)*sin(Phi0);
82  G4double pz = cos(Theta0);
83 
84  G4double sa = sin(alpha);
85  G4double ca = cos(alpha);
86  G4double sb = sin(beta);
87  G4double cb = cos(beta);
88  G4double sg = sin(gamma);
89  G4double cg = cos(gamma);
90 
91  G4double px_1 = px*(ca*cb*cg-sa*sg)+py*(-ca*cb*sg-sa*cg)+pz*(ca*sb);
92  G4double py_1 = px*(sa*cb*cg+ca*sg)+py*(-sa*cb*sg+ca*cg)+pz*(sa*sb);
93  G4double pz_1 = px*(-sb*cg) + py*(sb*sg) + pz*(cb);
94 
95  G4double pxy_1 = sqrt(px_1*px_1 + py_1*py_1);
96  G4double sithe1 = pxy_1;
97  G4double cothe1 = pz_1;
98 
99  G4double theta_1 = atan2(sithe1,cothe1);
100 
101  ThetaInLabSystem = theta_1;
102 
103  G4double phi_1=0.0;
104 
105  if(sithe1 != 0.0){
106  G4double siphi1 = py_1/pxy_1;
107  G4double cophi1 = px_1/pxy_1;
108  phi_1 = atan2(siphi1,cophi1);
109 
110  if(phi_1 < 0.0){
111  phi_1 = 2.*PI + phi_1;
112  }
113  }
114 
115  if(sithe1 == 0.0){
116  phi_1 = 0.0;
117  }
118 
119  PhiInLabSystem = phi_1;
120 }
121 
122 //////////////////////////////////////////////////////////////////
123 /// Dump (empty function)
125 }
126 
127 //////////////////////////////////////////////////////////////////
128 /// Prints results
130  G4cout << "Beam direction in the Lab frame:" << G4endl
131  << " theta=" << BeamDirectionAtVertexTheta << ", phi=" << BeamDirectionAtVertexPhi << G4endl;
132  G4cout << "Particle direction in the beam system:" << G4endl
133  << " theta=" << ThetaInBeamSystem << ", phi=" << PhiInBeamSystem << G4endl;
134  G4cout << "Particle direction in the Lab system:" << G4endl
135  << " theta=" << ThetaInLabSystem << ", phi=" << PhiInLabSystem << G4endl;
136 }
void Dump()
Dump (empty function)
STL namespace.