75{
77 *blockedExitedVol = nullptr;
81 G4double ourStep = currentProposedStepLength, ourSafety;
83 G4int localNoDaughters, sampleNo;
84 G4bool motherValidExitNormal =
false;
86
89 motherSolid = motherLogical->
GetSolid();
90
91
92
94 ourSafety = motherSafety;
95
97
98#ifdef G4VERBOSE
99 if ( fCheck && ( (localNoDaughters>0) || (ourStep < motherSafety) ) )
100 {
102 }
103#endif
104
105
106
107
108
109 if ( exiting && validExitNormal )
110 {
111 if ( localDirection.
dot(exitNormal)>=kMinExitingNormalCosine )
112 {
113
114
115 blockedExitedVol = (*pBlockedPhysical);
116 ourSafety = 0;
117 }
118 }
119 exiting = false;
120 entering = false;
121
122#ifdef G4VERBOSE
123 if ( fCheck )
124 {
125
126
127
128
129
131 localDirection,
132 true,
133 &motherValidExitNormal,
134 &motherExitNormal);
135
136 if( (motherStep >= kInfinity) || (motherStep < 0.0) )
137 {
138
140
141 ourStep = motherStep = 0.0;
142
143 exiting = true;
144 entering = false;
145
146
147 validExitNormal = motherValidExitNormal;
148 exitNormal = motherExitNormal;
149
150 *pBlockedPhysical = nullptr;
151 blockedReplicaNo = 0;
152
153 newSafety = 0.0;
154 return ourStep;
155 }
156 }
157#endif
158
159 for ( sampleNo=localNoDaughters-1; sampleNo>=0; sampleNo--)
160 {
161 samplePhysical = motherLogical->
GetDaughter(sampleNo);
162 if ( samplePhysical!=blockedExitedVol )
163 {
166 sampleTf.Invert();
167 const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
172
173 if ( sampleSafety<ourSafety )
174 {
175 ourSafety=sampleSafety;
176 }
177
178 if ( sampleSafety<=ourStep )
179 {
180 sampleDirection = sampleTf.TransformAxis(localDirection);
183#ifdef G4VERBOSE
184 if( fCheck )
185 {
187 sampleSafety, true,
188 sampleDirection, sampleStep);
189 }
190#endif
191 if ( sampleStep<=ourStep )
192 {
193 ourStep = sampleStep;
194 entering = true;
195 exiting = false;
196 *pBlockedPhysical = samplePhysical;
197 blockedReplicaNo = -1;
198#ifdef G4VERBOSE
199 if( fCheck )
200 {
202 sampleDirection, localDirection,
203 sampleSafety, sampleStep);
204 }
205#endif
206 }
207
208#ifdef G4VERBOSE
209 if( fCheck && (sampleStep < kInfinity) && (sampleStep >= motherStep) )
210 {
211
212
214 samplePoint, sampleDirection,
215 motherSolid,
216 localPoint, localDirection,
217 motherStep, sampleStep);
218 }
219#endif
220 }
221#ifdef G4VERBOSE
222 else if ( fCheck )
223 {
225 sampleSafety, false,
227 }
228#endif
229 }
230 }
231 if ( currentProposedStepLength<ourSafety )
232 {
233
234
235 entering = false;
236 exiting = false;
237 *pBlockedPhysical = nullptr;
238 ourStep = kInfinity;
239 }
240 else
241 {
242
243
244 if ( motherSafety<=ourStep )
245 {
246 if ( !fCheck )
247 {
249 localDirection,
250 true,
251 &motherValidExitNormal,
252 &motherExitNormal);
253 }
254#ifdef G4VERBOSE
255 else
256 {
258 motherStep, motherSafety);
259 if( motherValidExitNormal )
260 {
262 localPoint,
263 localDirection,
264 motherStep,
265 motherSolid,
266 "From motherSolid::DistanceToOut" );
267 }
268 }
269#endif
270
271 if( (motherStep >= kInfinity) || (motherStep < 0.0) )
272 {
273#ifdef G4VERBOSE
274 if( fCheck )
275 {
277 motherPhysical);
278 }
279#endif
280 ourStep = motherStep = 0.0;
281 exiting = true;
282 entering = false;
283
284
285
286
287 validExitNormal = false;
288 *pBlockedPhysical = nullptr;
289 blockedReplicaNo = 0;
290 newSafety= 0.0;
291 return ourStep;
292 }
293
294 if ( motherStep<=ourStep )
295 {
296 ourStep = motherStep;
297 exiting = true;
298 entering = false;
299 validExitNormal = motherValidExitNormal;
300 exitNormal = motherExitNormal;
301
302 if ( motherValidExitNormal )
303 {
305 if (rot)
306 {
308#ifdef G4VERBOSE
309 if( fCheck )
311 motherExitNormal,
312 *rot,
313 "From RotationMatrix" );
314#endif
315 }
316 }
317 }
318 else
319 {
320 validExitNormal = false;
321 }
322 }
323 }
324 newSafety = ourSafety;
325 return ourStep;
326}
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const
HepRotation inverse() const
void PreComputeStepLog(const G4VPhysicalVolume *motherPhysical, G4double motherSafety, const G4ThreeVector &localPoint) const
void CheckDaughterEntryPoint(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double sampleStep) const
void PrintDaughterLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, G4double sampleSafety, G4bool onlySafety, const G4ThreeVector &sampleDirection, G4double sampleStep) const
G4bool CheckAndReportBadNormal(const G4ThreeVector &unitNormal, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double step, const G4VSolid *solid, const char *msg) const
void PostComputeStepLog(const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) const
void ReportOutsideMother(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4VPhysicalVolume *motherPV, G4double tDist=30.0 *CLHEP::cm) const
void AlongComputeStepLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4ThreeVector &localDirection, G4double sampleSafety, G4double sampleStep) const