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,v 1.2 2008/10/24 14:00:03 gcosmo Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-cand-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // -------------------------------------------------------------------- |
---|
32 | // GEANT 4 class implementation file |
---|
33 | // -------------------------------------------------------------------- |
---|
34 | |
---|
35 | #include "G4ErrorPropagationNavigator.hh" |
---|
36 | |
---|
37 | #include "globals.hh" |
---|
38 | #include "G4ThreeVector.hh" |
---|
39 | #include "G4ErrorPropagatorData.hh" |
---|
40 | #include "G4ErrorSurfaceTarget.hh" |
---|
41 | |
---|
42 | //------------------------------------------------------------------- |
---|
43 | |
---|
44 | G4ErrorPropagationNavigator::G4ErrorPropagationNavigator() |
---|
45 | : G4Navigator() |
---|
46 | { |
---|
47 | } |
---|
48 | |
---|
49 | //------------------------------------------------------------------- |
---|
50 | |
---|
51 | G4ErrorPropagationNavigator::~G4ErrorPropagationNavigator() |
---|
52 | { |
---|
53 | } |
---|
54 | |
---|
55 | //------------------------------------------------------------------- |
---|
56 | |
---|
57 | G4double G4ErrorPropagationNavigator:: |
---|
58 | ComputeStep ( const G4ThreeVector &pGlobalPoint, |
---|
59 | const G4ThreeVector &pDirection, |
---|
60 | const G4double pCurrentProposedStepLength, |
---|
61 | G4double &pNewSafety ) |
---|
62 | { |
---|
63 | G4double Step = G4Navigator::ComputeStep(pGlobalPoint, pDirection, |
---|
64 | pCurrentProposedStepLength, |
---|
65 | pNewSafety); |
---|
66 | |
---|
67 | G4ErrorPropagatorData * g4edata |
---|
68 | = G4ErrorPropagatorData::GetErrorPropagatorData(); |
---|
69 | |
---|
70 | if (g4edata !=0) |
---|
71 | { |
---|
72 | const G4ErrorTarget* target = g4edata->GetTarget(); |
---|
73 | if( target != 0 ) |
---|
74 | { |
---|
75 | G4double StepPlane(target->GetDistanceFromPoint(pGlobalPoint,pDirection)); |
---|
76 | |
---|
77 | if( StepPlane < 0. ) // Negative means target is crossed, will not be found |
---|
78 | { |
---|
79 | StepPlane = DBL_MAX; |
---|
80 | } |
---|
81 | #ifdef G4VERBOSE |
---|
82 | if( G4ErrorPropagatorData::verbose() >= 4 ) |
---|
83 | { |
---|
84 | G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl |
---|
85 | << " Target step: " << StepPlane |
---|
86 | << ", Transportation step: " << Step << G4endl; |
---|
87 | target->Dump( "G4ErrorPropagationNavigator::ComputeStep Target " ); |
---|
88 | } |
---|
89 | #endif |
---|
90 | |
---|
91 | if(StepPlane<Step) |
---|
92 | { |
---|
93 | #ifdef G4VERBOSE |
---|
94 | if( G4ErrorPropagatorData::verbose() >= 2 ) |
---|
95 | { |
---|
96 | G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl |
---|
97 | << " TargetCloserThanBoundary: " << StepPlane << " < " |
---|
98 | << Step << G4endl; |
---|
99 | } |
---|
100 | #endif |
---|
101 | Step = StepPlane; |
---|
102 | g4edata->SetState(G4ErrorState_TargetCloserThanBoundary); |
---|
103 | } |
---|
104 | else |
---|
105 | { |
---|
106 | g4edata->SetState(G4ErrorState_Propagating); |
---|
107 | } |
---|
108 | } |
---|
109 | } |
---|
110 | pNewSafety = ComputeSafety(pGlobalPoint, pCurrentProposedStepLength); |
---|
111 | |
---|
112 | #ifdef G4VERBOSE |
---|
113 | if( G4ErrorPropagatorData::verbose() >= 3 ) |
---|
114 | { |
---|
115 | G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl |
---|
116 | << " Step: " << Step << ", ComputeSafety: " << pNewSafety |
---|
117 | << G4endl; |
---|
118 | } |
---|
119 | #endif |
---|
120 | |
---|
121 | return Step; |
---|
122 | } |
---|
123 | |
---|
124 | //------------------------------------------------------------------- |
---|
125 | |
---|
126 | G4double G4ErrorPropagationNavigator:: |
---|
127 | ComputeSafety( const G4ThreeVector &pGlobalpoint, |
---|
128 | const G4double pMaxLength, |
---|
129 | const G4bool keepState ) |
---|
130 | { |
---|
131 | G4double newSafety = G4Navigator::ComputeSafety(pGlobalpoint, |
---|
132 | pMaxLength, keepState); |
---|
133 | |
---|
134 | G4ErrorPropagatorData *g4edata |
---|
135 | = G4ErrorPropagatorData::GetErrorPropagatorData(); |
---|
136 | |
---|
137 | if (g4edata !=0) |
---|
138 | { |
---|
139 | const G4ErrorTarget* target = g4edata->GetTarget(); |
---|
140 | if( target != 0 ) |
---|
141 | { |
---|
142 | G4double distance = target->GetDistanceFromPoint(pGlobalpoint); |
---|
143 | |
---|
144 | if(distance<newSafety) |
---|
145 | { |
---|
146 | newSafety = distance; |
---|
147 | } |
---|
148 | } |
---|
149 | } |
---|
150 | return newSafety; |
---|
151 | } |
---|