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