+ //if there is ESD try to correct distance using TPC information on particle direct in CPV
+ if (fESD != 0x0) {
+
+ Double_t rCPV = cpvGlobal.Pt() ;// Radius from IP to current point
+
+ // Extrapolate the global track direction if any to CPV and find the closest track
+ Int_t nTracks = fESD->GetNumberOfTracks();
+ Int_t iClosestTrack = -1;
+ Double_t minDistance = 1.e6;
+ TVector3 inPHOS ;
+
+ AliESDtrack *track;
+ Double_t xyz[3] ;
+ Double_t pxyz[3];
+ for (Int_t iTrack=0; iTrack<nTracks; iTrack++) {
+ track = fESD->GetTrack(iTrack);
+ if (!track->GetXYZAt(rCPV, fESD->GetMagneticField(), xyz))
+ continue; //track coord on the cylinder of PHOS radius
+ if ((TMath::Abs(xyz[0])+TMath::Abs(xyz[1])+TMath::Abs(xyz[2]))<=0)
+ continue;
+ //Check if this track hits PHOS
+ inPHOS.SetXYZ(xyz[0],xyz[1],xyz[2]);
+ distance2Track = inPHOS.Angle(cpvGlobal) ;
+ // Find the closest track to the CPV recpoint
+ if (distance2Track < minDistance) {
+ minDistance = distance2Track;
+ iClosestTrack = iTrack;
+ }
+ }
+
+ if (iClosestTrack != -1) {
+ track = fESD->GetTrack(iClosestTrack);
+ if (track->GetPxPyPzAt(rCPV, fESD->GetMagneticField(), pxyz)) { // track momentum ibid.
+ vecP.SetXYZ(pxyz[0],pxyz[1],pxyz[2]);
+ Int_t dummyMod ;
+ geom->ImpactOnEmc(vtxCPV,vecP.Theta(),vecP.Phi(),dummyMod,xCPV,zCPV) ;
+ }
+ }
+
+ if(minDistance < fRtpc ){
+ trackindex = iClosestTrack ;
+ }
+ }
+ if(trackindex!=-1){
+ dx=xCPV - vecEmc.X() ;
+ dz=zCPV - vecEmc.Z() ;
+ }
+ else{
+ dz=999. ;
+ dx=999. ;
+ }
+ return ;
+}
+//____________________________________________________________________________
+void AliPHOSTrackSegmentMakerv1::Init()
+{
+ // Make all memory allocations that are not possible in default constructor
+
+ AliPHOSGetter* gime = AliPHOSGetter::Instance();
+ if(!gime)
+ gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data());