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()
16 // HMPID base class fo tracking
20 ClassImp(AliHMPIDTracker)
21 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 AliHMPIDTracker::AliHMPIDTracker():
24 fClu(new TObjArray(AliHMPIDParam::kMaxCh+1))
26 // ctor. Create TObjArray of TClonesArray of AliHMPIDCluster
29 fClu->SetOwner(kTRUE);
30 for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) fClu->AddAt(new TClonesArray("AliHMPIDCluster"),i);
32 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 Bool_t AliHMPIDTracker::GetTrackPoint(Int_t idx, AliTrackPoint& point) const
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
47 pClu->GetGlobalXYZ(xyz);
49 pClu->GetGlobalCov(cov);
50 point.SetXYZ(xyz,cov);
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)
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 AliHMPIDtrack *hmpTrk = new AliHMPIDtrack(*pTrk); //create a hmpid track to be used for propagation and matching
60 for(Int_t i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){ //chambers loop
61 Int_t chInt = IntTrkCha(i,hmpTrk,xPc,yPc,xRa,yRa,theta,phi);
62 if(chInt>=0) {delete hmpTrk;hmpTrk=0x0;return chInt;}
64 delete hmpTrk; hmpTrk=0x0;
65 return -1; //no intersection with HMPID chambers
67 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
68 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)
70 // Static method to find intersection in between given track and HMPID chambers
71 // Arguments: pTrk- HMPID track; xPc,yPc- track intersection with PC in LORS [cm]
72 // Returns: intersected chamber ID or -1
73 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
76 pParam->Point(ch,p1,AliHMPIDParam::kRad); //point & norm for middle of radiator plane
79 pParam->Point(ch,p2,AliHMPIDParam::kPc); //point & norm for entrance to PC plane
80 if(pTrk->Intersect(pTrk,p1,n1)==kFALSE) return -1; //try to intersect track with the middle of radiator
81 if(pTrk->Intersect(pTrk,p2,n2)==kFALSE) return -1;
82 pParam->Mars2LorsVec(ch,n1,theta,phi); //track angles at RAD
83 pParam->Mars2Lors (ch,p1,xRa,yRa); //TRKxRAD position
84 pParam->Mars2Lors (ch,p2,xPc,yPc); //TRKxPC position
85 if(AliHMPIDParam::IsInside(xPc,yPc,pParam->DistCut())==kTRUE) return ch; //return intersected chamber
86 return -1; //no intersection with HMPID chambers
88 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
89 Int_t AliHMPIDTracker::LoadClusters(TTree *pCluTree)
91 // Interface callback methode invoked from AliReconstruction::RunTracking() to load HMPID clusters before PropagateBack() gets control. Done once per event.
92 // Arguments: pCluTree- pointer to clusters tree got by AliHMPIDLoader::LoadRecPoints("read") then AliHMPIDLoader::TreeR()
93 // Returns: error code (currently ignored in AliReconstruction::RunTraking())
94 for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++) pCluTree->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));
95 pCluTree->GetEntry(0);
98 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
99 Int_t AliHMPIDTracker::PropagateBack(AliESDEvent *pEsd)
101 // Interface pure virtual in AliTracker. Invoked from AliReconstruction::RunTracking() after invocation of AliTracker::LoadClusters() once per event
102 // Agruments: pEsd - pointer to ESD
103 // Returns: error code
104 AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean"); //contains TObjArray of 42 TF1 + 1 EPhotMean
105 AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre"); //contains TObjArray of 42 (7ch * 6sec) TF1
106 if(!pNmeanEnt) AliError("No Nmean C6F14 ");
107 if(!pQthreEnt) AliError("No Qthre");
109 return Recon(pEsd,fClu,(TObjArray*)pNmeanEnt->GetObject(),(TObjArray*)pQthreEnt->GetObject());
111 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112 Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
114 // Static method to reconstruct Theta Ckov for all valid tracks of a given event.
115 // Arguments: pEsd- pointer ESD; pClu- pointer to clusters for all chambers; pNmean - pointer to all function Nmean=f(time)
116 // Returns: error code, 0 if no errors
118 AliHMPIDRecon recon; //instance of reconstruction class, nothing important in ctor
119 Float_t xPc,yPc,xRa,yRa,theta,phi;
120 Double_t cluLORS[2]={0},cluMARS[3]={0},trkMARS[3]={0};
121 // Double_t bestcluMARS[3]={0,0,0};
122 Double_t radClu,radInitTrk;
124 Double_t d3d=0,dmin=999999,bz=0;
125 Bool_t isMatched=kFALSE;
127 Double_t qthre = 0; Double_t nmean=0; Int_t cham=0; Int_t hvsec=0;
128 Int_t index=0; //index of the "best" matching cluster
129 Double_t bestChi2=-1; //Chi2 of the "best" matching cluster
131 Int_t nClusCh[AliHMPIDParam::kMaxCh+1];
132 Bool_t isOkQcut=kFALSE;
133 Bool_t isOkDcut=kFALSE;
135 AliHMPIDParam *pParam = AliHMPIDParam::Instance(); //Instance of AliHMPIDParam
137 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){ //loop on the ESD tracks in the event
138 isMatched=kFALSE;dmin=999999;bestChi2=99999;chi2=99999;cluSiz=0; //init. track matching params
140 AliHMPIDCluster *bestHmpCluster=0x0; //the best matching cluster
141 AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //get reconstructed track
142 AliHMPIDtrack *hmpTrk = new AliHMPIDtrack(*pTrk); //create a hmpid track to be used for propagation and matching
143 bz=AliTracker::GetBz();
145 Int_t ipCh=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi); //find the intersected chamber for this track
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
154 // track intersects the chamber ipCh: find the MIP
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;
160 for (Int_t iClu=0; iClu<nMipClusTot;iClu++) { //clusters loop
162 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu); //get the cluster
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
169 qthre=((TF1*)pQthre->At(6*cham+hvsec))->Eval(pEsd->GetTimeStamp()); //
172 if(pClu->Q()<qthre) continue; //charge compartible with MIP clusters
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
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();
192 cluLORS[0]=pClu->X(); cluLORS[1]=pClu->Y();
193 // pParam->Lors2Mars(ipCh,cluLORS[0],cluLORS[1],bestcluMARS);
197 pTrk->SetHMPIDmip(0,0,0,0); //store mip info in any case
200 pTrk->SetHMPIDcluIdx(ipCh,9999);
201 pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
205 if(dmin < pParam->DistCut()) {
210 pTrk->SetHMPIDmip(bestHmpCluster->X(),bestHmpCluster->Y(),(Int_t)bestHmpCluster->Q(),0); //store mip info in any case
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
215 if(isOkQcut*isOkDcut) isMatched = kTRUE; // MIP-Track matched !!
217 if(!isMatched) continue; // If matched continue...
220 for(Int_t iC=0;iC<ipCh;iC++) indexAll+=nClusCh[iC]; indexAll+=index; //to be verified...
222 Bool_t isOk = hmpTrk->Update(bestHmpCluster,bestChi2,indexAll);
224 pTrk->SetOuterParam(hmpTrk,AliESDtrack::kHMPIDout);
226 cham=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi);
228 if(cham<0) { //no intersection at all, go after next track
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
235 pTrk->SetHMPIDtrk(xRa,yRa,theta,phi); //store initial infos
237 if(pNmean->GetEntries()==21) { //for backward compatibility
238 nmean=((TF1*)pNmean->At(3*cham))->Eval(pEsd->GetTimeStamp()); //C6F14 Nmean for this chamber
240 Int_t iRad = pParam->Radiator(yRa); //evaluate the radiator involved
244 Double_t tLow = ((TF1*)pNmean->At(6*cham+2*iRad ))->Eval(pEsd->GetTimeStamp()); //C6F14 low temp for this chamber
245 Double_t tHigh = ((TF1*)pNmean->At(6*cham+2*iRad+1))->Eval(pEsd->GetTimeStamp()); //C6F14 high temp for this chamber
246 Double_t tExp = pParam->FindTemp(tLow,tHigh,yRa); //estimated temp for that chamber at that y
247 nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp); //mean ref idx @ a given temp
249 if(nmean < 0){ //track didn' t pass through the radiator
250 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad); //set the appropriate flag
251 pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz); //set index of cluster
256 recon.SetImpPC(xPc,yPc); //store track impact to PC
257 recon.CkovAngle(pTrk,(TClonesArray *)pClus->At(cham),index,nmean); //search for Cerenkov angle of this track
261 pID.FindPid(pTrk,5,prob);
262 pTrk->SetHMPIDpid(prob);
263 // 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);
265 delete hmpTrk;hmpTrk=0x0;
268 return 0; // error code: 0=no error;
270 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
271 Int_t AliHMPIDTracker::ReconHiddenTrk(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmean, TObjArray *pQthre)
273 // Static method to reconstruct Theta Ckov for all valid tracks of a given event.
274 // 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)
275 // Returns: error code, 0 if no errors
277 AliHMPIDReconHTA reconHTA; //instance of reconstruction class, nothing important in ctor
279 AliHMPIDParam *pParam = AliHMPIDParam::Instance(); //Instance of AliHMPIDParam
281 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){ //loop on the ESD tracks in the event
283 AliESDtrack *pTrk = pEsd->GetTrack(iTrk); //here it is simulated or just empty track
285 ipCh = pTrk->GetHMPIDcluIdx();ipCh/=1000000;
288 TClonesArray *pMipCluLst=(TClonesArray *)pClus->At(ipCh); //get the list of clusters
289 Int_t nMipClusTot = pMipCluLst->GetEntries(); //total number of clusters in the given chamber
298 for (Int_t iClu=0; iClu<nMipClusTot;iClu++) { //clusters loop
300 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu); //get the cluster
301 Double_t qClus = pClu->Q();
308 cluMipSiz = pClu->Size();
312 if(chMip<0) return 1;
317 if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) { // just for backward compatibility
318 qthre=((TF1*)pQthre->At(chMip))->Eval(pEsd->GetTimeStamp()); //
319 } else { // in the past just 1 qthre
320 hvsec = pParam->InHVSector(yMip); // per chamber
321 if(hvsec>=0) qthre=((TF1*)pQthre->At(6*chMip+hvsec))->Eval(pEsd->GetTimeStamp()); //
325 pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0); //store mip info in any case
326 pTrk->SetHMPIDcluIdx(chMip,indMip+1000*cluMipSiz);
327 pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
328 return 1; //charge compatible with MIP clusters
331 pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0); //store mip info in any case
332 pTrk->SetHMPIDcluIdx(chMip,indMip+1000*cluMipSiz);
334 Double_t yRa = yMip; //just an approx...
337 if(pNmean->GetEntries()==21) { //for backward compatibility
338 nmean=((TF1*)pNmean->At(3*chMip))->Eval(pEsd->GetTimeStamp()); //C6F14 Nmean for this chamber
340 Int_t iRad = pParam->Radiator(yRa); //evaluate the radiator involved
344 Double_t tLow = ((TF1*)pNmean->At(6*chMip+2*iRad ))->Eval(pEsd->GetTimeStamp()); //C6F14 low temp for this chamber
345 Double_t tHigh = ((TF1*)pNmean->At(6*chMip+2*iRad+1))->Eval(pEsd->GetTimeStamp()); //C6F14 high temp for this chamber
346 Double_t tExp = pParam->FindTemp(tLow,tHigh,yRa); //estimated temp for that chamber at that y
347 nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp); //mean ref idx @ a given temp
349 if(nmean < 0){ //track didn' t pass through the radiator
350 pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad); //set the appropriate flag
355 if(!reconHTA.CkovHiddenTrk(pTrk,(TClonesArray *)pClus->At(ipCh),indMip,nmean)) { //search for track parameters and Cerenkov angle of this track
358 pID.FindPid(pTrk,5,prob);
359 pTrk->SetHMPIDpid(prob);
361 // 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);
364 return 0; // error code: 0=no error;
367 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
368 void AliHMPIDTracker::FillClusterArray(TObjArray* array) const {
370 // Publishes all pointers to clusters known to the tracker into the
371 // passed object array.
372 // The ownership is not transfered - the caller is not expected to delete
375 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
376 TClonesArray *pCluArr=(TClonesArray*)(*fClu)[iCh];
377 for (Int_t iClu=0; iClu<pCluArr->GetEntriesFast();iClu++){
378 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluArr->UncheckedAt(iClu);
379 array->AddLast(pClu);
380 }//cluster loop in iCh
386 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++