GetTrackPoint modified for the HMPID track point in AliESDfriends
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDTracker.cxx
1 #include "AliHMPIDTracker.h"     //class header
2 #include "AliHMPIDtrack.h"       //class header
3 #include "AliHMPIDCluster.h"     //GetTrackPoint(),PropagateBack() 
4 #include "AliHMPIDParam.h"       //GetTrackPoint(),PropagateBack()
5 #include "AliHMPIDPid.h"         //Recon(),reconHTA()
6 #include "AliHMPIDRecon.h"       //Recon()
7 #include "AliHMPIDReconHTA.h"    //ReconHTA()
8 #include <AliESDEvent.h>         //PropagateBack(),Recon()  
9 #include <AliESDtrack.h>         //Intersect()  
10 #include <AliRun.h>              //GetTrackPoint(),PropagateBack()  
11 #include <AliTrackPointArray.h>  //GetTrackPoint()
12 #include <AliAlignObj.h>         //GetTrackPoint()
13 #include <AliCDBManager.h>       //PropageteBack()
14 #include <AliCDBEntry.h>         //PropageteBack()
15 //.
16 // HMPID base class fo tracking
17 //.
18 //.
19 //.
20 ClassImp(AliHMPIDTracker)
21 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 AliHMPIDTracker::AliHMPIDTracker():
23   AliTracker(),
24   fClu(new TObjArray(AliHMPIDParam::kMaxCh+1))  
25 {
26 // ctor. Create TObjArray of TClonesArray of AliHMPIDCluster  
27 // 
28 //  
29   fClu->SetOwner(kTRUE);
30   for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) fClu->AddAt(new TClonesArray("AliHMPIDCluster"),i);
31 }//ctor
32 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    
33 Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
34 {
35 // Interface callback methode invoked from AliReconstruction::WriteAlignmentData() to get position of MIP cluster in MARS associated to a current track.
36 // MIP cluster is reffered by index which is stored in AliESDtrack  ???????
37 // Arguments: idx- cluster index which is stored by HMPID in AliESDtrack
38 //            point- reference to the object where to store the point     
39 //   Returns: status of operation  if FALSE then AliReconstruction::WriteAlignmentData() do not store this point to array of points for current track. 
40   if(idx<0) return kFALSE; //no MIP cluster assigned to this track in PropagateBack()
41   Int_t iCham=idx/1000000; Int_t iClu=idx%1000000;
42   iClu = iClu%1000; //GetHMPIDcluIdx -> 1e+6*ch + 1e+3*clusize + cluIdx;
43   point.SetVolumeID(AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,iCham));//layer and chamber number
44   TClonesArray *pArr=(TClonesArray*)(*fClu)[iCham];
45   AliHMPIDCluster *pClu=(AliHMPIDCluster*)pArr->UncheckedAt(iClu);//get pointer to cluster
46   Float_t xyz[3];
47   pClu->GetGlobalXYZ(xyz);
48   Float_t cov[6];
49   pClu->GetGlobalCov(cov);
50   point.SetXYZ(xyz,cov);
51   return kTRUE;
52 }//GetTrackPoint()
53 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54 Int_t AliHMPIDTracker::IntTrkCha(AliESDtrack *pTrk,Float_t &xPc,Float_t &yPc,Float_t &xRa,Float_t &yRa,Float_t &theta,Float_t &phi)
55 {
56 // Static method to find intersection in between given track and HMPID chambers
57 // Arguments: pTrk- ESD track; xPc,yPc- track intersection with PC in LORS [cm]
58 //   Returns: intersected chamber ID or -1
59   AliHMPIDParam *pParam=AliHMPIDParam::Instance();
60   for(Int_t i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){                              //chambers loop
61     Double_t p1[3],n1[3]; pParam->Norm(i,n1); pParam->Point(i,p1,AliHMPIDParam::kRad);          //point & norm  for middle of radiator plane
62     Double_t p2[3],n2[3]; pParam->Norm(i,n2); pParam->Point(i,p2,AliHMPIDParam::kPc);           //point & norm  for entrance to PC plane
63     if(pTrk->Intersect(p1,n1,-GetBz())==kFALSE) continue;                                       //try to intersect track with the middle of radiator
64     if(pTrk->Intersect(p2,n2,-GetBz())==kFALSE) continue;                                       //try to intersect track with PC
65     pParam->Mars2LorsVec(i,n1,theta,phi);                                                       //track angles at RAD
66     pParam->Mars2Lors   (i,p1,xRa,yRa);                                                         //TRKxRAD position
67     pParam->Mars2Lors   (i,p2,xPc,yPc);                                                         //TRKxPC position
68     if(AliHMPIDParam::IsInside(xPc,yPc,pParam->DistCut())==kTRUE) return i;                     //return intersected chamber  
69   }                                                                                             //chambers loop
70   return -1;                                                                                    //no intersection with HMPID chambers
71 }//IntTrkCha()
72 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
73 Int_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)
74 {
75 // Static method to find intersection in between given track and HMPID chambers
76 // Arguments: pTrk- HMPID track; xPc,yPc- track intersection with PC in LORS [cm]
77 //   Returns: intersected chamber ID or -1
78     AliHMPIDParam *pParam=AliHMPIDParam::Instance();
79     Double_t p1[3],n1[3]; 
80     pParam->Norm(ch,n1); 
81     pParam->Point(ch,p1,AliHMPIDParam::kRad);                                                    //point & norm  for middle of radiator plane
82     Double_t p2[3],n2[3]; 
83     pParam->Norm(ch,n2); 
84     pParam->Point(ch,p2,AliHMPIDParam::kPc);                                                     //point & norm  for entrance to PC plane
85     if(pTrk->Intersect(pTrk,p1,n1)==kFALSE) return -1;                                           //try to intersect track with the middle of radiator
86     if(pTrk->Intersect(pTrk,p2,n2)==kFALSE) return -1;   
87     pParam->Mars2LorsVec(ch,n1,theta,phi);                                                       //track angles at RAD
88     pParam->Mars2Lors   (ch,p1,xRa,yRa);                                                         //TRKxRAD position
89     pParam->Mars2Lors   (ch,p2,xPc,yPc);                                                         //TRKxPC position
90     if(AliHMPIDParam::IsInside(xPc,yPc,pParam->DistCut())==kTRUE) return ch;                     //return intersected chamber  
91   return -1;                                                                                     //no intersection with HMPID chambers
92 }//IntTrkCha()
93 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
94 Int_t AliHMPIDTracker::LoadClusters(TTree *pCluTree)
95 {
96 // Interface callback methode invoked from AliReconstruction::RunTracking() to load HMPID clusters before PropagateBack() gets control. Done once per event.
97 // Arguments: pCluTree- pointer to clusters tree got by AliHMPIDLoader::LoadRecPoints("read") then AliHMPIDLoader::TreeR()
98 //   Returns: error code (currently ignored in AliReconstruction::RunTraking())    
99   for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) pCluTree->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));
100   pCluTree->GetEntry(0);
101   return 0;  
102 }//LoadClusters()
103 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
104 Int_t AliHMPIDTracker::PropagateBack(AliESDEvent *pEsd)
105 {
106 // Interface pure virtual in AliTracker. Invoked from AliReconstruction::RunTracking() after invocation of AliTracker::LoadClusters() once per event
107 // Agruments: pEsd - pointer to ESD
108 //   Returns: error code    
109   AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean"); //contains TObjArray of 42 TF1 + 1 EPhotMean
110   AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre"); //contains TObjArray of 42 (7ch * 6sec) TF1
111   if(!pNmeanEnt) AliError("No Nmean C6F14 ");
112   if(!pQthreEnt) AliError("No Qthre");
113     
114   return Recon(pEsd,fClu,(TObjArray*)pNmeanEnt->GetObject(),(TObjArray*)pQthreEnt->GetObject());  
115 }//PropagateBack()
116 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
117 Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
118 {
119 // Static method to reconstruct Theta Ckov for all valid tracks of a given event.
120 // Arguments: pEsd- pointer ESD; pClu- pointer to clusters for all chambers; pNmean - pointer to all function Nmean=f(time)
121 //   Returns: error code, 0 if no errors   
122   
123   AliHMPIDRecon recon;                                                                           //instance of reconstruction class, nothing important in ctor
124   Float_t xPc,yPc,xRa,yRa,theta,phi;
125   Double_t cluLORS[2]={0},cluMARS[3]={0},trkMARS[3]={0};
126 //  Double_t bestcluMARS[3]={0,0,0};
127   Double_t radClu,radInitTrk;   
128   Int_t nMipClusTot=0;
129   Double_t d3d=0,dmin=999999,bz=0;
130   Bool_t isMatched=kFALSE;
131   Int_t cluSiz=0;
132   Double_t qthre = 0;   Double_t nmean=0; Int_t cham=0; Int_t hvsec=0;
133   Int_t index=0;                                                                                //index of the "best" matching cluster
134   Double_t bestChi2=-1;                                                                         //Chi2 of the "best" matching cluster
135   Double_t chi2=0;   
136   Int_t nClusCh[AliHMPIDParam::kMaxCh+1];
137   Bool_t isOkQcut=kFALSE;
138   Bool_t isOkDcut=kFALSE;
139   
140   AliHMPIDParam *pParam = AliHMPIDParam::Instance();                                             //Instance of AliHMPIDParam
141   
142   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){                                        //loop on the ESD tracks in the event
143     isMatched=kFALSE;dmin=999999;bestChi2=99999;chi2=99999;cluSiz=0;                              //init. track matching params
144     isOkQcut = kFALSE;
145     AliHMPIDCluster *bestHmpCluster=0x0;                                                          //the best matching cluster
146     AliESDtrack *pTrk = pEsd->GetTrack(iTrk);                                                     //get reconstructed track    
147     AliHMPIDtrack *hmpTrk = new AliHMPIDtrack(*pTrk);                                             //create a hmpid track to be used for propagation and matching 
148     bz=AliTracker::GetBz();  
149     
150     Int_t ipCh=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi);                                        //find the intersected chamber for this track 
151     if(ipCh<0) {                                                                                 //no intersection at all, go after next track
152       pTrk->SetHMPIDtrk(0,0,0,0);                                                                //no intersection found
153       pTrk->SetHMPIDcluIdx   (99,99999);                                                         //chamber not found, mip not yet considered
154       pTrk->SetHMPIDsignal(AliHMPIDRecon::kNotPerformed);                                        //ring reconstruction not yet performed
155       continue;                                                                         
156     }
157     
158 // track intersects the chamber ipCh: find the MIP          
159     
160     TClonesArray *pMipCluLst=(TClonesArray *)pClus->At(ipCh);                                   //get the list of clusters
161     nMipClusTot = pMipCluLst->GetEntries();                                                     //total number of clusters in the given chamber
162     nClusCh[ipCh] = nMipClusTot;
163     
164     for (Int_t iClu=0; iClu<nMipClusTot;iClu++) {                                               //clusters loop
165       
166       AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu);                    //get the cluster
167 // evaluate qThre
168       if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) {                                             // just for backward compatibility
169         qthre=((TF1*)pQthre->At(pClu->Ch()))->Eval(pEsd->GetTimeStamp());                          //
170       } else {                                                                                     // in the past just 1 qthre
171         hvsec = pParam->InHVSector(pClu->Y());                                              //  per chamber
172         if(hvsec>=0)
173           qthre=((TF1*)pQthre->At(6*cham+hvsec))->Eval(pEsd->GetTimeStamp());                      //
174       }                                                                                            //
175 //
176       if(pClu->Q()<qthre) continue;                                                                      //charge compartible with MIP clusters      
177       isOkQcut = kTRUE;
178
179       cluLORS[0]=pClu->X(); cluLORS[1]=pClu->Y();                                            //get the LORS coordinates of the cluster
180       pParam->Lors2Mars(ipCh,cluLORS[0],cluLORS[1],cluMARS);              //convert cluster coors. from LORS to MARS
181       radClu=TMath::Sqrt(cluMARS[0]*cluMARS[0]+cluMARS[1]*cluMARS[1]);                       //radial distance of candidate cluster in MARS                                          
182       Double_t trkx0[3]; 
183       hmpTrk->GetXYZ(trkx0);                                                                 //get track position in MARS
184       radInitTrk=TMath::Sqrt(trkx0[0]*trkx0[0]+trkx0[1]*trkx0[1]);
185       hmpTrk->PropagateToR(radClu,10);
186       hmpTrk->GetXYZ(trkx0);                                                                   //get track position in MARS
187       hmpTrk->GetXYZAt(radClu,bz,trkMARS);                                                     //get the track coordinates at the rad distance after prop. 
188       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]));
189       chi2=hmpTrk->GetPredictedChi2(pClu);
190       if(dmin > d3d ) {                                                                         //to be saved for the moment...
191         cluSiz = pClu->Size();
192         dmin=d3d;
193         bestHmpCluster=pClu;
194         index=iClu;
195         bestChi2=chi2;
196         cluLORS[0]=pClu->X(); cluLORS[1]=pClu->Y();
197 //        pParam->Lors2Mars(ipCh,cluLORS[0],cluLORS[1],bestcluMARS); 
198       }//global dmin cut 
199     }//clus loop
200
201     pTrk->SetHMPIDmip(0,0,0,0);                                                                //store mip info in any case 
202    
203     if(!isOkQcut) {
204       pTrk->SetHMPIDcluIdx(ipCh,9999);                                                          
205       pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
206       continue;                                                                     
207     }
208     
209     if(dmin < pParam->DistCut()) {
210       isOkDcut = kTRUE;
211     }
212
213     if(!isOkDcut) {
214       pTrk->SetHMPIDmip(bestHmpCluster->X(),bestHmpCluster->Y(),(Int_t)bestHmpCluster->Q(),0);  //store mip info in any case 
215       pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz);                                             //set chamber, index of cluster + cluster size
216       pTrk->SetHMPIDsignal(pParam->kMipDistCut);                                                //closest cluster with enough charge is still too far from intersection
217     }
218     
219     if(isOkQcut*isOkDcut) isMatched = kTRUE;                                                    // MIP-Track matched !!    
220     
221     if(!isMatched) continue;                                                                    // If matched continue...
222     
223     Int_t indexAll = 0;
224     for(Int_t iC=0;iC<ipCh;iC++) indexAll+=nClusCh[iC]; indexAll+=index;                        //to be verified...
225
226     Bool_t isOk = hmpTrk->Update(bestHmpCluster,bestChi2,indexAll);
227     if(!isOk) continue;
228     pTrk->SetOuterParam(hmpTrk,AliESDtrack::kHMPIDout);                 
229
230 //    cham=IntTrkCha(ipCh,hmpTrk,xPc,yPc,xRa,yRa,theta,phi);
231     cham=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi);
232     if(cham<0) {                                                                                  //no intersection at all, go after next track
233       pTrk->SetHMPIDtrk(0,0,0,0);                                                                //no intersection found
234       pTrk->SetHMPIDcluIdx   (99,99999);                                                         //chamber not found, mip not yet considered
235       pTrk->SetHMPIDsignal(AliHMPIDRecon::kNotPerformed);                                        //ring reconstruction not yet performed
236       continue;                                                                         
237     }
238
239     pTrk->SetHMPIDtrk(xRa,yRa,theta,phi);                                                        //store initial infos
240     //evaluate nMean
241     if(pNmean->GetEntries()==21) {                                                              //for backward compatibility
242       nmean=((TF1*)pNmean->At(3*cham))->Eval(pEsd->GetTimeStamp());                             //C6F14 Nmean for this chamber
243     } else {
244       Int_t iRad     = pParam->Radiator(yRa);                                                   //evaluate the radiator involved
245       if(iRad < 0) {
246         nmean = -1;
247       } else {
248       Double_t tLow  = ((TF1*)pNmean->At(6*cham+2*iRad  ))->Eval(pEsd->GetTimeStamp());         //C6F14 low  temp for this chamber
249       Double_t tHigh = ((TF1*)pNmean->At(6*cham+2*iRad+1))->Eval(pEsd->GetTimeStamp());         //C6F14 high temp for this chamber
250       Double_t tExp  = pParam->FindTemp(tLow,tHigh,yRa);                                        //estimated temp for that chamber at that y
251       nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp);                  //mean ref idx @ a given temp
252       }
253       if(nmean < 0){                                                                            //track didn' t pass through the radiator
254          pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad);                                           //set the appropriate flag
255          pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz);                                          //set index of cluster
256          continue;
257       }
258     }
259     //
260     recon.SetImpPC(xPc,yPc);                                                                     //store track impact to PC
261     recon.CkovAngle(pTrk,(TClonesArray *)pClus->At(cham),index,nmean);                           //search for Cerenkov angle of this track
262     
263     AliHMPIDPid pID;
264     Double_t prob[5];
265     pID.FindPid(pTrk,5,prob);
266     pTrk->SetHMPIDpid(prob);
267 //      Printf(" Prob e- %6.2f mu %6.2f pi %6.2f k %6.2f p %6.2f",prob[0]*100,prob[1]*100,prob[2]*100,prob[3]*100,prob[4]*100);
268
269   }//iTrk
270
271   return 0; // error code: 0=no error;
272 }//Recon()
273 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
274 Int_t AliHMPIDTracker::ReconHiddenTrk(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
275 {
276 // Static method to reconstruct Theta Ckov for all valid tracks of a given event.
277 // 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)
278 //   Returns: error code, 0 if no errors
279   
280   AliHMPIDReconHTA reconHTA;                                                                     //instance of reconstruction class, nothing important in ctor
281   
282   AliHMPIDParam *pParam = AliHMPIDParam::Instance();                                             //Instance of AliHMPIDParam
283   
284   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){                                        //loop on the ESD tracks in the event
285     
286     AliESDtrack *pTrk = pEsd->GetTrack(iTrk);                                                     //here it is simulated or just empty track
287     Int_t ipCh;
288     ipCh = pTrk->GetHMPIDcluIdx();ipCh/=1000000;
289     if(ipCh<0) continue;
290
291     TClonesArray *pMipCluLst=(TClonesArray *)pClus->At(ipCh);                                   //get the list of clusters
292     Int_t nMipClusTot = pMipCluLst->GetEntries();                                               //total number of clusters in the given chamber
293     
294     Double_t qMip=-1;
295     Int_t chMip=-1;    
296     Double_t xMip = 0;
297     Double_t yMip = 0;
298     Int_t indMip  = 0;
299     Int_t cluMipSiz = 0;
300
301     for (Int_t iClu=0; iClu<nMipClusTot;iClu++) {                                               //clusters loop
302       
303       AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu);                    //get the cluster
304       Double_t qClus = pClu->Q();
305       if(qClus>qMip) {
306         qMip  = qClus;
307         chMip = pClu->Ch();
308         xMip = pClu->X();
309         yMip = pClu->Y();
310         indMip = iClu;
311         cluMipSiz = pClu->Size();
312       }
313     }//clus loop
314
315     if(chMip<0) return 1;    
316     
317     Int_t hvsec;
318     Double_t qthre=0;
319 // evaluate qThre
320     if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) {                                              // just for backward compatibility
321       qthre=((TF1*)pQthre->At(chMip))->Eval(pEsd->GetTimeStamp());                                //
322     } else {                                                                                      // in the past just 1 qthre
323       hvsec = pParam->InHVSector(yMip);                                                           //  per chamber
324       if(hvsec>=0) qthre=((TF1*)pQthre->At(6*chMip+hvsec))->Eval(pEsd->GetTimeStamp());           //
325     }
326 //
327     if(qMip<qthre) {
328       pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0);                                                        //store mip info in any case 
329       pTrk->SetHMPIDcluIdx(chMip,indMip+1000*cluMipSiz);                                                          
330       pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
331       return 1;                                                                                   //charge compatible with MIP clusters      
332     }
333       
334     pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0);                                                   //store mip info in any case 
335     pTrk->SetHMPIDcluIdx(chMip,indMip+1000*cluMipSiz);                                                          
336
337     Double_t yRa = yMip;                                                                        //just an approx...
338     Double_t nmean;
339     //evaluate nMean
340     if(pNmean->GetEntries()==21) {                                                              //for backward compatibility
341       nmean=((TF1*)pNmean->At(3*chMip))->Eval(pEsd->GetTimeStamp());                            //C6F14 Nmean for this chamber
342     } else {
343       Int_t iRad     = pParam->Radiator(yRa);                                                   //evaluate the radiator involved
344       if(iRad < 0) {
345         nmean = -1;
346       } else {
347       Double_t tLow  = ((TF1*)pNmean->At(6*chMip+2*iRad  ))->Eval(pEsd->GetTimeStamp());        //C6F14 low  temp for this chamber
348       Double_t tHigh = ((TF1*)pNmean->At(6*chMip+2*iRad+1))->Eval(pEsd->GetTimeStamp());        //C6F14 high temp for this chamber
349       Double_t tExp  = pParam->FindTemp(tLow,tHigh,yRa);                                        //estimated temp for that chamber at that y
350       nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp);                  //mean ref idx @ a given temp
351       }
352       if(nmean < 0){                                                                            //track didn' t pass through the radiator
353          pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad);                                           //set the appropriate flag
354          return 1;
355       }
356     }
357     //
358     if(!reconHTA.CkovHiddenTrk(pTrk,(TClonesArray *)pClus->At(ipCh),indMip,nmean)) {                 //search for track parameters and Cerenkov angle of this track
359       AliHMPIDPid pID;
360       Double_t prob[5];
361       pID.FindPid(pTrk,5,prob);
362       pTrk->SetHMPIDpid(prob);
363     }
364 //      Printf(" Prob e- %6.2f mu %6.2f pi %6.2f k %6.2f p %6.2f",prob[0]*100,prob[1]*100,prob[2]*100,prob[3]*100,prob[4]*100);
365   }//iTrk
366
367   return 0; // error code: 0=no error;
368
369 }//Recon()
370 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
371 void AliHMPIDTracker::FillClusterArray(TObjArray* array) const {
372   
373  // Publishes all pointers to clusters known to the tracker into the
374   // passed object array.
375   // The ownership is not transfered - the caller is not expected to delete
376   // the clusters
377  
378   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){    
379     TClonesArray *pCluArr=(TClonesArray*)(*fClu)[iCh];
380     for (Int_t iClu=0; iClu<pCluArr->GetEntriesFast();iClu++){
381       AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluArr->UncheckedAt(iClu);    
382       array->AddLast(pClu);
383     }//cluster loop in iCh
384     pCluArr->Delete();
385   }//Ch loop
386     
387   return;
388 }
389 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++