1140{
1141 const G4double toleratedRelativeError= 1.0e-10;
1142 G4double minStep= kInfinity, newSafety=0.0;
1146
1147#ifdef G4DEBUG_PATHFINDER
1149 if( fVerboseLevel > 2 )
1150 {
1151 G4cout <<
" G4PathFinder::DoNextCurvedStep ****** " <<
G4endl;
1152 G4cout <<
" Initial value of field track is " << fieldTrack
1153 <<
" and proposed step= " << proposedStepLength <<
G4endl;
1154 }
1155#endif
1156
1157 fPreStepCenterRenewed= true;
1158
1159 if( fNoActiveNavigators > 1 )
1160 {
1161
1162
1163 G4double minSafety= kInfinity, safety;
1164 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1165 {
1166 safety= fpNavigator[numNav]->
ComputeSafety( startPoint,
false );
1167 fPreSafetyValues[numNav]= safety;
1168 fCurrentPreStepSafety[numNav]= safety;
1169 minSafety = std::min( safety, minSafety );
1170 }
1171
1172
1173
1174 fPreSafetyLocation= startPoint;
1175 fPreSafetyMinValue= minSafety;
1176 fPreStepLocation= startPoint;
1177 fMinSafety_PreStepPt= minSafety;
1178 }
1179
1180
1181
1182 minStep= fpFieldPropagator->
ComputeStep( fieldTrack,
1183 proposedStepLength,
1184 newSafety,
1185 pCurrentPhysicalVolume );
1186
1187
1188
1189 fEndState= fieldTrack;
1190 fMinStep= minStep;
1191 fTrueMinStep = std::min( minStep, proposedStepLength );
1192
1193 if( fNoActiveNavigators== 1 )
1194 {
1195
1196
1197
1198 fPreSafetyValues[0]= newSafety;
1199 fPreSafetyLocation= startPoint;
1200 fPreSafetyMinValue= newSafety;
1201
1202
1203
1204 fCurrentPreStepSafety[0]= newSafety;
1205 fPreStepLocation= startPoint;
1206 fMinSafety_PreStepPt= newSafety;
1207 }
1208
1209#ifdef G4DEBUG_PATHFINDER
1210 if( fVerboseLevel > 2 )
1211 {
1212 G4cout <<
"G4PathFinder::DoNextCurvedStep : " <<
G4endl
1213 <<
" initialState = " << initialState <<
G4endl
1214 <<
" and endState = " << fEndState <<
G4endl;
1215 G4cout <<
"G4PathFinder::DoNextCurvedStep : "
1216 << " minStep = " << minStep
1217 << " proposedStepLength " << proposedStepLength
1218 <<
" safety = " << newSafety <<
G4endl;
1219 }
1220#endif
1222 if( minStep < proposedStepLength )
1223 {
1224
1225
1226
1228 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1229 {
1230 G4double finalStep, lastPreSafety=0.0, minStepLast;
1233
1235 minStepLast, didLimit );
1236
1237
1238
1239
1240 currentStepSize = fTrueMinStep;
1242 if( (minStepLast != kInfinity) )
1243 {
1244 diffStep = (finalStep-minStepLast);
1245 if ( std::abs(diffStep) <= toleratedRelativeError * finalStep )
1246 {
1247 diffStep = 0.0;
1248 }
1249 currentStepSize += diffStep;
1250 }
1251 fCurrentStepSize[numNav] = currentStepSize;
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264 fLimitedStep[numNav] = didLimit;
1265 fLimitTruth[numNav] = limited = (didLimit !=
kDoNot );
1266 if( limited ) { noLimited++; }
1267
1268#ifdef G4DEBUG_PATHFINDER
1269 G4bool StepError= (currentStepSize < 0)
1270 || ( (minStepLast != kInfinity) && (diffStep < 0) ) ;
1271 if( StepError || (fVerboseLevel > 2) )
1272 {
1274
1275 G4cout <<
" G4PathFinder::ComputeStep. Geometry " << numNav
1276 << " step= " << fCurrentStepSize[numNav]
1277 << " from final-step= " << finalStep
1278 << " fTrueMinStep= " << fTrueMinStep
1279 << " minStepLast= " << minStepLast
1280 << " limited = " << (fLimitTruth[numNav] ? "YES" : " NO")
1281 << " ";
1282 G4cout <<
" status = " << limitedString <<
" #= " << didLimit
1284
1285 if( StepError )
1286 {
1287 std::ostringstream message;
1288 message << "Incorrect calculation of step size for one navigator"
1290 << " currentStepSize = " << currentStepSize
1291 <<
", diffStep= " << diffStep <<
G4endl
1292 << "ERROR in computing step size for this navigator.";
1295 }
1296 }
1297#endif
1298 }
1299
1300 fNoGeometriesLimiting= noLimited;
1301 }
1302 else if ( (minStep == proposedStepLength)
1303 || (minStep == kInfinity)
1304 || ( std::abs(minStep-proposedStepLength)
1305 < toleratedRelativeError * proposedStepLength ) )
1306 {
1307
1308
1309
1310
1311
1312
1313
1314 currentStepSize= minStep;
1315 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1316 {
1317 fCurrentStepSize[numNav] = minStep;
1318
1319 fLimitedStep[numNav] =
kDoNot;
1320 fLimitTruth[numNav] = false;
1321 }
1322 fNoGeometriesLimiting= 0;
1323 }
1324 else
1325 {
1326 std::ostringstream message;
1327 message <<
"Incorrect calculation of step size for one navigator." <<
G4endl
1328 << " currentStepSize = " << minStep << " is larger than "
1329 << " proposed StepSize = " << proposedStepLength << ".";
1332 }
1333
1334#ifdef G4DEBUG_PATHFINDER
1335 if( fVerboseLevel > 2 )
1336 {
1337 G4cout <<
" Exiting G4PathFinder::DoNextCurvedStep " <<
G4endl;
1339 }
1341#endif
1342
1343 return minStep;
1344}
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
G4String & LimitedString(ELimited lim)
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=0)