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