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