Removing include AliRun.h (not needed)
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDTracker.cxx
3c6274c1 1#include "AliHMPIDTracker.h" //class header
2#include "AliHMPIDCluster.h" //GetTrackPoint(),PropagateBack()
3#include "AliHMPIDParam.h" //GetTrackPoint(),PropagateBack()
4#include "AliHMPIDRecon.h" //PropagateBack()
d3da6dc4 5#include <AliESD.h> //PropagateBack()
6#include <AliRun.h> //GetTrackPoint(),PropagateBack()
7#include <AliTrackPointArray.h> //GetTrackPoint()
8#include <AliAlignObj.h> //GetTrackPoint()
d3da6dc4 10//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
13// Interface callback methode invoked from AliReconstruction::WriteAlignmentData() to get position of MIP cluster in MARS associated to a current track.
14// MIP cluster is reffered by index which is stored in AliESDtrack ???????
15// Arguments: idx- cluster index which is stored by HMPID in AliESDtrack
16// point- reference to the object where to store the point
17// Returns: status of operation if FALSE then AliReconstruction::WriteAlignmentData() do not store this point to array of points for current track.
18 if(idx<0) return kFALSE; //no MIP cluster assigned to this track in PropagateBack()
19 Int_t iCham=idx/1000000;
20 Int_t iClu=idx%1000000;
21 point.SetVolumeID(AliAlignObj::LayerToVolUID(AliAlignObj::kHMPID,iCham-1));//layer and chamber number
22 AliHMPID *pRich=((AliHMPID*)gAlice->GetDetector("HMPID"));
23 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pRich->CluLst(iCham)->UncheckedAt(iClu);//get pointer to cluster
24 Double_t mars[3];
25 AliHMPIDParam::Instance()->Lors2Mars(iCham,pClu->X(),pClu->Y(),mars);
26 point.SetXYZ(mars[0],mars[1],mars[2]);
27 return kTRUE;
30Int_t AliHMPIDTracker::LoadClusters(TTree *pCluTree)
32// Interface callback methode invoked from AliReconstruction::RunTracking() to load HMPID clusters before PropagateBack() gets control
33// Arguments: pCluTree- pointer to clusters tree got by AliHMPIDLoader::LoadRecPoints("read") then AliHMPIDLoader::TreeR()
34// Returns: error code (currently ignored in AliReconstruction::RunTraking())
35 AliDebug(1,"Start."); pCluTree->GetEntry(0); AliDebug(1,"Stop."); return 0;
3c6274c1 38Int_t AliHMPIDTracker::Recon(AliESD *pESD,TObjArray *pCluAll)
d3da6dc4 39{
40// Interface callback methode invoked by AliRecontruction::RunTracking() during tracking after TOF. It's done just once per event
41// Arguments: pESD - pointer to Event Summary Data class instance which contains a list of tracks
42// Returns: error code, 0 if no errors
3c6274c1 43 Int_t iNtracks=pESD->GetNumberOfTracks(); AliDebugClass(1,Form("Start with %i tracks",iNtracks));
d3da6dc4 44 AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
46 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
48 for(Int_t iTrk=0;iTrk<iNtracks;iTrk++){ //ESD tracks loop
49 AliESDtrack *pTrk = pESD->GetTrack(iTrk); //get next reconstructed track
51 Float_t xRa=0,yRa=0,xPc=0,yPc=0,th=0,ph=0; //track intersection point and angles, LORS
52 Int_t iCh=-1; //intersected chamber
53 for(Int_t i=0;i<7;i++){ //chambers loop
54 Double_t p1[3],n1[3]; pParam->Norm(i,n1); pParam->Lors2Mars(i,0,0,p1,AliHMPIDParam::kRad); //point & norm for RAD
55 Double_t p2[3],n2[3]; pParam->Norm(i,n2); pParam->Lors2Mars(i,0,0,p2,AliHMPIDParam::kPc); //point & norm for PC
57 if(pTrk->Intersect(p1,n1,-GetBz())==kFALSE) continue; //try to intersect track with the middle of radiator
58 if(pTrk->Intersect(p2,n2,-GetBz())==kFALSE) continue; //try to intersect track with PC
60 pParam->Mars2LorsVec(i,n1,th,ph); //track angles
61 pParam->Mars2Lors (i,p1,xRa,yRa); //TRKxRAD position
62 pParam->Mars2Lors (i,p2,xPc,yPc); //TRKxPC position
64 if(AliHMPIDDigit::IsInside(xPc,yPc)==kFALSE) continue; //not in active area
65 iCh=i;
66 break;
67 }//chambers loop
69 if(iCh==-1) continue; //no intersection at all, go after next track
3c6274c1 71 TClonesArray *pCluLst=(TClonesArray *)pCluAll->At(iCh); //get clusters list for intersected chamber
d3da6dc4 72
73 Double_t dMin=999; //distance between track-PC intersection point and current cluster
74 Int_t iMip=-1; //index of cluster nearest to intersection point
75 for(Int_t iClu=0;iClu<pCluLst->GetEntries();iClu++){ //clusters loop for intersected chamber
76 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->At(iClu); //get pointer to current cluster
77 if(pClu->Q()<100) continue; //QDC is incompartible with mip, go after another one
79 Float_t dX=xPc-pClu->X(); //distance between current cluster and intersection point
80 Float_t dY=yPc-pClu->Y();
81 Float_t d =TMath::Sqrt(dX*dX+dY*dY);
83 if( d < dMin) {iMip=iClu; dMin=d;} //current cluster is closer, overwrite data for min cluster
84 }//clusters loop for intersected chamber
86 pTrk->SetHMPIDtrk (xPc,yPc,th,ph); //store track info
87 if(iMip==-1) {pTrk->SetHMPIDsignal (kMipQdcCut); continue;} //no clusters with QDC more the threshold at all
89 AliHMPIDCluster *pMipClu=(AliHMPIDCluster*)pCluLst->At(iMip); //take mip cluster
d1bf51e1 91 pTrk->SetHMPIDmip ((Float_t)pMipClu->X(),(Float_t)pMipClu->Y(),(Int_t)pMipClu->Q()); //store mip info
d3da6dc4 92 if(dMin>1) {pTrk->SetHMPIDsignal (kMipDistCut); continue;} //closest cluster with enough charge is still too far
93 pTrk->SetHMPIDcluIdx (iCh,iMip); //set mip cluster index
94 recon.SetTrack(th,ph,xRa,yRa); Int_t iNphot=0; //initialize track parameters
95 pTrk->SetHMPIDsignal (recon.CkovAngle(pCluLst,iNphot)); //search for Cerenkov angle for this track
96 pTrk->SetHMPIDchi2 (recon.CkovSigma2()); //error squared
d1bf51e1 97 pTrk->SetHMPIDmip ((Float_t)pMipClu->X(),(Float_t)pMipClu->Y(),(Int_t)pMipClu->Q(),iMip); //info on mip cluster + n. phot.
d3da6dc4 98 }//ESD tracks loop
3c6274c1 99 AliDebugClass(1,"Stop pattern recognition");
d3da6dc4 100 return 0; // error code: 0=no error;