- Double_t energyclus = nPart.P();
-
- // reset cluster/track matching
- c->SetEmcCpvDistance(-1);
- c->SetTrackDistance(999,999);
-
- // run cluster-track matching
- Int_t imin = -1;
- Double_t dEtaMin = 1e9;
- Double_t dPhiMin = 1e9;
- Double_t dRmin = 1e9;
- Double_t totalTrkP = 0.0; // count total track momentum
- Int_t Nmatches = 0; // count total number of matches
- for (Int_t t = 0; t<Ntrks; ++t) {
-
- AliVTrack *track = dynamic_cast<AliVTrack*>(tracks->At(t));
-
- if (!track)
- continue;
- if (!track->IsEMCAL())
- continue;
- if (track->Pt() < fMinPt)
- continue;
-
- Double_t etadiff = 999;
- Double_t phidiff = 999;
- AliPicoTrack::GetEtaPhiDiff(track, c, phidiff, etadiff);
- Double_t dR = TMath::Sqrt(etadiff * etadiff + phidiff * phidiff);
- if(dR<dRmin){
- dEtaMin = etadiff;
- dPhiMin = phidiff;
- dRmin = dR;
- imin = t;
- }
-
- Double_t mom = track->P();
- Int_t mombin = GetMomBin(mom);
- Int_t centbinch = centbin;
- if (track->Charge() == -1 || track->Charge() == 255)
- centbinch += 4;
-
- if (fCreateHisto) {
- if (fHadCorr > 1 && mombin > -1) {
- fHistMatchEtaPhi[centbinch][mombin]->Fill(etadiff, phidiff);
- fHistMatchdRvsEP[centbin]->Fill(dR, energyclus / mom);
- }
- }
-
- Double_t EtaCut = 0.0;
- Double_t PhiCutlo = 0.0;
- Double_t PhiCuthi = 0.0;
- if(fPhiMatch > 0){
- PhiCutlo = -fPhiMatch;
- PhiCuthi = fPhiMatch;
- }
- else {
- PhiCutlo = GetPhiMean(mombin,centbinch)-GetPhiSigma(mombin,centbin);
- PhiCuthi = GetPhiMean(mombin,centbinch)+GetPhiSigma(mombin,centbin);
- }
-
- if(fEtaMatch > 0){
- EtaCut = fEtaMatch;
- }
- else {
- EtaCut = GetEtaSigma(mombin);
- }
-
- if ((phidiff < PhiCuthi && phidiff > PhiCutlo) && TMath::Abs(etadiff) < EtaCut) {
- if((fDoTrackClus && (track->GetEMCALcluster()) == iClus) || !fDoTrackClus){
- ++Nmatches;
- totalTrkP += track->P();
- }
- }
- }
-
- // store closest track
- c->SetEmcCpvDistance(imin);
- c->SetTrackDistance(dPhiMin, dEtaMin);
-
- if(fCreateHisto) {
- fHistNclusvsCent->Fill(cent);
- fHistEbefore->Fill(cent, energyclus);
- fHistNMatchCent->Fill(cent, Nmatches);
-
- if(Nmatches > 0)
- fHistNclusMatchvsCent->Fill(cent);
- }