- istep = 0;
- if (mcgeom->IsDebugging()) printf(" boundary: step made %g\n", snext);
- while (gGeoManager->IsSameLocation() && steptot<propStep) {
- if (istep>1E3) {
- printf("Geometry error: could not cross boundary after extra 10 microns\n");
- return;
- }
- for (i=0;i<3;i++) point[i]+=1E-6*dir[i];
- gGeoManager->FindNode();
- sLt[lttcFlag] += 1E-6;
- retStep = sLt[lttcFlag];
- steptot += 1E-6;
- istep++;
- }
- if (steptot>propStep) {printf("Error\n");return;}
- // we managed to cross the boundary -> in which region
- newReg = (gGeoManager->IsOutside())?(mcgeom->NofVolumes()+1):gGeoManager->GetCurrentVolume()->GetNumber();
- lttcFlag++; //1
- newLttc = (gGeoManager->IsOutside())?999999999:gGeoManager->GetCurrentNodeId()+1;
- sLt[lttcFlag] = snext; // at 1
- jrLt[lttcFlag] = newLttc;
- sLt[lttcFlag+1] = 0.;
- jrLt[lttcFlag+1] = -1;
- // !!!!!!!!!!
-
- while (newReg==oldReg && steptot<propStep) {
- if (mcgeom->IsDebugging()) printf(" Entered SAME region... continue\n");
- pst = propStep-steptot;
- gGeoManager->FindNextBoundary(-pst);
- snext = gGeoManager->GetStep();
- steptot += snext;
- if (snext<pst) {
- printf("Found new boundary\n");
- sLt[lttcFlag] = snext;
- retStep = steptot; // ???
- for (i=0;i<3;i++) point[i]+=(snext+1E-6)*dir[i];
- steptot += 1E-6;
- gGeoManager->FindNode();
- if (gGeoManager->IsSameLocation()) {
- printf("Cannot cross boundary\n");
- break;
- }
- newReg = (gGeoManager->IsOutside())?(mcgeom->NofVolumes()+1):gGeoManager->GetCurrentVolume()->GetNumber();
- newLttc = (gGeoManager->IsOutside())?999999999:gGeoManager->GetCurrentNodeId()+1;
- if (mcgeom->IsDebugging()) printf("Found newreg=%i, newLttc=%i, lttFlag is: %i\n", newReg, newLttc, lttcFlag);
- sLt[lttcFlag-1] += snext; // correct step in old region
- sLt[lttcFlag] = propStep-snext;
- jrLt[lttcFlag] = newLttc;
- sLt[lttcFlag+1] = 0.;
- jrLt[lttcFlag+1] = -1;
- if (newReg != oldReg) break; // lttcFlag=1
- lttcFlag++;
- } else {
- if (mcgeom->IsDebugging()) printf("Not crossing next\n");
- lttcFlag--; //0
- retStep=steptot;
- sLt[lttcFlag] = retStep;
- sLt[lttcFlag+1] = 0.;
- jrLt[lttcFlag+1] = -1;
- done = kTRUE;
- }