+Double_t AliHMPIDPid::Resolution(Double_t thetaCerTh, AliESDtrack *pTrk)
+{
+ AliHMPIDParam *pParam = AliHMPIDParam::Instance();
+
+ AliHMPIDRecon rec;
+ Float_t xRa,yRa,thRa,phRa;
+ pTrk->GetHMPIDtrk(xRa,yRa,thRa,phRa);
+ rec.SetTrack(xRa,yRa,thRa,phRa);
+ Double_t thetaMax = TMath::ACos(1./pParam->MeanIdxRad());
+ Int_t nPhots = (Int_t)(21.*TMath::Sin(thetaCerTh)*TMath::Sin(thetaCerTh)/(TMath::Sin(thetaMax)*TMath::Sin(thetaMax))+0.01);
+
+ Double_t sigmatot = 0;
+ Int_t nTrks = 20;
+ for(Int_t iTrk=0;iTrk<nTrks;iTrk++) {
+ Double_t invSigma = 0;
+ Int_t nPhotsAcc = 0;
+ for(Int_t j=0;j<nPhots;j++){
+ Double_t phi = gRandom->Rndm()*TMath::TwoPi();
+ TVector2 pos; pos=rec.TracePhot(thetaCerTh,phi);
+ if(!pParam->IsInside(pos.X(),pos.Y())) continue;
+ if(pParam->IsInDead(pos.X(),pos.Y())) continue;
+ Double_t sigma2 = pParam->Sigma2(thRa,phRa,thetaCerTh,phi);//photon candidate sigma^2
+ if(sigma2!=0) {
+ invSigma += 1./sigma2;
+ nPhotsAcc++;
+ }
+ }
+ if(invSigma!=0) sigmatot += 1./TMath::Sqrt(invSigma);
+ }
+ return sigmatot/nTrks;
+}