ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LatticePhysical.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4LatticePhysical.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 // 20131115 Save rotation results in local variable, report verbosely
31 // 20131116 Replace G4Transform3D with G4RotationMatrix
32 
33 #include "G4LatticePhysical.hh"
34 #include "G4LatticeLogical.hh"
35 #include "G4PhysicalConstants.hh"
36 #include "G4RotationMatrix.hh"
37 #include "G4SystemOfUnits.hh"
38 
39 
40 // Unit vectors defined for convenience (avoid memory churn)
41 
42 namespace {
43  G4ThreeVector xhat(1,0,0), yhat(0,1,0), zhat(0,0,1), nullVec(0,0,0);
44 }
45 
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
48 
50  const G4RotationMatrix* Rot)
51  : verboseLevel(0), fTheta(0), fPhi(0), fLattice(Lat) {
53 }
54 
56 
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
61  if (!Rot) { // No orientation specified
63  } else {
64  fLocalToGlobal = fGlobalToLocal = *Rot; // Frame rotation
66  }
67 
68  if (verboseLevel) {
69  G4cout << "G4LatticePhysical::SetPhysicalOrientation " << *Rot
70  << "\nfLocalToGlobal: " << fLocalToGlobal
71  << "\nfGlobalToLocal: " << fGlobalToLocal
72  << G4endl;
73  }
74 }
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
77 
79  fTheta = t_rot;
80  fPhi = p_rot;
81 
82  if (verboseLevel)
83  G4cout << "G4LatticePhysical::SetLatticeOrientation " << fTheta << " "
84  << fPhi << G4endl;
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
88 
90  fTheta = halfpi - std::atan2(n+0.000001,l+0.000001);
91  fPhi = halfpi - std::atan2(l+0.000001,k+0.000001);
92 
93  if (verboseLevel)
94  G4cout << "G4LatticePhysical::SetMillerOrientation(" << l << k << n
95  << ") : " << fTheta << " " << fPhi << G4endl;
96 }
97 
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
100 
102 //Loads the group velocity in m/s
105  G4ThreeVector k) const {
106  if (verboseLevel>1) G4cout << "G4LatticePhysical::MapKtoV " << k << G4endl;
107 
108  k.rotate(yhat,fTheta).rotate(zhat, fPhi);
109  return fLattice->MapKtoV(polarizationState, k);
110 }
111 
113 //Loads the normalized direction vector along VG
116  G4ThreeVector k) const {
117  if (verboseLevel>1) G4cout << "G4LatticePhysical::MapKtoVDir " << k << G4endl;
118 
119  k.rotate(yhat,fTheta).rotate(zhat,fPhi);
120 
121  G4ThreeVector VG = fLattice->MapKtoVDir(polarizationState, k);
122 
123  return VG.rotate(zhat,-fPhi).rotate(yhat,-fTheta);
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
127 
128 // Apply orientation transforms to specified vector
129 
132  if (verboseLevel>1) {
133  G4cout << "G4LatticePhysical::RotateToGlobal " << dir
134  << "\nusing fLocalToGlobal " << fLocalToGlobal
135  << G4endl;
136  }
137 
139  if (verboseLevel>1) G4cout << " result " << result << G4endl;
140 
141  return result;
142 }
143 
146  if (verboseLevel>1) {
147  G4cout << "G4LatticePhysical::RotateToLocal " << dir
148  << "\nusing fGlobalToLocal " << fGlobalToLocal
149  << G4endl;
150  }
151 
153  if (verboseLevel>1) G4cout << " result " << result << G4endl;
154 
155  return result;
156 }