Coding convention
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDTracker.cxx
CommitLineData
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()
abb5f786 9#include <AliCDBManager.h>
10#include <AliCDBEntry.h>
423554a3 11//.
12// HMPID base class fo tracking
13//.
14//.
15//.
d3da6dc4 16ClassImp(AliHMPIDTracker)
94b1fbfa 17//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18AliHMPIDTracker::AliHMPIDTracker():AliTracker()
19{
20// ctor
21 fClu=new TObjArray(AliHMPIDDigit::kMaxCh+1);
22 fClu->SetOwner(kTRUE);
23 for(int i=AliHMPIDDigit::kMinCh;i<=AliHMPIDDigit::kMaxCh;i++) fClu->AddAt(new TClonesArray("AliHMPIDCluster"),i);
24}
d3da6dc4 25//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
27{
28// Interface callback methode invoked from AliReconstruction::WriteAlignmentData() to get position of MIP cluster in MARS associated to a current track.
29// MIP cluster is reffered by index which is stored in AliESDtrack ???????
30// Arguments: idx- cluster index which is stored by HMPID in AliESDtrack
31// point- reference to the object where to store the point
32// Returns: status of operation if FALSE then AliReconstruction::WriteAlignmentData() do not store this point to array of points for current track.
33 if(idx<0) return kFALSE; //no MIP cluster assigned to this track in PropagateBack()
34 Int_t iCham=idx/1000000;
35 Int_t iClu=idx%1000000;
36 point.SetVolumeID(AliAlignObj::LayerToVolUID(AliAlignObj::kHMPID,iCham-1));//layer and chamber number
94b1fbfa 37 TClonesArray *pArr=(TClonesArray*)(*fClu)[iCham];
38 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pArr->UncheckedAt(iClu);//get pointer to cluster
d3da6dc4 39 Double_t mars[3];
40 AliHMPIDParam::Instance()->Lors2Mars(iCham,pClu->X(),pClu->Y(),mars);
41 point.SetXYZ(mars[0],mars[1],mars[2]);
42 return kTRUE;
43}
44//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45Int_t AliHMPIDTracker::LoadClusters(TTree *pCluTree)
46{
47// Interface callback methode invoked from AliReconstruction::RunTracking() to load HMPID clusters before PropagateBack() gets control
48// Arguments: pCluTree- pointer to clusters tree got by AliHMPIDLoader::LoadRecPoints("read") then AliHMPIDLoader::TreeR()
49// Returns: error code (currently ignored in AliReconstruction::RunTraking())
94b1fbfa 50 AliDebug(1,"Start.");
51 for(int i=AliHMPIDDigit::kMinCh;i<=AliHMPIDDigit::kMaxCh;i++) pCluTree->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));
52 pCluTree->GetEntry(0);
53 AliDebug(1,"Stop.");
54 return 0;
d3da6dc4 55}
56//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
abb5f786 57Int_t AliHMPIDTracker::PropagateBack(AliESD *pEsd)
58{
59// This method defined as pure virtual in AliTracker. It is invoked from AliReconstruction::RunTracking() after invocation of AliTracker::LoadClusters()
60// Agruments: pEsd - pointer to ESD
61// Returns: error code
f6998a13 62 AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean"); //contains TObjArray of 21 TF1
63 AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre"); //contains TObjArray of 7 TF1
abb5f786 64 if(!pNmeanEnt) AliFatal("No Nmean C6F14 ");
65 if(!pQthreEnt) AliFatal("No Qthre");
94b1fbfa 66
f6998a13 67 return Recon(pEsd,fClu,(TObjArray*)pNmeanEnt->GetObject());
abb5f786 68}
69//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
70Int_t AliHMPIDTracker::Recon(AliESD *pEsd,TObjArray *pCluAll,TObjArray *pNmean)
d3da6dc4 71{
a591e55f 72// Interface callback method invoked by AliRecontruction::RunTracking() during tracking after TOF. It's done just once per event
abb5f786 73// Arguments: pEsd - pointer to Event Summary Data class instance which contains a list of tracks
d3da6dc4 74// Returns: error code, 0 if no errors
abb5f786 75 Int_t iNtracks=pEsd->GetNumberOfTracks(); AliDebugClass(1,Form("Start with %i tracks",iNtracks));
76
abb5f786 77 AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
a591e55f 78 Double_t xPc,yPc;
d3da6dc4 79 for(Int_t iTrk=0;iTrk<iNtracks;iTrk++){ //ESD tracks loop
abb5f786 80 AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //get next reconstructed track
a591e55f 81 Int_t cham=IntTrkCha(pTrk,xPc,yPc); //get chamber intersected by this track
59280a5a 82 if(cham<0) continue; //no intersection at all, go after next track
a591e55f 83 Double_t nmean=((TF1*)pNmean->At(3*cham))->Eval(pEsd->GetTimeStamp()); //C6F14 Nmean for this chamber
84 recon.SetImpPC(xPc,yPc); //store track impact to PC
85 recon.CkovAngle(pTrk,(TClonesArray *)pCluAll->At(cham),nmean); //search for Cerenkov angle of this track
59280a5a 86 } //ESD tracks loop
3c6274c1 87 AliDebugClass(1,"Stop pattern recognition");
d3da6dc4 88 return 0; // error code: 0=no error;
89}//PropagateBack()
90//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a591e55f 91Int_t AliHMPIDTracker::IntTrkCha(AliESDtrack *pTrk,Double_t &xToPc,Double_t &yToPc)
59280a5a 92{
93// Static method to find intersection in between given track and HMPID chambers
94// Arguments: pTrk - ESD track
a591e55f 95// xPc,yPc - track intersection with PC, LORS
59280a5a 96// Returns: intersected chamber ID or -1
97
98 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
a591e55f 99 Float_t xRa=0,yRa=0,xPc=0,yPc=0,theta=0,phi=0; //track intersection point and angles, LORS
100 for(Int_t i=AliHMPIDDigit::kMinCh;i<=AliHMPIDDigit::kMaxCh;i++){ //chambers loop
59280a5a 101 Double_t p1[3],n1[3]; pParam->Norm(i,n1); pParam->Lors2Mars(i,0,0,p1,AliHMPIDParam::kRad); //point & norm for RAD
102 Double_t p2[3],n2[3]; pParam->Norm(i,n2); pParam->Lors2Mars(i,0,0,p2,AliHMPIDParam::kPc); //point & norm for PC
103
104 if(pTrk->Intersect(p1,n1,-GetBz())==kFALSE) continue; //try to intersect track with the middle of radiator
105 if(pTrk->Intersect(p2,n2,-GetBz())==kFALSE) continue; //try to intersect track with PC
106
a591e55f 107 pParam->Mars2LorsVec(i,n1,theta,phi); //track angles at RAD
59280a5a 108 pParam->Mars2Lors (i,p1,xRa,yRa); //TRKxRAD position
109 pParam->Mars2Lors (i,p2,xPc,yPc); //TRKxPC position
a591e55f 110 xToPc=(Double_t)xPc;yToPc=(Double_t)yPc; //conversion float->double only
111 if(AliHMPIDDigit::IsInside(xPc,yPc,pParam->DistCut())==kFALSE) continue; //not in active area
112 pTrk->SetHMPIDtrk (xRa,yRa,theta,phi); //store track intersection info
59280a5a 113 pTrk->SetHMPIDcluIdx (i,0);
114 return i;
115 } //chambers loop
116 return -1; //no intersection with HMPID chambers
117}