- Bool_t ok=kTRUE;
- while (TMath::Abs(y) > kYmax) { // Find the matching module
- Double_t alp=t.GetAlpha();
- if (y > kYmax) {
- if (!t.Rotate(alp+kAlpha)) {ok=kFALSE; break;}
- imod--;
- } else if (y < -kYmax) {
- if (!t.Rotate(alp-kAlpha)) {ok=kFALSE; break;}
- imod++;
- }
- if (!t.GetYAt(kR,bz,y)) {ok=kFALSE; break;}
- }
- if (!ok) continue; // Track rotation failed
-
-
- if ((imod<0)||(imod>4)) continue; // Some tracks miss the PHOS in azimuth
-
- //t.CorrectForMaterial(...); // Correct for the TOF material, if needed
- t.PropagateTo(kR,bz); // Propagate to the matching module
-
-
- // *** Search for the "best" cluster (can be improved)
- TClonesArray &cArray=*fModules[imod];
- Int_t ncl=cArray.GetEntriesFast();
- AliPHOSEmcRecPoint *bestCluster=0; // The "best" cluster
- Double_t maxd2=400; // (cm^2)
- for (Int_t j=0; j<ncl; j++) {
- AliPHOSEmcRecPoint *c=(AliPHOSEmcRecPoint *)cArray.UncheckedAt(j);
-
- if (c->TestBit(14)) continue; // This clusters is "used"
-
- Double_t dy = t.GetY() - c->GetY(), dz = t.GetZ() - c->GetZ();
- Double_t d2 = dy*dy + dz*dz;
- if (d2 < maxd2) {
- maxd2=d2;
- bestCluster=c;
+ Double_t y; // Some tracks do not reach the PHOS
+ if (!t.GetYAt(rPHOS,bz,y)) continue; // because of the bending
+
+ Double_t z;
+ if(!t.GetZAt(rPHOS,bz,z))
+ continue ;
+ if (TMath::Abs(z) > kZmax)
+ continue; // Some tracks miss the PHOS in Z
+ if(TMath::Abs(y) < kYmax){
+ t.PropagateToBxByBz(rPHOS,b); // Propagate to the matching module
+ //t.CorrectForMaterial(...); // Correct for the TOF material, if needed
+ t.GetXYZ(gposTrack) ;
+ TVector3 globalPositionTr(gposTrack) ;
+ TVector3 localPositionTr ;
+ geom->Global2Local(localPositionTr,globalPositionTr,mod) ;
+ for(Int_t icl=0;icl<fModules[mod-1]->GetEntriesFast();icl++){
+ AliPHOSEmcRecPoint * clu =static_cast<AliPHOSEmcRecPoint*>(fModules[mod-1]->At(icl)) ;
+ clu->GetLocalPosition(vecEmc) ;
+ Double_t ddx = vecEmc.X()-localPositionTr.X();
+ Double_t ddz = vecEmc.Z()-localPositionTr.Z();
+ Double_t d2 = ddx*ddx + ddz*ddz;
+ if(d2 < minDistance) {
+ dx = ddx ;
+ dz = ddz ;
+ emcIndex=clu->GetIndexInList() ;
+ minDistance=d2 ;
+ }
+ }
+ break ;