Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LatticeManager Class Reference

#include <G4LatticeManager.hh>

Public Member Functions

void SetVerboseLevel (G4int vb)
 
void Reset ()
 
G4bool RegisterLattice (G4VPhysicalVolume *, G4LatticePhysical *)
 
G4bool RegisterLattice (G4VPhysicalVolume *, G4LatticeLogical *)
 
G4bool RegisterLattice (G4Material *, G4LatticeLogical *)
 
G4LatticeLogicalLoadLattice (G4Material *, const G4String &latDir)
 
G4LatticeLogicalGetLattice (G4Material *) const
 
G4bool HasLattice (G4Material *) const
 
G4LatticePhysicalLoadLattice (G4VPhysicalVolume *, const G4String &latDir)
 
G4LatticePhysicalGetLattice (G4VPhysicalVolume *) const
 
G4bool HasLattice (G4VPhysicalVolume *) const
 
G4double MapKtoV (G4VPhysicalVolume *, G4int, const G4ThreeVector &) const
 
G4ThreeVector MapKtoVDir (G4VPhysicalVolume *, G4int, const G4ThreeVector &) const
 

Static Public Member Functions

static G4LatticeManagerGetLatticeManager ()
 

Protected Types

typedef std::map< G4Material *, G4LatticeLogical * > LatticeMatMap
 
typedef std::set< G4LatticeLogical * > LatticeLogReg
 
typedef std::map< G4VPhysicalVolume *, G4LatticePhysical * > LatticeVolMap
 
typedef std::set< G4LatticePhysical * > LatticePhyReg
 

Protected Member Functions

void Clear ()
 

Protected Attributes

G4int verboseLevel
 
LatticeLogReg fLLattices
 
LatticeMatMap fLLatticeList
 
LatticePhyReg fPLattices
 
LatticeVolMap fPLatticeList
 

Detailed Description

Definition at line 47 of file G4LatticeManager.hh.

Member Typedef Documentation

◆ LatticeLogReg

Definition at line 89 of file G4LatticeManager.hh.

◆ LatticeMatMap

Definition at line 88 of file G4LatticeManager.hh.

◆ LatticePhyReg

Definition at line 95 of file G4LatticeManager.hh.

◆ LatticeVolMap

Member Function Documentation

◆ Clear()

void G4LatticeManager::Clear ( )
protected

Definition at line 79 of file G4LatticeManager.cc.

79 {
80 fPLatticeList.clear();
81 fPLattices.clear();
82
83 fLLatticeList.clear();
84 fLLattices.clear();
85}
LatticeMatMap fLLatticeList
LatticeLogReg fLLattices
LatticePhyReg fPLattices
LatticeVolMap fPLatticeList

Referenced by Reset().

◆ GetLattice() [1/2]

G4LatticeLogical * G4LatticeManager::GetLattice ( G4Material * Mat) const

Definition at line 209 of file G4LatticeManager.cc.

209 {
210 LatticeMatMap::const_iterator latFind = fLLatticeList.find(Mat);
211 if (latFind != fLLatticeList.end()) {
212 if (verboseLevel)
213 G4cout << "G4LatticeManager::GetLattice found " << latFind->second
214 << " for "<< (Mat ? Mat->GetName() : G4String("NULL")) << "."
215 << G4endl;
216 return latFind->second;
217 }
218
219 if (verboseLevel)
220 G4cerr << "G4LatticeManager:: Found no matching lattices for "
221 << (Mat ? Mat->GetName() : G4String("NULL")) << "." << G4endl;
222
223 return nullptr; // No lattice associated with volume
224}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const

Referenced by MapKtoV(), MapKtoVDir(), and G4VPhononProcess::StartTracking().

◆ GetLattice() [2/2]

G4LatticePhysical * G4LatticeManager::GetLattice ( G4VPhysicalVolume * Vol) const

Definition at line 229 of file G4LatticeManager.cc.

229 {
230 LatticeVolMap::const_iterator latFind = fPLatticeList.find(Vol);
231 if (latFind != fPLatticeList.end()) {
232 if (verboseLevel)
233 G4cout << "G4LatticeManager::GetLattice found " << latFind->second
234 << " for " << (Vol ? Vol->GetName() : G4String("default")) << "."
235 << G4endl;
236 return latFind->second;
237 }
238
239 if (verboseLevel)
240 G4cerr << "G4LatticeManager::GetLattice found no matching lattices for "
241 << (Vol ? Vol->GetName() : G4String("default")) << "." << G4endl;
242
243 return nullptr; // No lattice associated with volume
244}
const G4String & GetName() const

