ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtEulerTransformation.cxx
Go to the documentation of this file.
2 
3 #include <Rtypes.h>
4 
5 #include <cmath>
6 #include <iostream>
7 
9 {
10 
11  // *** Transformation coordinate system (Euler angles) : ***
12  // DEFINITIONS:
13  // --from beam to lab system
14  // alpha = phi
15  // beta = theta
16  // gamma = 0
17  // *** inputs: theta_beam, phi_beam, alpha, beta, gamma
18  // *** calculate: theta_lab, phi_lab (from beam to lab)
19  //
20  // --or from lab to beam system
21  // alpha = pi
22  // beta = theta_beam
23  // gamma = pi - phi_beam
24 
25  // BE CAREFUL of the units! Here the angles are not in degrees!
26 
27  const Double_t PI = 3.14159265358979323846;
28  // const G4double rad=180.0/PI;
29 
30  Double_t Theta0 = ThetaInBeamSystem;
31  Double_t Phi0 = PhiInBeamSystem;
32 
33  Double_t alpha = BeamDirectionAtVertexPhi; // alpha=phi
34  Double_t beta = BeamDirectionAtVertexTheta; // beta =theta
35  Double_t gamma = 0.0;
36 
37  Double_t px = sin(Theta0) * cos(Phi0);
38  Double_t py = sin(Theta0) * sin(Phi0);
39  Double_t pz = cos(Theta0);
40 
41  Double_t sa = sin(alpha);
42  Double_t ca = cos(alpha);
43  Double_t sb = sin(beta);
44  Double_t cb = cos(beta);
45  Double_t sg = sin(gamma);
46  Double_t cg = cos(gamma);
47 
48  Double_t px_1 = px * (ca * cb * cg - sa * sg) + py * (-ca * cb * sg - sa * cg) + pz * (ca * sb);
49  Double_t py_1 = px * (sa * cb * cg + ca * sg) + py * (-sa * cb * sg + ca * cg) + pz * (sa * sb);
50  Double_t pz_1 = px * (-sb * cg) + py * (sb * sg) + pz * (cb);
51 
52  Double_t pxy_1 = sqrt(px_1 * px_1 + py_1 * py_1);
53  Double_t sithe1 = pxy_1;
54  Double_t cothe1 = pz_1;
55 
56  Double_t theta_1 = atan2(sithe1, cothe1);
57 
58  ThetaInLabSystem = theta_1;
59 
60  Double_t phi_1 = 0.0;
61 
62  if (sithe1 != 0.0) {
63  Double_t siphi1 = py_1 / pxy_1;
64  Double_t cophi1 = px_1 / pxy_1;
65  phi_1 = atan2(siphi1, cophi1);
66 
67  if (phi_1 < 0.0) {
68  phi_1 = 2. * PI + phi_1;
69  }
70  }
71 
72  if (sithe1 == 0.0) {
73  phi_1 = 0.0;
74  }
75 
76  PhiInLabSystem = phi_1;
77 }
78 
80 
82 {
83  std::cout << "Beam direction in the Lab frame:" << std::endl
84  << " theta=" << BeamDirectionAtVertexTheta << ", phi=" << BeamDirectionAtVertexPhi << std::endl;
85  std::cout << "Particle direction in the beam system:" << std::endl
86  << " theta=" << ThetaInBeamSystem << ", phi=" << PhiInBeamSystem << std::endl;
87  std::cout << "Particle direction in the Lab system:" << std::endl
88  << " theta=" << ThetaInLabSystem << ", phi=" << PhiInLabSystem << std::endl;
89 }
90 
ClassImp
ClassImp(AtFindVertex)
AtEulerTransformation::PrintResults
void PrintResults()
Definition: AtEulerTransformation.cxx:81
AtEulerTransformation::Dump
void Dump()
Definition: AtEulerTransformation.cxx:79
AtEulerTransformation
Definition: AtEulerTransformation.h:30
AtEulerTransformation::DoTheEulerTransformationBeam2Lab
void DoTheEulerTransformationBeam2Lab()
Definition: AtEulerTransformation.cxx:8
AtEulerTransformation.h