Geant4-11
G4ITNavigator1.icc
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//
27//
28// class G4ITNavigator1 Inline implementation
29//
30// G4ITNavigator1 is a duplicate version of G4Navigator started from Geant4.9.5
31// initially written by Paul Kent and colleagues.
32// The only difference resides in the way the information is saved and managed
33//
34// ********************************************************************
35
36// ********************************************************************
37// GetCurrentLocalCoordinate
38//
39// Returns the local coordinate of the current track
40// ********************************************************************
41//
42inline
43G4ThreeVector G4ITNavigator1::GetCurrentLocalCoordinate() const
44{
45 return fLastLocatedPointLocal;
46}
47
48// ********************************************************************
49// ComputeLocalAxis
50//
51// Returns local direction of vector direction in world coord system
52// ********************************************************************
53//
54inline
55G4ThreeVector G4ITNavigator1::ComputeLocalAxis(const G4ThreeVector& pVec) const
56{
57 return (fHistory.GetTopTransform().IsRotated())
58 ? fHistory.GetTopTransform().TransformAxis(pVec) : pVec ;
59}
60
61// ********************************************************************
62// ComputeLocalPoint
63//
64// Returns local coordinates of a point in the world coord system
65// ********************************************************************
66//
67inline
68G4ThreeVector
69G4ITNavigator1::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const
70{
71 return ( fHistory.GetTopTransform().TransformPoint(pGlobalPoint) ) ;
72}
73
74// ********************************************************************
75// GetWorldVolume
76//
77// Returns the current world (`topmost') volume
78// ********************************************************************
79//
80inline
81G4VPhysicalVolume* G4ITNavigator1::GetWorldVolume() const
82{
83 return fTopPhysical;
84}
85
86// ********************************************************************
87// SetWorldVolume
88//
89// Sets the world (`topmost') volume
90// ********************************************************************
91//
92inline
93void G4ITNavigator1::SetWorldVolume(G4VPhysicalVolume* pWorld)
94{
95 if ( !(pWorld->GetTranslation()==G4ThreeVector(0,0,0)) )
96 {
97 G4Exception ("G4ITNavigator1::SetWorldVolume()", "GeomNav0002",
98 FatalException, "Volume must be centered on the origin.");
99 }
100 const G4RotationMatrix* rm = pWorld->GetRotation();
101 if ( rm && (!rm->isIdentity()) )
102 {
103 G4Exception ("G4ITNavigator1::SetWorldVolume()", "GeomNav0002",
104 FatalException, "Volume must not be rotated.");
105 }
106 fTopPhysical = pWorld;
107 fHistory.SetFirstEntry(pWorld);
108}
109
110// ********************************************************************
111// SetGeometrycallyLimitedStep
112//
113// Informs the navigator that the previous Step calculated
114// by the geometry was taken in its entirety
115// ********************************************************************
116//
117inline
118void G4ITNavigator1::SetGeometricallyLimitedStep()
119{
120 fWasLimitedByGeometry=true;
121}
122
123// ********************************************************************
124// ResetStackAndState
125//
126// Resets stack and minimum of navigator state `machine'
127// ********************************************************************
128//
129inline
130void G4ITNavigator1::ResetStackAndState()
131{
132 fHistory.Reset();
133 ResetState();
134}
135
136// ********************************************************************
137// VolumeType
138// ********************************************************************
139//
140inline
141EVolume G4ITNavigator1::VolumeType(const G4VPhysicalVolume *pVol) const
142{
143 return pVol->VolumeType();
144}
145
146// ********************************************************************
147// CharacteriseDaughters
148// ********************************************************************
149//
150inline
151EVolume G4ITNavigator1::CharacteriseDaughters(const G4LogicalVolume *pLog) const
152{
153 return pLog->CharacteriseDaughters();
154}
155
156// ********************************************************************
157// GetDaughtersRegularStructureId
158// ********************************************************************
159//
160inline
161G4int G4ITNavigator1::
162GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
163{
164 G4int regId = 0;
165 G4VPhysicalVolume *pVol;
166
167 if ( pLog->GetNoDaughters()==1 )
168 {
169 pVol = pLog->GetDaughter(0);
170 regId = pVol->GetRegularStructureId();
171 }
172 return regId;
173}
174
175// ********************************************************************
176// GetGlobalToLocalTransform
177//
178// Returns local to global transformation.
179// I.e. transformation that will take point or axis in world coord system
180// and return one in the local coord system
181// ********************************************************************
182//
183inline
184const G4AffineTransform& G4ITNavigator1::GetGlobalToLocalTransform() const
185{
186 return fHistory.GetTopTransform();
187}
188
189// ********************************************************************
190// GetLocalToGlobalTransform
191//
192// Returns global to local transformation
193// ********************************************************************
194//
195inline
196const G4AffineTransform G4ITNavigator1::GetLocalToGlobalTransform() const
197{
198 G4AffineTransform tempTransform;
199 tempTransform = fHistory.GetTopTransform().Inverse();
200 return tempTransform;
201}
202
203// ********************************************************************
204// NetTranslation
205//
206// Computes+returns the local->global translation of current volume
207// ********************************************************************
208//
209inline
210G4ThreeVector G4ITNavigator1::NetTranslation() const
211{
212 G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
213 return tf.NetTranslation();
214}
215
216// ********************************************************************
217// NetRotation
218//
219// Computes+returns the local->global rotation of current volume
220// ********************************************************************
221//
222inline
223G4RotationMatrix G4ITNavigator1::NetRotation() const
224{
225 G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
226 return tf.NetRotation();
227}
228
229// ********************************************************************
230// CreateGRSVolume
231//
232// `Touchable' creation method: caller has deletion responsibility
233// ********************************************************************
234//
235inline
236G4GRSVolume* G4ITNavigator1::CreateGRSVolume() const
237{
238 G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
239 return new G4GRSVolume(fHistory.GetTopVolume(),
240 tf.NetRotation(),
241 tf.NetTranslation());
242}
243
244// ********************************************************************
245// CreateGRSSolid
246//
247// `Touchable' creation method: caller has deletion responsibility
248// ********************************************************************
249//
250inline
251G4GRSSolid* G4ITNavigator1::CreateGRSSolid() const
252{
253 G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
254 return new G4GRSSolid(fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid(),
255 tf.NetRotation(),
256 tf.NetTranslation());
257}
258
259// ********************************************************************
260// CreateTouchableHistory
261//
262// `Touchable' creation method: caller has deletion responsibility
263// ********************************************************************
264//
265inline
266G4TouchableHistory* G4ITNavigator1::CreateTouchableHistory() const
267{
268 return new G4TouchableHistory(fHistory);
269}
270
271// ********************************************************************
272// CreateTouchableHistory(history)
273//
274// `Touchable' creation method: caller has deletion responsibility
275// ********************************************************************
276//
277inline
278G4TouchableHistory*
279G4ITNavigator1::CreateTouchableHistory(const G4NavigationHistory* history) const
280{
281 return new G4TouchableHistory(*history);
282}
283
284// ********************************************************************
285// LocateGlobalPointAndUpdateTouchableHandle
286// ********************************************************************
287//
288inline
289void G4ITNavigator1::LocateGlobalPointAndUpdateTouchableHandle(
290 const G4ThreeVector& position,
291 const G4ThreeVector& direction,
292 G4TouchableHandle& oldTouchableToUpdate,
293 const G4bool RelativeSearch )
294{
295 G4VPhysicalVolume* pPhysVol;
296 pPhysVol = LocateGlobalPointAndSetup( position,&direction,RelativeSearch );
297 if( fEnteredDaughter || fExitedMother )
298 {
299 oldTouchableToUpdate = CreateTouchableHistory();
300 if( pPhysVol == 0 )
301 {
302 // We want to ensure that the touchable is correct in this case.
303 // The method below should do this and recalculate a lot more ....
304 //
305 oldTouchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
306 }
307 }
308 return;
309}
310
311// ********************************************************************
312// LocateGlobalPointAndUpdateTouchable
313//
314// Use direction
315// ********************************************************************
316//
317inline
318void G4ITNavigator1::LocateGlobalPointAndUpdateTouchable(
319 const G4ThreeVector& position,
320 const G4ThreeVector& direction,
321 G4VTouchable* touchableToUpdate,
322 const G4bool RelativeSearch )
323{
324 G4VPhysicalVolume* pPhysVol;
325 pPhysVol = LocateGlobalPointAndSetup( position, &direction, RelativeSearch);
326 touchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
327}
328
329// ********************************************************************
330// LocateGlobalPointAndUpdateTouchable
331// ********************************************************************
332//
333inline
334void G4ITNavigator1::LocateGlobalPointAndUpdateTouchable(
335 const G4ThreeVector& position,
336 G4VTouchable* touchableToUpdate,
337 const G4bool RelativeSearch )
338{
339 G4VPhysicalVolume* pPhysVol;
340 pPhysVol = LocateGlobalPointAndSetup( position, 0, RelativeSearch);
341 touchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
342}
343
344// ********************************************************************
345// GetVerboseLevel
346// ********************************************************************
347//
348inline
349G4int G4ITNavigator1::GetVerboseLevel() const
350{
351 return fVerbose;
352}
353
354// ********************************************************************
355// SetVerboseLevel
356// ********************************************************************
357//
358inline
359void G4ITNavigator1::SetVerboseLevel(G4int level)
360{
361 fVerbose = level;
362 fnormalNav.SetVerboseLevel(level);
363 fvoxelNav.SetVerboseLevel(level);
364 fparamNav.SetVerboseLevel(level);
365 freplicaNav.SetVerboseLevel(level);
366 fregularNav.SetVerboseLevel(level);
367}
368
369// ********************************************************************
370// IsActive
371// ********************************************************************
372//
373inline
374G4bool G4ITNavigator1::IsActive() const
375{
376 return fActive;
377}
378
379// ********************************************************************
380// Activate
381// ********************************************************************
382//
383inline
384void G4ITNavigator1::Activate(G4bool flag)
385{
386 fActive = flag;
387}
388
389// ********************************************************************
390// EnteredDaughterVolume
391//
392// To inform the caller if the track is entering a daughter volume
393// ********************************************************************
394//
395inline
396G4bool G4ITNavigator1::EnteredDaughterVolume() const
397{
398 return fEnteredDaughter;
399}
400
401// ********************************************************************
402// ExitedMotherVolume
403// ********************************************************************
404//
405inline
406G4bool G4ITNavigator1::ExitedMotherVolume() const
407{
408 return fExitedMother;
409}
410
411// ********************************************************************
412// CheckMode
413// ********************************************************************
414//
415inline
416void G4ITNavigator1::CheckMode(G4bool mode)
417{
418 fCheck = mode;
419 fnormalNav.CheckMode(mode);
420 fvoxelNav.CheckMode(mode);
421 fparamNav.CheckMode(mode);
422 freplicaNav.CheckMode(mode);
423 fregularNav.CheckMode(mode);
424}
425
426// ********************************************************************
427// IsCheckModeActive
428// ********************************************************************
429//
430inline
431G4bool G4ITNavigator1::IsCheckModeActive() const
432{
433 return fCheck;
434}
435
436// ********************************************************************
437// SetPushVerbosity
438// ********************************************************************
439//
440inline
441void G4ITNavigator1::SetPushVerbosity(G4bool mode)
442{
443 fWarnPush = mode;
444}
445
446// ********************************************************************
447// SeverityOfZeroStepping
448//
449// Reports on severity of error in case Navigator is stuck
450// and is returning zero steps
451// ********************************************************************
452//
453inline
454G4int G4ITNavigator1::SeverityOfZeroStepping( G4int* noZeroSteps ) const
455{
456 G4int severity=0, noZeros= fNumberZeroSteps;
457 if( noZeroSteps) *noZeroSteps = fNumberZeroSteps;
458
459 if( noZeros >= fAbandonThreshold_NoZeroSteps )
460 {
461 severity = 10;
462 }
463 if( noZeros > 0 && noZeros < fActionThreshold_NoZeroSteps )
464 {
465 severity = 5 * noZeros / fActionThreshold_NoZeroSteps;
466 }
467 else if( noZeros == fActionThreshold_NoZeroSteps )
468 {
469 severity = 5;
470 }
471 else if( noZeros >= fAbandonThreshold_NoZeroSteps - 2 )
472 {
473 severity = 9;
474 }
475 else if( noZeros < fAbandonThreshold_NoZeroSteps - 2 )
476 {
477 severity = 5 + 4 * (noZeros-fAbandonThreshold_NoZeroSteps)
478 / fActionThreshold_NoZeroSteps;
479 }
480 return severity;
481}
482
483// ********************************************************************
484// EnableBestSafety
485// ********************************************************************
486//
487inline void G4ITNavigator1::EnableBestSafety( G4bool value )
488{
489 fvoxelNav.EnableBestSafety( value );
490}