]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HMPID/AliHMPIDTracker.cxx
Added code to allow sending back of EventDoneData from the DoEvent methods of AliHLTP...
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDTracker.cxx
CommitLineData
3c6274c1 1#include "AliHMPIDTracker.h" //class header
496c71b0 2#include "AliHMPIDtrack.h" //class header
3c6274c1 3#include "AliHMPIDCluster.h" //GetTrackPoint(),PropagateBack()
4#include "AliHMPIDParam.h" //GetTrackPoint(),PropagateBack()
59d9d4b3 5#include "AliHMPIDRecon.h" //Recon()
57fcdc2b 6#include "AliHMPIDReconHTA.h" //ReconHTA()
7#include <AliESDEvent.h> //PropagateBack(),Recon()
8#include <AliESDtrack.h> //Intersect()
d3da6dc4 9#include <AliRun.h> //GetTrackPoint(),PropagateBack()
10#include <AliTrackPointArray.h> //GetTrackPoint()
11#include <AliAlignObj.h> //GetTrackPoint()
59d9d4b3 12#include <AliCDBManager.h> //PropageteBack()
13#include <AliCDBEntry.h> //PropageteBack()
423554a3 14//.
15// HMPID base class fo tracking
16//.
17//.
18//.
d3da6dc4 19ClassImp(AliHMPIDTracker)
94b1fbfa 20//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c61a7285 21AliHMPIDTracker::AliHMPIDTracker():
22 AliTracker(),
23 fClu(new TObjArray(AliHMPIDParam::kMaxCh+1))
94b1fbfa 24{
59d9d4b3 25// ctor. Create TObjArray of TClonesArray of AliHMPIDCluster
26//
27//
c61a7285 28 fClu->SetOwner(kTRUE);
ae5a42aa 29 for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) fClu->AddAt(new TClonesArray("AliHMPIDCluster"),i);
59d9d4b3 30}//ctor
d3da6dc4 31//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
33{
34// Interface callback methode invoked from AliReconstruction::WriteAlignmentData() to get position of MIP cluster in MARS associated to a current track.
35// MIP cluster is reffered by index which is stored in AliESDtrack ???????
36// Arguments: idx- cluster index which is stored by HMPID in AliESDtrack
37// point- reference to the object where to store the point
38// Returns: status of operation if FALSE then AliReconstruction::WriteAlignmentData() do not store this point to array of points for current track.
39 if(idx<0) return kFALSE; //no MIP cluster assigned to this track in PropagateBack()
59d9d4b3 40 Int_t iCham=idx/1000000; Int_t iClu=idx%1000000;
ae079791 41 point.SetVolumeID(AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,iCham-1));//layer and chamber number
94b1fbfa 42 TClonesArray *pArr=(TClonesArray*)(*fClu)[iCham];
43 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pArr->UncheckedAt(iClu);//get pointer to cluster
d3da6dc4 44 Double_t mars[3];
45 AliHMPIDParam::Instance()->Lors2Mars(iCham,pClu->X(),pClu->Y(),mars);
46 point.SetXYZ(mars[0],mars[1],mars[2]);
47 return kTRUE;
59d9d4b3 48}//GetTrackPoint()
49//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39cd22e6 50Int_t AliHMPIDTracker::IntTrkCha(AliESDtrack *pTrk,Float_t &xPc,Float_t &yPc,Float_t &xRa,Float_t &yRa,Float_t &theta,Float_t &phi)
59d9d4b3 51{
52// Static method to find intersection in between given track and HMPID chambers
53// Arguments: pTrk- ESD track; xPc,yPc- track intersection with PC in LORS [cm]
54// Returns: intersected chamber ID or -1
55 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
ae5a42aa 56 for(Int_t i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){ //chambers loop
59d9d4b3 57 Double_t p1[3],n1[3]; pParam->Norm(i,n1); pParam->Point(i,p1,AliHMPIDParam::kRad); //point & norm for middle of radiator plane
58 Double_t p2[3],n2[3]; pParam->Norm(i,n2); pParam->Point(i,p2,AliHMPIDParam::kPc); //point & norm for entrance to PC plane
59 if(pTrk->Intersect(p1,n1,-GetBz())==kFALSE) continue; //try to intersect track with the middle of radiator
60 if(pTrk->Intersect(p2,n2,-GetBz())==kFALSE) continue; //try to intersect track with PC
61 pParam->Mars2LorsVec(i,n1,theta,phi); //track angles at RAD
62 pParam->Mars2Lors (i,p1,xRa,yRa); //TRKxRAD position
63 pParam->Mars2Lors (i,p2,xPc,yPc); //TRKxPC position
39cd22e6 64 if(AliHMPIDParam::IsInside(xPc,yPc,pParam->DistCut())==kTRUE) return i; //return intersected chamber
59d9d4b3 65 } //chambers loop
39cd22e6 66 return -1; //no intersection with HMPID chambers
59d9d4b3 67}//IntTrkCha()
d3da6dc4 68//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
496c71b0 69Int_t AliHMPIDTracker::IntTrkCha(Int_t ch,AliHMPIDtrack *pTrk,Float_t &xPc,Float_t &yPc,Float_t &xRa,Float_t &yRa,Float_t &theta,Float_t &phi)
70{
71// Static method to find intersection in between given track and HMPID chambers
72// Arguments: pTrk- HMPID track; xPc,yPc- track intersection with PC in LORS [cm]
73// Returns: intersected chamber ID or -1
74 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
75 Double_t p1[3],n1[3];
76 pParam->Norm(ch,n1);
77 pParam->Point(ch,p1,AliHMPIDParam::kRad); //point & norm for middle of radiator plane
78 Double_t p2[3],n2[3];
79 pParam->Norm(ch,n2);
80 pParam->Point(ch,p2,AliHMPIDParam::kPc); //point & norm for entrance to PC plane
81 if(pTrk->Intersect(pTrk,p1,n1)==kFALSE) return -1; //try to intersect track with the middle of radiator
82 if(pTrk->Intersect(pTrk,p2,n2)==kFALSE) return -1;
83 pParam->Mars2LorsVec(ch,n1,theta,phi); //track angles at RAD
84 pParam->Mars2Lors (ch,p1,xRa,yRa); //TRKxRAD position
85 pParam->Mars2Lors (ch,p2,xPc,yPc); //TRKxPC position
86 if(AliHMPIDParam::IsInside(xPc,yPc,pParam->DistCut())==kTRUE) return ch; //return intersected chamber
87 return -1; //no intersection with HMPID chambers
88}//IntTrkCha()
89//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
d3da6dc4 90Int_t AliHMPIDTracker::LoadClusters(TTree *pCluTree)
91{
59d9d4b3 92// Interface callback methode invoked from AliReconstruction::RunTracking() to load HMPID clusters before PropagateBack() gets control. Done once per event.
d3da6dc4 93// Arguments: pCluTree- pointer to clusters tree got by AliHMPIDLoader::LoadRecPoints("read") then AliHMPIDLoader::TreeR()
94// Returns: error code (currently ignored in AliReconstruction::RunTraking())
ae5a42aa 95 for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) pCluTree->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));
94b1fbfa 96 pCluTree->GetEntry(0);
94b1fbfa 97 return 0;
59d9d4b3 98}//LoadClusters()
d3da6dc4 99//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
af885e0f 100Int_t AliHMPIDTracker::PropagateBack(AliESDEvent *pEsd)
abb5f786 101{
59d9d4b3 102// Interface pure virtual in AliTracker. Invoked from AliReconstruction::RunTracking() after invocation of AliTracker::LoadClusters() once per event
abb5f786 103// Agruments: pEsd - pointer to ESD
104// Returns: error code
f455af6e 105 AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean"); //contains TObjArray of 42 TF1 + 1 EPhotMean
49881df7 106 AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre"); //contains TObjArray of 42 (7ch * 6sec) TF1
496c71b0 107 if(!pNmeanEnt) AliFatal("No Nmean C6F14 ");
108 if(!pQthreEnt) AliFatal("No Qthre");
94b1fbfa 109
afe12692 110 return Recon(pEsd,fClu,(TObjArray*)pNmeanEnt->GetObject(),(TObjArray*)pQthreEnt->GetObject());
611e810d 111}//PropagateBack()
abb5f786 112//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
afe12692 113Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
d3da6dc4 114{
59d9d4b3 115// Static method to reconstruct Theta Ckov for all valid tracks of a given event.
116// Arguments: pEsd- pointer ESD; pClu- pointer to clusters for all chambers; pNmean - pointer to all function Nmean=f(time)
d3da6dc4 117// Returns: error code, 0 if no errors
496c71b0 118
119 AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
39cd22e6 120 Float_t xPc,yPc,xRa,yRa,theta,phi;
496c71b0 121 Double_t cluLORS[2]={0},cluMARS[3]={0},trkMARS[3]={0};
122// Double_t bestcluMARS[3]={0,0,0};
123 Double_t radClu,radInitTrk;
124 Int_t nMipClusTot=0;
125 Double_t d3d=0,dmin=999999,bz=0;
126 Bool_t isMatched=kFALSE;
496c71b0 127 Int_t cluSiz=0;
128 Double_t qthre = 0; Double_t nmean=0; Int_t cham=0; Int_t hvsec=0;
129 Int_t index=0; //index of the "best" matching cluster
130 Double_t bestChi2=-1; //Chi2 of the "best" matching cluster
131 Double_t chi2=0;
132 Int_t nClusCh[AliHMPIDParam::kMaxCh+1];
133 Bool_t isOkQcut=kFALSE;
134 Bool_t isOkDcut=kFALSE;
135
136 AliHMPIDParam *pParam = AliHMPIDParam::Instance(); //Instance of AliHMPIDParam
137
138 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){ //loop on the ESD tracks in the event
af291e40 139 isMatched=kFALSE;dmin=999999;bestChi2=99999;chi2=99999;cluSiz=0; //init. track matching params
496c71b0 140 isOkQcut = kFALSE;
141 AliHMPIDCluster *bestHmpCluster=0x0; //the best matching cluster
142 AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //get reconstructed track
143 AliHMPIDtrack *hmpTrk = new AliHMPIDtrack(*pTrk); //create a hmpid track to be used for propagation and matching
144 bz=AliTracker::GetBz();
145
af291e40 146 Int_t ipCh=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi); //find the intersected chamber for this track
496c71b0 147 if(ipCh<0) { //no intersection at all, go after next track
148 pTrk->SetHMPIDtrk(0,0,0,0); //no intersection found
149 pTrk->SetHMPIDcluIdx (99,99999); //chamber not found, mip not yet considered
150 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNotPerformed); //ring reconstruction not yet performed
151 continue;
152 }
153
154// track intersects the chamber ipCh: find the MIP
155
156 TClonesArray *pMipCluLst=(TClonesArray *)pClus->At(ipCh); //get the list of clusters
157 nMipClusTot = pMipCluLst->GetEntries(); //total number of clusters in the given chamber
158 nClusCh[ipCh] = nMipClusTot;
159
160 for (Int_t iClu=0; iClu<nMipClusTot;iClu++) { //clusters loop
161
162 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu); //get the cluster
163// evaluate qThre
164 if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) { // just for backward compatibility
165 qthre=((TF1*)pQthre->At(pClu->Ch()))->Eval(pEsd->GetTimeStamp()); //
166 } else { // in the past just 1 qthre
167 hvsec = pParam->InHVSector(pClu->Y()); // per chamber
168 if(hvsec>=0)
169 qthre=((TF1*)pQthre->At(6*cham+hvsec))->Eval(pEsd->GetTimeStamp()); //
170 } //
171//
172 if(pClu->Q()<qthre) continue; //charge compartible with MIP clusters
173 isOkQcut = kTRUE;
174
175 cluLORS[0]=pClu->X(); cluLORS[1]=pClu->Y(); //get the LORS coordinates of the cluster
176 pParam->Lors2Mars(ipCh,cluLORS[0],cluLORS[1],cluMARS); //convert cluster coors. from LORS to MARS
177 radClu=TMath::Sqrt(cluMARS[0]*cluMARS[0]+cluMARS[1]*cluMARS[1]); //radial distance of candidate cluster in MARS
178 Double_t trkx0[3];
179 hmpTrk->GetXYZ(trkx0); //get track position in MARS
180 radInitTrk=TMath::Sqrt(trkx0[0]*trkx0[0]+trkx0[1]*trkx0[1]);
181 hmpTrk->PropagateToR(radClu,10);
182 hmpTrk->GetXYZ(trkx0); //get track position in MARS
183 hmpTrk->GetXYZAt(radClu,bz,trkMARS); //get the track coordinates at the rad distance after prop.
184 d3d=TMath::Sqrt((cluMARS[0]-trkMARS[0])*(cluMARS[0]-trkMARS[0])+(cluMARS[1]-trkMARS[1])*(cluMARS[1]-trkMARS[1])+(cluMARS[2]-trkMARS[2])*(cluMARS[2]-trkMARS[2]));
185 chi2=hmpTrk->GetPredictedChi2(pClu);
186 if(dmin > d3d ) { //to be saved for the moment...
187 cluSiz = pClu->Size();
188 dmin=d3d;
496c71b0 189 bestHmpCluster=pClu;
190 index=iClu;
191 bestChi2=chi2;
192 cluLORS[0]=pClu->X(); cluLORS[1]=pClu->Y();
193// pParam->Lors2Mars(ipCh,cluLORS[0],cluLORS[1],bestcluMARS);
194 }//global dmin cut
195 }//clus loop
196
299f06bd 197 pTrk->SetHMPIDmip(0,0,0,0); //store mip info in any case
198
496c71b0 199 if(!isOkQcut) {
200 pTrk->SetHMPIDcluIdx(ipCh,9999);
201 pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
202 continue;
203 }
204
205 if(dmin < pParam->DistCut()) {
206 isOkDcut = kTRUE;
207 }
208
209 if(!isOkDcut) {
299f06bd 210 pTrk->SetHMPIDmip(bestHmpCluster->X(),bestHmpCluster->Y(),(Int_t)bestHmpCluster->Q(),0); //store mip info in any case
496c71b0 211 pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set chamber, index of cluster + cluster size
212 pTrk->SetHMPIDsignal(pParam->kMipDistCut); //closest cluster with enough charge is still too far from intersection
213 }
214
215 if(isOkQcut*isOkDcut) isMatched = kTRUE; // MIP-Track matched !!
216
217 if(!isMatched) continue; // If matched continue...
218
219 Int_t indexAll = 0;
af291e40 220 for(Int_t iC=0;iC<ipCh;iC++) indexAll+=nClusCh[iC]; indexAll+=index; //to be verified...
496c71b0 221
222 Bool_t isOk = hmpTrk->Update(bestHmpCluster,bestChi2,indexAll);
223 if(!isOk) continue;
224 pTrk->SetOuterParam((AliExternalTrackParam*)&hmpTrk,AliESDtrack::kHMPIDout);
225
af291e40 226// cham=IntTrkCha(ipCh,hmpTrk,xPc,yPc,xRa,yRa,theta,phi);
496c71b0 227 cham=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi);
228 if(cham<0) { //no intersection at all, go after next track
39cd22e6 229 pTrk->SetHMPIDtrk(0,0,0,0); //no intersection found
230 pTrk->SetHMPIDcluIdx (99,99999); //chamber not found, mip not yet considered
231 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNotPerformed); //ring reconstruction not yet performed
232 continue;
233 }
496c71b0 234
39cd22e6 235 pTrk->SetHMPIDtrk(xRa,yRa,theta,phi); //store initial infos
496c71b0 236 //evaluate nMean
237 if(pNmean->GetEntries()==21) { //for backward compatibility
238 nmean=((TF1*)pNmean->At(3*cham))->Eval(pEsd->GetTimeStamp()); //C6F14 Nmean for this chamber
239 } else {
240 Int_t iRad = pParam->Radiator(yRa); //evaluate the radiator involved
241 Double_t tLow = ((TF1*)pNmean->At(6*cham+2*iRad ))->Eval(pEsd->GetTimeStamp()); //C6F14 low temp for this chamber
242 Double_t tHigh = ((TF1*)pNmean->At(6*cham+2*iRad+1))->Eval(pEsd->GetTimeStamp()); //C6F14 high temp for this chamber
243 Double_t tExp = pParam->FindTemp(tLow,tHigh,yRa); //estimated temp for that chamber at that y
244 nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp); //mean ref idx @ a given temp
245 if(nmean < 0){ //track didn' t pass through the radiator
246 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad); //set the appropriate flag
247 pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set index of cluster
248 continue;
249 }
250 }
251 //
a591e55f 252 recon.SetImpPC(xPc,yPc); //store track impact to PC
496c71b0 253 recon.CkovAngle(pTrk,(TClonesArray *)pClus->At(cham),index,nmean); //search for Cerenkov angle of this track
254 }//iTrk
255
d3da6dc4 256 return 0; // error code: 0=no error;
611e810d 257}//Recon()
258//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49881df7 259Int_t AliHMPIDTracker::ReconHiddenTrk(Int_t iCh,Int_t iHVsec,AliESDtrack *pTrk,TClonesArray *pCluLst,TObjArray *pNmean,TObjArray *pQthre)
611e810d 260{
261// Static method to reconstruct Theta Ckov for all valid tracks of a given event.
afe12692 262// Arguments: pEsd- pointer ESD; pClu- pointer to clusters for all chambers; pNmean - pointer to all function Nmean=f(time), pQthre - pointer to all function Qthre=f(time)
611e810d 263// Returns: error code, 0 if no errors
57fcdc2b 264 AliHMPIDReconHTA reconHTA; //instance of reconstruction class, nothing important in ctor
611e810d 265 Double_t nmean=((TF1*)pNmean->At(3*iCh))->Eval(0); //C6F14 Nmean for this chamber
6b7f1827 266 Double_t qthre = 0;
fd47aebf 267 if(pQthre->GetEntriesFast()==AliHMPIDParam::kMaxCh+1) //
268 qthre=((TF1*)pQthre->At(iCh))->Eval(0); //just for backward compatibi
269 else qthre=((TF1*)pQthre->At(6*iCh+iHVsec))->Eval(0); //
611e810d 270 if(pCluLst->GetEntriesFast()<4) return 1; //min 4 clusters (3 + 1 mip) to find a ring!
57fcdc2b 271 if(reconHTA.CkovHiddenTrk(pTrk,pCluLst,nmean,qthre)) return 0; //search for track parameters and Cerenkov angle of this track
5b2b2013 272 else return 1; // error code: 0=no error,1=fit not performed;
611e810d 273}//Recon()
d3da6dc4 274//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c1af14f7 275void AliHMPIDTracker::FillClusterArray(TObjArray* array) const {
276
277 // Publishes all pointers to clusters known to the tracker into the
278 // passed object array.
279 // The ownership is not transfered - the caller is not expected to delete
280 // the clusters
281
282 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
283 TClonesArray *pCluArr=(TClonesArray*)(*fClu)[iCh];
284 for (Int_t iClu=0; iClu<pCluArr->GetEntriesFast();iClu++){
285 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluArr->UncheckedAt(iClu);
286 array->AddLast(pClu);
287 }//cluster loop in iCh
288 pCluArr->Delete();
289 }//Ch loop
290
291 return;
292}
293//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++