◆ GetLatticeManager()

G4LatticeManager * G4LatticeManager::GetLatticeManager ( )
static

Definition at line 89 of file G4LatticeManager.cc.

89 {
90 // if no lattice manager exists, create one.
91 G4AutoLock latLock(&latMutex); // Protect before changing pointer
92 if (!fLM) fLM = new G4LatticeManager();
93 latLock.unlock();
94
95 return fLM;
96}

Referenced by G4VPhononProcess::StartTracking().

◆ HasLattice() [1/2]

G4bool G4LatticeManager::HasLattice ( G4Material * Mat) const

Definition at line 256 of file G4LatticeManager.cc.

256 {
257 return (fLLatticeList.find(Mat) != fLLatticeList.end());
258}

◆ HasLattice() [2/2]

G4bool G4LatticeManager::HasLattice ( G4VPhysicalVolume * Vol) const

Definition at line 250 of file G4LatticeManager.cc.

250 {
251 return (fPLatticeList.find(Vol) != fPLatticeList.end());
252}

◆ LoadLattice() [1/2]

G4LatticeLogical * G4LatticeManager::LoadLattice ( G4Material * Mat,
const G4String & latDir )

Definition at line 122 of file G4LatticeManager.cc.

123 {
124 if (verboseLevel) {
125 G4cout << "G4LatticeManager::LoadLattice material " << Mat->GetName()
126 << " " << latDir << G4endl;
127 }
128
129 G4LatticeReader latReader(verboseLevel);
130 G4LatticeLogical* newLat = latReader.MakeLattice(latDir+"/config.txt");
131 if (verboseLevel>1) G4cout << " Created newLat " << newLat << G4endl;
132
133 if (newLat) RegisterLattice(Mat, newLat);
134 else {
135 G4cerr << "ERROR creating " << latDir << " lattice for material "
136 << Mat->GetName() << G4endl;
137 }
138
139 return newLat;
140}
G4bool RegisterLattice(G4VPhysicalVolume *, G4LatticePhysical *)

Referenced by LoadLattice().

◆ LoadLattice() [2/2]

G4LatticePhysical * G4LatticeManager::LoadLattice ( G4VPhysicalVolume * Vol,
const G4String & latDir )

Definition at line 144 of file G4LatticeManager.cc.

145 {
146 if (verboseLevel) {
147 G4cout << "G4LatticeManager::LoadLattice volume " << Vol->GetName()
148 << " " << latDir << G4endl;
149 }
150
151 G4Material* theMat = Vol->GetLogicalVolume()->GetMaterial();
152
153 // Create and register the logical lattice, then the physical lattice
154 G4LatticeLogical* lLattice = LoadLattice(theMat, latDir);
155 if (!lLattice) return 0;
156
157 G4LatticePhysical* pLattice =
158 new G4LatticePhysical(lLattice, Vol->GetFrameRotation());
159 if (pLattice) RegisterLattice(Vol, pLattice);
160
161 if (verboseLevel>1) G4cout << " Created pLattice " << pLattice << G4endl;
162
163 return pLattice;
164}
G4LatticeLogical * LoadLattice(G4Material *, const G4String &latDir)
G4Material * GetMaterial() const
G4LogicalVolume * GetLogicalVolume() const
const G4RotationMatrix * GetFrameRotation() const

◆ MapKtoV()

G4double G4LatticeManager::MapKtoV ( G4VPhysicalVolume * Vol,
G4int polarizationState,
const G4ThreeVector & k ) const

Definition at line 266 of file G4LatticeManager.cc.

268 {
269 G4LatticePhysical* theLattice = GetLattice(Vol);
270 if (verboseLevel)
271 G4cout << "G4LatticeManager::MapKtoV using lattice " << theLattice
272 << G4endl;
273
274 // If no lattice available, use generic "speed of sound"
275 return theLattice ? theLattice->MapKtoV(polarizationState, k) : 300.*m/s;
276}
G4LatticeLogical * GetLattice(G4Material *) const
G4double MapKtoV(G4int, G4ThreeVector) const

◆ MapKtoVDir()

G4ThreeVector G4LatticeManager::MapKtoVDir ( G4VPhysicalVolume * Vol,
G4int polarizationState,
const G4ThreeVector & k ) const

Definition at line 284 of file G4LatticeManager.cc.

