Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LatticePhysical.cc
Go to the documentation of this file.
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//
26/// \file materials/src/G4LatticePhysical.cc
27/// \brief Implementation of the G4LatticePhysical class
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"
36#include "G4RotationMatrix.hh"
37#include "G4SystemOfUnits.hh"
38
39
40// Unit vectors defined for convenience (avoid memory churn)
41
42namespace {
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 == nullptr)
62 { // No orientation specified
63 fLocalToGlobal = fGlobalToLocal = G4RotationMatrix::IDENTITY;
64 }
65 else
66 {
67 fLocalToGlobal = fGlobalToLocal = *Rot; // Frame rotation
68 fGlobalToLocal.invert();
69 }
70
71 if(verboseLevel != 0)
72 {
73 G4cout << "G4LatticePhysical::SetPhysicalOrientation " << *Rot
74 << "\nfLocalToGlobal: " << fLocalToGlobal
75 << "\nfGlobalToLocal: " << fGlobalToLocal
76 << G4endl;
77 }
78}
79
80//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
81
83 fTheta = t_rot;
84 fPhi = p_rot;
85
86 if(verboseLevel != 0)
87 {
88 G4cout << "G4LatticePhysical::SetLatticeOrientation " << fTheta << " "
89 << fPhi << G4endl;
90 }
91}
92
93//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
94
96 fTheta = halfpi - std::atan2(n+0.000001,l+0.000001);
97 fPhi = halfpi - std::atan2(l+0.000001,k+0.000001);
98
99 if(verboseLevel != 0)
100 {
101 G4cout << "G4LatticePhysical::SetMillerOrientation(" << l << k << n
102 << ") : " << fTheta << " " << fPhi << G4endl;
103 }
104}
105
106
107//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
108
109///////////////////////////////
110//Loads the group velocity in m/s
111/////////////////////////////
113 G4ThreeVector k) const {
114 if(verboseLevel > 1)
115 {
116 G4cout << "G4LatticePhysical::MapKtoV " << k << G4endl;
117 }
118
119 k.rotate(yhat,fTheta).rotate(zhat, fPhi);
120 return fLattice->MapKtoV(polarizationState, k);
121}
122
123///////////////////////////////
124//Loads the normalized direction vector along VG
125///////////////////////////////
127 G4ThreeVector k) const {
128 if(verboseLevel > 1)
129 {
130 G4cout << "G4LatticePhysical::MapKtoVDir " << k << G4endl;
131 }
132
133 k.rotate(yhat,fTheta).rotate(zhat,fPhi);
134
135 G4ThreeVector VG = fLattice->MapKtoVDir(polarizationState, k);
136
137 return VG.rotate(zhat,-fPhi).rotate(yhat,-fTheta);
138}
139
140//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
141
142// Apply orientation transforms to specified vector
143
146 if (verboseLevel>1) {
147 G4cout << "G4LatticePhysical::RotateToGlobal " << dir
148 << "\nusing fLocalToGlobal " << fLocalToGlobal
149 << G4endl;
150 }
151
152 G4ThreeVector result = fLocalToGlobal*dir;
153 if(verboseLevel > 1)
154 {
155 G4cout << " result " << result << G4endl;
156 }
157
158 return result;
159}
160
163 if (verboseLevel>1) {
164 G4cout << "G4LatticePhysical::RotateToLocal " << dir
165 << "\nusing fGlobalToLocal " << fGlobalToLocal
166 << G4endl;
167 }
168
169 G4ThreeVector result = fGlobalToLocal*dir;
170 if(verboseLevel > 1)
171 {
172 G4cout << " result " << result << G4endl;
173 }
174
175 return result;
176}
Definition of the G4LatticeLogical class.
Definition of the G4LatticePhysical class.
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Hep3Vector & rotate(double, const Hep3Vector &)
Definition: ThreeVectorR.cc:24
static DLL_API const HepRotation IDENTITY
Definition: Rotation.h:366
HepRotation & invert()
virtual G4double MapKtoV(G4int, const G4ThreeVector &) const
virtual G4ThreeVector MapKtoVDir(G4int, const G4ThreeVector &) const
void SetLatticeOrientation(G4double, G4double)
void SetPhysicalOrientation(const G4RotationMatrix *Rot)
G4ThreeVector RotateToLocal(const G4ThreeVector &dir) const
G4ThreeVector RotateToGlobal(const G4ThreeVector &dir) const
virtual ~G4LatticePhysical()
G4double MapKtoV(G4int, G4ThreeVector) const
G4ThreeVector MapKtoVDir(G4int, G4ThreeVector) const
void SetMillerOrientation(G4int, G4int, G4int)
G4LatticePhysical(const G4LatticeLogical *Lat=nullptr, const G4RotationMatrix *Rot=nullptr)