set AC_VERSION automatically from AliRoot tag or revision (for trunk)
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDRecon.cxx
CommitLineData
d3da6dc4 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// AliHMPIDRecon //
19// //
20// HMPID class to perfom pattern recognition based on Hough transfrom //
21// for single chamber //
22//////////////////////////////////////////////////////////////////////////
23
a591e55f 24#include "AliHMPIDRecon.h" //class header
d3da6dc4 25#include "AliHMPIDCluster.h" //CkovAngle()
a591e55f 26#include <TRotation.h> //TracePhot()
27#include <TH1D.h> //HoughResponse()
28#include <TClonesArray.h> //CkovAngle()
29#include <AliESDtrack.h> //CkovAngle()
d3da6dc4 30
d3da6dc4 31//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c61a7285 32AliHMPIDRecon::AliHMPIDRecon():
33 TTask("RichRec","RichPat"),
34 fPhotCnt(-1),
35 fPhotFlag(0),
36 fPhotCkov(0),
37 fPhotPhi(0),
38 fPhotWei(0),
39 fCkovSigma2(0),
40 fIsWEIGHT(kFALSE),
41 fDTheta(0.001),
42 fWindowWidth(0.045),
43 fRingArea(0),
44 fRingAcc(0),
45 fTrkDir(0,0,1), // Just for test
46 fTrkPos(30,40), // Just for test
47 fMipPos(0),
48 fPc(0),
49 fParam(AliHMPIDParam::Instance())
d3da6dc4 50{
ffb1ac19 51//..
52//init of data members
53//..
54
ffb1ac19 55 fParam->SetRefIdx(fParam->MeanIdxRad()); // initialization of ref index to a default one
56}
57//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
58void AliHMPIDRecon::InitVars(Int_t n)
59{
60//..
61//Init some variables
62//..
63 if(n<0) return;
64 fPhotFlag = new Int_t[n];
65 fPhotCkov = new Double_t[n];
66 fPhotPhi = new Double_t[n];
67 fPhotWei = new Double_t[n];
68//
69}
70//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
606697a8 71void AliHMPIDRecon::DeleteVars()const
ffb1ac19 72{
73//..
74//Delete variables
75//..
76 delete fPhotFlag;
77 delete fPhotCkov;
78 delete fPhotPhi;
79 delete fPhotWei;
d3da6dc4 80}
81//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
afe12692 82void AliHMPIDRecon::CkovAngle(AliESDtrack *pTrk,TClonesArray *pCluLst,Double_t nmean,Double_t qthre)
d3da6dc4 83{
84// Pattern recognition method based on Hough transform
59280a5a 85// Arguments: pTrk - track for which Ckov angle is to be found
86// pCluLst - list of clusters for this chamber
87// Returns: - track ckov angle, [rad],
a591e55f 88
ffb1ac19 89 Int_t nClusTot = pCluLst->GetEntries();
90 if(nClusTot>fParam->MultCut()) fIsWEIGHT = kTRUE; // offset to take into account bkg in reconstruction
91 else fIsWEIGHT = kFALSE;
d3da6dc4 92
ffb1ac19 93 InitVars(nClusTot);
94
611e810d 95 Float_t xRa,yRa,th,ph;
a591e55f 96 pTrk->GetHMPIDtrk(xRa,yRa,th,ph); //initialize this track: th and ph angles at middle of RAD
a591e55f 97 SetTrack(xRa,yRa,th,ph);
611e810d 98
ffb1ac19 99 fParam->SetRefIdx(nmean);
d3da6dc4 100
59280a5a 101 Float_t dMin=999,mipX=-1,mipY=-1;Int_t chId=-1,mipId=-1,mipQ=-1;
d3da6dc4 102 fPhotCnt=0;
103 for (Int_t iClu=0; iClu<pCluLst->GetEntriesFast();iClu++){//clusters loop
104 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(iClu); //get pointer to current cluster
59280a5a 105 chId=pClu->Ch();
afe12692 106 if(pClu->Q()>qthre){ //charge compartible with MIP clusters
a591e55f 107 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
108 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
109 }else{ //charge compatible with photon cluster
110 Double_t thetaCer,phiCer;
111 if(FindPhotCkov(pClu->X(),pClu->Y(),thetaCer,phiCer)){ //find ckov angle for this photon candidate
112 fPhotCkov[fPhotCnt]=thetaCer; //actual theta Cerenkov (in TRS)
b4ad85e9 113 fPhotPhi [fPhotCnt]=phiCer; //actual phi Cerenkov (in TRS): -pi to come back to "unusual" ref system (X,Y,-Z)
28500fe1 114 //PH Printf("photon n. %i reconstructed theta = %f",fPhotCnt,fPhotCkov[fPhotCnt]);
a591e55f 115 fPhotCnt++; //increment counter of photon candidates
116 }
59280a5a 117 }
d3da6dc4 118 }//clusters loop
4598109f 119 fMipPos.Set(mipX,mipY);
76fd1a96 120 if(fPhotCnt<=3) pTrk->SetHMPIDsignal(kNoPhotAccept); //no reconstruction with <=3 photon candidates
2d1a9b21 121 Int_t iNrec=FlagPhot(HoughResponse()); //flag photons according to individual theta ckov with respect to most probable
122 pTrk->SetHMPIDmip(mipX,mipY,mipQ,iNrec); //store mip info
59280a5a 123
a591e55f 124 if(mipId==-1) {pTrk->SetHMPIDsignal(kMipQdcCut); return;} //no clusters with QDC more the threshold at all
ffb1ac19 125 if(dMin>fParam->DistCut()) {pTrk->SetHMPIDsignal(kMipDistCut); return;} //closest cluster with enough charge is still too far from intersection
a591e55f 126 pTrk->SetHMPIDcluIdx(chId,mipId); //set index of cluster
2d1a9b21 127 if(iNrec<1){
128 pTrk->SetHMPIDsignal(kNoPhotAccept); //no photon candidates are accepted
76fd1a96 129 }
130 else {
2d1a9b21 131 Double_t thetaC = FindRingCkov(pCluLst->GetEntries()); //find the best reconstructed theta Cherenkov
132// FindRingGeom(thetaC,2);
133 pTrk->SetHMPIDsignal(thetaC); //store theta Cherenkov
134 pTrk->SetHMPIDchi2(fCkovSigma2); //store errors squared
76fd1a96 135 }
d3da6dc4 136
ffb1ac19 137 DeleteVars();
43400d2d 138}//CkovAngle()
d3da6dc4 139//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a591e55f 140Bool_t AliHMPIDRecon::FindPhotCkov(Double_t cluX,Double_t cluY,Double_t &thetaCer,Double_t &phiCer)
d3da6dc4 141{
142// Finds Cerenkov angle for this photon candidate
143// Arguments: cluX,cluY - position of cadidate's cluster
a591e55f 144// Returns: Cerenkov angle
d3da6dc4 145
a591e55f 146 TVector3 dirCkov;
147
ffb1ac19 148 Double_t zRad= -0.5*fParam->RadThick()-0.5*fParam->WinThick(); //z position of middle of RAD
67a1c24c 149 TVector3 rad(fTrkPos.X(),fTrkPos.Y(),zRad); //impact point at middle of RAD
ffb1ac19 150 TVector3 pc(cluX,cluY,0.5*fParam->WinThick()+fParam->GapIdx()); //mip at PC
a591e55f 151 Double_t cluR = TMath::Sqrt((cluX-fTrkPos.X())*(cluX-fTrkPos.X())+
152 (cluY-fTrkPos.Y())*(cluY-fTrkPos.Y()));//ref. distance impact RAD-CLUSTER
67a1c24c 153 Double_t phi=(pc-rad).Phi(); //phi of photon
a591e55f 154
b4ad85e9 155 Double_t ckov1=0;
67a1c24c 156 Double_t ckov2=0.75+fTrkDir.Theta(); //start to find theta cerenkov in DRS
b4ad85e9 157 const Double_t kTol=0.01;
d3da6dc4 158 Int_t iIterCnt = 0;
159 while(1){
a591e55f 160 if(iIterCnt>=50) return kFALSE;
d3da6dc4 161 Double_t ckov=0.5*(ckov1+ckov2);
67a1c24c 162 dirCkov.SetMagThetaPhi(1,ckov,phi);
a591e55f 163 TVector2 posC=TraceForward(dirCkov); //trace photon with actual angles
164 Double_t dist=cluR-(posC-fTrkPos).Mod(); //get distance between trial point and cluster position
165 if(posC.X()==-999) dist = - 999; //total reflection problem
166 iIterCnt++; //counter step
b4ad85e9 167 if (dist> kTol) ckov1=ckov; //cluster @ larger ckov
d3da6dc4 168 else if(dist<-kTol) ckov2=ckov; //cluster @ smaller ckov
a591e55f 169 else{ //precision achived: ckov in DRS found
170 dirCkov.SetMagThetaPhi(1,ckov,phi); //
2d1a9b21 171 Lors2Trs(dirCkov,thetaCer,phiCer); //find ckov (in TRS:the effective Cherenkov angle!)
a591e55f 172 return kTRUE;
173 }
d3da6dc4 174 }
175}//FindPhotTheta()
176//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a591e55f 177TVector2 AliHMPIDRecon::TraceForward(TVector3 dirCkov)const
d3da6dc4 178{
a591e55f 179 //Trace forward a photon from (x,y) up to PC
180 // Arguments: dirCkov photon vector in LORS
181 // Returns: pos of traced photon at PC
ffb1ac19 182
a591e55f 183 TVector2 pos(-999,-999);
67a1c24c 184 Double_t thetaCer = dirCkov.Theta();
ffb1ac19 185 if(thetaCer > TMath::ASin(1./fParam->GetRefIdx())) return pos; //total refraction on WIN-GAP boundary
186 Double_t zRad= -0.5*fParam->RadThick()-0.5*fParam->WinThick(); //z position of middle of RAD
187 TVector3 posCkov(fTrkPos.X(),fTrkPos.Y(),zRad); //RAD: photon position is track position @ middle of RAD
188 Propagate(dirCkov,posCkov, -0.5*fParam->WinThick()); //go to RAD-WIN boundary
189 Refract (dirCkov, fParam->GetRefIdx(),fParam->WinIdx()); //RAD-WIN refraction
190 Propagate(dirCkov,posCkov, 0.5*fParam->WinThick()); //go to WIN-GAP boundary
191 Refract (dirCkov, fParam->WinIdx(),fParam->GapIdx()); //WIN-GAP refraction
192 Propagate(dirCkov,posCkov,0.5*fParam->WinThick()+fParam->GapThick()); //go to PC
a591e55f 193 pos.Set(posCkov.X(),posCkov.Y());
194 return pos;
195}//TraceForward()
196//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2d1a9b21 197void AliHMPIDRecon::Lors2Trs(TVector3 dirCkov,Double_t &thetaCer,Double_t &phiCer)const
a591e55f 198{
199 //Theta Cerenkov reconstruction
2d1a9b21 200 // Arguments: dirCkov photon vector in LORS
201 // Returns: thetaCer of photon in TRS
202 // phiCer of photon in TRS
a591e55f 203// TVector3 dirTrk;
204// dirTrk.SetMagThetaPhi(1,fTrkDir.Theta(),fTrkDir.Phi());
205// Double_t thetaCer = TMath::ACos(dirCkov*dirTrk);
2d1a9b21 206 TRotation mtheta; mtheta.RotateY(-fTrkDir.Theta());
207 TRotation mphi; mphi.RotateZ(-fTrkDir.Phi());
a591e55f 208 TRotation mrot=mtheta*mphi;
209 TVector3 dirCkovTRS;
210 dirCkovTRS=mrot*dirCkov;
211 phiCer = dirCkovTRS.Phi(); //actual value of the phi of the photon
212 thetaCer= dirCkovTRS.Theta(); //actual value of thetaCerenkov of the photon
d3da6dc4 213}
214//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2d1a9b21 215void AliHMPIDRecon::Trs2Lors(TVector3 dirCkov,Double_t &thetaCer,Double_t &phiCer)const
216{
217 //Theta Cerenkov reconstruction
218 // Arguments: dirCkov photon vector in TRS
219 // Returns: thetaCer of photon in LORS
220 // phiCer of photon in LORS
221 TRotation mtheta; mtheta.RotateY(fTrkDir.Theta());
222 TRotation mphi; mphi.RotateZ(fTrkDir.Phi());
223 TRotation mrot=mphi*mtheta;
224 TVector3 dirCkovLORS;
225 dirCkovLORS=mrot*dirCkov;
226 phiCer = dirCkovLORS.Phi(); //actual value of the phi of the photon
227 thetaCer= dirCkovLORS.Theta(); //actual value of thetaCerenkov of the photon
228}
229//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
230void AliHMPIDRecon::FindRingGeom(Double_t ckovAng,Int_t level)
d3da6dc4 231{
4598109f 232// Find area covered in the PC acceptance
2d1a9b21 233// Arguments: ckovAng - cerenkov angle
234// level - precision in finding area and portion of ring accepted (multiple of 50)
d3da6dc4 235// Returns: area of the ring in cm^2 for given theta ckov
236
2d1a9b21 237 Int_t kN=50*level;
238 Int_t nPoints = 0;
afe12692 239 Double_t area=0;
2d1a9b21 240
4598109f 241 Bool_t first=kFALSE;
2d1a9b21 242 TVector2 pos1;
243
afe12692 244 for(Int_t i=0;i<kN;i++){
4598109f 245 if(!first) {
2d1a9b21 246 pos1=TracePhot(ckovAng,Double_t(TMath::TwoPi()*(i+1)/kN)); //find a good trace for the first photon
4598109f 247 if(pos1.X()==-999) continue; //no area: open ring
2d1a9b21 248 if(!fParam->IsInside(pos1.X(),pos1.Y(),0)) {
249 pos1 = IntWithEdge(fMipPos,pos1); // find the very first intersection...
250 } else {
251 if(!AliHMPIDParam::IsInDead(pos1.X(),pos1.Y())) nPoints++; //photon is accepted if not in dead zone
252 }
4598109f 253 first=kTRUE;
254 continue;
255 }
256 TVector2 pos2=TracePhot(ckovAng,Double_t(TMath::TwoPi()*(i+1)/kN)); //trace the next photon
257 if(pos2.X()==-999) continue; //no area: open ring
ffb1ac19 258 if(!fParam->IsInside(pos2.X(),pos2.Y(),0)) {
4598109f 259 pos2 = IntWithEdge(fMipPos,pos2);
2d1a9b21 260 } else {
261 if(!AliHMPIDParam::IsInDead(pos2.X(),pos2.Y())) nPoints++; //photon is accepted if not in dead zone
4598109f 262 }
263 area+=TMath::Abs((pos1-fMipPos).X()*(pos2-fMipPos).Y()-(pos1-fMipPos).Y()*(pos2-fMipPos).X()); //add area of the triangle...
264 pos1 = pos2;
d3da6dc4 265 }
2d1a9b21 266//--- find area and length of the ring;
267 fRingAcc = (Double_t)nPoints/(Double_t)kN;
7fc88c5e 268 area*=0.5;
2d1a9b21 269 fRingArea = area;
270}//FindRingGeom()
d3da6dc4 271//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4598109f 272TVector2 AliHMPIDRecon::IntWithEdge(TVector2 p1,TVector2 p2)const
273{
274// It finds the intersection of the line for 2 points traced as photons
275// and the edge of a given PC
276// Arguments: 2 points obtained tracing the photons
277// Returns: intersection point with detector (PC) edges
278
4598109f 279 Double_t xmin = (p1.X()<p2.X())? p1.X():p2.X();
280 Double_t xmax = (p1.X()<p2.X())? p2.X():p1.X();
281 Double_t ymin = (p1.Y()<p2.Y())? p1.Y():p2.Y();
282 Double_t ymax = (p1.Y()<p2.Y())? p2.Y():p1.Y();
283
284 Double_t m = TMath::Tan((p2-p1).Phi());
285 TVector2 pint;
286 //intersection with low X
287 pint.Set((Double_t)(p1.X() + (0-p1.Y())/m),0.);
ffb1ac19 288 if(pint.X()>=0 && pint.X()<=fParam->SizeAllX() &&
4598109f 289 pint.X()>=xmin && pint.X()<=xmax &&
290 pint.Y()>=ymin && pint.Y()<=ymax) return pint;
291 //intersection with high X
ffb1ac19 292 pint.Set((Double_t)(p1.X() + (fParam->SizeAllY()-p1.Y())/m),(Double_t)(fParam->SizeAllY()));
293 if(pint.X()>=0 && pint.X()<=fParam->SizeAllX() &&
4598109f 294 pint.X()>=xmin && pint.X()<=xmax &&
295 pint.Y()>=ymin && pint.Y()<=ymax) return pint;
296 //intersection with left Y
297 pint.Set(0.,(Double_t)(p1.Y() + m*(0-p1.X())));
ffb1ac19 298 if(pint.Y()>=0 && pint.Y()<=fParam->SizeAllY() &&
4598109f 299 pint.Y()>=ymin && pint.Y()<=ymax &&
300 pint.X()>=xmin && pint.X()<=xmax) return pint;
301 //intersection with righ Y
ffb1ac19 302 pint.Set((Double_t)(fParam->SizeAllX()),(Double_t)(p1.Y() + m*(fParam->SizeAllX()-p1.X())));
303 if(pint.Y()>=0 && pint.Y()<=fParam->SizeAllY() &&
4598109f 304 pint.Y()>=ymin && pint.Y()<=ymax &&
305 pint.X()>=xmin && pint.X()<=xmax) return pint;
306 return p1;
307}//IntWithEdge()
308//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
d3da6dc4 309Double_t AliHMPIDRecon::FindRingCkov(Int_t)
310{
311// 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
312// collecting errors for all single Ckov candidates thetas. (Assuming they are independent)
313// Arguments: iNclus- total number of clusters in chamber for background estimation
314// Return: best estimation of track Theta ckov
315
316 Double_t wei = 0.;
317 Double_t weightThetaCerenkov = 0.;
318
319 Double_t ckovMin=9999.,ckovMax=0.;
320 Double_t sigma2 = 0; //to collect error squared for this ring
321
322 for(Int_t i=0;i<fPhotCnt;i++){//candidates loop
323 if(fPhotFlag[i] == 2){
a591e55f 324 if(fPhotCkov[i]<ckovMin) ckovMin=fPhotCkov[i]; //find max and min Theta ckov from all candidates within probable window
d3da6dc4 325 if(fPhotCkov[i]>ckovMax) ckovMax=fPhotCkov[i];
a591e55f 326 weightThetaCerenkov += fPhotCkov[i]*fPhotWei[i];
327 wei += fPhotWei[i]; //collect weight as sum of all candidate weghts
d3da6dc4 328
3278403b 329 sigma2 += 1./fParam->Sigma2(fTrkDir.Theta(),fTrkDir.Phi(),fPhotCkov[i],fPhotPhi[i]);
d3da6dc4 330 }
331 }//candidates loop
332
333 if(sigma2>0) fCkovSigma2=1./sigma2;
334 else fCkovSigma2=1e10;
335
b4ad85e9 336 if(wei != 0.) weightThetaCerenkov /= wei; else weightThetaCerenkov = 0.;
d3da6dc4 337 return weightThetaCerenkov;
338}//FindCkovRing()
339//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
340Int_t AliHMPIDRecon::FlagPhot(Double_t ckov)
341{
342// Flag photon candidates if their individual ckov angle is inside the window around ckov angle returned by HoughResponse()
343// Arguments: ckov- value of most probable ckov angle for track as returned by HoughResponse()
344// Returns: number of photon candidates happened to be inside the window
345
a591e55f 346// Photon Flag: Flag = 0 initial set;
347// Flag = 1 good candidate (charge compatible with photon);
348// Flag = 2 photon used for the ring;
d3da6dc4 349
350 Int_t steps = (Int_t)((ckov )/ fDTheta); //how many times we need to have fDTheta to fill the distance between 0 and thetaCkovHough
351
352 Double_t tmin = (Double_t)(steps - 1)*fDTheta;
353 Double_t tmax = (Double_t)(steps)*fDTheta;
354 Double_t tavg = 0.5*(tmin+tmax);
355
356 tmin = tavg - 0.5*fWindowWidth; tmax = tavg + 0.5*fWindowWidth;
357
358 Int_t iInsideCnt = 0; //count photons which Theta ckov inside the window
359 for(Int_t i=0;i<fPhotCnt;i++){//photon candidates loop
afe12692 360 fPhotFlag[i] = 0;
d3da6dc4 361 if(fPhotCkov[i] >= tmin && fPhotCkov[i] <= tmax) {
362 fPhotFlag[i]=2;
363 iInsideCnt++;
364 }
365 }
366 return iInsideCnt;
367}//FlagPhot()
368//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a591e55f 369TVector2 AliHMPIDRecon::TracePhot(Double_t ckovThe,Double_t ckovPhi)const
d3da6dc4 370{
371// Trace a single Ckov photon from emission point somewhere in radiator up to photocathode taking into account ref indexes of materials it travereses
ffb1ac19 372// Arguments: ckovThe,ckovPhi- photon ckov angles in TRS, [rad]
d3da6dc4 373// Returns: distance between photon point on PC and track projection
2d1a9b21 374
375 Double_t theta,phi;
376 TVector3 dirTRS,dirLORS;
377 dirTRS.SetMagThetaPhi(1,ckovThe,ckovPhi); //photon in TRS
378 Trs2Lors(dirTRS,theta,phi);
379 dirLORS.SetMagThetaPhi(1,theta,phi); //photon in LORS
380 return TraceForward(dirLORS); //now foward tracing
a591e55f 381}//TracePhot()
d3da6dc4 382//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a591e55f 383void AliHMPIDRecon::Propagate(const TVector3 dir,TVector3 &pos,Double_t z)const
d3da6dc4 384{
385// Finds an intersection point between a line and XY plane shifted along Z.
386// Arguments: dir,pos - vector along the line and any point of the line
387// z - z coordinate of plain
388// Returns: none
389// On exit: pos is the position if this intesection if any
390 static TVector3 nrm(0,0,1);
391 TVector3 pnt(0,0,z);
392
393 TVector3 diff=pnt-pos;
394 Double_t sint=(nrm*diff)/(nrm*dir);
395 pos+=sint*dir;
396}//Propagate()
397//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
398void AliHMPIDRecon::Refract(TVector3 &dir,Double_t n1,Double_t n2)const
399{
400// Refract direction vector according to Snell law
401// Arguments:
402// n1 - ref idx of first substance
403// n2 - ref idx of second substance
404// Returns: none
405// On exit: dir is new direction
67a1c24c 406 Double_t sinref=(n1/n2)*TMath::Sin(dir.Theta());
76fd1a96 407 if(TMath::Abs(sinref)>1.) dir.SetXYZ(-999,-999,-999);
67a1c24c 408 else dir.SetTheta(TMath::ASin(sinref));
d3da6dc4 409}//Refract()
410//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
411Double_t AliHMPIDRecon::HoughResponse()
412{
413//
611e810d 414// fIdxMip = mipId;
415
d3da6dc4 416//
417 Double_t kThetaMax=0.75;
418 Int_t nChannels = (Int_t)(kThetaMax/fDTheta+0.5);
419 TH1D *phots = new TH1D("Rphot" ,"phots" ,nChannels,0,kThetaMax);
420 TH1D *photsw = new TH1D("RphotWeighted" ,"photsw" ,nChannels,0,kThetaMax);
421 TH1D *resultw = new TH1D("resultw","resultw" ,nChannels,0,kThetaMax);
422 Int_t nBin = (Int_t)(kThetaMax/fDTheta);
423 Int_t nCorrBand = (Int_t)(fWindowWidth/(2*fDTheta));
424
425 for (Int_t i=0; i< fPhotCnt; i++){//photon cadidates loop
426 Double_t angle = fPhotCkov[i]; if(angle<0||angle>kThetaMax) continue;
427 phots->Fill(angle);
428 Int_t bin = (Int_t)(0.5+angle/(fDTheta));
429 Double_t weight=1.;
430 if(fIsWEIGHT){
afe12692 431 Double_t lowerlimit = ((Double_t)bin)*fDTheta - 0.5*fDTheta; Double_t upperlimit = ((Double_t)bin)*fDTheta + 0.5*fDTheta;
2d1a9b21 432 FindRingGeom(lowerlimit);
433 Double_t areaLow = GetRingArea();
434 FindRingGeom(upperlimit);
435 Double_t areaHigh = GetRingArea();
436 Double_t diffArea = areaHigh - areaLow;
d3da6dc4 437 if(diffArea>0) weight = 1./diffArea;
438 }
439 photsw->Fill(angle,weight);
440 fPhotWei[i]=weight;
441 }//photon candidates loop
442
443 for (Int_t i=1; i<=nBin;i++){
444 Int_t bin1= i-nCorrBand;
445 Int_t bin2= i+nCorrBand;
446 if(bin1<1) bin1=1;
447 if(bin2>nBin)bin2=nBin;
448 Double_t sumPhots=phots->Integral(bin1,bin2);
449 if(sumPhots<3) continue; // if less then 3 photons don't trust to this ring
450 Double_t sumPhotsw=photsw->Integral(bin1,bin2);
451 resultw->Fill((Double_t)((i+0.5)*fDTheta),sumPhotsw);
452 }
453// evaluate the "BEST" theta ckov as the maximum value of histogramm
454 Double_t *pVec = resultw->GetArray();
455 Int_t locMax = TMath::LocMax(nBin,pVec);
3ebd8038 456 delete phots;delete photsw;delete resultw; // Reset and delete objects
d3da6dc4 457
458 return (Double_t)(locMax*fDTheta+0.5*fDTheta); //final most probable track theta ckov
459}//HoughResponse()
460//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++