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