]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHResponseV0.cxx
MC-dependent part of AliRun extracted in AliMC (F.Carminati)
[u/mrichter/AliRoot.git] / RICH / AliRICHResponseV0.cxx
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 /* $Id$ */
17
18 #include <TMath.h>
19 #include <TParticle.h>
20 #include <TRandom.h>
21 #include <TVirtualMC.h>
22
23 #include "AliRICHResponseV0.h"
24 #include "AliRun.h"
25 #include "AliSegmentation.h"
26 #include "AliMC.h"
27
28 //___________________________________________
29 ClassImp(AliRICHResponseV0)
30
31 AliRICHResponseV0::AliRICHResponseV0()
32 {
33    SetSigmaIntegration(5.);
34    SetChargeSlope(27.);
35    SetChargeSpread(0.18, 0.18);
36    SetMaxAdc(4096);
37    SetAlphaFeedback(0.036);
38    SetEIonisation(26.e-9);
39    SetSqrtKx3(0.77459667);
40    SetKx2(0.962);
41    SetKx4(0.379);
42    SetSqrtKy3(0.77459667);
43    SetKy2(0.962);
44    SetKy4(0.379);
45    SetPitch(0.25);
46    SetWireSag(1);                     // 1->On, 0->Off
47    SetVoltage(2150);                  // Should only be 2000, 2050, 2100 or 2150
48 }//AliRICHResponseV0::ctor()
49 Float_t AliRICHResponseV0::IntPH(Float_t eloss, Float_t yhit)
50 {
51     // Get number of electrons and return charge
52     
53     Int_t nel;
54     nel= Int_t(eloss/fEIonisation);
55     
56     Float_t charge=0;
57     Double_t gain_var=1;
58
59     if (nel == 0) nel=1;
60
61     if (fWireSag)
62       {
63         //printf("Voltage:%d, Yhit:%f\n",fVoltage, yhit);
64
65         if (fVoltage==2150)
66           {
67             gain_var = 9e-6*TMath::Power(yhit,4) + 2e-7*TMath::Power(yhit,3) - 0.0316*TMath::Power(yhit,2) - 3e-4*yhit + 25.367;
68             //gain_var = 9e-5*TMath::Power(yhit,4) + 2e-6*TMath::Power(yhit,3) - 0.316*TMath::Power(yhit,2) - 3e-3*yhit + 253.67;
69           }
70         if (fVoltage==2100)
71             gain_var = 8e-6*TMath::Power(yhit,4) + 2e-7*TMath::Power(yhit,3) - 0.0283*TMath::Power(yhit,2) - 2e-4*yhit + 23.015;
72         if (fVoltage==2050)
73             gain_var = 7e-6*TMath::Power(yhit,4) + 1e-7*TMath::Power(yhit,3) - 0.0254*TMath::Power(yhit,2) - 2e-4*yhit + 20.888;
74         if (fVoltage==2000)
75             gain_var = 6e-6*TMath::Power(yhit,4) + 8e-8*TMath::Power(yhit,3) - 0.0227*TMath::Power(yhit,2) - 1e-4*yhit + 18.961;
76                 
77         gain_var = gain_var/100;
78         //printf("Yhit:%f, Gain variation:%f\n",yhit,gain_var);
79
80         Float_t gain = (fChargeSlope + fChargeSlope*gain_var)*.9; 
81         //printf(" Yhit:%f, Gain variation:%f\n",yhit, gain);
82
83         for (Int_t i=1;i<=nel;i++) {
84           charge -= gain*TMath::Log(gRandom->Rndm());    
85         }
86       }
87     else
88       {
89         for (Int_t i=1;i<=nel;i++) {
90           charge -= fChargeSlope*TMath::Log(gRandom->Rndm());    
91         }
92       }
93
94     return charge;
95 }
96
97 Float_t AliRICHResponseV0::IntPH(Float_t yhit)
98 {
99
100 //  Get number of electrons and return charge, for a single photon
101
102   Float_t charge=0;
103   Double_t gain_var=1;
104
105    if (fWireSag)
106       {
107         if (fVoltage==2150)
108           {
109             gain_var = 9e-6*TMath::Power(yhit,4) + 2e-7*TMath::Power(yhit,3) - 0.0316*TMath::Power(yhit,2) - 3e-4*yhit + 25.367;
110             //gain_var = 9e-5*TMath::Power(yhit,4) + 2e-6*TMath::Power(yhit,3) - 0.316*TMath::Power(yhit,2) - 3e-3*yhit + 253.67;
111           }
112         if (fVoltage==2100)
113             gain_var = 8e-6*TMath::Power(yhit,4) + 2e-7*TMath::Power(yhit,3) - 0.0283*TMath::Power(yhit,2) - 2e-4*yhit + 23.015;
114         if (fVoltage==2050)
115             gain_var = 7e-6*TMath::Power(yhit,4) + 1e-7*TMath::Power(yhit,3) - 0.0254*TMath::Power(yhit,2) - 2e-4*yhit + 20.888;
116         if (fVoltage==2000)
117             gain_var = 6e-6*TMath::Power(yhit,4) + 8e-8*TMath::Power(yhit,3) - 0.0227*TMath::Power(yhit,2) - 1e-4*yhit + 18.961;
118
119         gain_var = gain_var/100;
120         //printf(" Yhit:%f, Gain variation:%f\n",yhit, gain_var);
121         
122         Float_t gain = (fChargeSlope + fChargeSlope*gain_var)*.9; 
123         
124         charge -= gain*TMath::Log(gRandom->Rndm());
125         //printf(" Yhit:%f, Gain variation:%f\n",yhit, gain);
126       }
127    else
128      {
129        charge -= fChargeSlope*TMath::Log(gRandom->Rndm());
130      }
131     return charge;
132 }
133
134
135
136 // -------------------------------------------
137 Float_t AliRICHResponseV0::IntXY(AliSegmentation * segmentation)
138 {
139     
140     const Float_t kInversePitch = 1/fPitch;
141     Float_t response;
142 //
143 //  Integration limits defined by segmentation model
144 //  
145     
146     Float_t xi1, xi2, yi1, yi2;
147     segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
148
149     xi1=xi1*kInversePitch;
150     xi2=xi2*kInversePitch;
151     yi1=yi1*kInversePitch;
152     yi2=yi2*kInversePitch;
153
154     //printf("Integration Limits: %f-%f, %f-%f\n",xi1,xi2,yi1,yi2);
155     
156     //printf("KInversePitch:%f\n",kInversePitch);
157
158     //
159 // The Mathieson function 
160     Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
161     Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
162     
163     Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
164     Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
165
166     //printf("Integration Data: %f-%f, %f-%f\n",ux1,ux2,uy1,uy2);
167     
168     //printf("%f %f %f %f\n",fSqrtKx3,fKx2,fKy4,fKx4);
169     
170     response=4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1));
171
172     //printf("Response:%f\n",response);
173
174     return response;       
175     
176 }
177
178 Int_t AliRICHResponseV0::FeedBackPhotons(Float_t *source, Float_t qtot)
179 {
180   //
181   // Generate FeedBack photons
182   //
183   Int_t j, ipart, nt;
184     
185   Int_t sNfeed=0;
186   
187   
188   // Local variables 
189   Double_t ranf[2];
190   Float_t cthf, phif, enfp = 0, sthf;
191   Int_t i, ifeed;
192   Float_t e1[3], e2[3], e3[3];
193   Float_t vmod, uswop;
194   Float_t fp;
195   Double_t random;
196   Float_t dir[3], phi;
197   Int_t nfp;
198   Float_t pol[3], mom[4];
199   TLorentzVector position;
200   //
201   // Determine number of feedback photons
202
203   //  Get weight of current particle
204   TParticle *current = (TParticle*) 
205     (*gAlice->GetMCApp()->Particles())[gAlice->GetMCApp()->GetCurrentTrackNumber()];
206     
207   ifeed = Int_t(current->GetWeight()/100+0.5);
208   ipart = gMC->TrackPid();
209   fp = fAlphaFeedback * qtot;
210   nfp = gRandom->Poisson(fp);
211   
212   // This call to fill the time of flight
213   gMC->TrackPosition(position);
214   //printf("Track position: %f %f %f %15.12f\n", position[0],position[1],position[2],position[3]);
215   //
216   // Generate photons
217   for (i = 0; i <nfp; i++) {
218         
219     // Direction
220     gMC->GetRandom()->RndmArray(2,ranf);
221     cthf = ranf[0] * 2 - 1.;
222     if (cthf < 0)  continue;
223     sthf = TMath::Sqrt((1 - cthf) * (1 + cthf));
224     phif = ranf[1] * 2 * TMath::Pi();
225     //
226     //gMC->Rndm(&random, 1);
227     gMC->GetRandom()->RndmArray(1, &random);
228     if (random <= .57) {
229       enfp = 7.5e-9;
230     } else if (random <= .7) {
231       enfp = 6.4e-9;
232     } else {
233       enfp = 7.9e-9;
234     }
235
236     dir[0] = sthf * TMath::Sin(phif);
237     dir[1] = cthf;
238     dir[2] = sthf * TMath::Cos(phif);
239     gMC->Gdtom(dir, mom, 2);
240     mom[0]*=enfp;
241     mom[1]*=enfp;
242     mom[2]*=enfp;
243     mom[3] = TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]+mom[2]*mom[2]);
244     //printf("Dir %f %f %f\n",dir[0],dir[1],dir[2]);
245     //printf("Momentum %15.12f %15.12f %15.12f\n",mom[0],mom[1],mom[2]);
246     //printf("Energy %e\n", mom[3]);
247     
248     // Polarisation
249     e1[0] = 0;
250     e1[1] = -dir[2];
251     e1[2] = dir[1];
252     
253     e2[0] = -dir[1];
254     e2[1] = dir[0];
255     e2[2] = 0;
256     
257     e3[0] = dir[1];
258     e3[1] = 0;
259     e3[2] = -dir[0];
260     
261     vmod=0;
262     for(j=0;j<3;j++) vmod+=e1[j]*e1[j];
263     if (!vmod) for(j=0;j<3;j++) {
264       uswop=e1[j];
265       e1[j]=e3[j];
266       e3[j]=uswop;
267     }
268     vmod=0;
269     for(j=0;j<3;j++) vmod+=e2[j]*e2[j];
270     if (!vmod) for(j=0;j<3;j++) {
271       uswop=e2[j];
272       e2[j]=e3[j];
273       e3[j]=uswop;
274     }
275     
276     vmod=0;
277     for(j=0;j<3;j++) vmod+=e1[j]*e1[j];
278     vmod=TMath::Sqrt(1/vmod);
279     for(j=0;j<3;j++) e1[j]*=vmod;
280     
281     vmod=0;
282     for(j=0;j<3;j++) vmod+=e2[j]*e2[j];
283     vmod=TMath::Sqrt(1/vmod);
284     for(j=0;j<3;j++) e2[j]*=vmod;
285     
286     //gMC->Rndm(ranf, 1);
287     gMC->GetRandom()->RndmArray(1,ranf);
288     phi = ranf[0] * 2 * TMath::Pi();
289     for(j=0;j<3;j++) pol[j]=e1[j]*TMath::Sin(phi)+e2[j]*TMath::Cos(phi);
290     gMC->Gdtom(pol, pol, 2);
291     
292     // Put photon on the stack and label it as feedback (51, 52) 
293     ++sNfeed;
294
295     gAlice->GetMCApp()->PushTrack(Int_t(1), gAlice->GetMCApp()->GetCurrentTrackNumber(), Int_t(50000051),
296                      mom[0],mom[1],mom[2],mom[3],source[0],source[1],source[2],position[3],pol[0],pol[1],pol[2],
297                      kPFeedBackPhoton, nt, 1.);
298     
299     //printf("Adding feedback with tof %f and going to %f %f %f\n",position[3],mom[0],mom[1],mom[2]);
300   }
301   //if(sNfeed)
302     //printf("feedbacks produced:%d\n",sNfeed);
303   return(sNfeed);
304 }
305
306
307
308