1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //////////////////////////////////////////////////////////////////////////
20 // HMPID class to perfom pattern recognition based on Hough transfrom //
21 // for single chamber //
22 //////////////////////////////////////////////////////////////////////////
24 #include "AliHMPIDRecon.h" //class header
25 #include "AliHMPIDParam.h" //CkovAngle()
26 #include "AliHMPIDCluster.h" //CkovAngle()
27 #include <TMinuit.h> //FitEllipse()
28 #include <TRotation.h> //TracePhot()
29 #include <TH1D.h> //HoughResponse()
30 #include <TClonesArray.h> //CkovAngle()
31 #include <AliESDtrack.h> //CkovAngle()
33 const Double_t AliHMPIDRecon::fgkRadThick=1.5;
34 const Double_t AliHMPIDRecon::fgkWinThick=0.5;
35 const Double_t AliHMPIDRecon::fgkGapThick=8.0;
36 const Double_t AliHMPIDRecon::fgkWinIdx =1.5787;
37 const Double_t AliHMPIDRecon::fgkGapIdx =1.0005;
39 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40 AliHMPIDRecon::AliHMPIDRecon():TTask("RichRec","RichPat"),
47 fTrkDir(TVector3(0,0,1)),fTrkPos(TVector2(30,40))
50 for (Int_t i=0; i<3000; i++) {
57 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
58 void AliHMPIDRecon::CkovAngle(AliESDtrack *pTrk,TClonesArray *pCluLst,Double_t nmean)
60 // Pattern recognition method based on Hough transform
61 // Arguments: pTrk - track for which Ckov angle is to be found
62 // pCluLst - list of clusters for this chamber
63 // Returns: - track ckov angle, [rad],
65 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
67 if(pCluLst->GetEntries()>pParam->MultCut()) fIsWEIGHT = kTRUE; // offset to take into account bkg in reconstruction
68 else fIsWEIGHT = kFALSE;
70 Float_t xRa,yRa,th,ph;
71 pTrk->GetHMPIDtrk(xRa,yRa,th,ph); //initialize this track: th and ph angles at middle of RAD
72 SetTrack(xRa,yRa,th,ph);
76 Float_t dMin=999,mipX=-1,mipY=-1;Int_t chId=-1,mipId=-1,mipQ=-1;
78 for (Int_t iClu=0; iClu<pCluLst->GetEntriesFast();iClu++){//clusters loop
79 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(iClu); //get pointer to current cluster
81 if(pClu->Q()>pParam->QCut()){ //charge compartible with MIP clusters
82 Float_t dX=fPc.X()-pClu->X(),dY=fPc.Y()-pClu->Y(),d =TMath::Sqrt(dX*dX+dY*dY); //distance between current cluster and intersection point
83 if( d < dMin) {mipId=iClu; dMin=d;mipX=pClu->X();mipY=pClu->Y();mipQ=(Int_t)pClu->Q();} //current cluster is closer, overwrite data for min cluster
84 }else{ //charge compatible with photon cluster
85 Double_t thetaCer,phiCer;
86 if(FindPhotCkov(pClu->X(),pClu->Y(),thetaCer,phiCer)){ //find ckov angle for this photon candidate
87 fPhotCkov[fPhotCnt]=thetaCer; //actual theta Cerenkov (in TRS)
88 fPhotPhi [fPhotCnt]=phiCer; //actual phi Cerenkov (in TRS): -pi to come back to "unusual" ref system (X,Y,-Z)
89 fPhotCnt++; //increment counter of photon candidates
93 Int_t iNacc=FlagPhot(HoughResponse()); //flag photons according to individual theta ckov with respect to most probable
94 pTrk->SetHMPIDmip(mipX,mipY,mipQ,iNacc); //store mip info
96 if(mipId==-1) {pTrk->SetHMPIDsignal(kMipQdcCut); return;} //no clusters with QDC more the threshold at all
97 if(dMin>pParam->DistCut()) {pTrk->SetHMPIDsignal(kMipDistCut); return;} //closest cluster with enough charge is still too far from intersection
98 pTrk->SetHMPIDcluIdx(chId,mipId); //set index of cluster
99 if(iNacc<1) pTrk->SetHMPIDsignal(kNoPhotAccept); //no photon candidates is accepted
100 else pTrk->SetHMPIDsignal(FindRingCkov(pCluLst->GetEntries())); //find best Theta ckov for ring i.e. track
102 pTrk->SetHMPIDchi2(fCkovSigma2); //errors squared
105 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106 Bool_t AliHMPIDRecon::FindPhotCkov(Double_t cluX,Double_t cluY,Double_t &thetaCer,Double_t &phiCer)
108 // Finds Cerenkov angle for this photon candidate
109 // Arguments: cluX,cluY - position of cadidate's cluster
110 // Returns: Cerenkov angle
114 Double_t zRad= -0.5*fgkRadThick-0.5*fgkWinThick; //z position of middle of RAD
115 TVector3 rad(fTrkPos.X(),fTrkPos.Y(),zRad); //impact point at middle of RAD
116 TVector3 pc(cluX,cluY,0.5*fgkWinThick+fgkGapIdx); //mip at PC
117 Double_t cluR = TMath::Sqrt((cluX-fTrkPos.X())*(cluX-fTrkPos.X())+
118 (cluY-fTrkPos.Y())*(cluY-fTrkPos.Y()));//ref. distance impact RAD-CLUSTER
119 Double_t phi=(pc-rad).Phi(); //phi of photon
122 Double_t ckov2=0.75+fTrkDir.Theta(); //start to find theta cerenkov in DRS
123 const Double_t kTol=0.01;
126 if(iIterCnt>=50) return kFALSE;
127 Double_t ckov=0.5*(ckov1+ckov2);
128 dirCkov.SetMagThetaPhi(1,ckov,phi);
129 TVector2 posC=TraceForward(dirCkov); //trace photon with actual angles
130 Double_t dist=cluR-(posC-fTrkPos).Mod(); //get distance between trial point and cluster position
131 if(posC.X()==-999) dist = - 999; //total reflection problem
132 iIterCnt++; //counter step
133 if (dist> kTol) ckov1=ckov; //cluster @ larger ckov
134 else if(dist<-kTol) ckov2=ckov; //cluster @ smaller ckov
135 else{ //precision achived: ckov in DRS found
136 dirCkov.SetMagThetaPhi(1,ckov,phi); //
137 RecPhot(dirCkov,thetaCer,phiCer); //find ckov (in TRS:the effective Cherenkov angle!)
142 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
143 TVector2 AliHMPIDRecon::TraceForward(TVector3 dirCkov)const
145 //Trace forward a photon from (x,y) up to PC
146 // Arguments: dirCkov photon vector in LORS
147 // Returns: pos of traced photon at PC
148 TVector2 pos(-999,-999);
149 Double_t thetaCer = dirCkov.Theta();
150 if(thetaCer > TMath::ASin(1./fRadNmean)) return pos; //total refraction on WIN-GAP boundary
151 Double_t zRad= -0.5*fgkRadThick-0.5*fgkWinThick; //z position of middle of RAD
152 TVector3 posCkov(fTrkPos.X(),fTrkPos.Y(),zRad); //RAD: photon position is track position @ middle of RAD
153 Propagate(dirCkov,posCkov, -0.5*fgkWinThick); //go to RAD-WIN boundary
154 Refract (dirCkov, fRadNmean,fgkWinIdx); //RAD-WIN refraction
155 Propagate(dirCkov,posCkov, 0.5*fgkWinThick); //go to WIN-GAP boundary
156 Refract (dirCkov, fgkWinIdx,fgkGapIdx); //WIN-GAP refraction
157 Propagate(dirCkov,posCkov,0.5*fgkWinThick+fgkGapThick); //go to PC
158 pos.Set(posCkov.X(),posCkov.Y());
161 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
162 void AliHMPIDRecon::RecPhot(TVector3 dirCkov,Double_t &thetaCer,Double_t &phiCer)
164 //Theta Cerenkov reconstruction
165 // Arguments: (x,y) of initial point in LORS, dirCkov photon vector in LORS
166 // Returns: thetaCer theta cerenkov reconstructed
168 // dirTrk.SetMagThetaPhi(1,fTrkDir.Theta(),fTrkDir.Phi());
169 // Double_t thetaCer = TMath::ACos(dirCkov*dirTrk);
170 TRotation mtheta; mtheta.RotateY(- fTrkDir.Theta());
171 TRotation mphi; mphi.RotateZ(- fTrkDir.Phi());
172 TRotation mrot=mtheta*mphi;
174 dirCkovTRS=mrot*dirCkov;
175 phiCer = dirCkovTRS.Phi(); //actual value of the phi of the photon
176 thetaCer= dirCkovTRS.Theta(); //actual value of thetaCerenkov of the photon
178 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179 Double_t AliHMPIDRecon::FindRingArea(Double_t ckovAng)const
181 // Find area inside the cerenkov ring which lays inside PCs
182 // Arguments: ckovAng - cerenkov angle
183 // Returns: area of the ring in cm^2 for given theta ckov
187 for(Int_t i=0;i<kN;i++){
188 TVector2 pos1=TracePhot(ckovAng,Double_t(TMath::TwoPi()*i /kN));//trace this photon
189 TVector2 pos2=TracePhot(ckovAng,Double_t(TMath::TwoPi()*(i+1)/kN));//trace the next photon
190 area+=(pos1-fTrkPos)*(pos2-fTrkPos); //add area of the triangle...
194 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
195 Double_t AliHMPIDRecon::FindRingCkov(Int_t)
197 // Loops on all Ckov candidates and estimates the best Theta Ckov for a ring formed by those candidates. Also estimates an error for that Theat Ckov
198 // collecting errors for all single Ckov candidates thetas. (Assuming they are independent)
199 // Arguments: iNclus- total number of clusters in chamber for background estimation
200 // Return: best estimation of track Theta ckov
203 Double_t weightThetaCerenkov = 0.;
205 Double_t ckovMin=9999.,ckovMax=0.;
206 Double_t sigma2 = 0; //to collect error squared for this ring
208 for(Int_t i=0;i<fPhotCnt;i++){//candidates loop
209 if(fPhotFlag[i] == 2){
210 if(fPhotCkov[i]<ckovMin) ckovMin=fPhotCkov[i]; //find max and min Theta ckov from all candidates within probable window
211 if(fPhotCkov[i]>ckovMax) ckovMax=fPhotCkov[i];
212 weightThetaCerenkov += fPhotCkov[i]*fPhotWei[i];
213 wei += fPhotWei[i]; //collect weight as sum of all candidate weghts
215 sigma2 += 1./Sigma2(fPhotCkov[i],fPhotPhi[i]);
219 if(sigma2>0) fCkovSigma2=1./sigma2;
220 else fCkovSigma2=1e10;
222 if(wei != 0.) weightThetaCerenkov /= wei; else weightThetaCerenkov = 0.;
223 return weightThetaCerenkov;
225 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
226 Int_t AliHMPIDRecon::FlagPhot(Double_t ckov)
228 // Flag photon candidates if their individual ckov angle is inside the window around ckov angle returned by HoughResponse()
229 // Arguments: ckov- value of most probable ckov angle for track as returned by HoughResponse()
230 // Returns: number of photon candidates happened to be inside the window
232 // Photon Flag: Flag = 0 initial set;
233 // Flag = 1 good candidate (charge compatible with photon);
234 // Flag = 2 photon used for the ring;
236 Int_t steps = (Int_t)((ckov )/ fDTheta); //how many times we need to have fDTheta to fill the distance between 0 and thetaCkovHough
238 Double_t tmin = (Double_t)(steps - 1)*fDTheta;
239 Double_t tmax = (Double_t)(steps)*fDTheta;
240 Double_t tavg = 0.5*(tmin+tmax);
242 tmin = tavg - 0.5*fWindowWidth; tmax = tavg + 0.5*fWindowWidth;
244 Int_t iInsideCnt = 0; //count photons which Theta ckov inside the window
245 for(Int_t i=0;i<fPhotCnt;i++){//photon candidates loop
246 if(fPhotCkov[i] >= tmin && fPhotCkov[i] <= tmax) {
253 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
254 TVector2 AliHMPIDRecon::TracePhot(Double_t ckovThe,Double_t ckovPhi)const
256 // Trace a single Ckov photon from emission point somewhere in radiator up to photocathode taking into account ref indexes of materials it travereses
257 // Arguments: ckovThe,ckovPhi- photon ckov angles in DRS, [rad]
258 // Returns: distance between photon point on PC and track projection
259 TRotation mtheta; mtheta.RotateY(fTrkDir.Theta());
260 TRotation mphi; mphi.RotateZ(fTrkDir.Phi());
261 TRotation mrot=mphi*mtheta;
262 TVector3 dirCkov,dirCkovTors;
264 dirCkovTors.SetMagThetaPhi(1,ckovThe,ckovPhi); //initially photon is directed according to requested ckov angle
265 dirCkov=mrot*dirCkovTors; //now we know photon direction in LORS
266 return TraceForward(dirCkov);
268 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
269 void AliHMPIDRecon::Propagate(const TVector3 dir,TVector3 &pos,Double_t z)const
271 // Finds an intersection point between a line and XY plane shifted along Z.
272 // Arguments: dir,pos - vector along the line and any point of the line
273 // z - z coordinate of plain
275 // On exit: pos is the position if this intesection if any
276 static TVector3 nrm(0,0,1);
279 TVector3 diff=pnt-pos;
280 Double_t sint=(nrm*diff)/(nrm*dir);
283 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
284 void AliHMPIDRecon::Refract(TVector3 &dir,Double_t n1,Double_t n2)const
286 // Refract direction vector according to Snell law
288 // n1 - ref idx of first substance
289 // n2 - ref idx of second substance
291 // On exit: dir is new direction
292 Double_t sinref=(n1/n2)*TMath::Sin(dir.Theta());
293 if(sinref>1.) dir.SetXYZ(-999,-999,-999);
294 else dir.SetTheta(TMath::ASin(sinref));
296 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
297 Double_t AliHMPIDRecon::HoughResponse()
302 Double_t kThetaMax=0.75;
303 Int_t nChannels = (Int_t)(kThetaMax/fDTheta+0.5);
304 TH1D *phots = new TH1D("Rphot" ,"phots" ,nChannels,0,kThetaMax);
305 TH1D *photsw = new TH1D("RphotWeighted" ,"photsw" ,nChannels,0,kThetaMax);
306 TH1D *resultw = new TH1D("resultw","resultw" ,nChannels,0,kThetaMax);
307 Int_t nBin = (Int_t)(kThetaMax/fDTheta);
308 Int_t nCorrBand = (Int_t)(fWindowWidth/(2*fDTheta));
310 for (Int_t i=0; i< fPhotCnt; i++){//photon cadidates loop
311 Double_t angle = fPhotCkov[i]; if(angle<0||angle>kThetaMax) continue;
313 Int_t bin = (Int_t)(0.5+angle/(fDTheta));
316 Double_t lowerlimit = ((Double_t)bin)*fDTheta - 0.5*fDTheta; Double_t upperlimit = ((Double_t)bin)*fDTheta + 0.5*fDTheta;
317 Double_t diffArea = FindRingArea(upperlimit)-FindRingArea(lowerlimit);
318 if(diffArea>0) weight = 1./diffArea;
320 photsw->Fill(angle,weight);
322 }//photon candidates loop
324 for (Int_t i=1; i<=nBin;i++){
325 Int_t bin1= i-nCorrBand;
326 Int_t bin2= i+nCorrBand;
328 if(bin2>nBin)bin2=nBin;
329 Double_t sumPhots=phots->Integral(bin1,bin2);
330 if(sumPhots<3) continue; // if less then 3 photons don't trust to this ring
331 Double_t sumPhotsw=photsw->Integral(bin1,bin2);
332 resultw->Fill((Double_t)((i+0.5)*fDTheta),sumPhotsw);
334 // evaluate the "BEST" theta ckov as the maximum value of histogramm
335 Double_t *pVec = resultw->GetArray();
336 Int_t locMax = TMath::LocMax(nBin,pVec);
337 phots->Delete();photsw->Delete();resultw->Delete(); // Reset and delete objects
339 return (Double_t)(locMax*fDTheta+0.5*fDTheta); //final most probable track theta ckov
341 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
342 Double_t AliHMPIDRecon::Sigma2(Double_t ckovTh, Double_t ckovPh)const
344 // Analithical calculation of total error (as a sum of localization, geometrical and chromatic errors) on Cerenkov angle for a given Cerenkov photon
345 // created by a given MIP. Fromulae according to CERN-EP-2000-058
346 // Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
347 // dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
349 // Returns: absolute error on Cerenkov angle, [radians]
351 TVector3 v(-999,-999,-999);
352 Double_t trkBeta = 1./(TMath::Cos(ckovTh)*fRadNmean);
354 v.SetX(SigLoc (ckovTh,ckovPh,trkBeta));
355 v.SetY(SigGeom(ckovTh,ckovPh,trkBeta));
356 v.SetZ(SigCrom(ckovTh,ckovPh,trkBeta));
360 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
361 Double_t AliHMPIDRecon::SigLoc(Double_t thetaC, Double_t phiC,Double_t betaM)const
363 // Analithical calculation of localization error (due to finite segmentation of PC) on Cerenkov angle for a given Cerenkov photon
364 // created by a given MIP. Fromulae according to CERN-EP-2000-058
365 // Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
366 // dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
368 // Returns: absolute error on Cerenkov angle, [radians]
369 Double_t phiDelta = phiC - fTrkDir.Phi();
371 Double_t alpha =TMath::Cos(fTrkDir.Theta())-TMath::Tan(thetaC)*TMath::Cos(phiDelta)*TMath::Sin(fTrkDir.Theta());
372 Double_t k = 1.-fRadNmean*fRadNmean+alpha*alpha/(betaM*betaM);
373 if (k<0) return 1e10;
375 Double_t mu =TMath::Sin(fTrkDir.Theta())*TMath::Sin(fTrkDir.Phi())+TMath::Tan(thetaC)*(TMath::Cos(fTrkDir.Theta())*TMath::Cos(phiDelta)*TMath::Sin(fTrkDir.Phi())+TMath::Sin(phiDelta)*TMath::Cos(fTrkDir.Phi()));
376 Double_t e =TMath::Sin(fTrkDir.Theta())*TMath::Cos(fTrkDir.Phi())+TMath::Tan(thetaC)*(TMath::Cos(fTrkDir.Theta())*TMath::Cos(phiDelta)*TMath::Cos(fTrkDir.Phi())-TMath::Sin(phiDelta)*TMath::Sin(fTrkDir.Phi()));
378 Double_t kk = betaM*TMath::Sqrt(k)/(8*alpha);
379 Double_t dtdxc = kk*(k*(TMath::Cos(phiDelta)*TMath::Cos(fTrkDir.Phi())-TMath::Cos(fTrkDir.Theta())*TMath::Sin(phiDelta)*TMath::Sin(fTrkDir.Phi()))-(alpha*mu/(betaM*betaM))*TMath::Sin(fTrkDir.Theta())*TMath::Sin(phiDelta));
380 Double_t dtdyc = kk*(k*(TMath::Cos(phiDelta)*TMath::Sin(fTrkDir.Phi())+TMath::Cos(fTrkDir.Theta())*TMath::Sin(phiDelta)*TMath::Cos(fTrkDir.Phi()))+(alpha* e/(betaM*betaM))*TMath::Sin(fTrkDir.Theta())*TMath::Sin(phiDelta));
382 return TMath::Sqrt(0.2*0.2*dtdxc*dtdxc + 0.25*0.25*dtdyc*dtdyc);
384 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
385 Double_t AliHMPIDRecon::SigCrom(Double_t thetaC, Double_t phiC,Double_t betaM)const
387 // Analithical calculation of chromatic error (due to lack of knowledge of Cerenkov photon energy) on Cerenkov angle for a given Cerenkov photon
388 // created by a given MIP. Fromulae according to CERN-EP-2000-058
389 // Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
390 // dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
392 // Returns: absolute error on Cerenkov angle, [radians]
393 Double_t phiDelta = phiC - fTrkDir.Phi();
394 Double_t alpha =TMath::Cos(fTrkDir.Theta())-TMath::Tan(thetaC)*TMath::Cos(phiDelta)*TMath::Sin(fTrkDir.Theta());
396 Double_t dtdn = TMath::Cos(fTrkDir.Theta())*fRadNmean*betaM*betaM/(alpha*TMath::Tan(thetaC));
398 Double_t f = 0.00928*(7.75-5.635)/TMath::Sqrt(12.);
402 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
403 Double_t AliHMPIDRecon::SigGeom(Double_t thetaC, Double_t phiC,Double_t betaM)const
405 // Analithical calculation of geometric error (due to lack of knowledge of creation point in radiator) on Cerenkov angle for a given Cerenkov photon
406 // created by a given MIP. Formulae according to CERN-EP-2000-058
407 // Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
408 // dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
410 // Returns: absolute error on Cerenkov angle, [radians]
412 Double_t phiDelta = phiC - fTrkDir.Phi();
413 Double_t alpha =TMath::Cos(fTrkDir.Theta())-TMath::Tan(thetaC)*TMath::Cos(phiDelta)*TMath::Sin(fTrkDir.Theta());
415 Double_t k = 1.-fRadNmean*fRadNmean+alpha*alpha/(betaM*betaM);
416 if (k<0) return 1e10;
418 Double_t eTr = 0.5*1.5*betaM*TMath::Sqrt(k)/(8*alpha);
419 Double_t lambda = 1.-TMath::Sin(fTrkDir.Theta())*TMath::Sin(fTrkDir.Theta())*TMath::Sin(phiC)*TMath::Sin(phiC);
421 Double_t c = 1./(1.+ eTr*k/(alpha*alpha*TMath::Cos(thetaC)*TMath::Cos(thetaC)));
422 Double_t i = betaM*TMath::Tan(thetaC)*lambda*TMath::Power(k,1.5);
423 Double_t ii = 1.+eTr*betaM*i;
425 Double_t err = c * (i/(alpha*alpha*8) + ii*(1.-lambda) / ( alpha*alpha*8*betaM*(1.+eTr)) );
426 Double_t trErr = 1.5/(TMath::Sqrt(12.)*TMath::Cos(fTrkDir.Theta()));
430 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
442 // From here Hidden track algorithm....
450 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
451 void AliHMPIDRecon::CkovHiddenTrk(TClonesArray *pCluLst,Double_t nmean)
453 // Pattern recognition method without any infos from tracking...
454 // The method finds in the chmber the cluster with the highest charge
455 // compatibile with a MIP, then the strategy is applied
456 // Arguments: pCluLst - list of clusters for this chamber
457 // Returns: - track ckov angle, [rad],
461 Float_t mipX=-1,mipY=-1;Int_t mipId=-1,mipQ=-1;
464 fNClu = pCluLst->GetEntriesFast();
465 for (Int_t iClu=0;iClu<fNClu;iClu++){ //clusters loop
466 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(iClu); //get pointer to current cluster
467 fXClu[iClu] = pClu->X();fYClu[iClu] = pClu->Y(); //store x,y for fitting procedure
468 if(pClu->Q()>qRef){ //searching the highest charge to select a MIP
470 mipId=iClu; mipX=pClu->X();mipY=pClu->Y();mipQ=(Int_t)pClu->Q();
475 fMipX = mipX; fMipY=mipY;
479 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
480 void AliHMPIDRecon::DoRecHiddenTrk()
482 // Pattern recognition method without any infos from tracking...
483 // Before a preclustering filter to avoid part of the noise
484 // Then only ellipsed-rings are fitted (no possibility,
485 // for the moment, to reconstruct very inclined tracks
486 // Finally a fitting with (th,ph) free starting by very close values
487 // previously evaluated.
492 if(!FitEllipse(phiRec)) {Printf("Not an ellipse, bye!");return;}
493 Printf("--->now it starts the free fit with phi = %f",phiRec*TMath::RadToDeg());
494 return FitFree(phiRec);
496 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
497 void AliHMPIDRecon::CluPreFilter()
499 // Filter of bkg clusters
500 // based on elliptical-shapes...
504 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
505 Bool_t AliHMPIDRecon::FitEllipse(Double_t &phiRec)
507 //Fit a set of clusters with an analitical conical section function:
509 // Ax^2 + B*y^2 + 2Hxy + 2Gx + 2Fy + 1 = 0 ---> conical section
511 // H*H - A*B > 0 hyperbola
515 // tan 2alfa = 2H/(A-B) alfa=angle of rotation
517 // coordinate of the centre of the conical section:
529 Double_t cA,cB,cF,cG,cH;
530 Double_t aArg=-1,parStep,parLow,parHigh; Int_t iErrFlg; //tmp vars for TMinuit
532 if(!gMinuit) gMinuit = new TMinuit(100); //init MINUIT with this number of parameters (5 params)
533 gMinuit->mncler(); // reset Minuit list of paramters
534 gMinuit->SetObjectFit((TObject*)this); gMinuit->SetFCN(AliHMPIDRecon::FunMinEl); //set fit function
535 gMinuit->mnexcm("SET PRI",&aArg,1,iErrFlg); //suspend all printout from TMinuit
536 gMinuit->mnexcm("SET NOW",&aArg,0,iErrFlg); //suspend all warning printout from TMinuit
541 gMinuit->mnparm(0," A ",1,parStep=0.01,parLow=0,parHigh=0,iErrFlg);
542 gMinuit->mnparm(1," B ",1,parStep=0.01,parLow=0,parHigh=0,iErrFlg);
543 gMinuit->mnparm(2," H ",1,parStep=0.01,parLow=0,parHigh=0,iErrFlg);
544 gMinuit->mnparm(3," G ",1,parStep=0.01,parLow=0,parHigh=0,iErrFlg);
545 gMinuit->mnparm(4," F ",1,parStep=0.01,parLow=0,parHigh=0,iErrFlg);
547 gMinuit->mnexcm("SIMPLEX" ,&aArg,0,iErrFlg);
548 gMinuit->mnexcm("MIGRAD" ,&aArg,0,iErrFlg);
549 gMinuit->mnpout(0,sName,cA,d1,d2,d3,iErrFlg);
550 gMinuit->mnpout(1,sName,cB,d1,d2,d3,iErrFlg);
551 gMinuit->mnpout(2,sName,cH,d1,d2,d3,iErrFlg);
552 gMinuit->mnpout(3,sName,cG,d1,d2,d3,iErrFlg);
553 gMinuit->mnpout(4,sName,cF,d1,d2,d3,iErrFlg);
556 Double_t i2 = cA*cB-cH*cH; //quartic invariant : i2 > 0 ellipse, i2 < 0 hyperbola
557 Double_t aX = (cH*cF-cB*cG)/i2; //x centre of the canonical section
558 Double_t bY = (cH*cG-cA*cF)/i2; //y centre of the canonical section
559 Double_t alfa1 = TMath::ATan(2*cH/(cA-cB)); //alpha = angle of rotation of the conical section
560 if(alfa1<0) alfa1+=TMath::Pi();
562 Double_t alfa2 = alfa1+TMath::Pi();
563 Double_t phiref = TMath::ATan2(bY-fMipY,aX-fMipX); //evaluate in a unique way the angle of rotation comapring it
564 if(phiref<0) phiref+=TMath::TwoPi(); //with the vector that poinst to the centre from the mip
565 if(i2<0) phiref+=TMath::Pi();
566 if(phiref>TMath::TwoPi()) phiref-=TMath::TwoPi();
568 // Printf(" alfa1 %f",alfa1*TMath::RadToDeg());
569 // Printf(" alfa2 %f",alfa2*TMath::RadToDeg());
570 // Printf(" firef %f",phiref*TMath::RadToDeg());
571 if(TMath::Abs(alfa1-phiref)<TMath::Abs(alfa2-phiref)) phiRec = alfa1; else phiRec = alfa2;
573 // cout << " phi reconstructed " << phiRec*TMath::RadToDeg() << endl;
577 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
578 void AliHMPIDRecon::FitFree(Double_t phiRec)
580 // Fit performed by minimizing RMS/sqrt(n) of the
581 // photons reconstructed. First phi is fixed and theta
582 // is fouond, then (th,ph) of the track
583 // as free parameters
584 // Arguments: PhiRec phi of the track
586 Double_t aArg=-1,parStep,parLow,parHigh; Int_t iErrFlg; //tmp vars for TMinuit
587 if(!gMinuit) gMinuit = new TMinuit(100); //init MINUIT with this number of parameters (5 params)
588 gMinuit->mncler(); // reset Minuit list of paramters
589 gMinuit->SetObjectFit((TObject*)this); gMinuit->SetFCN(AliHMPIDRecon::FunMinPhot); //set fit function
590 gMinuit->mnexcm("SET PRI",&aArg,1,iErrFlg); //suspend all printout from TMinuit
591 gMinuit->mnexcm("SET NOW",&aArg,0,iErrFlg); //suspend all warning printout from TMinuit
597 gMinuit->mnexcm("SET PRI",&aArg,1,iErrFlg); //suspend all printout from TMinuit
598 gMinuit->mnexcm("SET NOW",&aArg,0,iErrFlg);
600 gMinuit->mnparm(0," theta ",0.01,parStep=0.01,parLow=0,parHigh=TMath::PiOver2(),iErrFlg);
601 gMinuit->mnparm(1," phi ",phiRec,parStep=0.01,parLow=0,parHigh=TMath::TwoPi(),iErrFlg);
603 gMinuit->FixParameter(1);
604 gMinuit->mnexcm("SIMPLEX" ,&aArg,0,iErrFlg);
605 gMinuit->mnexcm("MIGRAD" ,&aArg,0,iErrFlg);
607 gMinuit->mnexcm("MIGRAD" ,&aArg,0,iErrFlg);
609 gMinuit->mnpout(0,sName,th,d1,d2,d3,iErrFlg);
610 gMinuit->mnpout(1,sName,ph,d1,d2,d3,iErrFlg);
612 Printf(" reconstr. theta %f phi %f",th*TMath::RadToDeg(),ph*TMath::RadToDeg());
614 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
615 Double_t AliHMPIDRecon::FunConSect(Double_t *c,Double_t x,Double_t y)
617 return c[0]*x*x+c[1]*y*y+2*c[2]*x*y+2*c[3]*x+2*c[4]*y+1;
619 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
620 void AliHMPIDRecon::FunMinEl(Int_t &/* */,Double_t* /* */,Double_t &f,Double_t *par,Int_t /* */)
622 AliHMPIDRecon *pRec=(AliHMPIDRecon*)gMinuit->GetObjectFit();
624 Int_t np = pRec->NClu();
625 for(Int_t i=0;i<np;i++) {
626 if(i==pRec->IdxMip()) continue;
627 Double_t el = pRec->FunConSect(par,pRec->XClu(i),pRec->YClu(i));
632 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
633 void AliHMPIDRecon::FunMinPhot(Int_t &/* */,Double_t* /* */,Double_t &f,Double_t *par,Int_t /* */)
635 AliHMPIDRecon *pRec=(AliHMPIDRecon*)gMinuit->GetObjectFit();
637 Double_t sizeCh = fgkRadThick+fgkWinThick+fgkGapThick;
638 Double_t thTrk = par[0];
639 Double_t phTrk = par[1];
640 Double_t xrad = pRec->MipX() - sizeCh*TMath::Tan(thTrk)*TMath::Cos(phTrk);
641 Double_t yrad = pRec->MipY() - sizeCh*TMath::Tan(thTrk)*TMath::Sin(phTrk);
643 pRec->SetTrack(xrad,yrad,thTrk,phTrk);
646 Double_t meanCkov2=0;
647 Double_t thetaCer,phiCer;
648 for(Int_t i=0;i<pRec->NClu();i++) {
649 pRec->FindPhotCkov(pRec->XClu(i),pRec->YClu(i),thetaCer,phiCer);
651 meanCkov += thetaCer;
652 meanCkov2 += thetaCer*thetaCer;
654 meanCkov/=pRec->NClu();
655 Double_t rms = TMath::Sqrt(meanCkov2/pRec->NClu() - meanCkov*meanCkov);
656 f = rms/TMath::Sqrt(pRec->NClu());
657 pRec->SetCkovFit(meanCkov);