]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHSegResV0.cxx
Minor changes on class names
[u/mrichter/AliRoot.git] / RICH / AliRICHSegResV0.cxx
CommitLineData
4c039060 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/*
87a6e868 17 $Log$
4c039060 18*/
19
87a6e868 20
ddae0931 21#include "AliRICHSegResV0.h"
22#include "AliRun.h"
23#include "TParticle.h"
24#include "TMath.h"
25#include "TRandom.h"
87a6e868 26#include "TArc.h"
ddae0931 27
28
87a6e868 29ClassImp(AliRICHSegmentation)
30ClassImp(AliRICHResponse)
31ClassImp(AliRICHGeometry)
ddae0931 32//___________________________________________
87a6e868 33ClassImp(AliRICHSegmentationV0)
ddae0931 34
87a6e868 35void AliRICHSegmentationV0::Init(AliRICHChamber* Chamber)
ddae0931 36{
87a6e868 37 //fNpx=(Int_t) (Chamber->ROuter()/fDpx+1);
38 //fNpy=(Int_t) (Chamber->ROuter()/fDpy+1);
39 fNpx=160;
40 fNpy=144;
41 //fNpx=80;
42 //fNpy=48;
43 fSector=-1;
ddae0931 44}
45
46
87a6e868 47Float_t AliRICHSegmentationV0::GetAnod(Float_t xhit)
ddae0931 48{
49 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
50 return fWireD*wire;
51}
52
87a6e868 53void AliRICHSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
ddae0931 54{
55 fDpx=p1;
56 fDpy=p2;
57}
87a6e868 58void AliRICHSegmentationV0::GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
ddae0931 59{
60// returns pad coordinates (ix,iy) for given real coordinates (x,y)
61//
87a6e868 62// Please check origin of pad numbering !!!
63
64
65 ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
66 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
67 if (iy > fNpy) iy= fNpy;
68 if (iy < -fNpy) iy=-fNpy;
69 if (ix > fNpx) ix= fNpx;
70 if (ix < -fNpx) ix=-fNpx;
ddae0931 71}
87a6e868 72void AliRICHSegmentationV0::
ddae0931 73GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
74{
75// returns real coordinates (x,y) for given pad coordinates (ix,iy)
76//
87a6e868 77
78 x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)-fDpx/2.;
79 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)-fDpy/2.;
80}
81
82void AliRICHSegmentationV0::
83SetHit(Float_t xhit, Float_t yhit)
84{
85//
86// Find the wire position (center of charge distribution)
87// Float_t x0a=GetAnod(xhit);
88 fxhit=xhit;
89 fyhit=yhit;
90}
91
92void AliRICHSegmentationV0::
93SetPad(Int_t ix, Int_t iy)
94{
95 GetPadCxy(ix,iy,fx,fy);
ddae0931 96}
97
87a6e868 98
99
100void AliRICHSegmentationV0::
ddae0931 101FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
102{
87a6e868 103
ddae0931 104 //
105 // Find the wire position (center of charge distribution)
106 Float_t x0a=GetAnod(xhit);
87a6e868 107 fxhit=x0a;
108 fyhit=yhit;
ddae0931 109 //
110 // and take fNsigma*sigma around this center
111 Float_t x01=x0a - dx;
112 Float_t x02=x0a + dx;
113 Float_t y01=yhit - dy;
114 Float_t y02=yhit + dy;
115 //
116 // find the pads over which the charge distributes
117 GetPadIxy(x01,y01,fixmin,fiymin);
118 GetPadIxy(x02,y02,fixmax,fiymax);
119 //
120 // Set current pad to lower left corner
121 fix=fixmin;
122 fiy=fiymin;
123 GetPadCxy(fix,fiy,fx,fy);
87a6e868 124
125 //if (fSector==2)
126 //printf("fix: %d, fiy: %d fx: %f, fy: %f\n",fix,fiy,fx,fy);
ddae0931 127}
128
87a6e868 129void AliRICHSegmentationV0::NextPad()
ddae0931 130{
87a6e868 131 //printf("\n Next Pad \n");
132
ddae0931 133 //
134 // Step to next pad in integration region
87a6e868 135 if (fix <= fixmax) {
136// if (fix==-1) fix++;
ddae0931 137 fix++;
87a6e868 138 } else if (fiy <= fiymax) {
139// if (fiy==-1) fiy++;
ddae0931 140 fix=fixmin;
141 fiy++;
142 } else {
143 printf("\n Error: Stepping outside integration region\n ");
144 }
145 GetPadCxy(fix,fiy,fx,fy);
146}
147
87a6e868 148Int_t AliRICHSegmentationV0::MorePads()
149
ddae0931 150//
151// Are there more pads in the integration region
152{
87a6e868 153 //printf("\n More Pads ? \n");
154
155
156 if (fix >= fixmax && fiy >= fiymax) {
157 //printf("There are no more pads\n\n\n\n\n");
158 return 0;
159 } else {
160 //printf("There are more pads\n\n");
161 return 1;
162 }
ddae0931 163}
164
87a6e868 165void AliRICHSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
ddae0931 166{
167//
168// Initialises pad and wire position during stepping
169 fxt =x;
170 fyt =y;
171 GetPadIxy(x,y,fixt,fiyt);
87a6e868 172 fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
ddae0931 173}
174
87a6e868 175Int_t AliRICHSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
ddae0931 176{
177//
178// Signal will be generated if particle crosses pad boundary or
179// boundary between two wires.
180 Int_t ixt, iyt;
181 GetPadIxy(x,y,ixt,iyt);
87a6e868 182 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
ddae0931 183
184 if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
87a6e868 185 return 1;
ddae0931 186 } else {
87a6e868 187 return 0;
ddae0931 188 }
189}
87a6e868 190void AliRICHSegmentationV0::
ddae0931 191IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
192{
87a6e868 193/*
194 x1=fxt-fx-fDpx/2.;
195 x2=x1+fDpx;
196 y1=fyt-fy-fDpy/2.;
197 y2=y1+fDpy;
198*/
199 x1=fxhit-fx-fDpx/2.;
200 x2=x1+fDpx;
201 y1=fyhit-fy-fDpy/2.;
202 y2=y1+fDpy;
ddae0931 203}
204
87a6e868 205void AliRICHSegmentationV0::
ddae0931 206Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
207{
208//Is used for the cluster finder, include diagonal elements
209
210 *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
211 Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
87a6e868 212/*
213 *Nlist=8;
214 Xlist[0]=Xlist[1]=iX;
215 Xlist[2]=iX-1;
216 Xlist[3]=iX+1;
217 Ylist[0]=iY-1;
218 Ylist[1]=iY+1;
219 Ylist[2]=Ylist[3]=iY;
220
221 // Diagonal elements
222 Xlist[4]=iX+1;
223 Ylist[4]=iY+1;
224
225 Xlist[5]=iX-1;
226 Ylist[5]=iY-1;
227
228 Xlist[6]=iX-1;
229 Ylist[6]=iY+1;
230
231 Xlist[7]=iX+1;
232 Ylist[7]=iY-1;
233*/
ddae0931 234}
235
87a6e868 236Float_t AliRICHSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
237, Int_t *dummy)
238// Returns the square of the distance between 1 pad
239// labelled by its Channel numbers and a coordinate
ddae0931 240{
87a6e868 241 Float_t x,y;
242 GetPadCxy(iX,iY,x,y);
243 return (x-X)*(x-X) + (y-Y)*(y-Y);
244}
245
246
247void AliRICHSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
248{
249 n=1;
250 x[0]=0.;
251 y[0]=x[0];
252}
253
254void AliRICHSegmentationV0::Draw()
255{
256/*
257 TArc *circle;
258 Float_t scale=0.95/fRmax/2.;
259
260
261 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
262 circle->SetFillColor(2);
263 circle->Draw();
264
265 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
266 circle->SetFillColor(1);
267 circle->Draw();
268*/
ddae0931 269 ;
87a6e868 270
ddae0931 271}
272
273
274//___________________________________________
87a6e868 275ClassImp(AliRICHResponseV0)
276
277Float_t AliRICHResponseV0::IntPH(Float_t eloss)
ddae0931 278{
279 // Get number of electrons and return charge
280
281 Int_t nel;
87a6e868 282 nel= Int_t(eloss/fEIonisation);
283
ddae0931 284 Float_t charge=0;
285 if (nel == 0) nel=1;
286 for (Int_t i=1;i<=nel;i++) {
87a6e868 287 charge -= fChargeSlope*TMath::Log(gRandom->Rndm());
ddae0931 288 }
289 return charge;
290}
87a6e868 291
292Float_t AliRICHResponseV0::IntPH()
293{
294 Float_t charge = -fChargeSlope*TMath::Log(gRandom->Rndm());
295 return charge;
296}
297
298
299
ddae0931 300// -------------------------------------------
87a6e868 301Float_t AliRICHResponseV0::IntXY(AliRICHSegmentation * segmentation)
ddae0931 302{
303
304 const Float_t invpitch = 1/fPitch;
305 Float_t response;
306//
307// Integration limits defined by segmentation model
308//
309
310 Float_t xi1, xi2, yi1, yi2;
311 segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
87a6e868 312
ddae0931 313 xi1=xi1*invpitch;
314 xi2=xi2*invpitch;
315 yi1=yi1*invpitch;
316 yi2=yi2*invpitch;
87a6e868 317
318 //printf("Integration Limits: %f-%f, %f-%f\n",xi1,xi2,yi1,yi2);
ddae0931 319
87a6e868 320 //printf("Invpitch:%f\n",invpitch);
321
ddae0931 322 //
323// The Mathieson function
324 Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
325 Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
326
327 Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
328 Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
87a6e868 329
330 //printf("Integration Data: %f-%f, %f-%f\n",ux1,ux2,uy1,uy2);
331
332 //printf("%f %f %f %f\n",fSqrtKx3,fKx2,fKy4,fKx4);
ddae0931 333
334 response=4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1));
335
87a6e868 336 //printf("Response:%f\n",response);
337
ddae0931 338 return response;
339
340}
87a6e868 341
342Int_t AliRICHResponseV0::FeedBackPhotons(Float_t *source, Float_t qtot)
ddae0931 343{
344 //
345 // Generate FeedBack photons
346 //
347 Int_t j, ipart, nt;
348
ddae0931 349 Int_t sNfeed=0;
350
87a6e868 351
ddae0931 352 // Local variables
87a6e868 353 Float_t cthf, ranf[2], phif, enfp = 0, sthf;
ddae0931 354 Int_t i, ifeed;
355 Float_t e1[3], e2[3], e3[3];
356 Float_t vmod, uswop;
357 Float_t fp, random;
358 Float_t dir[3], phi;
359 Int_t nfp;
360 Float_t pol[3], mom[3];
361 TLorentzVector position;
362 //
363 // Determine number of feedback photons
364
365 // Get weight of current particle
366 TParticle *current = (TParticle*)
367 (*gAlice->Particles())[gAlice->CurrentTrack()];
368
369 ifeed = Int_t(current->GetWeight()/100+0.5);
370 ipart = gMC->TrackPid();
87a6e868 371 fp = fAlphaFeedback * qtot;
ddae0931 372 nfp = gRandom->Poisson(fp);
373
374 // This call to fill the time of flight
375 gMC->TrackPosition(position);
376 //
377 // Generate photons
87a6e868 378 for (i = 0; i <nfp; i++) {
ddae0931 379
380 // Direction
381 gMC->Rndm(ranf, 2);
382 cthf = ranf[0] * 2 - 1.;
383 if (cthf < 0) continue;
384 sthf = TMath::Sqrt((1 - cthf) * (1 + cthf));
385 phif = ranf[1] * 2 * TMath::Pi();
386 //
387 gMC->Rndm(&random, 1);
388 if (random <= .57) {
389 enfp = 7.5e-9;
390 } else if (random <= .7) {
391 enfp = 6.4e-9;
392 } else {
393 enfp = 7.9e-9;
394 }
395
396 dir[0] = sthf * TMath::Sin(phif);
397 dir[1] = cthf;
398 dir[2] = sthf * TMath::Cos(phif);
399 gMC->Gdtom(dir, mom, 2);
400 mom[0]*=enfp;
401 mom[1]*=enfp;
402 mom[2]*=enfp;
403
404 // Polarisation
405 e1[0] = 0;
406 e1[1] = -dir[2];
407 e1[2] = dir[1];
408
409 e2[0] = -dir[1];
410 e2[1] = dir[0];
411 e2[2] = 0;
412
413 e3[0] = dir[1];
414 e3[1] = 0;
415 e3[2] = -dir[0];
416
417 vmod=0;
418 for(j=0;j<3;j++) vmod+=e1[j]*e1[j];
419 if (!vmod) for(j=0;j<3;j++) {
420 uswop=e1[j];
421 e1[j]=e3[j];
422 e3[j]=uswop;
423 }
424 vmod=0;
425 for(j=0;j<3;j++) vmod+=e2[j]*e2[j];
426 if (!vmod) for(j=0;j<3;j++) {
427 uswop=e2[j];
428 e2[j]=e3[j];
429 e3[j]=uswop;
430 }
431
432 vmod=0;
433 for(j=0;j<3;j++) vmod+=e1[j]*e1[j];
434 vmod=TMath::Sqrt(1/vmod);
435 for(j=0;j<3;j++) e1[j]*=vmod;
436
437 vmod=0;
438 for(j=0;j<3;j++) vmod+=e2[j]*e2[j];
439 vmod=TMath::Sqrt(1/vmod);
440 for(j=0;j<3;j++) e2[j]*=vmod;
441
442 gMC->Rndm(ranf, 1);
443 phi = ranf[0] * 2 * TMath::Pi();
444 for(j=0;j<3;j++) pol[j]=e1[j]*TMath::Sin(phi)+e2[j]*TMath::Cos(phi);
445 gMC->Gdtom(pol, pol, 2);
446
447 // Put photon on the stack and label it as feedback (51, 52)
448 ++sNfeed;
87a6e868 449
450 gAlice->SetTrack(Int_t(1), gAlice->CurrentTrack(), Int_t(50000051),
ddae0931 451 mom,source,pol,position[3],
87a6e868 452 "Feedback", nt, 1.);
ddae0931 453 }
f91473f6 454 return(sNfeed);
ddae0931 455}
87a6e868 456
457//___________________________________________
458ClassImp(AliRICHGeometryV0)