+Double_t AliEMCALTracker::CheckPairV3
+(AliEMCALTrack *track, AliEMCALMatchCluster *cl)
+{
+ //
+ // Given a track and a cluster,
+ // propagates the first to the radius of the second.
+ // Then, checks the propagation point against all cuts.
+ // If at least a cut is not passed, a valuer equal to
+ // twice the maximum allowed distance is passed (so the value returned
+ // will not be taken into account when creating matches)
+ //
+
+ AliEMCALTrack tr(*track);
+
+ Int_t sector=-1;
+ Double_t distance = 2.0 * fMaxDist;
+ Double_t dx=0., dy=0., dz=0.;
+ Double_t phi=0., alpha=0., slope=0., tgtXnum=0., tgtXden=0., sectorWidth = 20.0 * TMath::DegToRad();
+ Double_t xcurr=0., xprop=0., param[6] = {0., 0., 0., 0., 0., 0.}, x0=0., rho=0., bz=0.;
+ Double_t x[3]= {0., 0., 0.}, x1[3]= {0., 0., 0.}, x2[3]= {0., 0., 0.};
+
+ // get initial track position
+ xcurr = tr.GetX();
+
+ // evaluate the EMCAL sector number
+ phi = cl->Phi();
+ if (phi < 0.0) phi += TMath::TwoPi();
+ sector = (Int_t)(phi / sectorWidth);
+ alpha = ((Double_t)sector + 0.5) * sectorWidth;
+ // evaluate the corresponding X for track propagation
+ slope = TMath::Tan(alpha - 0.5*TMath::Pi());
+ tgtXnum = cl->Y() - slope * cl->X();
+ tgtXden = TMath::Sqrt(1.0 + slope*slope);
+ xprop = TMath::Abs(tgtXnum / tgtXden);
+
+ // propagate by small steps
+ tr.GetXYZ(x1);
+ bz = tr.GetBz();
+ if (!tr.GetXYZAt(xprop, bz, x2)) return distance;
+ //AliKalmanTrack::MeanMaterialBudget(x1, x2, param);
+ rho = param[0]*param[4];
+ x0 = param[1];
+ if (!tr.PropagateTo(xprop, x0, rho)) return distance;
+ //if (!tr.PropagateTo(xprop, 0.0, 0.0)) return distance;
+
+ // get propagated position at the end
+ tr.GetXYZ(x);
+ dx = TMath::Abs(x[0] - cl->X());
+ dy = TMath::Abs(x[1] - cl->Y());
+ dz = TMath::Abs(x[2] - cl->Z());
+ if (dx > fCutX || dy > fCutY || dz > fCutZ) return distance;
+
+ distance = TMath::Sqrt(dx*dx + dy*dy + dz*dz);
+
+ return distance;
+}
+//
+//------------------------------------------------------------------------------
+//
+Bool_t AliEMCALTracker::PropagateToEMCAL(AliEMCALTrack *tr)
+{
+ //
+ // Propagates the track to the proximity of the EMCAL surface
+ //
+
+ Double_t xcurr=0., xtemp=0., xprop = 438.0, step = 10.0, param[6]= {0., 0., 0., 0., 0., 0.}, x0=0., rho=0., bz=0.;
+ Double_t x1[3]= {0., 0., 0.}, x2[3]= {0., 0., 0.};
+
+ // get initial track position
+ xcurr = tr->GetX();
+
+ // propagate by small steps
+ for (xtemp = xcurr + step; xtemp < xprop; xtemp += step) {
+ // to compute material budget, take current position and
+ // propagated hypothesis without energy loss
+ tr->GetXYZ(x1);
+ bz = tr->GetBz();
+ if (!tr->GetXYZAt(xtemp, bz, x2)) return kFALSE;
+ MeanMaterialBudget(x1, x2, param);
+ rho = param[0]*param[4];
+ x0 = param[1];
+ if (!tr->PropagateTo(xtemp, x0, rho)) return kFALSE;
+ }
+
+ return kTRUE;
+}
+//
+//------------------------------------------------------------------------------
+//