Record correctly also the last step in Lego plot
authorfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Sep 1999 16:45:25 +0000 (16:45 +0000)
committerfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Sep 1999 16:45:25 +0000 (16:45 +0000)
STEER/AliLego.cxx

index c30142ec635db7429ba6128885ea7aa955ed5f7f..a2731f90d9c21e5d34507b44d09babb367395270 100644 (file)
@@ -222,6 +222,7 @@ void AliLego::StepManager()
    Float_t t, tt;
    Float_t a,z,dens,radl,absl;
    Int_t i;
+   Bool_t out;
    
    Float_t step  = gMC->TrackStep();
        
@@ -234,23 +235,28 @@ void AliLego::StepManager()
    
    if (z < 1) return;
    
-// --- See if we have to stop now
-   if (TMath::Abs(pos[2]) > fZMax  || 
-       pos[0]*pos[0] +pos[1]*pos[1] > fRadMax*fRadMax) {
-       gMC->StopEvent();
+// --- See how long we have to go
+   if (TMath::Abs(pos[2]) <= fZMax  && 
+       pos[0]*pos[0] +pos[1]*pos[1] <= fRadMax*fRadMax) {
+
+     tt = step;
+     out = kFALSE;
    } else {
 
-// --- See how long we have to go
       for(i=0;i<3;++i) {
        vect[i]=pos[i];
        dir[i]=mom[i];
       }
       t  = PropagateCylinder(vect,dir,fRadMax,fZMax);
       tt = TMath::Min(step,t);
-
-      fTotAbso += tt/absl;
-      fTotRadl += tt/radl;
-      fTotGcm2 += tt*dens;
+      out = kTRUE;
    }
+
+   fTotAbso += tt/absl;
+   fTotRadl += tt/radl;
+   fTotGcm2 += tt*dens;
+
+// --- See if we have to stop now
+   if(out) gMC->StopEvent();
 }