new 2d event display + optical properties restored in v1
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDTracker.cxx
1 #include "AliHMPIDTracker.h"     //class header
2 #include "AliHMPIDCluster.h"     //GetTrackPoint(),PropagateBack() 
3 #include "AliHMPIDParam.h"       //GetTrackPoint(),PropagateBack()
4 #include "AliHMPIDRecon.h"       //PropagateBack()
5 #include <AliESD.h>              //PropagateBack()  
6 #include <AliRun.h>              //GetTrackPoint(),PropagateBack()  
7 #include <AliTrackPointArray.h>  //GetTrackPoint()
8 #include <AliAlignObj.h>         //GetTrackPoint()
9 ClassImp(AliHMPIDTracker)
10 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    
11 Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
12 {
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;
28 }
29 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 Int_t AliHMPIDTracker::LoadClusters(TTree *pCluTree)
31 {
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;
36 }
37 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 Int_t AliHMPIDTracker::Recon(AliESD *pESD,TObjArray *pCluAll)
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   
43   Int_t iNtracks=pESD->GetNumberOfTracks();  AliDebugClass(1,Form("Start with %i tracks",iNtracks));
44   
45   AliHMPIDRecon recon;                                                                           //instance of reconstruction class, nothing important in ctor
46   Float_t xRa,yRa;
47   for(Int_t iTrk=0;iTrk<iNtracks;iTrk++){                                                        //ESD tracks loop
48     AliESDtrack *pTrk = pESD->GetTrack(iTrk);                                                    //get next reconstructed track    
49     Int_t cham=IntTrkCha(pTrk,xRa,yRa);                                                          //get chamber intersected by thie track 
50     if(cham<0) continue;                                                                         //no intersection at all, go after next track
51     recon.CkovAngle(pTrk,(TClonesArray *)pCluAll->At(cham));                                     //search for Cerenkov angle for this track
52   }                                                                                              //ESD tracks loop
53   AliDebugClass(1,"Stop pattern recognition");
54   return 0; // error code: 0=no error;
55 }//PropagateBack()
56 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57 Int_t AliHMPIDTracker::IntTrkCha(AliESDtrack *pTrk,Float_t &xRa,Float_t &yRa)
58 {
59 // Static method to find intersection in between given track and HMPID chambers
60 // Arguments: pTrk    - ESD track 
61 //            xRa,yRa - track intersection with the middle of radiator, LORS
62 //   Returns: intersected chamber ID or -1
63   
64   AliHMPIDParam *pParam=AliHMPIDParam::Instance();
65   Float_t xPc=0,yPc=0,th=0,ph=0;                                                                //track intersection point and angles, LORS  
66   for(Int_t i=0;i<7;i++){                                                                       //chambers loop
67     Double_t p1[3],n1[3]; pParam->Norm(i,n1); pParam->Lors2Mars(i,0,0,p1,AliHMPIDParam::kRad);  //point & norm  for RAD
68     Double_t p2[3],n2[3]; pParam->Norm(i,n2); pParam->Lors2Mars(i,0,0,p2,AliHMPIDParam::kPc);   //point & norm  for PC
69       
70     if(pTrk->Intersect(p1,n1,-GetBz())==kFALSE) continue;                                       //try to intersect track with the middle of radiator
71     if(pTrk->Intersect(p2,n2,-GetBz())==kFALSE) continue;                                       //try to intersect track with PC
72       
73     pParam->Mars2LorsVec(i,n1,th,ph);                                                           //track angles
74     pParam->Mars2Lors   (i,p1,xRa,yRa);                                                         //TRKxRAD position
75     pParam->Mars2Lors   (i,p2,xPc,yPc);                                                         //TRKxPC position
76       
77     if(AliHMPIDDigit::IsInside(xPc,yPc)==kFALSE) continue;                                      //not in active area  
78     pTrk->SetHMPIDtrk      (xPc,yPc,th,ph);                                                     //store track intersection info
79     pTrk->SetHMPIDcluIdx   (i,0);
80     return i;
81   }                                                                                             //chambers loop
82   return -1; //no intersection with HMPID chambers
83 }