+ /*****************/
+ /**** NEW CODE ***/
+ /*****************/
+
+ Int_t nfound = 0;
+ Bool_t accept = kFALSE;
+ Bool_t isInside = kFALSE;
+ for (Int_t istep=0; istep<nStepsDone; istep++) {
+
+ Bool_t gotInsideCluster = kFALSE;
+ Int_t trackInsideCluster = -1;
+
+ Float_t ctrackPos[3];
+ ctrackPos[0] = trackPos[0][istep];
+ ctrackPos[1] = trackPos[1][istep];
+ ctrackPos[2] = trackPos[2][istep];
+
+ //now see whether the track matches any of the TOF clusters
+
+ Float_t dist3d[3]={0.,0.,0.};
+ accept = kFALSE;
+ for (Int_t i=0; i<nc; i++) {
+
+ // ***** NEW *****
+ /* check whether track was inside another cluster
+ * and in case inhibit this cluster.
+ * this will allow to only go on and add track points for
+ * that cluster where the track got inside first */
+ if (gotInsideCluster && trackInsideCluster != i) {
+ AliDebug(2,Form(" A - istep=%d ~ %d %d ~ nfound=%d",istep,trackInsideCluster,i,nfound));
+ continue;
+ }
+ AliDebug(2,Form(" B - istep=%d ~ %d %d ~ nfound=%d",istep,trackInsideCluster,i,nfound));
+
+ /* check whether track is inside this cluster */
+ for (Int_t hh=0; hh<3; hh++) dist3d[hh]=0.;
+ isInside = fGeom->IsInsideThePad((TGeoHMatrix*)(&global[i]),ctrackPos,dist3d);
+
+ // ***** NEW *****
+ /* if track is inside this cluster set flags which will then
+ * inhibit to add track points for the other clusters */
+ if (isInside) {
+ gotInsideCluster = kTRUE;
+ trackInsideCluster = i;
+ }
+
+ if ( mLastStep ) {
+ Float_t yLoc = dist3d[1];
+ Float_t rLoc = TMath::Sqrt(dist3d[0]*dist3d[0]+dist3d[2]*dist3d[2]);
+ accept = (TMath::Abs(yLoc)<padDepth*0.5 && rLoc<dCut);
+ AliDebug(2," I am in the case mLastStep==kTRUE ");
+ }
+
+ //***** NEW *****
+ /* add point everytime that:
+ * - the track is inside the cluster
+ * - the track got inside the cluster, even when it eventually exited the cluster
+ * - the tracks is within dCut from the cluster
+ */
+ if (accept || isInside || gotInsideCluster) {
+
+ fTOFtrackPoints->AddLast(new AliTOFtrackPoint(clind[i],
+ TMath::Sqrt(dist3d[0]*dist3d[0] + dist3d[1]*dist3d[1] + dist3d[2]*dist3d[2]),
+ dist3d[2],dist3d[0],dist3d[1],
+ AliTOFGeometry::RinTOF()+istep*stepSize,trackPos[3][istep]));
+
+ AliDebug(2,Form(" dist3dLoc[0] = %f, dist3dLoc[1] = %f, dist3dLoc[2] = %f ",dist3d[0],dist3d[1],dist3d[2]));
+ nfound++;
+
+ AliDebug(2,Form(" C - istep=%d ~ %d %d ~ nfound=%d",istep,trackInsideCluster,i,nfound));
+
+ // ***** NEW *****
+ /* do not break loop in any case
+ * if the track got inside a cluster all other clusters
+ * are inhibited */
+ // if(accept &&!mLastStep)break;
+
+ }//end if accept
+
+ } //end for on the clusters
+
+ // ***** NEW *****
+ /* do not break loop in any case
+ * if the track got inside a cluster all other clusters
+ * are inhibited but we want to go on adding track points */
+ // if(accept &&!mLastStep)break;
+
+ } //end for on the steps
+
+
+ AliDebug(1,Form(" Number of track points for the track number %d: %d",iseed,nfound));