286 {
287 G4LatticePhysical* theLattice = GetLattice(Vol);
288 if (verboseLevel)
289 G4cout << "G4LatticeManager::MapKtoVDir using lattice " << theLattice
290 << G4endl;
291
292 // If no lattice available, propagate along input wavevector
293 return theLattice ? theLattice->MapKtoVDir(polarizationState, k) : k.unit();
294}
Hep3Vector unit() const
G4ThreeVector MapKtoVDir(G4int, G4ThreeVector) const

◆ RegisterLattice() [1/3]

G4bool G4LatticeManager::RegisterLattice ( G4Material * Mat,
G4LatticeLogical * Lat )

Definition at line 102 of file G4LatticeManager.cc.

103 {
104 if (!Mat || !Lat) return false; // Don't register null pointers
105
106 G4AutoLock latLock(&latMutex); // Protect before changing registry
107 fLLattices.insert(Lat); // Take ownership in registry
108 fLLatticeList[Mat] = Lat;
109 latLock.unlock();
110
111 if (verboseLevel) {
112 G4cout << "G4LatticeManager::RegisterLattice: "
113 << " Total number of logical lattices: " << fLLatticeList.size()
114 << " (" << fLLattices.size() << " unique)" << G4endl;
115 }
116
117 return true;
118}

◆ RegisterLattice() [2/3]

G4bool G4LatticeManager::RegisterLattice ( G4VPhysicalVolume * Vol,
G4LatticeLogical * LLat )

Definition at line 194 of file G4LatticeManager.cc.

195 {
196 if (!Vol || !LLat) return false; // Don't register null pointers
197
198 // Make sure logical lattice is registered for material
200
201 // Create and register new physical lattice to go with volume
202 return RegisterLattice(Vol, new G4LatticePhysical(LLat, Vol->GetFrameRotation()));
203}

◆ RegisterLattice() [3/3]

G4bool G4LatticeManager::RegisterLattice ( G4VPhysicalVolume * Vol,
G4LatticePhysical * Lat )

Definition at line 171 of file G4LatticeManager.cc.

172 {
173 if (!Vol || !Lat) return false; // Don't register null pointers
174
175 G4AutoLock latLock(&latMutex); // Protect before changing registry
176
177 // SPECIAL: Register first lattice with a null volume to act as default
178 if (fPLatticeList.empty()) fPLatticeList[0] = Lat;
179
180 fPLattices.insert(Lat);
181 fPLatticeList[Vol] = Lat;
182
183 latLock.unlock();
184
185 if (verboseLevel) {
186 G4cout << "G4LatticeManager::RegisterLattice: "
187 << " Total number of physical lattices: " << fPLatticeList.size()-1
188 << " (" << fPLattices.size() << " unique)" << G4endl;
189 }
190
191 return true;
192}

Referenced by LoadLattice(), LoadLattice(), and RegisterLattice().

◆ Reset()

void G4LatticeManager::Reset ( )

Definition at line 63 of file G4LatticeManager.cc.

63 {
64 for (LatticeLogReg::iterator lm=fLLattices.begin();
65 lm != fLLattices.end(); ++lm) {
66 delete (*lm);
67 }
68
69 for (LatticePhyReg::iterator pm=fPLattices.begin();
70 pm != fPLattices.end(); ++pm) {
71 delete (*pm);
72 }
73
74 Clear();
75}

◆ SetVerboseLevel()

void G4LatticeManager::SetVerboseLevel ( G4int vb)
inline

Definition at line 54 of file G4LatticeManager.hh.

54{ verboseLevel = vb; }

Member Data Documentation

◆ fLLatticeList

LatticeMatMap G4LatticeManager::fLLatticeList
protected

Definition at line 92 of file G4LatticeManager.hh.

Referenced by Clear(), GetLattice(), HasLattice(), and RegisterLattice().

◆ fLLattices

LatticeLogReg G4LatticeManager::fLLattices
protected

Definition at line 91 of file G4LatticeManager.hh.

Referenced by Clear(), RegisterLattice(), and Reset().

◆ fPLatticeList

LatticeVolMap G4LatticeManager::fPLatticeList
protected

Definition at line 98 of file G4LatticeManager.hh.

Referenced by Clear(), GetLattice(), HasLattice(), and RegisterLattice().

◆ fPLattices

LatticePhyReg G4LatticeManager::fPLattices
protected

Definition at line 97 of file G4LatticeManager.hh.

Referenced by Clear(), RegisterLattice(), and Reset().

◆ verboseLevel

G4int G4LatticeManager::verboseLevel
protected

The documentation for this class was generated from the following files: