-#include "AliHMPIDTracker.h" //class header
-#include "AliHMPID.h" //GetTrackPoint(),PropagateBack()
-#include "AliHMPIDCluster.h" //GetTrackPoint(),PropagateBack()
-#include "AliHMPIDParam.h" //GetTrackPoint(),PropagateBack()
-#include "AliHMPIDRecon.h" //PropagateBack()
+#include "AliHMPIDTracker.h" //class header
+#include "AliHMPIDCluster.h" //GetTrackPoint(),PropagateBack()
+#include "AliHMPIDParam.h" //GetTrackPoint(),PropagateBack()
+#include "AliHMPIDRecon.h" //PropagateBack()
#include <AliESD.h> //PropagateBack()
#include <AliRun.h> //GetTrackPoint(),PropagateBack()
#include <AliTrackPointArray.h> //GetTrackPoint()
#include <AliAlignObj.h> //GetTrackPoint()
+#include <AliCDBManager.h>
+#include <AliCDBEntry.h>
+
ClassImp(AliHMPIDTracker)
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-AliHMPIDTracker::AliHMPIDTracker():AliTracker()
-{
-// AliHMPIDTracker is created from AliReconstraction::Run() which invokes AliReconstraction::CreateTrackers()
-// which in turn invokes AliHMPIDReconstructor::CreateTracker().
-// Note that this is done just once per session before AliReconstruction::Run() goes to events loop.
-}
+
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
{
AliDebug(1,"Start."); pCluTree->GetEntry(0); AliDebug(1,"Stop."); return 0;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Int_t AliHMPIDTracker::PropagateBack(AliESD *pESD)
+Int_t AliHMPIDTracker::PropagateBack(AliESD *pEsd)
{
-// Interface callback methode invoked by AliRecontruction::RunTracking() during tracking after TOF. It's done just once per event
-// Arguments: pESD - pointer to Event Summary Data class instance which contains a list of tracks
+// This method defined as pure virtual in AliTracker. It is invoked from AliReconstruction::RunTracking() after invocation of AliTracker::LoadClusters()
+// Agruments: pEsd - pointer to ESD
+// Returns: error code
+ AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean",pEsd->GetRunNumber()); //contains TObjArray of 21 TF1
+ AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre",pEsd->GetRunNumber()); //contains TObjArray of 7 TF1
+ if(!pNmeanEnt) AliFatal("No Nmean C6F14 ");
+ if(!pQthreEnt) AliFatal("No Qthre");
+
+ AliHMPID *pHmpid=((AliHMPID*)gAlice->GetDetector("HMPID"));
+ return Recon(pEsd,pHmpid->CluLst(),(TObjArray*)pNmeanEnt->GetObject());
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Int_t AliHMPIDTracker::Recon(AliESD *pEsd,TObjArray *pCluAll,TObjArray *pNmean)
+{
+// Interface callback method invoked by AliRecontruction::RunTracking() during tracking after TOF. It's done just once per event
+// Arguments: pEsd - pointer to Event Summary Data class instance which contains a list of tracks
// Returns: error code, 0 if no errors
- Int_t iNtracks=pESD->GetNumberOfTracks(); AliDebug(1,Form("Start with %i tracks",iNtracks));
- AliHMPID *pRich=((AliHMPID*)gAlice->GetDetector("HMPID"));
- AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
-
- AliHMPIDParam *pParam=AliHMPIDParam::Instance();
-
+ Int_t iNtracks=pEsd->GetNumberOfTracks(); AliDebugClass(1,Form("Start with %i tracks",iNtracks));
+
+ AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
+ Double_t xPc,yPc;
for(Int_t iTrk=0;iTrk<iNtracks;iTrk++){ //ESD tracks loop
- AliESDtrack *pTrk = pESD->GetTrack(iTrk); //get next reconstructed track
-
- Float_t xRa=0,yRa=0,xPc=0,yPc=0,th=0,ph=0; //track intersection point and angles, LORS
- Int_t iCh=-1; //intersected chamber
- for(Int_t i=0;i<7;i++){ //chambers loop
- Double_t p1[3],n1[3]; pParam->Norm(i,n1); pParam->Lors2Mars(i,0,0,p1,AliHMPIDParam::kRad); //point & norm for RAD
- Double_t p2[3],n2[3]; pParam->Norm(i,n2); pParam->Lors2Mars(i,0,0,p2,AliHMPIDParam::kPc); //point & norm for PC
-
- if(pTrk->Intersect(p1,n1,-GetBz())==kFALSE) continue; //try to intersect track with the middle of radiator
- if(pTrk->Intersect(p2,n2,-GetBz())==kFALSE) continue; //try to intersect track with PC
-
- pParam->Mars2LorsVec(i,n1,th,ph); //track angles
- pParam->Mars2Lors (i,p1,xRa,yRa); //TRKxRAD position
- pParam->Mars2Lors (i,p2,xPc,yPc); //TRKxPC position
-
- if(AliHMPIDDigit::IsInside(xPc,yPc)==kFALSE) continue; //not in active area
- iCh=i;
- break;
- }//chambers loop
-
- if(iCh==-1) continue; //no intersection at all, go after next track
-
- TClonesArray *pCluLst=pRich->CluLst(iCh); //get clusters list for intersected chamber
-
- Double_t dMin=999; //distance between track-PC intersection point and current cluster
- Int_t iMip=-1; //index of cluster nearest to intersection point
- for(Int_t iClu=0;iClu<pCluLst->GetEntries();iClu++){ //clusters loop for intersected chamber
- AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->At(iClu); //get pointer to current cluster
- if(pClu->Q()<100) continue; //QDC is incompartible with mip, go after another one
-
- Float_t dX=xPc-pClu->X(); //distance between current cluster and intersection point
- Float_t dY=yPc-pClu->Y();
- Float_t d =TMath::Sqrt(dX*dX+dY*dY);
-
- if( d < dMin) {iMip=iClu; dMin=d;} //current cluster is closer, overwrite data for min cluster
- }//clusters loop for intersected chamber
-
- pTrk->SetHMPIDtrk (xPc,yPc,th,ph); //store track info
- if(iMip==-1) {pTrk->SetHMPIDsignal (kMipQdcCut); continue;} //no clusters with QDC more the threshold at all
-
- AliHMPIDCluster *pMipClu=(AliHMPIDCluster*)pCluLst->At(iMip); //take mip cluster
-
- pTrk->SetHMPIDmip (pMipClu->X(),pMipClu->Y(),pMipClu->Q()); //store mip info
- if(dMin>1) {pTrk->SetHMPIDsignal (kMipDistCut); continue;} //closest cluster with enough charge is still too far
- pTrk->SetHMPIDcluIdx (iCh,iMip); //set mip cluster index
- recon.SetTrack(th,ph,xRa,yRa); Int_t iNphot=0; //initialize track parameters
- pTrk->SetHMPIDsignal (recon.CkovAngle(pCluLst,iNphot)); //search for Cerenkov angle for this track
- pTrk->SetHMPIDchi2 (recon.CkovSigma2()); //error squared
- pTrk->SetHMPIDmip (pMipClu->X(),pMipClu->Y(),pMipClu->Q(),iMip); //info on mip cluster + n. phot.
- Printf("Ch=%i MIP-TRK=%5.2f cm Th=%f+-%f", iCh, dMin,pTrk->GetHMPIDsignal(),pTrk->GetHMPIDchi2());
- }//ESD tracks loop
- AliDebug(1,"Stop pattern recognition");
+ AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //get next reconstructed track
+ Int_t cham=IntTrkCha(pTrk,xPc,yPc); //get chamber intersected by this track
+ if(cham<0) continue; //no intersection at all, go after next track
+ Double_t nmean=((TF1*)pNmean->At(3*cham))->Eval(pEsd->GetTimeStamp()); //C6F14 Nmean for this chamber
+ recon.SetImpPC(xPc,yPc); //store track impact to PC
+ recon.CkovAngle(pTrk,(TClonesArray *)pCluAll->At(cham),nmean); //search for Cerenkov angle of this track
+ } //ESD tracks loop
+ AliDebugClass(1,"Stop pattern recognition");
return 0; // error code: 0=no error;
}//PropagateBack()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Int_t AliHMPIDTracker::IntTrkCha(AliESDtrack *pTrk,Double_t &xToPc,Double_t &yToPc)
+{
+// Static method to find intersection in between given track and HMPID chambers
+// Arguments: pTrk - ESD track
+// xPc,yPc - track intersection with PC, LORS
+// Returns: intersected chamber ID or -1
+
+ AliHMPIDParam *pParam=AliHMPIDParam::Instance();
+ Float_t xRa=0,yRa=0,xPc=0,yPc=0,theta=0,phi=0; //track intersection point and angles, LORS
+ for(Int_t i=AliHMPIDDigit::kMinCh;i<=AliHMPIDDigit::kMaxCh;i++){ //chambers loop
+ Double_t p1[3],n1[3]; pParam->Norm(i,n1); pParam->Lors2Mars(i,0,0,p1,AliHMPIDParam::kRad); //point & norm for RAD
+ Double_t p2[3],n2[3]; pParam->Norm(i,n2); pParam->Lors2Mars(i,0,0,p2,AliHMPIDParam::kPc); //point & norm for PC
+
+ if(pTrk->Intersect(p1,n1,-GetBz())==kFALSE) continue; //try to intersect track with the middle of radiator
+ if(pTrk->Intersect(p2,n2,-GetBz())==kFALSE) continue; //try to intersect track with PC
+
+ pParam->Mars2LorsVec(i,n1,theta,phi); //track angles at RAD
+ pParam->Mars2Lors (i,p1,xRa,yRa); //TRKxRAD position
+ pParam->Mars2Lors (i,p2,xPc,yPc); //TRKxPC position
+ xToPc=(Double_t)xPc;yToPc=(Double_t)yPc; //conversion float->double only
+ if(AliHMPIDDigit::IsInside(xPc,yPc,pParam->DistCut())==kFALSE) continue; //not in active area
+ pTrk->SetHMPIDtrk (xRa,yRa,theta,phi); //store track intersection info
+ pTrk->SetHMPIDcluIdx (i,0);
+ return i;
+ } //chambers loop
+ return -1; //no intersection with HMPID chambers
+}