Geant4  10.01
G4ErrorPropagationNavigator.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 //
27 // $Id: G4ErrorPropagationNavigator.cc 86987 2014-11-21 13:05:28Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class implementation file
32 // --------------------------------------------------------------------
33 
35 
36 #include "globals.hh"
37 #include "G4ThreeVector.hh"
38 #include "G4ErrorPropagatorData.hh"
39 #include "G4ErrorSurfaceTarget.hh"
40 
43 
44 
45 //-------------------------------------------------------------------
46 
48  : G4Navigator()
49 {
50 }
51 
52 //-------------------------------------------------------------------
53 
55 {
56 }
57 
58 //-------------------------------------------------------------------
59 
61 ComputeStep ( const G4ThreeVector &pGlobalPoint,
62  const G4ThreeVector &pDirection,
63  const G4double pCurrentProposedStepLength,
64  G4double &pNewSafety )
65 {
66  G4double Step = G4Navigator::ComputeStep(pGlobalPoint, pDirection,
67  pCurrentProposedStepLength,
68  pNewSafety);
69 
70  G4ErrorPropagatorData * g4edata
72 
73  if (g4edata !=0)
74  {
75  const G4ErrorTarget* target = g4edata->GetTarget();
76  if( target != 0 )
77  {
78  G4double StepPlane= target->GetDistanceFromPoint(pGlobalPoint,pDirection);
79 
80  if( StepPlane < 0. ) // Negative means target is crossed, will not be found
81  {
82  StepPlane = DBL_MAX;
83  }
84 #ifdef G4VERBOSE
86  {
87  G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
88  << " Target step: " << StepPlane
89  << ", Transportation step: " << Step << G4endl;
90  target->Dump( "G4ErrorPropagationNavigator::ComputeStep Target " );
91  }
92 #endif
93 
94  if(StepPlane<Step)
95  {
96 #ifdef G4VERBOSE
98  {
99  G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
100  << " TargetCloserThanBoundary: " << StepPlane << " < "
101  << Step << G4endl;
102  }
103 #endif
104  Step = StepPlane;
106  }
107  else
108  {
110  }
111  }
112  }
113  pNewSafety = ComputeSafety(pGlobalPoint, pCurrentProposedStepLength);
114 
115 #ifdef G4VERBOSE
116  if( G4ErrorPropagatorData::verbose() >= 3 )
117  {
118  G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
119  << " Step: " << Step << ", ComputeSafety: " << pNewSafety
120  << G4endl;
121  }
122 #endif
123 
124  return Step;
125 }
126 
127 //-------------------------------------------------------------------
128 
130 ComputeSafety( const G4ThreeVector &pGlobalpoint,
131  const G4double pMaxLength,
132  const G4bool keepState )
133 {
134  G4double newSafety = G4Navigator::ComputeSafety(pGlobalpoint,
135  pMaxLength, keepState);
136 
137  G4ErrorPropagatorData *g4edata
139 
140  if (g4edata !=0)
141  {
142  const G4ErrorTarget* target = g4edata->GetTarget();
143  if( target != 0 )
144  {
145  G4double distance = target->GetDistanceFromPoint(pGlobalpoint);
146 
147  if(distance<newSafety)
148  {
149  newSafety = distance;
150  }
151  }
152  }
153  return newSafety;
154 }
155 
158 {
159  G4ErrorPropagatorData *g4edata
161  const G4ErrorTarget* target = 0;
162 
163  G4ThreeVector normal(0.0, 0.0, 0.0);
164  G4double distance= 0;
165 
166  // Determine which 'geometry' limited the step
167  if (g4edata)
168  {
169  target = g4edata->GetTarget();
170  if(target)
171  {
172  distance = target->GetDistanceFromPoint(point);
173  }
174  }
175 
176  if( distance > kCarTolerance // Not reached the target.
177  || (!target) )
178  // If a target does not exist, this seems the best we can do
179  {
180  normal= G4Navigator::GetGlobalExitNormal(point, valid);
181  }
182  else
183  {
184  switch( target->GetType() )
185  {
187  // The volume is in the 'real' mass geometry
188  normal= G4Navigator::GetGlobalExitNormal(point, valid);
189  break;
190  case G4ErrorTarget_TrkL:
191  normal= G4ThreeVector( 0.0, 0.0, 0.0);
192  *valid= false;
193  G4Exception("G4ErrorPropagationNavigator::GetGlobalExitNormal",
194  "Geometry1003",
195  JustWarning, "Unexpected value of Target type");
196  break;
199  const G4ErrorSurfaceTarget* surfaceTarget=
200  static_cast<const G4ErrorSurfaceTarget*>(target);
201  normal= surfaceTarget->GetTangentPlane(point).normal().unit();
202  *valid= true;
203  break;
204 
205 // default:
206 // normal= G4ThreeVector( 0.0, 0.0, 0.0);
207 // *valid= false;
208 // G4Exception("G4ErrorPropagationNavigator::GetGlobalExitNormal",
209 // "Geometry:003",
210 // FatalException, "Impossible value of Target type");
211 // exit(1);
212 // break;
213  }
214  }
215  return normal;
216 }
217 
CLHEP::Hep3Vector G4ThreeVector
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
Definition: G4Navigator.cc:744
G4ErrorTargetType GetType() const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
virtual void Dump(const G4String &msg) const =0
void SetState(G4ErrorState sta)
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double kCarTolerance
Definition: G4Navigator.hh:361
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
Definition: Step.hh:41
virtual G4double GetDistanceFromPoint(const G4ThreeVector &, const G4ThreeVector &) const
const G4ErrorTarget * GetTarget(G4bool mustExist=0) const
#define G4endl
Definition: G4ios.hh:61
G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
double G4double
Definition: G4Types.hh:76
static G4ErrorPropagatorData * GetErrorPropagatorData()
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
#define DBL_MAX
Definition: templates.hh:83
virtual G4Plane3D GetTangentPlane(const G4ThreeVector &point) const =0