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 "AliHMPIDRecoParamV1.h" //Recon()
8 #include "AliHMPIDReconstructor.h"//Recon()
9 #include "AliHMPIDReconHTA.h" //ReconHTA()
10 #include <AliLog.h> //Recon()
11 #include <AliESDEvent.h> //PropagateBack(),Recon()
12 #include <AliESDtrack.h> //Intersect()
13 #include <AliTracker.h>
14 #include <AliRun.h> //GetTrackPoint(),PropagateBack()
15 #include <AliTrackPointArray.h> //GetTrackPoint()
16 #include <AliAlignObj.h> //GetTrackPoint()
17 #include <AliCDBManager.h> //PropageteBack()
18 #include <AliCDBEntry.h> //PropageteBack()
19 #include "TTreeStream.h" // debug streamer
21 // HMPID base class fo tracking
25 ClassImp(AliHMPIDTracker)
26 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27 AliHMPIDTracker::AliHMPIDTracker():
29 fClu(new TObjArray(AliHMPIDParam::kMaxCh+1)),
32 // ctor. Create TObjArray of TClonesArray of AliHMPIDCluster
35 fClu->SetOwner(kTRUE);
36 for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) fClu->AddAt(new TClonesArray("AliHMPIDCluster"),i);
37 fDebugStreamer = new TTreeSRedirector("HMPIDdebug.root");
42 AliHMPIDTracker::~AliHMPIDTracker(){
47 if (fDebugStreamer) delete fDebugStreamer;
50 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51 Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
53 // Interface callback methode invoked from AliReconstruction::WriteAlignmentData() to get position of MIP cluster in MARS associated to a current track.
54 // MIP cluster is reffered by index which is stored in AliESDtrack ???????
55 // Arguments: idx- cluster index which is stored by HMPID in AliESDtrack
56 // point- reference to the object where to store the point
57 // Returns: status of operation if FALSE then AliReconstruction::WriteAlignmentData() do not store this point to array of points for current track.
58 if(idx<0) return kFALSE; //no MIP cluster assigned to this track in PropagateBack()
59 Int_t iCham=idx/1000000; Int_t iClu=idx%1000000;
60 iClu = iClu%1000; //GetHMPIDcluIdx -> 1e+6*ch + 1e+3*clusize + cluIdx;
61 point.SetVolumeID(AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,iCham));//layer and chamber number
62 TClonesArray *pArr=(TClonesArray*)(*fClu)[iCham];
63 if(!pArr) return kFALSE;
64 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pArr->UncheckedAt(iClu);//get pointer to cluster
65 if(!pClu) return kFALSE;
67 pClu->GetGlobalXYZ(xyz);
69 pClu->GetGlobalCov(cov);
70 point.SetXYZ(xyz,cov);
73 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
74 Int_t AliHMPIDTracker::IntTrkCha(AliESDtrack *pTrk,Float_t &xPc,Float_t &yPc,Float_t &xRa,Float_t &yRa,Float_t &theta,Float_t &phi)
76 // Static method to find intersection in between given track and HMPID chambers
77 // Arguments: pTrk- ESD track; xPc,yPc- track intersection with PC in LORS [cm]
78 // Returns: intersected chamber ID or -1
79 AliHMPIDtrack *hmpTrk = new AliHMPIDtrack(*pTrk); //create a hmpid track to be used for propagation and matching
80 for(Int_t i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){ //chambers loop
81 Int_t chInt = IntTrkCha(i,hmpTrk,xPc,yPc,xRa,yRa,theta,phi);
82 if(chInt>=0) {delete hmpTrk;hmpTrk=0x0;return chInt;}
84 delete hmpTrk; hmpTrk=0x0;
85 return -1; //no intersection with HMPID chambers
87 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
88 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)
90 // Static method to find intersection in between given track and HMPID chambers
91 // Arguments: pTrk- HMPID track; xPc,yPc- track intersection with PC in LORS [cm]
92 // Returns: intersected chamber ID or -1
93 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
96 pParam->Point(ch,p1,AliHMPIDParam::kRad); //point & norm for middle of radiator plane
99 pParam->Point(ch,p2,AliHMPIDParam::kPc); //point & norm for entrance to PC plane
100 if(pTrk->Intersect(p1,n1)==kFALSE) return -1; //try to intersect track with the middle of radiator
101 if(pTrk->Intersect(p2,n2)==kFALSE) return -1;
102 pParam->Mars2LorsVec(ch,n1,theta,phi); //track angles at RAD
103 pParam->Mars2Lors (ch,p1,xRa,yRa); //TRKxRAD position
104 pParam->Mars2Lors (ch,p2,xPc,yPc); //TRKxPC position
105 if(AliHMPIDParam::IsInside(xPc,yPc,pParam->DistCut())==kTRUE) return ch; //return intersected chamber
106 return -1; //no intersection with HMPID chambers
108 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
109 Int_t AliHMPIDTracker::LoadClusters(TTree *pCluTree)
111 // Interface callback methode invoked from AliReconstruction::RunTracking() to load HMPID clusters before PropagateBack() gets control. Done once per event.
112 // Arguments: pCluTree- pointer to clusters tree got by AliHMPIDLoader::LoadRecPoints("read") then AliHMPIDLoader::TreeR()
113 // Returns: error code (currently ignored in AliReconstruction::RunTraking())
114 for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) pCluTree->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));
115 pCluTree->GetEntry(0);
118 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
119 Int_t AliHMPIDTracker::PropagateBack(AliESDEvent *pEsd)
121 // Interface pure virtual in AliTracker. Invoked from AliReconstruction::RunTracking() after invocation of AliTracker::LoadClusters() once per event
122 // Agruments: pEsd - pointer to ESD
123 // Returns: error code
124 AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean"); //contains TObjArray of 42 TF1 + 1 EPhotMean
125 AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre"); //contains TObjArray of 42 (7ch * 6sec) TF1
126 if(!pNmeanEnt) AliError("No Nmean C6F14 ");
127 if(!pQthreEnt) AliError("No Qthre");
129 return Recon(pEsd,fClu,(TObjArray*)pNmeanEnt->GetObject(),(TObjArray*)pQthreEnt->GetObject());
131 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
132 Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
134 // Static method to reconstruct the Cherenkov angle for all valid tracks of a given event.
135 // Arguments: pEsd- pointer ESD; pClu- pointer to clusters for all chambers; pNmean - pointer to all function Nmean=f(time)
136 // Returns: error code, 0 if no errors
138 // Algortihm: Loop over tracks
140 // 1. Find the closest MIP cluster using fast tracks extrapolation method
141 // 2. Propagate track to the MIP cluster using the STEER method
142 // 3. Update the track information with MIP cluster (Improved angular and position resolution - to be used for Cherenkov angle calculation)
143 // 4. Propagate back the constrained track to the radiator radius ( not exact yet)
144 // 5. Propagation in the last 10 cm with the fast method
145 // 6. Set ESDtrack information
146 // 7. Calculate the Cherenkov angle
148 const Double_t kMaxSnp=0.9; //maximal snp for prolongation
149 const Double_t kdRadiator=10; // distance between radiator and the plane
150 AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
151 AliHMPIDParam *pParam = AliHMPIDParam::Instance(); //Instance of AliHMPIDParam
152 Float_t xPc,yPc,xRa,yRa,theta,phi;
154 Double_t cluLORS[2]={0};
157 Double_t qthre = 0; Double_t nmean=0; Int_t hvsec=0;
158 Int_t nClusCh[AliHMPIDParam::kMaxCh+1];
160 Bool_t tsRight = kTRUE;
162 UInt_t tsmin = (UInt_t)((TF1*)pQthre->At(0))->GetXmin(); //
163 UInt_t tsmax = (UInt_t)((TF1*)pQthre->At(0))->GetXmax(); //
164 UInt_t ts = pEsd->GetTimeStamp();
166 if(ts<tsmin || ts>tsmax) {
167 AliWarning(Form(" in HMPID time stamp out of range!!! Please check!!! ts = %i",ts));
171 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){ //loop on the ESD tracks in the event
173 // Double_t bestChi2=99999;chi2=99999; //init. track matching params
174 Double_t dmin=999999,bz=0,distCut=1,distParams[5]={1};
176 Bool_t isOkDcut=kFALSE;
177 Bool_t isOkQcut=kFALSE;
178 Bool_t isMatched=kFALSE;
180 AliHMPIDCluster *bestHmpCluster=0x0; //the best matching cluster
181 AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //get reconstructed track
183 if(!pTrk->IsOn(AliESDtrack::kTPCout)) continue;
185 if(pTrk->IsOn(AliESDtrack::kTPCrefit)) continue;
186 AliESDfriendTrack *ftrack= (AliESDfriendTrack *)pTrk->GetFriendTrack();
187 if (!ftrack) continue;
188 if (!ftrack->GetTPCOut()) continue;
189 AliHMPIDtrack *hmpTrk = new AliHMPIDtrack(*pTrk); //create a hmpid track to be used for propagation and matching
190 AliHMPIDtrack *hmpTrkConstrained = 0; //create a hmpid track to be used for propagation and matching
191 hmpTrk->Set(ftrack->GetTPCOut()->GetX(), ftrack->GetTPCOut()->GetAlpha(),ftrack->GetTPCOut()->GetParameter(), ftrack->GetTPCOut()->GetCovariance());
193 bz=AliTracker::GetBz();
195 //initial flags for HMPID ESD infos
196 pTrk->SetHMPIDtrk(0,0,0,0); //no intersection found
197 pTrk->SetHMPIDmip(0,0,0,0); //store mip info in any case
198 pTrk->SetHMPIDcluIdx(99,99999); //chamber not found, mip not yet considered
199 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNotPerformed); //ring reconstruction not yet performed
201 Int_t ipCh=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi); //find the intersected chamber for this track
202 if(ipCh<0) {delete hmpTrk;hmpTrk=0x0;continue;} //no intersection at all, go after next track
204 pTrk->SetHMPIDtrk(xPc,yPc,theta,phi); //store initial infos
205 pTrk->SetHMPIDcluIdx(ipCh,9999); //set chamber, index of cluster + cluster size
207 // track intersects the chamber ipCh: find the MIP
209 TClonesArray *pMipCluLst=(TClonesArray *)pClus->At(ipCh); //get the list of clusters
210 nMipClusTot = pMipCluLst->GetEntries(); //total number of clusters in the given chamber
211 nClusCh[ipCh] = nMipClusTot;
213 if(nMipClusTot==0) {delete hmpTrk;hmpTrk=0x0;continue;}
215 Int_t index=-1; //index of the "best" matching cluster
217 // 1. Find the closest MIP cluster using fast tracks extrapolation method
219 for (Int_t iClu=0; iClu<nMipClusTot;iClu++) { //clusters loop
221 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu); //get the cluster
224 if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) {
225 qthre=((TF1*)pQthre->At(pClu->Ch()))->Eval(ts); //
226 } else { // in the past just 1 qthre
227 hvsec = pParam->InHVSector(pClu->Y()); // per chamber
228 if(hvsec>=0) qthre=((TF1*)pQthre->At(6*ipCh+hvsec))->Eval(ts); //
230 } else qthre = pParam->QCut();
233 if(pClu->Q()<qthre) continue; //charge compartible with MIP clusters
236 cluLORS[0]=pClu->X(); cluLORS[1]=pClu->Y(); //get the LORS coordinates of the cluster
237 Double_t dist = TMath::Sqrt((xPc-cluLORS[0])*(xPc-cluLORS[0])+(yPc-cluLORS[1])*(yPc-cluLORS[1]));
248 pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
249 delete hmpTrk;hmpTrk=0x0; continue;
253 // 2. Propagate track to the MIP cluster using the STEER method
256 if(!bestHmpCluster) {delete hmpTrk;hmpTrk=0x0; delete hmpTrkConstrained;hmpTrkConstrained=0x0; continue;}
258 TVector3 vG = pParam->Lors2Mars(ipCh,bestHmpCluster->X(),bestHmpCluster->Y());
262 Double_t alpha=TMath::ATan2(gy,gx);
263 Double_t radiusH=TMath::Sqrt(gy*gy+gx*gx);
264 if (!(hmpTrk->Rotate(alpha,kTRUE))) continue;
265 if(!AliTrackerBase::PropagateTrackToBxByBz(hmpTrk,radiusH,pTrk->GetMass(),1,kFALSE,kMaxSnp,-1)) {delete hmpTrk;hmpTrk=0x0; delete hmpTrkConstrained;hmpTrkConstrained=0x0; continue;}
267 // 3. Update the track with MIP cluster (Improved angular and position resolution - to be used for Cherenkov angle calculation)
269 AliExternalTrackParam trackC(*hmpTrk);
270 Double_t posC[2]={0,gz};
271 Double_t covC[3]={0.1*0.1, 0, 0.1*0.1};
272 trackC.Update(posC,covC);
274 // 4. Propagate back the constrained track to the radiator radius ( not exact yet)
276 hmpTrkConstrained = new AliHMPIDtrack(*pTrk);
277 hmpTrkConstrained->Set(trackC.GetX(), trackC.GetAlpha(),trackC.GetParameter(), trackC.GetCovariance());
278 if(!AliTrackerBase::PropagateTrackToBxByBz(hmpTrkConstrained,radiusH-kdRadiator,pTrk->GetMass(),1,kFALSE,kMaxSnp,1)) {delete hmpTrk;hmpTrk=0x0; delete hmpTrkConstrained;hmpTrkConstrained=0x0;continue;}
280 // 5. Propagation in the last 10 cm with the fast method
282 Float_t xPc0=0, yPc0=0;
284 IntTrkCha(ipCh, hmpTrk, xPc0,yPc0,xRa,yRa,theta,phi);
285 IntTrkCha(ipCh, hmpTrkConstrained, xPc,yPc,xRa,yRa,theta,phi);
287 // 6. Set ESDtrack information
289 Int_t cluSiz = bestHmpCluster->Size();
290 pTrk->SetHMPIDmip(bestHmpCluster->X(),bestHmpCluster->Y(),(Int_t)bestHmpCluster->Q(),0); //store mip info in any case
291 pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set chamber, index of cluster + cluster size
292 pTrk->SetHMPIDtrk(xPc0,yPc0,theta,phi);
295 // Dump debug info if specified
297 if (AliHMPIDReconstructor::StreamLevel()>0) {
298 AliExternalTrackParam * trackTPC=new AliExternalTrackParam(*(ftrack->GetTPCOut()));
299 AliExternalTrackParam * trackCurrent=new AliExternalTrackParam(*pTrk);
300 if(!trackTPC->Rotate(alpha)) continue;
301 if(!trackCurrent->Rotate(alpha)) continue;
302 Bool_t statusTPC= AliTracker::PropagateTrackToBxByBz(trackTPC,radiusH,pTrk->GetMass(),1,kFALSE,kMaxSnp,-1);
303 Bool_t statusCurrent=AliTracker::PropagateTrackToBxByBz(trackCurrent,radiusH,pTrk->GetMass(),1,kFALSE,kMaxSnp,-1);
304 AliExternalTrackParam * trackTPCNB=new AliExternalTrackParam(*(ftrack->GetTPCOut()));
305 if(!trackTPCNB->Rotate(alpha)) continue;
306 Bool_t statusTPCNB=kTRUE;
307 Double_t bfield[3]={0,0,0};
308 for (Double_t radius=trackTPCNB->GetX(); radius<radiusH; radius+=1){
310 trackTPCNB->GetXYZ(xyz);
311 GetBxByBz(xyz,bfield);
312 statusTPCNB&=trackTPCNB->PropagateToBxByBz(radius,bfield);
314 statusTPCNB&=trackTPCNB->PropagateToBxByBz(radiusH,bfield);
316 Double_t tanAlpha=TMath::Tan(TMath::ASin(trackTPC->GetSnp()));
317 Double_t deltaC= trackTPC->GetC(AliTrackerBase::GetBz())-ftrack->GetTPCOut()->GetC(AliTrackerBase::GetBz());
319 AliExternalTrackParam * trackTPCConstrained= new AliExternalTrackParam(*trackTPC);
320 Double_t pos[2]={0,gz};
321 Double_t cov[3]={0.1*0.1, 0, 0.1*0.1};
322 Double_t chi2C = trackTPCConstrained->GetPredictedChi2(pos,cov);
323 trackTPCConstrained->Update(pos,cov);
324 (*fDebugStreamer)<<"track"<<
325 "rH="<<radiusH<< // radius of cluster
326 "angle="<<tanAlpha<< // tan of the local inlination angle
327 "dC="<<deltaC<< // delta of the curvature
328 "trackTPC.="<<trackTPC<< // TPC outer param extrapolated to the HMPID
329 "trackTPCNB.="<<trackTPCNB<< // TPC track prpagated with material budget correction
331 "trackTPCC.="<<trackTPCConstrained<< // TPC outer param extrapolated to the HMPID constrained
332 "trackCurrent.="<<trackCurrent<< // current track extrapolated to the HMPID
333 "sTPC="<<statusTPC<< // status for the current TPC track
334 "sCurrent="<<statusCurrent<< // status for the current global track
335 "cl.="<<bestHmpCluster<< // HMPID cluster
337 "t.="<<pTrk<< // curent esd track
338 "ft.="<<ftrack<< // friend track
339 "hmpTrk.="<<hmpTrk<< // hmpid tracks as used in the following code
340 "hmpTrkC.="<<hmpTrkConstrained<< // constrained hmpid tracks as used in the following code
341 "gx="<<gx<< // global cluster position X
350 pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
351 delete hmpTrk;hmpTrk=0x0;
352 delete hmpTrkConstrained;hmpTrkConstrained=0x0;
356 if(AliHMPIDReconstructor::GetRecoParam()) //retrieve distance cut
358 if(AliHMPIDReconstructor::GetRecoParam()->IsFixedDistCut()==kTRUE) //distance cut is fixed number
360 distCut=AliHMPIDReconstructor::GetRecoParam()->GetHmpTrackMatchingDist();
364 for(Int_t ipar=0;ipar<5;ipar++) distParams[ipar]=AliHMPIDReconstructor::GetRecoParam()->GetHmpTrackMatchingDistParam(ipar); //prevision: distance cut is function of momentum
365 distCut=distParams[0]+distParams[1]*TMath::Power(distParams[2]*pTrk->GetP(),distParams[3]); //prevision: change functional form to be more precise
368 else {distCut=pParam->DistCut();}
372 dmin = TMath::Sqrt((xPc0-bestHmpCluster->X())*(xPc0-bestHmpCluster->X())+(yPc0-bestHmpCluster->Y())*(yPc0-bestHmpCluster->Y()));
377 //isOkDcut = kTRUE; // switch OFF cut
380 pTrk->SetHMPIDsignal(pParam->kMipDistCut); //closest cluster with enough charge is still too far from intersection
383 if(isOkQcut*isOkDcut) isMatched = kTRUE; // MIP-Track matched !!
385 if(!isMatched) {delete hmpTrk;hmpTrk=0x0;delete hmpTrkConstrained;hmpTrkConstrained=0x0;continue;} // If matched continue...
388 if(!isOk) {delete hmpTrk;hmpTrk=0x0; delete hmpTrkConstrained;hmpTrkConstrained=0x0; continue;}
389 pTrk->SetOuterHmpParam(hmpTrkConstrained,AliESDtrack::kHMPIDout);
391 FillResiduals(hmpTrk,bestHmpCluster,kFALSE);
393 Int_t iRad = pParam->Radiator(yRa); //evaluate the radiator involved
397 if(pNmean->GetEntries()==21) { //for backward compatibility
398 nmean=((TF1*)pNmean->At(3*ipCh))->Eval(ts); //C6F14 Nmean for this chamber
403 Double_t tLow = ((TF1*)pNmean->At(6*ipCh+2*iRad ))->Eval(ts); //C6F14 low temp for this chamber
404 Double_t tHigh = ((TF1*)pNmean->At(6*ipCh+2*iRad+1))->Eval(ts); //C6F14 high temp for this chamber
405 Double_t tExp = pParam->FindTemp(tLow,tHigh,yRa); //estimated temp for that chamber at that y
406 nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp); //mean ref idx @ a given temp
408 if(nmean < 0){ //track didn' t pass through the radiator
409 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad); //set the appropriate flag
410 pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set index of cluster
411 delete hmpTrk;hmpTrk=0x0;
412 delete hmpTrkConstrained;hmpTrkConstrained=0x0;
416 } else nmean = pParam->MeanIdxRad();
418 // 7. Calculate the Cherenkov angle
420 recon.SetImpPC(xPc0,yPc0); //store track impact to PC
421 recon.CkovAngle(pTrk,(TClonesArray *)pClus->At(ipCh),index,nmean,xRa,yRa); //search for Cerenkov angle of this track
423 Double_t thetaCkov = pTrk->GetHMPIDsignal();
425 if (AliHMPIDReconstructor::StreamLevel()>0) {
426 AliExternalTrackParam * trackTPC=new AliExternalTrackParam(*(ftrack->GetTPCOut()));
427 AliExternalTrackParam * trackCurrent=new AliExternalTrackParam(*pTrk);
428 if(!trackTPC->Rotate(alpha)) continue;
429 if(!trackCurrent->Rotate(alpha)) continue;
430 Bool_t statusTPC= AliTracker::PropagateTrackToBxByBz(trackTPC,radiusH,pTrk->GetMass(),1,kFALSE,kMaxSnp,-1);
431 Bool_t statusCurrent=AliTracker::PropagateTrackToBxByBz(trackCurrent,radiusH,pTrk->GetMass(),1,kFALSE,kMaxSnp,-1);
432 Double_t tanAlpha=TMath::Tan(TMath::ASin(trackTPC->GetSnp()));
433 Double_t deltaC= trackTPC->GetC(AliTrackerBase::GetBz())-ftrack->GetTPCOut()->GetC(AliTrackerBase::GetBz());
435 AliExternalTrackParam * trackTPCNB=new AliExternalTrackParam(*(ftrack->GetTPCOut()));
436 if(!trackTPCNB->Rotate(alpha)) continue;
437 Bool_t statusTPCNB=kTRUE;
438 Double_t bfield[3]={0,0,0};
439 for (Double_t radius=trackTPCNB->GetX(); radius<radiusH; radius+=1){
441 trackTPCNB->GetXYZ(xyz);
442 GetBxByBz(xyz,bfield);
443 statusTPCNB&=trackTPCNB->PropagateToBxByBz(radius,bfield);
445 statusTPCNB&=trackTPCNB->PropagateToBxByBz(radiusH,bfield);
447 AliExternalTrackParam * trackTPCConstrained= new AliExternalTrackParam(*trackTPC);
448 Double_t pos[2]={0,gz};
449 Double_t cov[3]={0.1*0.1, 0, 0.1*0.1};
450 Double_t chi2C = trackTPCConstrained->GetPredictedChi2(pos,cov);
451 trackTPCConstrained->Update(pos,cov);
452 (*fDebugStreamer)<<"track2"<<
453 "rH="<<radiusH<< // radius of cluster
454 "angle="<<tanAlpha<< // tan of the local inlination angle
455 "dC="<<deltaC<< // delta of the curvature
456 "trackTPC.="<<trackTPC<< // TPC outer param extrapolated to the HMPID
457 "trackTPCNB.="<<trackTPCNB<< // TPC outer param extrapolated to the HMPID
459 "trackTPCC.="<<trackTPCConstrained<< // TPC outer param extrapolated to the HMPID constrained
460 "trackCurrent.="<<trackCurrent<< // current track extrapolated to the HMPID
461 "sTPC="<<statusTPC<< // status for the current TPC track
462 "sCurrent="<<statusCurrent<< // status for the current global track
463 "cl.="<<bestHmpCluster<< // HMPID cluster
465 "t.="<<pTrk<< // curent esd track
466 "ft.="<<ftrack<< // friend track
467 "hmpTrk.="<<hmpTrk<< // hmpid tracks as used in the following code
468 "hmpTrkC.="<<hmpTrkConstrained<< // constrained hmpid tracks as used in the following code
469 "gx="<<gx<< // global cluster position X
472 "thetaCkov="<<thetaCkov<< // Cherenkov angle
476 if(pTrk->GetHMPIDsignal()<0) {
477 delete hmpTrk;hmpTrk=0x0;
478 delete hmpTrkConstrained; hmpTrkConstrained=0x0;
483 pID.FindPid(pTrk,nmean,5,prob);
484 pTrk->SetHMPIDpid(prob);
485 delete hmpTrk; hmpTrk=0x0;
486 delete hmpTrkConstrained; hmpTrkConstrained=0x0;
489 return 0; // error code: 0=no error;
491 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
492 Int_t AliHMPIDTracker::ReconFromKin(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
494 // Static method to reconstruct Theta Ckov for all valid tracks of a given event.
495 // Arguments: pEsd- pointer ESD; pClu- pointer to clusters for all chambers; pNmean - pointer to all function Nmean=f(time)
496 // Returns: error code, 0 if no errors
498 AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
499 AliHMPIDParam *pParam = AliHMPIDParam::Instance(); //Instance of AliHMPIDParam
500 Float_t xPc,yPc,xRa,yRa,theta,phi;
501 Double_t cluLORS[2]={0};
503 Double_t qthre = 0; Double_t nmean=0; Int_t hvsec=0;
504 Int_t nClusCh[AliHMPIDParam::kMaxCh+1];
506 Bool_t tsRight = kTRUE;
508 UInt_t tsmin = (UInt_t)((TF1*)pQthre->At(0))->GetXmin(); //
509 UInt_t tsmax = (UInt_t)((TF1*)pQthre->At(0))->GetXmax(); //
510 UInt_t ts = pEsd->GetTimeStamp();
512 if(ts<tsmin || ts>tsmax) {
513 AliWarning(Form(" in HMPID time stamp out of range!!! Please check!!! ts = %i",ts));
517 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){ //loop on the ESD tracks in the event
519 Double_t dmin=999999,bz=0,distCut=1,distParams[5]={1};
521 Bool_t isOkDcut=kFALSE;
522 Bool_t isOkQcut=kFALSE;
523 Bool_t isMatched=kFALSE;
525 AliHMPIDCluster *bestHmpCluster=0x0; //the best matching cluster
526 AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //get reconstructed track
528 AliHMPIDtrack *hmpTrk = new AliHMPIDtrack(*pTrk); //create a hmpid track to be used for propagation and matching
529 bz=AliTracker::GetBz();
530 //initial flags for HMPID ESD infos
531 pTrk->SetHMPIDtrk(0,0,0,0); //no intersection found
532 pTrk->SetHMPIDmip(0,0,0,0); //store mip info in any case
533 pTrk->SetHMPIDcluIdx(99,99999); //chamber not found, mip not yet considered
534 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNotPerformed); //ring reconstruction not yet performed
536 Int_t ipCh=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi); //find the intersected chamber for this track
537 if(ipCh<0) {delete hmpTrk;hmpTrk=0x0;continue;} //no intersection at all, go after next track
539 pTrk->SetHMPIDtrk(xPc,yPc,theta,phi); //store initial infos
540 pTrk->SetHMPIDcluIdx(ipCh,9999); //set chamber, index of cluster + cluster size
542 // track intersects the chamber ipCh: find the MIP
544 TClonesArray *pMipCluLst=(TClonesArray *)pClus->At(ipCh); //get the list of clusters
545 nMipClusTot = pMipCluLst->GetEntries(); //total number of clusters in the given chamber
546 nClusCh[ipCh] = nMipClusTot;
548 if(nMipClusTot==0) {delete hmpTrk;hmpTrk=0x0;continue;}
550 Int_t index=-1; //index of the "best" matching cluster
552 for (Int_t iClu=0; iClu<nMipClusTot;iClu++) { //clusters loop
554 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu); //get the cluster
557 if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) {
558 qthre=((TF1*)pQthre->At(pClu->Ch()))->Eval(ts); //
559 } else { // in the past just 1 qthre
560 hvsec = pParam->InHVSector(pClu->Y()); // per chamber
561 if(hvsec>=0) qthre=((TF1*)pQthre->At(6*ipCh+hvsec))->Eval(ts); //
563 } else qthre = pParam->QCut();
566 if(pClu->Q()<qthre) continue; //charge compartible with MIP clusters
569 cluLORS[0]=pClu->X(); cluLORS[1]=pClu->Y(); //get the LORS coordinates of the cluster
570 Double_t dist = TMath::Sqrt((xPc-cluLORS[0])*(xPc-cluLORS[0])+(yPc-cluLORS[1])*(yPc-cluLORS[1]));
580 pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
581 delete hmpTrk;hmpTrk=0x0; continue;
584 Double_t radius = (pParam->Lors2Mars(ipCh,pParam->SizeAllX()/2,pParam->SizeAllY()/2)).Mag();
586 if(!AliTracker::PropagateTrackToBxByBz(hmpTrk,radius,pTrk->GetMass(),1,kFALSE)) {delete hmpTrk;hmpTrk=0x0;continue;}
588 if(!hmpTrk->PropagateTo(bestHmpCluster)) {delete hmpTrk;hmpTrk=0x0;continue;}
590 Int_t cluSiz = bestHmpCluster->Size();
591 pTrk->SetHMPIDmip(bestHmpCluster->X(),bestHmpCluster->Y(),(Int_t)bestHmpCluster->Q(),0); //store mip info in any case
592 pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set chamber, index of cluster + cluster size
594 if(AliHMPIDReconstructor::GetRecoParam()) //retrieve distance cut
596 if(AliHMPIDReconstructor::GetRecoParam()->IsFixedDistCut()==kTRUE) //distance cut is fixed number
598 distCut=AliHMPIDReconstructor::GetRecoParam()->GetHmpTrackMatchingDist();
602 for(Int_t ipar=0;ipar<5;ipar++) distParams[ipar]=AliHMPIDReconstructor::GetRecoParam()->GetHmpTrackMatchingDistParam(ipar); //prevision: distance cut is function of momentum
603 distCut=distParams[0]+distParams[1]*TMath::Power(distParams[2]*pTrk->GetP(),distParams[3]); //prevision: change functional form to be more precise
606 else {distCut=pParam->DistCut();}
613 pTrk->SetHMPIDsignal(pParam->kMipDistCut); //closest cluster with enough charge is still too far from intersection
616 if(isOkQcut*isOkDcut) isMatched = kTRUE; // MIP-Track matched !!
618 if(!isMatched) {delete hmpTrk;hmpTrk=0x0;continue;} // If matched continue...
620 Bool_t isOk = hmpTrk->Update(bestHmpCluster,0.1,0);
621 if(!isOk) {delete hmpTrk;hmpTrk=0x0;continue;}
622 pTrk->SetOuterHmpParam(hmpTrk,AliESDtrack::kHMPIDout);
624 FillResiduals(hmpTrk,bestHmpCluster,kFALSE);
626 Int_t iRad = pParam->Radiator(yRa); //evaluate the radiator involved
630 if(pNmean->GetEntries()==21) { //for backward compatibility
631 nmean=((TF1*)pNmean->At(3*ipCh))->Eval(ts); //C6F14 Nmean for this chamber
636 Double_t tLow = ((TF1*)pNmean->At(6*ipCh+2*iRad ))->Eval(ts); //C6F14 low temp for this chamber
637 Double_t tHigh = ((TF1*)pNmean->At(6*ipCh+2*iRad+1))->Eval(ts); //C6F14 high temp for this chamber
638 Double_t tExp = pParam->FindTemp(tLow,tHigh,yRa); //estimated temp for that chamber at that y
639 nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp); //mean ref idx @ a given temp
641 if(nmean < 0){ //track didn' t pass through the radiator
642 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad); //set the appropriate flag
643 pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set index of cluster
644 delete hmpTrk;hmpTrk=0x0;
648 } else nmean = pParam->MeanIdxRad();
651 recon.SetImpPC(xPc,yPc); //store track impact to PC
652 recon.CkovAngle(pTrk,(TClonesArray *)pClus->At(ipCh),index,nmean,xRa,yRa); //search for Cerenkov angle of this track
654 if(pTrk->GetHMPIDsignal()<0) {delete hmpTrk;hmpTrk=0x0;continue;}
658 pID.FindPid(pTrk,nmean,5,prob);
659 // Printf("Tracker RefIndex = %f, chmaber = %i, prob1 = %f, prob2 = %f, prob3 = %f, prob4 = %f, prob5 = %f", nmean,ipCh,prob[0],prob[1],prob[2],prob[3],prob[4]);
660 pTrk->SetHMPIDpid(prob);
661 delete hmpTrk;hmpTrk=0x0;
664 return 0; // error code: 0=no error;
666 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
667 Int_t AliHMPIDTracker::ReconHiddenTrk(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
669 // Static method to reconstruct Theta Ckov for all valid tracks of a given event.
670 // 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)
671 // Returns: error code, 0 if no errors
673 AliHMPIDReconHTA reconHTA; //instance of reconstruction class, nothing important in ctor
675 AliHMPIDParam *pParam = AliHMPIDParam::Instance(); //Instance of AliHMPIDParam
677 Bool_t tsRight = kTRUE;
679 UInt_t tsmin = (UInt_t)((TF1*)pQthre->At(0))->GetXmin(); //
680 UInt_t tsmax = (UInt_t)((TF1*)pQthre->At(0))->GetXmax(); //
681 UInt_t ts = pEsd->GetTimeStamp();
683 if(ts<tsmin || ts>tsmax) {
684 AliWarning(Form(" in HMPID time stamp out of range!!! Please check!!! ts = %i",ts));
688 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){ //loop on the ESD tracks in the event
690 AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //here it is simulated or just empty track
692 ipCh = pTrk->GetHMPIDcluIdx();ipCh/=1000000;
695 TClonesArray *pMipCluLst=(TClonesArray *)pClus->At(ipCh); //get the list of clusters
696 Int_t nMipClusTot = pMipCluLst->GetEntries(); //total number of clusters in the given chamber
705 for (Int_t iClu=0; iClu<nMipClusTot;iClu++) { //clusters loop
707 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu); //get the cluster
708 Double_t qClus = pClu->Q();
715 cluMipSiz = pClu->Size();
719 if(chMip<0) return 1;
726 if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) { // just for backward compatibility
727 qthre=((TF1*)pQthre->At(chMip))->Eval(ts); //
728 } else { // in the past just 1 qthre
729 hvsec = pParam->InHVSector(yMip); // per chamber
730 if(hvsec>=0) qthre=((TF1*)pQthre->At(6*chMip+hvsec))->Eval(ts); //
732 } else qthre = pParam->QCut();
735 pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0); //store mip info in any case
736 pTrk->SetHMPIDcluIdx(chMip,indMip+1000*cluMipSiz);
737 pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
738 return 1; //charge compatible with MIP clusters
741 pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0); //store mip info in any case
742 pTrk->SetHMPIDcluIdx(chMip,indMip+1000*cluMipSiz);
744 Double_t yRa = yMip; //just an approx...
747 Int_t iRad = pParam->Radiator(yRa); //evaluate the radiator involved
751 if(pNmean->GetEntries()==21) { //for backward compatibility
752 nmean=((TF1*)pNmean->At(3*chMip))->Eval(ts); //C6F14 Nmean for this chamber
757 Double_t tLow = ((TF1*)pNmean->At(6*chMip+2*iRad ))->Eval(ts); //C6F14 low temp for this chamber
758 Double_t tHigh = ((TF1*)pNmean->At(6*chMip+2*iRad+1))->Eval(ts); //C6F14 high temp for this chamber
759 Double_t tExp = pParam->FindTemp(tLow,tHigh,yRa); //estimated temp for that chamber at that y
760 nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp); //mean ref idx @ a given temp
762 if(nmean < 0){ //track didn' t pass through the radiator
763 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad); //set the appropriate flag
767 } else nmean = pParam->MeanIdxRad();
769 if(!reconHTA.CkovHiddenTrk(pTrk,(TClonesArray *)pClus->At(ipCh),indMip,nmean)) { //search for track parameters and Cerenkov angle of this track
772 pID.FindPid(pTrk,nmean,5,prob);
773 pTrk->SetHMPIDpid(prob);
775 // 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);
778 return 0; // error code: 0=no error;
781 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
782 void AliHMPIDTracker::FillClusterArray(TObjArray* array) const {
784 // Publishes all pointers to clusters known to the tracker into the
785 // passed object array.
786 // The ownership is not transfered - the caller is not expected to delete
789 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
790 TClonesArray *pCluArr=(TClonesArray*)(*fClu)[iCh];
791 for (Int_t iClu=0; iClu<pCluArr->GetEntriesFast();iClu++){
792 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluArr->UncheckedAt(iClu);
793 array->AddLast(pClu);
794 }//cluster loop in iCh
800 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++