source: trunk/source/geometry/navigation/include/G4Navigator.icc@ 1190

Last change on this file since 1190 was 921, checked in by garnier, 17 years ago

en test de gl2ps. Problemes de libraries

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