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