]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHPatRec.cxx
Corrected invertes arguments in pad size setter
[u/mrichter/AliRoot.git] / RICH / AliRICHPatRec.cxx
CommitLineData
e7257cad 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 $Log$
4a5c8776 18 Revision 1.7 2000/10/03 21:44:09 morsch
19 Use AliSegmentation and AliHit abstract base classes.
20
a2f7eaf6 21 Revision 1.6 2000/10/02 21:28:12 fca
22 Removal of useless dependecies via forward declarations
23
94de3818 24 Revision 1.5 2000/10/02 15:50:25 jbarbosa
25 Fixed forward declarations.
26
488e98ba 27 Revision 1.4 2000/06/30 16:33:43 dibari
28 Several changes (ring drawing, fiducial selection, etc.)
29
e0b63a71 30 Revision 1.3 2000/06/15 15:47:12 jbarbosa
31 Corrected compilation errors on HP-UX (replaced pow with TMath::Power)
32
00df6e79 33 Revision 1.2 2000/06/12 15:26:09 jbarbosa
34 Cleaned up version.
35
237c933d 36 Revision 1.1 2000/06/09 14:53:01 jbarbosa
37 Bari's pattern recognition algorithm
38
e7257cad 39*/
40
237c933d 41#include "AliRICHHit.h"
42#include "AliRICHCerenkov.h"
43#include "AliRICHPadHit.h"
44#include "AliRICHDigit.h"
45#include "AliRICHRawCluster.h"
4a5c8776 46#include "AliRICHRecHit1D.h"
e7257cad 47#include "AliRun.h"
48#include "AliDetector.h"
49#include "AliRICH.h"
50#include "AliRICHPoints.h"
a2f7eaf6 51#include "AliSegmentation.h"
e7257cad 52#include "AliRICHPatRec.h"
53#include "AliRICH.h"
54#include "AliRICHConst.h"
55#include "AliRICHPoints.h"
56#include "AliConst.h"
a2f7eaf6 57#include "AliHitMap.h"
237c933d 58
59#include <TParticle.h>
60#include <TMath.h>
61#include <TRandom.h>
62#include <TCanvas.h>
63#include <TH2.h>
94de3818 64#include <TTree.h>
e7257cad 65
66
67ClassImp(AliRICHPatRec)
68//___________________________________________
69AliRICHPatRec::AliRICHPatRec() : TObject()
70{
237c933d 71 // Default constructor
72
e7257cad 73 //fChambers = 0;
74}
75//___________________________________________
76AliRICHPatRec::AliRICHPatRec(const char *name, const char *title)
77 : TObject()
78{
237c933d 79 //Constructor for Bari's pattern recogniton method object
e7257cad 80}
81
82void AliRICHPatRec::PatRec()
83{
84
237c933d 85// Pattern recognition algorithm
86
e7257cad 87 AliRICHChamber* iChamber;
a2f7eaf6 88 AliSegmentation* segmentation;
e7257cad 89
237c933d 90 Int_t ntracks, ndigits[kNCH];
e7257cad 91 Int_t itr, ich, i;
237c933d 92 Int_t goodPhotons;
e7257cad 93 Int_t x,y,q;
a2f7eaf6 94 Float_t rx,ry,rz;
e7257cad 95 Int_t nent,status;
e0b63a71 96 Int_t padsUsedX[100];
97 Int_t padsUsedY[100];
e7257cad 98
e0b63a71 99 Float_t rechit[7];
e7257cad 100
101 printf("PatRec started\n");
102
237c933d 103 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
104 TTree *treeH = gAlice->TreeH();
e7257cad 105
237c933d 106 ntracks =(Int_t) treeH->GetEntries();
e7257cad 107 // ntracks = 1;
108 for (itr=0; itr<ntracks; itr++) {
109
110 status = TrackParam(itr,ich);
111 if(status==1) continue;
e0b63a71 112 //printf(" theta %f phi %f track \n",fTrackTheta,fTrackPhi);
e7257cad 113 // ring->Fill(fTrackLoc[0],fTrackLoc[1],100.);
114
237c933d 115 iChamber = &(pRICH->Chamber(ich));
e7257cad 116 segmentation=iChamber->GetSegmentationModel();
117
118 nent=(Int_t)gAlice->TreeD()->GetEntries();
119 gAlice->TreeD()->GetEvent(nent-1);
237c933d 120 TClonesArray *pDigitss = pRICH->DigitsAddress(ich);
121 ndigits[ich] = pDigitss->GetEntriesFast();
e0b63a71 122 printf("Digits in chamber %d: %d\n",ich,ndigits[ich]);
e7257cad 123 AliRICHDigit *padI = 0;
124
237c933d 125 goodPhotons = 0;
e7257cad 126
127 for (Int_t dig=0;dig<ndigits[ich];dig++) {
237c933d 128 padI=(AliRICHDigit*) pDigitss->UncheckedAt(dig);
e7257cad 129 x=padI->fPadX;
130 y=padI->fPadY;
131 q=padI->fSignal;
a2f7eaf6 132 segmentation->GetPadC(x,y,rx,ry,rz);
e7257cad 133
e0b63a71 134 //printf("Pad coordinates x:%d, Real coordinates x:%f\n",x,rx);
135 //printf("Pad coordinates y:%d, Real coordinates y:%f\n",y,ry);
136
e7257cad 137 fXpad = rx-fXshift;
138 fYpad = ry-fYshift;
139 fQpad = q;
140
e7257cad 141 fCerenkovAnglePad = PhotonCerenkovAngle();
142 if(fCerenkovAnglePad==-999) continue;
143
144 if(!PhotonInBand()) continue;
145
e0b63a71 146 Int_t xpad;
147 Int_t ypad;
148
a2f7eaf6 149 segmentation->GetPadI(fXpad,fYpad,0,xpad,ypad);
e7257cad 150
e0b63a71 151 padsUsedX[goodPhotons]=xpad;
152 padsUsedY[goodPhotons]=ypad;
153
237c933d 154 goodPhotons++;
e0b63a71 155 fEtaPhotons[goodPhotons-1] = fCerenkovAnglePad;
e7257cad 156 }
237c933d 157 fNumEtaPhotons = goodPhotons;
e7257cad 158
159 BackgroundEstimation();
160
e7257cad 161 HoughResponse();
e0b63a71 162 //CerenkovRingDrawing();
e7257cad 163
164 rechit[0] = 0;
165 rechit[1] = 0;
166 rechit[2] = fThetaCerenkov;
e0b63a71 167 rechit[3] = fXshift + fTrackLoc[0];
168 rechit[4] = fYshift + fTrackLoc[1];
169 rechit[5] = fEmissPoint;
170 rechit[6] = goodPhotons;
e7257cad 171
e0b63a71 172 //printf("Center coordinates:%f %f\n",rechit[3],rechit[4]);
e7257cad 173
4a5c8776 174 pRICH->AddRecHit1D(ich,rechit,fEtaPhotons,padsUsedX,padsUsedY);
e7257cad 175
e7257cad 176 }
177
178 gAlice->TreeR()->Fill();
179 TClonesArray *fRec;
237c933d 180 for (i=0;i<kNCH;i++) {
4a5c8776 181 fRec=pRICH->RecHitsAddress1D(i);
e7257cad 182 int ndig=fRec->GetEntriesFast();
183 printf ("Chamber %d, rings %d\n",i,ndig);
184 }
4a5c8776 185 pRICH->ResetRecHits1D();
e7257cad 186
e7257cad 187}
188
189
190Int_t AliRICHPatRec::TrackParam(Int_t itr, Int_t &ich)
191{
192 // Get Local coordinates of track impact
193
194 AliRICHChamber* iChamber;
a2f7eaf6 195 AliSegmentation* segmentation;
e7257cad 196
197 Float_t trackglob[3];
198 Float_t trackloc[3];
199 Float_t thetatr;
200 Float_t phitr;
201 Float_t iloss;
202 Float_t part;
203 Float_t pX, pY, pZ;
204
4a5c8776 205 //printf("Calling TrackParam\n");
e7257cad 206
207 gAlice->ResetHits();
237c933d 208 TTree *treeH = gAlice->TreeH();
209 treeH->GetEvent(itr);
e7257cad 210
237c933d 211 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
212 AliRICHHit* mHit=(AliRICHHit*)pRICH->FirstHit(-1);
e7257cad 213 if(mHit==0) return 1;
214 ich = mHit->fChamber-1;
94de3818 215 trackglob[0] = mHit->X();
216 trackglob[1] = mHit->Y();
217 trackglob[2] = mHit->Z();
e7257cad 218 pX = mHit->fMomX;
219 pY = mHit->fMomY;
220 pZ = mHit->fMomZ;
00df6e79 221 fTrackMom = sqrt(TMath::Power(pX,2)+TMath::Power(pY,2)+TMath::Power(pZ,2));
e0b63a71 222 thetatr = (mHit->fTheta)*(Float_t)kDegrad;
e7257cad 223 phitr = mHit->fPhi*(Float_t)kDegrad;
224 iloss = mHit->fLoss;
225 part = mHit->fParticle;
226
237c933d 227 iChamber = &(pRICH->Chamber(ich));
e7257cad 228 iChamber->GlobaltoLocal(trackglob,trackloc);
229
230 segmentation=iChamber->GetSegmentationModel();
231
232 // retrieve geometrical params
233
234 AliRICHGeometry* fGeometry=iChamber->GetGeometryModel();
235
236 fRw = fGeometry->GetFreonThickness();
237 fQw = fGeometry->GetQuartzThickness();
e0b63a71 238 fTgap = fGeometry->GetGapThickness();
239 Float_t radiatorToPads= fGeometry->GetRadiatorToPads();
240 //+ fGeometry->GetProximityGapThickness();
e7257cad 241
e0b63a71 242 //printf("Distance to pads. From geometry:%f, From calculations:%f\n",radiatorToPads,fRw + fQw + fTgap);
243
244 //Float_t apar = (fRw + fQw + fTgap)*tan(thetatr);
245 Float_t apar = radiatorToPads*tan(thetatr);
e7257cad 246 fTrackLoc[0] = apar*cos(phitr);
247 fTrackLoc[1] = apar*sin(phitr);
e0b63a71 248 //fTrackLoc[2] = fRw + fQw + fTgap;
249 fTrackLoc[2] = radiatorToPads;
e7257cad 250 fTrackTheta = thetatr;
251 fTrackPhi = phitr;
252
253 fXshift = trackloc[0] - fTrackLoc[0];
254 fYshift = trackloc[2] - fTrackLoc[1];
255
256 return 0;
257}
258
259Float_t AliRICHPatRec::EstimationAtLimits(Float_t lim, Float_t radius,
260 Float_t phiphot)
261{
237c933d 262
263// Estimation of emission point
264
e7257cad 265 Float_t nquartz = 1.585;
266 Float_t ngas = 1.;
267 Float_t nfreon = 1.295;
268 Float_t value;
269
270 // printf("Calling EstimationLimits\n");
271
272 Float_t apar = (fRw -fEmissPoint + fQw + fTgap)*tan(fTrackTheta);
273 Float_t b1 = (fRw-fEmissPoint)*tan(lim);
00df6e79 274 Float_t b2 = fQw / sqrt(TMath::Power(nquartz,2)-TMath::Power(nfreon*sin(lim),2));
275 Float_t b3 = fTgap / sqrt(TMath::Power(ngas,2)-TMath::Power(nfreon*sin(lim),2));
e7257cad 276 Float_t bpar = b1 + nfreon*sin(lim)*(b2+b3);
00df6e79 277 value = TMath::Power(radius,2)
278 -TMath::Power((apar*cos(fTrackPhi)-bpar*cos(phiphot)),2)
279 -TMath::Power((apar*sin(fTrackPhi)-bpar*sin(phiphot)),2);
e7257cad 280 return value;
281}
282
283
284Float_t AliRICHPatRec::PhotonCerenkovAngle()
285{
286 // Cherenkov pad angle reconstruction
287
288 Float_t radius;
289 Float_t cherMin = 0;
290 Float_t cherMax = 0.8;
291 Float_t phiphot;
292 Float_t eps = 0.0001;
293 Int_t niterEmiss = 0;
294 Int_t niterEmissMax = 0;
237c933d 295 Float_t x1,x2,x3=0,p1,p2,p3;
e7257cad 296 Float_t argY,argX;
297 Int_t niterFun;
298
299 // printf("Calling PhotonCerenkovAngle\n");
300
00df6e79 301 radius = sqrt(TMath::Power(fTrackLoc[0]-fXpad,2)+TMath::Power(fTrackLoc[1]-fYpad,2));
e7257cad 302 fEmissPoint = fRw/2.; //Start value of EmissionPoint
303
304 while(niterEmiss<=niterEmissMax) {
305
306 niterFun = 0;
307 argY = fYpad - fEmissPoint*tan(fTrackTheta)*sin(fTrackPhi);
308 argX = fXpad - fEmissPoint*tan(fTrackTheta)*cos(fTrackPhi);
309 phiphot = atan2(argY,argX);
310 p1 = EstimationAtLimits(cherMin,radius,phiphot);
311 p2 = EstimationAtLimits(cherMax,radius,phiphot);
312 if(p1*p2>0)
313 {
314 // printf("PhotonCerenkovAngle failed\n");
315 return -999;
316 }
317
318 //start to find the Cherenkov pad angle
319 x1 = cherMin;
320 x2 = cherMax;
321 x3 = (x1+x2)/2.;
322 p3 = EstimationAtLimits(x3,radius,phiphot);
323 while(TMath::Abs(p3)>eps){
324 if(p1*p3<0) x2 = x3;
325 if(p1*p3>0) {
326 x1 = x3;
327 p1 = EstimationAtLimits(x1,radius,phiphot);
328 }
329 x3 = (x1+x2)/2.;
330 p3 = EstimationAtLimits(x3,radius,phiphot);
331 niterFun++;
332
333 if(niterFun>=1000) {
334 // printf(" max iterations in PhotonCerenkovAngle\n");
335 return x3;
336 }
337 }
338 // printf("niterFun %i \n",niterFun);
339 niterEmiss++;
340 if (niterEmiss != niterEmissMax+1) EmissionPoint();
341 }
342 /*
343 printf(" phiphot %f fXpad %f fYpad %f fEmiss %f \n",
344 phiphot,fXpad,fYpad,fEmissPoint);
345 */
346
347 return x3;
348
349}
350
351
352void AliRICHPatRec::EmissionPoint()
353{
237c933d 354
355// Find emission point
356
357 Float_t absorbtionLength=7.83*fRw; //absorption length in the freon (cm)
e7257cad 358 // 7.83 = -1/ln(T0) where
359 // T0->Trasmission freon at 180nm = 0.88 (Eph=6.85eV)
237c933d 360 Float_t photonLength, photonLengthMin, photonLengthMax;
e7257cad 361
237c933d 362 photonLength=exp(-fRw/(absorbtionLength*cos(fCerenkovAnglePad)));
363 photonLengthMin=fRw*photonLength/(1.-photonLength);
364 photonLengthMax=absorbtionLength*cos(fCerenkovAnglePad);
365 fEmissPoint = fRw + photonLengthMin - photonLengthMax;
e7257cad 366
367}
368
369void AliRICHPatRec::PhotonSelection(Int_t track, Int_t &nphot, Float_t &thetamean)
370{
237c933d 371
372// not implemented yet
373
e7257cad 374 printf("Calling PhotonSelection\n");
375}
376
377void AliRICHPatRec::BackgroundEstimation()
378{
237c933d 379
380// estimate background noise
381
382 Float_t stepEta = 0.001;
383 Float_t etaMinBkg = 0.72;
384 Float_t etaMaxBkg = 0.75;
385 Float_t etaMin = 0.;
386 Float_t etaMax = 0.75;
e7257cad 387 Float_t ngas = 1.;
388 Float_t nfreon = 1.295;
389
237c933d 390 Float_t etaStepMin,etaStepMax,etaStepAvg;
e7257cad 391 Int_t i,ip,nstep;
237c933d 392 Int_t numPhotBkg, numPhotonStep;
393 Float_t funBkg,areaBkg,normBkg;
394 Float_t densityBkg,storeBkg,numStore;
395 Float_t thetaSig;
e7257cad 396
237c933d 397 numPhotBkg = 0;
398 areaBkg = 0.;
e7257cad 399
237c933d 400 nstep = (int)((etaMaxBkg-etaMinBkg)/stepEta);
e7257cad 401
402 for (i=0;i<fNumEtaPhotons;i++) {
403
237c933d 404 if(fEtaPhotons[i]>etaMinBkg && fEtaPhotons[i]<etaMaxBkg) {
405 numPhotBkg++;
e7257cad 406 }
407 }
237c933d 408 if (numPhotBkg == 0) {
e7257cad 409 for (i=0;i<fNumEtaPhotons;i++) {
410 fWeightPhotons[i] = 1.;
411 }
412 return;
413 }
414
237c933d 415 // printf(" numPhotBkg %i ",numPhotBkg);
e7257cad 416
417 for (i=0;i<nstep;i++) {
237c933d 418 etaStepMin = etaMinBkg + (Float_t)(i)*stepEta;
419 etaStepMax = etaMinBkg + (Float_t)(i+1)*stepEta;
420 etaStepAvg = 0.5*(etaStepMax + etaStepMin);
e7257cad 421 /*
00df6e79 422 funBkg = tan(etaStepAvg)*TMath::Power((1.+TMath::Power(tan(etaStepAvg),2)),
237c933d 423 5.52)-7.803 + 22.02*tan(etaStepAvg);
e7257cad 424 */
4a5c8776 425
426 //printf("etaStepAvg: %f, etaStepMax: %f, etaStepMin: %f", etaStepAvg,etaStepMax,etaStepMin);
427
428 thetaSig = TMath::ASin(nfreon/ngas*TMath::Sin(etaStepAvg));
00df6e79 429 funBkg = tan(thetaSig)*(1.+TMath::Power(tan(thetaSig),2))*nfreon
237c933d 430 /ngas*cos(etaStepAvg)/cos(thetaSig);
431 areaBkg += stepEta*funBkg;
e7257cad 432 }
433
237c933d 434 densityBkg = 0.95*(Float_t)(numPhotBkg)/areaBkg;
435 // printf(" densityBkg %f \n",densityBkg);
e7257cad 436
237c933d 437 nstep = (int)((etaMax-etaMin)/stepEta);
438 storeBkg = 0.;
439 numStore = 0;
e7257cad 440 for (i=0;i<nstep;i++) {
237c933d 441 etaStepMin = etaMinBkg + (Float_t)(i)*stepEta;
442 etaStepMax = etaMinBkg + (Float_t)(i+1)*stepEta;
443 etaStepAvg = 0.5*(etaStepMax + etaStepMin);
e7257cad 444 /*
00df6e79 445 funBkg = tan(etaStepAvg)*TMath::Power((1.+TMath::Power(tan(etaStepAvg),2)),
237c933d 446 5.52)-7.803 + 22.02*tan(etaStepAvg);
e7257cad 447 */
448
237c933d 449 thetaSig = asin(nfreon/ngas*sin(etaStepAvg));
00df6e79 450 funBkg = tan(thetaSig)*(1.+TMath::Power(tan(thetaSig),2))*nfreon
237c933d 451 /ngas*cos(etaStepAvg)/cos(thetaSig);
e7257cad 452
237c933d 453 areaBkg = stepEta*funBkg;
454 normBkg = densityBkg*areaBkg;
455 numPhotonStep = 0;
e7257cad 456 for (ip=0;ip<fNumEtaPhotons;ip++) {
237c933d 457 if(fEtaPhotons[ip]>etaStepMin && fEtaPhotons[ip]<etaStepMax) {
458 numPhotonStep++;
e7257cad 459 }
460 }
237c933d 461 if (numPhotonStep == 0) {
462 storeBkg += normBkg;
463 numStore++;
464 if (numStore>50) {
465 numStore = 0;
466 storeBkg = 0.;
e7257cad 467 }
468 }
237c933d 469 if (numPhotonStep == 0) continue;
e7257cad 470 for (ip=0;ip<fNumEtaPhotons;ip++) {
237c933d 471 if(fEtaPhotons[ip]>etaStepMin && fEtaPhotons[ip]<etaStepMax) {
472 normBkg +=storeBkg;
473 storeBkg = 0;
474 numStore = 0;
475 fWeightPhotons[ip] = 1. - normBkg/(Float_t)(numPhotonStep);
e7257cad 476 /*
237c933d 477 printf(" normBkg %f numPhotonStep %i fW %f \n",
478 normBkg, numPhotonStep, fWeightPhotons[ip]);
e7257cad 479 */
480 if(fWeightPhotons[ip]<0) fWeightPhotons[ip] = 0.;
481 }
482 }
483 }
484}
485
486
487void AliRICHPatRec::FlagPhotons(Int_t track, Float_t theta)
488{
237c933d 489
490// not implemented yet
491
e7257cad 492 printf("Calling FlagPhotons\n");
493}
494
495
496//////////////////////////////////////////
497
498
499
500
501
502Int_t AliRICHPatRec::PhotonInBand()
503{
504 //0=label for parameters giving internal band ellipse
505 //1=label for parameters giving external band ellipse
506
237c933d 507 Float_t imp[2], mass[2], energy[2], beta[2];
508 Float_t emissPointLength[2];
509 Float_t e1, e2, f1, f2;
e7257cad 510 Float_t nfreon[2], nquartz[2];
511 Int_t times;
e0b63a71 512 Float_t pointsOnCathode[3];
e7257cad 513
514 Float_t phpad, thetacer[2];
515 Float_t bandradius[2], padradius;
516
517 imp[0] = 5.0; //threshold momentum for the proton Cherenkov emission
518 imp[1] = 1.2;
519
520 mass[0] = 0.938; //proton mass
521 mass[1] = 0.139; //pion mass
522
237c933d 523 emissPointLength[0] = fRw-0.0001; //at the beginning of the radiator
524 emissPointLength[1] = 0.;//at the end of radiator
e7257cad 525
526 //parameters to calculate freon window refractive index vs. energy
527 Float_t a = 1.177;
528 Float_t b = 0.0172;
529
530 //parameters to calculate quartz window refractive index vs. energy
531 /*
532 Energ[0] = 5.6;
533 Energ[1] = 7.7;
534 */
237c933d 535 energy[0] = 5.0;
536 energy[1] = 8.0;
537 e1 = 10.666;
538 e2 = 18.125;
539 f1 = 46.411;
540 f2 = 228.71;
e7257cad 541
e7257cad 542 phpad = PhiPad();
543
544 for (times=0; times<=1; times++) {
545
237c933d 546 nfreon[times] = a+b*energy[times];
e0b63a71 547 //nfreon[times] = 1;
e7257cad 548
00df6e79 549 nquartz[times] = sqrt(1+(f1/(TMath::Power(e1,2)-TMath::Power(energy[times],2)))+
550 (f2/(TMath::Power(e2,2)-TMath::Power(energy[times],2))));
e7257cad 551
00df6e79 552 beta[times] = imp[times]/sqrt(TMath::Power(imp[times],2)+TMath::Power(mass[times],2));
e7257cad 553
554 thetacer[times] = CherenkovAngle( nfreon[times], beta[times]);
555
556 bandradius[times] = DistanceFromMip( nfreon[times], nquartz[times],
e0b63a71 557 emissPointLength[times],
558 thetacer[times], phpad, pointsOnCathode);
559 //printf(" ppp %f %f %f \n",pointsOnCathode);
560}
e7257cad 561
562 bandradius[0] -= 1.6;
563 bandradius[1] += 1.6;
00df6e79 564 padradius = sqrt(TMath::Power(fXpad,2)+TMath::Power(fYpad,2));
e7257cad 565 // printf(" rmin %f r %f rmax %f \n",bandradius[0],padradius,bandradius[1]);
566
567 if(padradius>=bandradius[0] && padradius<=bandradius[1]) return 1;
568 return 0;
569}
570
571Float_t AliRICHPatRec::DistanceFromMip(Float_t nfreon, Float_t nquartz,
237c933d 572 Float_t emissPointLength, Float_t thetacer,
e0b63a71 573 Float_t phpad, Float_t pointsOnCathode[3])
e7257cad 574{
e7257cad 575
237c933d 576// Find the distance to MIP impact
577
578 Float_t distanceValue;
579
580 TVector3 radExitPhot(1,1,1);//photon impact at the radiator exit with respect
e7257cad 581 //to local reference sistem with the origin in the MIP entrance
582
237c933d 583 TVector3 vectEmissPointLength(1,1,1);
584 Float_t magEmissPointLenght;
e7257cad 585
237c933d 586 TVector3 radExitPhot2(1,1,1);//photon impact at the radiator exit with respect
587 Float_t magRadExitPhot2;
e7257cad 588 //to a reference sistem with origin in the photon emission point and
589 //axes parallel to the MIP reference sistem
590
237c933d 591 TVector3 quarExitPhot(1,1,1);//photon impact at the quartz exit with respect
592 Float_t magQuarExitPhot;
e7257cad 593 //
237c933d 594 TVector3 gapExitPhot(1,1,1) ;
595 Float_t magGapExitPhot;
e7257cad 596 //
e0b63a71 597 TVector3 PhotocatExitPhot(1,1,1);
e7257cad 598 Double_t theta2;
599 Double_t thetarad , phirad ;
600 Double_t thetaquar, phiquar;
601 Double_t thetagap , phigap ;
602
603 Float_t ngas = 1.;
604
237c933d 605 magEmissPointLenght = emissPointLength/cos(fTrackTheta);
e7257cad 606
237c933d 607 vectEmissPointLength.SetMag(magEmissPointLenght);
608 vectEmissPointLength.SetTheta(fTrackTheta);
609 vectEmissPointLength.SetPhi(fTrackPhi);
e7257cad 610
611
237c933d 612 radExitPhot2.SetTheta(thetacer);
613 radExitPhot2.SetPhi(phpad);
e7257cad 614
615
616 TRotation r1;
617 TRotation r2;
618 TRotation r;
619
620 r1. RotateY(fTrackTheta);
621 r2. RotateZ(fTrackPhi);
622
623
624
625 r = r2 * r1;//rotation about the y axis by MIP theta incidence angle
626 //following by a rotation about the z axis by MIP phi incidence angle;
627
628
237c933d 629 radExitPhot2 = r * radExitPhot2;
630 theta2 = radExitPhot2.Theta();
631 magRadExitPhot2 = (fRw - vectEmissPointLength(2))/cos(theta2);
632 radExitPhot2.SetMag(magRadExitPhot2);
e7257cad 633
634
237c933d 635 radExitPhot = vectEmissPointLength + radExitPhot2;
636 thetarad = radExitPhot.Theta();
237c933d 637 phirad = radExitPhot.Phi(); //check on the original file //
e7257cad 638
639 thetaquar = SnellAngle( nfreon, nquartz, theta2);
237c933d 640 phiquar = radExitPhot2.Phi();
e7257cad 641 if(thetaquar == 999.) return thetaquar;
237c933d 642 magQuarExitPhot = fQw/cos(thetaquar);
643 quarExitPhot.SetMag( magQuarExitPhot);
644 quarExitPhot.SetTheta(thetaquar);
645 quarExitPhot.SetPhi(phiquar);
e7257cad 646
647 thetagap = SnellAngle( nquartz, ngas, thetaquar);
648 phigap = phiquar;
649 if(thetagap == 999.) return thetagap;
237c933d 650 magGapExitPhot = fTgap/cos(thetagap);
651 gapExitPhot.SetMag( magGapExitPhot);
652 gapExitPhot.SetTheta(thetagap);
653 gapExitPhot.SetPhi(phigap);
e7257cad 654
e0b63a71 655 PhotocatExitPhot = radExitPhot + quarExitPhot + gapExitPhot;
e7257cad 656
e0b63a71 657 distanceValue = sqrt(TMath::Power(PhotocatExitPhot(0),2)
658 +TMath::Power(PhotocatExitPhot(1),2));
659 pointsOnCathode[0] = (Float_t) PhotocatExitPhot(0) + fXshift - fTrackLoc[0];
660 pointsOnCathode[1] = (Float_t) PhotocatExitPhot(1) + fYshift - fTrackLoc[1];
661 pointsOnCathode[2] = (Float_t) PhotocatExitPhot(2);
662
663 //printf(" point in Distance.2. %f %f %f \n",pointsOnCathode[0],pointsOnCathode[1],pointsOnCathode[2]);
664
665 return distanceValue;
666
667 }
e7257cad 668
669Float_t AliRICHPatRec::PhiPad()
670{
237c933d 671
672// ??
673
e7257cad 674 Float_t zpad;
675 Float_t thetapad, phipad;
676 Float_t thetarot, phirot;
677
678 zpad = fRw + fQw + fTgap;
679
237c933d 680 TVector3 photonPad(fXpad, fYpad, zpad);
681 thetapad = photonPad.Theta();
682 phipad = photonPad.Phi();
e7257cad 683
684 TRotation r1;
685 TRotation r2;
686 TRotation r;
687
688 thetarot = - fTrackTheta;
689 phirot = - fTrackPhi;
690 r1. RotateZ(phirot);
691 r2. RotateY(thetarot);
692
693 r = r2 * r1;//rotation about the z axis by MIP -phi incidence angle
694 //following by a rotation about the y axis by MIP -theta incidence angle;
695
237c933d 696 photonPad = r * photonPad;
e7257cad 697
237c933d 698 phipad = photonPad.Phi();
e7257cad 699
700 return phipad;
701}
702
703Float_t AliRICHPatRec:: SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
704{
237c933d 705
706// Compute the Snell angle
707
e7257cad 708 Float_t sinrefractangle;
709 Float_t refractangle;
710
711 sinrefractangle = (n1/n2)*sin(theta1);
712
713 if(sinrefractangle>1.) {
714 refractangle = 999.;
715 return refractangle;
716 }
717
718 refractangle = asin(sinrefractangle);
719 return refractangle;
720}
721
722Float_t AliRICHPatRec::CherenkovAngle(Float_t n, Float_t beta)
723{
237c933d 724
725// Compute the cerenkov angle
726
e7257cad 727 Float_t thetacer;
728
729 if((n*beta)<1.) {
730 thetacer = 999.;
731 return thetacer;
732 }
733
734 thetacer = acos (1./(n*beta));
735 return thetacer;
736}
737
738Float_t AliRICHPatRec::BetaCerenkov(Float_t n, Float_t theta)
739{
237c933d 740
741// Find beta
742
e7257cad 743 Float_t beta;
744
745 beta = 1./(n*cos(theta));
746 return beta;
747}
748
749
750
751
752void AliRICHPatRec::HoughResponse()
753
754{
237c933d 755
756// Implement Hough response pat. rec. method
757
e7257cad 758 int bin=0;
759 int bin1=0;
760 int bin2=0;
237c933d 761 int i, j, k, nCorrBand;
762 int etaBin = 750;
763 float hcs[750];
764 float angle, thetaCerMean;
e7257cad 765
237c933d 766 float etaPeak[30];
767 float etaMin = 0.00;
768 float etaMax = 0.75;
769 float stepEta = 0.001;
770 float windowEta = 0.040;
e7257cad 771
237c933d 772 int nBin;
e7257cad 773
237c933d 774 float etaPeakPos = -1;
775 Int_t etaPeakCount = -1;
e7257cad 776
237c933d 777 thetaCerMean = 0.;
e7257cad 778 fThetaCerenkov = 0.;
779
237c933d 780 nBin = (int)(0.5+etaMax/(stepEta));
781 nCorrBand = (int)(0.5+ windowEta/(2 * stepEta));
782 memset ((void *)hcs, 0, etaBin*sizeof(int));
e7257cad 783
784 for (k=0; k< fNumEtaPhotons; k++) {
785
786 angle = fEtaPhotons[k];
787
237c933d 788 if (angle>=etaMin && angle<= etaMax) {
789 bin = (int)(0.5+angle/(stepEta));
790 bin1= bin-nCorrBand;
791 bin2= bin+nCorrBand;
e7257cad 792 if (bin1<0) bin1=0;
237c933d 793 if (bin2>nBin) bin2=nBin;
e7257cad 794
795 for (j=bin1; j<bin2; j++) {
237c933d 796 hcs[j] += fWeightPhotons[k];
e7257cad 797 }
798
237c933d 799 thetaCerMean += angle;
e7257cad 800 }
801 }
802
237c933d 803 thetaCerMean /= fNumEtaPhotons;
e7257cad 804
237c933d 805 HoughFiltering(hcs);
806
807 for (bin=0; bin <nBin; bin++) {
808 angle = (bin+0.5) * (stepEta);
809 if (hcs[bin] && hcs[bin] > etaPeakPos) {
810 etaPeakCount = 0;
811 etaPeakPos = hcs[bin];
812 etaPeak[0]=angle;
e7257cad 813 }
814 else {
237c933d 815 if (hcs[bin] == etaPeakPos) {
816 etaPeak[++etaPeakCount] = angle;
e7257cad 817 }
818 }
819 }
820
237c933d 821 for (i=0; i<etaPeakCount+1; i++) {
822 fThetaCerenkov += etaPeak[i];
e7257cad 823 }
237c933d 824 if (etaPeakCount>=0) {
825 fThetaCerenkov /= etaPeakCount+1;
826 fThetaPeakPos = etaPeakPos;
e7257cad 827 }
828}
829
830
237c933d 831void AliRICHPatRec::HoughFiltering(float hcs[])
e7257cad 832{
237c933d 833
834// hough filtering
835
836 float hcsFilt[750];
837 float k[5] = {0.05, 0.25, 0.4, 0.25, 0.05};
838 int nx, i, nxDx;
e7257cad 839 int sizeHCS;
237c933d 840 int nBin;
e7257cad 841
237c933d 842 int etaBin = 750;
843 float etaMax = 0.75;
844 float stepEta = 0.001;
e7257cad 845
237c933d 846 nBin = (int)(1+etaMax/stepEta);
847 sizeHCS = etaBin*sizeof(float);
e7257cad 848
237c933d 849 memset ((void *)hcsFilt, 0, sizeHCS);
e7257cad 850
237c933d 851 for (nx = 0; nx < nBin; nx++) {
e7257cad 852 for (i = 0; i < 5; i++) {
237c933d 853 nxDx = nx + (i-2);
854 if (nxDx> -1 && nxDx<nBin)
855 hcsFilt[nx] += hcs[nxDx] * k[i];
e7257cad 856 }
857 }
858
237c933d 859 for (nx = 0; nx < nBin; nx++) {
860 hcs[nx] = hcsFilt[nx];
e7257cad 861 }
862}
863
e0b63a71 864/*void AliRICHPatRec::CerenkovRingDrawing()
e7257cad 865{
866
867//to draw Cherenkov ring by known Cherenkov angle
868
e0b63a71 869 Int_t nmaxdegrees;
870 Int_t Nphpad;
871 Float_t phpad;
237c933d 872 Float_t nfreonave, nquartzave;
873 Float_t aveEnerg;
874 Float_t energy[2];
875 Float_t e1, e2, f1, f2;
876 Float_t bandradius;
e0b63a71 877
e7257cad 878//parameters to calculate freon window refractive index vs. energy
e0b63a71 879
237c933d 880 Float_t a = 1.177;
881 Float_t b = 0.0172;
882
e7257cad 883//parameters to calculate quartz window refractive index vs. energy
e0b63a71 884
237c933d 885 energy[0] = 5.0;
886 energy[1] = 8.0;
887 e1 = 10.666;
888 e2 = 18.125;
889 f1 = 46.411;
890 f2 = 228.71;
891
e7257cad 892
e0b63a71 893 nmaxdegrees = 36;
237c933d 894
e0b63a71 895 for (Nphpad=0; Nphpad<nmaxdegrees;Nphpad++) {
896
897 phpad = (360./(Float_t)nmaxdegrees)*(Float_t)Nphpad;
e7257cad 898
237c933d 899 aveEnerg = (energy[0]+energy[1])/2.;
900
901 nfreonave = a+b*aveEnerg;
00df6e79 902 nquartzave = sqrt(1+(f1/(TMath::Power(e1,2)-TMath::Power(aveEnerg,2)))+
903 (f2/(TMath::Power(e2,2)-TMath::Power(aveEnerg,2))));
237c933d 904
237c933d 905 bandradius = DistanceFromMip(nfreonave, nquartzave,
e0b63a71 906 fEmissPoint,fThetaCerenkov, phpad);
e7257cad 907
e0b63a71 908 fCoordEllipse[0][Nphpad] = fOnCathode[0];
909 fCoordEllipse[1][Nphpad] = fOnCathode[1];
910 printf(" values %f %f \n",fOnCathode[0],fOnCathode[1]);
237c933d 911
237c933d 912 }
913
e0b63a71 914}*/
e7257cad 915
e7257cad 916