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