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