1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 #include "AliRICHSegResV0.h"
23 #include "TParticle.h"
29 ClassImp(AliRICHSegmentation)
30 ClassImp(AliRICHResponse)
31 ClassImp(AliRICHGeometry)
32 //___________________________________________
33 ClassImp(AliRICHSegmentationV0)
35 void AliRICHSegmentationV0::Init(AliRICHChamber* Chamber)
37 //fNpx=(Int_t) (Chamber->ROuter()/fDpx+1);
38 //fNpy=(Int_t) (Chamber->ROuter()/fDpy+1);
47 Float_t AliRICHSegmentationV0::GetAnod(Float_t xhit)
49 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
53 void AliRICHSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
58 void AliRICHSegmentationV0::GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
60 // returns pad coordinates (ix,iy) for given real coordinates (x,y)
62 // Please check origin of pad numbering !!!
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;
72 void AliRICHSegmentationV0::
73 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
75 // returns real coordinates (x,y) for given pad coordinates (ix,iy)
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.;
82 void AliRICHSegmentationV0::
83 SetHit(Float_t xhit, Float_t yhit)
86 // Find the wire position (center of charge distribution)
87 // Float_t x0a=GetAnod(xhit);
92 void AliRICHSegmentationV0::
93 SetPad(Int_t ix, Int_t iy)
95 GetPadCxy(ix,iy,fx,fy);
100 void AliRICHSegmentationV0::
101 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
105 // Find the wire position (center of charge distribution)
106 Float_t x0a=GetAnod(xhit);
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;
116 // find the pads over which the charge distributes
117 GetPadIxy(x01,y01,fixmin,fiymin);
118 GetPadIxy(x02,y02,fixmax,fiymax);
120 // Set current pad to lower left corner
123 GetPadCxy(fix,fiy,fx,fy);
126 //printf("fix: %d, fiy: %d fx: %f, fy: %f\n",fix,fiy,fx,fy);
129 void AliRICHSegmentationV0::NextPad()
131 //printf("\n Next Pad \n");
134 // Step to next pad in integration region
136 // if (fix==-1) fix++;
138 } else if (fiy <= fiymax) {
139 // if (fiy==-1) fiy++;
143 printf("\n Error: Stepping outside integration region\n ");
145 GetPadCxy(fix,fiy,fx,fy);
148 Int_t AliRICHSegmentationV0::MorePads()
151 // Are there more pads in the integration region
153 //printf("\n More Pads ? \n");
156 if (fix >= fixmax && fiy >= fiymax) {
157 //printf("There are no more pads\n\n\n\n\n");
160 //printf("There are more pads\n\n");
165 void AliRICHSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
168 // Initialises pad and wire position during stepping
171 GetPadIxy(x,y,fixt,fiyt);
172 fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
175 Int_t AliRICHSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
178 // Signal will be generated if particle crosses pad boundary or
179 // boundary between two wires.
181 GetPadIxy(x,y,ixt,iyt);
182 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
184 if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
190 void AliRICHSegmentationV0::
191 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
205 void AliRICHSegmentationV0::
206 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
208 //Is used for the cluster finder, include diagonal elements
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;
214 Xlist[0]=Xlist[1]=iX;
219 Ylist[2]=Ylist[3]=iY;
236 Float_t AliRICHSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
238 // Returns the square of the distance between 1 pad
239 // labelled by its Channel numbers and a coordinate
242 GetPadCxy(iX,iY,x,y);
243 return (x-X)*(x-X) + (y-Y)*(y-Y);
247 void AliRICHSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
254 void AliRICHSegmentationV0::Draw()
258 Float_t scale=0.95/fRmax/2.;
261 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
262 circle->SetFillColor(2);
265 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
266 circle->SetFillColor(1);
274 //___________________________________________
275 ClassImp(AliRICHResponseV0)
277 Float_t AliRICHResponseV0::IntPH(Float_t eloss)
279 // Get number of electrons and return charge
282 nel= Int_t(eloss/fEIonisation);
286 for (Int_t i=1;i<=nel;i++) {
287 charge -= fChargeSlope*TMath::Log(gRandom->Rndm());
292 Float_t AliRICHResponseV0::IntPH()
294 Float_t charge = -fChargeSlope*TMath::Log(gRandom->Rndm());
300 // -------------------------------------------
301 Float_t AliRICHResponseV0::IntXY(AliRICHSegmentation * segmentation)
304 const Float_t invpitch = 1/fPitch;
307 // Integration limits defined by segmentation model
310 Float_t xi1, xi2, yi1, yi2;
311 segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
318 //printf("Integration Limits: %f-%f, %f-%f\n",xi1,xi2,yi1,yi2);
320 //printf("Invpitch:%f\n",invpitch);
323 // The Mathieson function
324 Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
325 Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
327 Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
328 Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
330 //printf("Integration Data: %f-%f, %f-%f\n",ux1,ux2,uy1,uy2);
332 //printf("%f %f %f %f\n",fSqrtKx3,fKx2,fKy4,fKx4);
334 response=4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1));
336 //printf("Response:%f\n",response);
342 Int_t AliRICHResponseV0::FeedBackPhotons(Float_t *source, Float_t qtot)
345 // Generate FeedBack photons
353 Float_t cthf, ranf[2], phif, enfp = 0, sthf;
355 Float_t e1[3], e2[3], e3[3];
360 Float_t pol[3], mom[3];
361 TLorentzVector position;
363 // Determine number of feedback photons
365 // Get weight of current particle
366 TParticle *current = (TParticle*)
367 (*gAlice->Particles())[gAlice->CurrentTrack()];
369 ifeed = Int_t(current->GetWeight()/100+0.5);
370 ipart = gMC->TrackPid();
371 fp = fAlphaFeedback * qtot;
372 nfp = gRandom->Poisson(fp);
374 // This call to fill the time of flight
375 gMC->TrackPosition(position);
378 for (i = 0; i <nfp; i++) {
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();
387 gMC->Rndm(&random, 1);
390 } else if (random <= .7) {
396 dir[0] = sthf * TMath::Sin(phif);
398 dir[2] = sthf * TMath::Cos(phif);
399 gMC->Gdtom(dir, mom, 2);
418 for(j=0;j<3;j++) vmod+=e1[j]*e1[j];
419 if (!vmod) for(j=0;j<3;j++) {
425 for(j=0;j<3;j++) vmod+=e2[j]*e2[j];
426 if (!vmod) for(j=0;j<3;j++) {
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;
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;
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);
447 // Put photon on the stack and label it as feedback (51, 52)
450 gAlice->SetTrack(Int_t(1), gAlice->CurrentTrack(), Int_t(50000051),
451 mom,source,pol,position[3],
457 //___________________________________________
458 ClassImp(AliRICHGeometryV0)