+ "t.="<<pTrk<< // curent esd track
+ "ft.="<<ftrack<< // friend track
+ "hmpTrk.="<<hmpTrk<< // hmpid tracks as used in the following code
+ "hmpTrkC.="<<hmpTrkConstrained<< // constrained hmpid tracks as used in the following code
+ "gx="<<gx<< // global cluster position X
+ "gy="<<gy<< // Y
+ "gz="<<gz<< // Z
+ "\n";
+ }
+ //
+ //
+ //
+ if(!isOkQcut) {
+ pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
+ delete hmpTrk;hmpTrk=0x0;
+ delete hmpTrkConstrained;hmpTrkConstrained=0x0;
+ continue;
+ }
+
+ if(AliHMPIDReconstructor::GetRecoParam()) //retrieve distance cut
+ {
+ if(AliHMPIDReconstructor::GetRecoParam()->IsFixedDistCut()==kTRUE) //distance cut is fixed number
+ {
+ distCut=AliHMPIDReconstructor::GetRecoParam()->GetHmpTrackMatchingDist();
+ }
+ else
+ {
+ for(Int_t ipar=0;ipar<5;ipar++) distParams[ipar]=AliHMPIDReconstructor::GetRecoParam()->GetHmpTrackMatchingDistParam(ipar); //prevision: distance cut is function of momentum
+ distCut=distParams[0]+distParams[1]*TMath::Power(distParams[2]*pTrk->GetP(),distParams[3]); //prevision: change functional form to be more precise
+ }
+ }
+ else {distCut=pParam->DistCut();}
+
+ //dmin recalculated
+
+ dmin = TMath::Sqrt((xPc0-bestHmpCluster->X())*(xPc0-bestHmpCluster->X())+(yPc0-bestHmpCluster->Y())*(yPc0-bestHmpCluster->Y()));
+
+ if(dmin < distCut) {
+ isOkDcut = kTRUE;
+ }
+ //isOkDcut = kTRUE; // switch OFF cut
+
+ if(!isOkDcut) {
+ pTrk->SetHMPIDsignal(pParam->kMipDistCut); //closest cluster with enough charge is still too far from intersection
+ }
+
+ if(isOkQcut*isOkDcut) isMatched = kTRUE; // MIP-Track matched !!
+
+ if(!isMatched) {delete hmpTrk;hmpTrk=0x0;delete hmpTrkConstrained;hmpTrkConstrained=0x0;continue;} // If matched continue...
+
+ Bool_t isOk = kTRUE;
+ if(!isOk) {delete hmpTrk;hmpTrk=0x0; delete hmpTrkConstrained;hmpTrkConstrained=0x0; continue;}
+ pTrk->SetOuterHmpParam(hmpTrkConstrained,AliESDtrack::kHMPIDout);
+
+ FillResiduals(hmpTrk,bestHmpCluster,kFALSE);
+
+ Int_t iRad = pParam->Radiator(yRa); //evaluate the radiator involved
+
+ //evaluate nMean
+ if(tsRight){
+ if(pNmean->GetEntries()==21) { //for backward compatibility
+ nmean=((TF1*)pNmean->At(3*ipCh))->Eval(ts); //C6F14 Nmean for this chamber
+ } else {
+ if(iRad < 0) {
+ nmean = -1;
+ } else {
+ Double_t tLow = ((TF1*)pNmean->At(6*ipCh+2*iRad ))->Eval(ts); //C6F14 low temp for this chamber
+ Double_t tHigh = ((TF1*)pNmean->At(6*ipCh+2*iRad+1))->Eval(ts); //C6F14 high temp for this chamber
+ Double_t tExp = pParam->FindTemp(tLow,tHigh,yRa); //estimated temp for that chamber at that y
+ nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp); //mean ref idx @ a given temp
+ }
+ if(nmean < 0){ //track didn' t pass through the radiator
+ pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad); //set the appropriate flag
+ pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set index of cluster
+ delete hmpTrk;hmpTrk=0x0;
+ delete hmpTrkConstrained;hmpTrkConstrained=0x0;
+ continue;
+ }
+ }
+ } else nmean = pParam->MeanIdxRad();
+ //
+ // 7. Calculate the Cherenkov angle
+ //
+ recon.SetImpPC(xPc0,yPc0); //store track impact to PC
+ recon.CkovAngle(pTrk,(TClonesArray *)pClus->At(ipCh),index,nmean,xRa,yRa); //search for Cerenkov angle of this track
+
+ Double_t thetaCkov = pTrk->GetHMPIDsignal();
+
+ if (AliHMPIDReconstructor::StreamLevel()>0) {
+ AliExternalTrackParam * trackTPC=new AliExternalTrackParam(*(ftrack->GetTPCOut()));
+ AliExternalTrackParam * trackCurrent=new AliExternalTrackParam(*pTrk);
+ if(!trackTPC->Rotate(alpha)) continue;
+ if(!trackCurrent->Rotate(alpha)) continue;
+ Bool_t statusTPC= AliTracker::PropagateTrackToBxByBz(trackTPC,radiusH,pTrk->GetMass(),1,kFALSE,kMaxSnp,-1);
+ Bool_t statusCurrent=AliTracker::PropagateTrackToBxByBz(trackCurrent,radiusH,pTrk->GetMass(),1,kFALSE,kMaxSnp,-1);
+ Double_t tanAlpha=TMath::Tan(TMath::ASin(trackTPC->GetSnp()));
+ Double_t deltaC= trackTPC->GetC(AliTrackerBase::GetBz())-ftrack->GetTPCOut()->GetC(AliTrackerBase::GetBz());
+ //
+ AliExternalTrackParam * trackTPCNB=new AliExternalTrackParam(*(ftrack->GetTPCOut()));
+ if(!trackTPCNB->Rotate(alpha)) continue;
+ Bool_t statusTPCNB=kTRUE;
+ Double_t bfield[3]={0,0,0};
+ for (Double_t radius=trackTPCNB->GetX(); radius<radiusH; radius+=1){
+ Double_t xyz[3];
+ trackTPCNB->GetXYZ(xyz);
+ GetBxByBz(xyz,bfield);
+ statusTPCNB&=trackTPCNB->PropagateToBxByBz(radius,bfield);
+ }
+ statusTPCNB&=trackTPCNB->PropagateToBxByBz(radiusH,bfield);
+
+ AliExternalTrackParam * trackTPCConstrained= new AliExternalTrackParam(*trackTPC);
+ Double_t pos[2]={0,gz};
+ Double_t cov[3]={0.1*0.1, 0, 0.1*0.1};
+ Double_t chi2C = trackTPCConstrained->GetPredictedChi2(pos,cov);
+ trackTPCConstrained->Update(pos,cov);
+ (*fDebugStreamer)<<"track2"<<
+ "rH="<<radiusH<< // radius of cluster
+ "angle="<<tanAlpha<< // tan of the local inlination angle
+ "dC="<<deltaC<< // delta of the curvature
+ "trackTPC.="<<trackTPC<< // TPC outer param extrapolated to the HMPID
+ "trackTPCNB.="<<trackTPCNB<< // TPC outer param extrapolated to the HMPID
+ "chi2C="<<chi2C<<
+ "trackTPCC.="<<trackTPCConstrained<< // TPC outer param extrapolated to the HMPID constrained
+ "trackCurrent.="<<trackCurrent<< // current track extrapolated to the HMPID
+ "sTPC="<<statusTPC<< // status for the current TPC track
+ "sCurrent="<<statusCurrent<< // status for the current global track
+ "cl.="<<bestHmpCluster<< // HMPID cluster
+ //
+ "t.="<<pTrk<< // curent esd track
+ "ft.="<<ftrack<< // friend track
+ "hmpTrk.="<<hmpTrk<< // hmpid tracks as used in the following code
+ "hmpTrkC.="<<hmpTrkConstrained<< // constrained hmpid tracks as used in the following code
+ "gx="<<gx<< // global cluster position X
+ "gy="<<gy<< // Y
+ "gz="<<gz<< // Z
+ "thetaCkov="<<thetaCkov<< // Cherenkov angle