]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDsim.cxx
Correction connected with compiler warnings on Darwin
[u/mrichter/AliRoot.git] / TRD / AliTRDsim.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 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  TRD simulation - multimodule (regular rad.)                              //
21 //  after: M. CASTELLANO et al., COMP. PHYS. COMM. 51 (1988) 431             //
22 //                             + COMP. PHYS. COMM. 61 (1990) 395             //
23 //                                                                           //
24 //   17.07.1998 - A.Andronic                                                 //
25 //   08.12.1998 - simplified version                                         //
26 //   11.07.2000 - Adapted code to aliroot environment (C.Blume)              //
27 //                                                                           //
28 ///////////////////////////////////////////////////////////////////////////////
29
30 #include <stdlib.h>
31
32 #include <TH1.h>
33 #include <TRandom.h>
34 #include <TMath.h>
35 #include <TParticle.h>
36
37 #include "AliModule.h"
38
39 #include "AliTRDsim.h"
40
41 ClassImp(AliTRDsim)
42
43 //_____________________________________________________________________________
44 AliTRDsim::AliTRDsim():TObject()
45 {
46   //
47   // AliTRDsim default constructor
48   // 
49
50   fSpectrum = 0;
51   fSigma    = 0;
52
53   Init();
54
55 }
56
57 //_____________________________________________________________________________
58 AliTRDsim::AliTRDsim(AliModule *mod, Int_t foil, Int_t gap)
59 {
60   //
61   // AliTRDsim constructor. Takes the material properties of the radiator
62   // foils and the gas in the gaps from AliModule <mod>.
63   // The default number of foils is 100 with a thickness of 20 mu. The 
64   // thickness of the gaps is 500 mu.
65   //
66
67   Float_t aFoil, zFoil, rhoFoil;
68   Float_t aGap,  zGap,  rhoGap;
69   Float_t rad, abs;
70   Char_t  name[21];
71
72   fSpectrum = 0;
73   fSigma    = 0;
74
75   Init();
76
77   mod->AliGetMaterial(foil,name,aFoil,zFoil,rhoFoil,rad,abs);
78   mod->AliGetMaterial(gap ,name,aGap ,zGap ,rhoGap ,rad,abs);
79
80   fFoilDens  = rhoFoil;
81   fFoilA     = aFoil;
82   fFoilZ     = zFoil;
83   fFoilOmega = Omega(fFoilDens,fFoilZ,fFoilA);
84
85   fGapDens   = rhoGap;
86   fGapA      = aGap;
87   fGapZ      = zGap;
88   fGapOmega  = Omega(fGapDens ,fGapZ ,fGapA );
89
90 }
91
92 //_____________________________________________________________________________
93 AliTRDsim::AliTRDsim(const AliTRDsim &s)
94 {
95   //
96   // AliTRDsim copy constructor
97   //
98
99   ((AliTRDsim &) s).Copy(*this);
100
101 }
102
103 //_____________________________________________________________________________
104 AliTRDsim::~AliTRDsim() 
105 {
106   //
107   // AliTRDsim destructor
108   //
109
110   //  if (fSpectrum) delete fSpectrum;
111   if (fSigma)    delete [] fSigma;
112
113 }
114
115 //_____________________________________________________________________________
116 AliTRDsim &AliTRDsim::operator=(const AliTRDsim &s)
117 {
118   //
119   // Assignment operator
120   //
121
122   if (this != &s) ((AliTRDsim &) s).Copy(*this);
123   return *this;
124
125 }
126
127 //_____________________________________________________________________________
128 void AliTRDsim::Copy(TObject &s)
129 {
130   //
131   // Copy function
132   //
133
134   ((AliTRDsim &) s).fNFoils     = fNFoils;
135   ((AliTRDsim &) s).fFoilThick  = fFoilThick;
136   ((AliTRDsim &) s).fFoilDens   = fFoilDens;
137   ((AliTRDsim &) s).fFoilOmega  = fFoilOmega;
138   ((AliTRDsim &) s).fFoilZ      = fFoilZ;
139   ((AliTRDsim &) s).fFoilA      = fFoilA;
140   ((AliTRDsim &) s).fGapThick   = fGapThick;
141   ((AliTRDsim &) s).fGapDens    = fGapDens;
142   ((AliTRDsim &) s).fGapOmega   = fGapOmega;
143   ((AliTRDsim &) s).fGapZ       = fGapZ;
144   ((AliTRDsim &) s).fGapA       = fGapA;
145   ((AliTRDsim &) s).fTemp       = fTemp;
146   ((AliTRDsim &) s).fSpNBins    = fSpNBins;
147   ((AliTRDsim &) s).fSpRange    = fSpRange;
148   ((AliTRDsim &) s).fSpBinWidth = fSpBinWidth;
149   ((AliTRDsim &) s).fSpLower    = fSpLower;
150   ((AliTRDsim &) s).fSpUpper    = fSpUpper;
151
152   if (((AliTRDsim &) s).fSigma) delete [] ((AliTRDsim &) s).fSigma;
153   ((AliTRDsim &) s).fSigma = new Double_t[fSpNBins];
154   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
155     ((AliTRDsim &) s).fSigma[iBin] = fSigma[iBin];
156   }  
157
158   fSpectrum->Copy(*((AliTRDsim &) s).fSpectrum);
159
160 }
161
162 //_____________________________________________________________________________
163 void AliTRDsim::Init()
164 {
165   //
166   // Initialization 
167   // The default radiator are 100 prolypropilene foils of 13 mu thickness
168   // with gaps of 60 mu filled with CO2.
169   // 
170
171   fNFoils     = 100;
172
173   fFoilThick  = 0.0013;
174   fFoilDens   = 0.92;   
175   fFoilZ      = 5.28571;
176   fFoilA      = 10.4286;
177   fFoilOmega  = Omega(fFoilDens,fFoilZ,fFoilA);
178
179   fGapThick   = 0.0060;
180   fGapDens    = 0.001977;  
181   fGapZ       = 7.45455;
182   fGapA       = 14.9091;
183   fGapOmega   = Omega(fGapDens ,fGapZ ,fGapA );
184
185   fTemp       = 293.16;
186
187   fSpNBins    = 200;
188   fSpRange    = 100;
189   fSpBinWidth = fSpRange / fSpNBins;
190   fSpLower    = 1.0 - 0.5 * fSpBinWidth;
191   fSpUpper    = fSpLower + fSpRange;
192
193   if (fSpectrum) delete fSpectrum;
194   fSpectrum   = new TH1D("TRspectrum","TR spectrum",fSpNBins,fSpLower,fSpUpper);
195   fSpectrum->SetDirectory(0);
196
197   // Set the sigma values 
198   SetSigma();
199
200 }
201
202 //_____________________________________________________________________________
203 Int_t AliTRDsim::CreatePhotons(Int_t pdg, Float_t p
204                              , Int_t &nPhoton, Float_t *ePhoton)
205 {
206   //
207   // Create TRD photons for a charged particle of type <pdg> with the total 
208   // momentum <p>. 
209   // Number of produced TR photons:       <nPhoton>
210   // Energies of the produced TR photons: <ePhoton>
211   //
212
213   // PDG codes
214   const Int_t kPdgEle  =  11;
215   const Int_t kPdgMuon =  13;
216   const Int_t kPdgPion = 211;
217   const Int_t kPdgKaon = 321;
218
219   Float_t  mass        = 0;
220   switch (TMath::Abs(pdg)) {
221   case kPdgEle:
222     mass      =  5.11e-4;
223     break;
224   case kPdgMuon:
225     mass      =  0.10566;
226     break;
227   case kPdgPion:
228     mass      =  0.13957;
229     break;
230   case kPdgKaon:
231     mass      =  0.4937;
232     break;
233   default:
234     return 0;
235     break;
236   };
237
238   // Calculate gamma
239   Double_t gamma = TMath::Sqrt(p*p + mass*mass) / mass;
240
241   // Calculate the TR photons
242   return TrPhotons(gamma, nPhoton, ePhoton);
243
244 }
245
246 //_____________________________________________________________________________
247 Int_t AliTRDsim::TrPhotons(Double_t gamma, Int_t &nPhoton, Float_t *ePhoton)
248 {
249   //
250   // Produces TR photons.
251   //
252
253   const Double_t kAlpha  = 0.0072973;
254   const Int_t    kSumMax = 10;
255
256   Double_t kappa = fGapThick / fFoilThick;
257
258   fSpectrum->Reset();
259
260   // The TR spectrum
261   Double_t stemp = 0;
262   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
263
264     // keV -> eV
265     Double_t energyeV = (fSpBinWidth * iBin + 1.0) * 1e3;
266
267     Double_t csFoil   = fFoilOmega / energyeV;
268     Double_t csGap    = fGapOmega  / energyeV;
269
270     Double_t rho1     = energyeV * fFoilThick * 1e4 * 2.5 
271                                  * (1.0 / (gamma*gamma) + csFoil*csFoil);
272     Double_t rho2     = energyeV * fFoilThick * 1e4 * 2.5 
273                                  * (1.0 / (gamma*gamma) + csGap *csGap);
274
275     // Calculate the sum
276     Double_t sum = 0;
277     for (Int_t iSum = 0; iSum < kSumMax; iSum++) {
278       Double_t tetan = (TMath::Pi() * 2.0 * (iSum+1) - (rho1 + kappa * rho2)) 
279                      / (kappa + 1.0);
280       if (tetan < 0.0) tetan = 0.0;
281       Double_t aux   = 1.0 / (rho1 + tetan) - 1.0 / (rho2 + tetan);
282                sum  += tetan * (aux*aux) * (1.0 - TMath::Cos(rho1 + tetan));
283     }
284
285     // Absorbtion
286     Double_t conv      = 1.0 - TMath::Exp(-fNFoils * fSigma[iBin]);
287
288     // eV -> keV
289     Float_t  energykeV = energyeV * 0.001;
290
291     // dN / domega
292     Double_t wn        = kAlpha * 4.0 / (fSigma[iBin] * (kappa + 1.0)) 
293                                 * conv * sum / energykeV;
294     fSpectrum->SetBinContent(iBin,wn);
295
296     stemp += wn;
297
298   }
299
300   // <nTR> (binsize corr.)
301   Float_t ntr = stemp * fSpBinWidth;
302   // Number of TR photons from Poisson distribution with mean <ntr>
303   nPhoton = gRandom->Poisson(ntr);
304   // Energy of the TR photons
305   for (Int_t iPhoton = 0; iPhoton < nPhoton; iPhoton++) {
306     ePhoton[iPhoton] = fSpectrum->GetRandom();
307   }
308
309   return 1;
310
311 }
312
313 //_____________________________________________________________________________
314 void AliTRDsim::SetSigma() 
315 {
316   //
317   // Sets the absorbtion crosssection for the energies of the TR spectrum
318   //
319
320   if (fSigma) delete [] fSigma;
321   fSigma = new Double_t[fSpNBins];
322   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
323     Double_t energykeV = iBin * fSpBinWidth + 1.0;
324     fSigma[iBin]       = Sigma(energykeV);
325     //printf("SetSigma(): iBin = %d fSigma %g\n",iBin,fSigma[iBin]);
326   }
327
328 }
329
330 //_____________________________________________________________________________
331 Double_t AliTRDsim::Sigma(Double_t energykeV)
332 {
333   //
334   // Calculates the absorbtion crosssection for a one-foil-one-gap-radiator
335   //
336
337   // keV -> MeV
338   Double_t energyMeV = energykeV * 0.001;
339   if (energyMeV >= 0.001) {
340     return(GetMuPo(energyMeV) * fFoilDens * fFoilThick +
341            GetMuAi(energyMeV) * fGapDens  * fGapThick  * GetTemp());
342   }
343   else {
344     return 1e6;
345   }
346
347 }
348
349 //_____________________________________________________________________________
350 Double_t AliTRDsim::GetMuPo(Double_t energyMeV)
351 {
352   //
353   // Returns the photon absorbtion cross section for polypropylene
354   //
355
356   const Int_t kN = 36;
357
358   Double_t mu[kN] = { 1.894E+03, 5.999E+02, 2.593E+02
359                     , 7.743E+01, 3.242E+01, 1.643E+01
360                     , 9.432E+00, 3.975E+00, 2.088E+00
361                     , 7.452E-01, 4.315E-01, 2.706E-01
362                     , 2.275E-01, 2.084E-01, 1.970E-01
363                     , 1.823E-01, 1.719E-01, 1.534E-01
364                     , 1.402E-01, 1.217E-01, 1.089E-01
365                     , 9.947E-02, 9.198E-02, 8.078E-02
366                     , 7.262E-02, 6.495E-02, 5.910E-02   
367                     , 5.064E-02, 4.045E-02, 3.444E-02
368                     , 3.045E-02, 2.760E-02, 2.383E-02
369                     , 2.145E-02, 1.819E-02, 1.658E-02 };
370
371   Double_t en[kN] = { 1.000E-03, 1.500E-03, 2.000E-03
372                     , 3.000E-03, 4.000E-03, 5.000E-03
373                     , 6.000E-03, 8.000E-03, 1.000E-02
374                     , 1.500E-02, 2.000E-02, 3.000E-02
375                     , 4.000E-02, 5.000E-02, 6.000E-02
376                     , 8.000E-02, 1.000E-01, 1.500E-01
377                     , 2.000E-01, 3.000E-01, 4.000E-01
378                     , 5.000E-01, 6.000E-01, 8.000E-01
379                     , 1.000E+00, 1.250E+00, 1.500E+00
380                     , 2.000E+00, 3.000E+00, 4.000E+00
381                     , 5.000E+00, 6.000E+00, 8.000E+00
382                     , 1.000E+01, 1.500E+01, 2.000E+01 };
383
384   return Interpolate(energyMeV,en,mu,kN);
385
386 }
387
388 //_____________________________________________________________________________
389 Double_t AliTRDsim::GetMuCO(Double_t energyMeV)
390 {
391   //
392   // Returns the photon absorbtion cross section for CO2
393   //
394
395   const Int_t kN = 36;
396
397   Double_t mu[kN] = { 0.39383E+04, 0.13166E+04, 0.58750E+03
398                     , 0.18240E+03, 0.77996E+02, 0.40024E+02
399                     , 0.23116E+02, 0.96997E+01, 0.49726E+01
400                     , 0.15543E+01, 0.74915E+00, 0.34442E+00
401                     , 0.24440E+00, 0.20589E+00, 0.18632E+00
402                     , 0.16578E+00, 0.15394E+00, 0.13558E+00
403                     , 0.12336E+00, 0.10678E+00, 0.95510E-01
404                     , 0.87165E-01, 0.80587E-01, 0.70769E-01
405                     , 0.63626E-01, 0.56894E-01, 0.51782E-01
406                     , 0.44499E-01, 0.35839E-01, 0.30825E-01
407                     , 0.27555E-01, 0.25269E-01, 0.22311E-01
408                     , 0.20516E-01, 0.18184E-01, 0.17152E-01 };
409
410   Double_t en[kN] = { 0.10000E-02, 0.15000E-02, 0.20000E-02
411                     , 0.30000E-02, 0.40000E-02, 0.50000E-02
412                     , 0.60000E-02, 0.80000E-02, 0.10000E-01
413                     , 0.15000E-01, 0.20000E-01, 0.30000E-01
414                     , 0.40000E-01, 0.50000E-01, 0.60000E-01
415                     , 0.80000E-01, 0.10000E+00, 0.15000E+00
416                     , 0.20000E+00, 0.30000E+00, 0.40000E+00
417                     , 0.50000E+00, 0.60000E+00, 0.80000E+00
418                     , 0.10000E+01, 0.12500E+01, 0.15000E+01
419                     , 0.20000E+01, 0.30000E+01, 0.40000E+01
420                     , 0.50000E+01, 0.60000E+01, 0.80000E+01
421                     , 0.10000E+02, 0.15000E+02, 0.20000E+02 };
422
423   return Interpolate(energyMeV,en,mu,kN);
424
425 }
426
427 //_____________________________________________________________________________
428 Double_t AliTRDsim::GetMuXe(Double_t energyMeV)
429 {
430   //
431   // Returns the photon absorbtion cross section for xenon
432   //
433
434   const Int_t kN = 48;
435
436   Double_t mu[kN] = { 9.413E+03, 8.151E+03, 7.035E+03
437                     , 7.338E+03, 4.085E+03, 2.088E+03
438                     , 7.780E+02, 3.787E+02, 2.408E+02
439                     , 6.941E+02, 6.392E+02, 6.044E+02
440                     , 8.181E+02, 7.579E+02, 6.991E+02
441                     , 8.064E+02, 6.376E+02, 3.032E+02
442                     , 1.690E+02, 5.743E+01, 2.652E+01
443                     , 8.930E+00, 6.129E+00, 3.316E+01
444                     , 2.270E+01, 1.272E+01, 7.825E+00
445                     , 3.633E+00, 2.011E+00, 7.202E-01
446                     , 3.760E-01, 1.797E-01, 1.223E-01
447                     , 9.699E-02, 8.281E-02, 6.696E-02
448                     , 5.785E-02, 5.054E-02, 4.594E-02
449                     , 4.078E-02, 3.681E-02, 3.577E-02
450                     , 3.583E-02, 3.634E-02, 3.797E-02
451                     , 3.987E-02, 4.445E-02, 4.815E-02 };
452
453   Double_t en[kN] = { 1.00000E-03, 1.07191E-03, 1.14900E-03
454                     , 1.14900E-03, 1.50000E-03, 2.00000E-03
455                     , 3.00000E-03, 4.00000E-03, 4.78220E-03
456                     , 4.78220E-03, 5.00000E-03, 5.10370E-03
457                     , 5.10370E-03, 5.27536E-03, 5.45280E-03
458                     , 5.45280E-03, 6.00000E-03, 8.00000E-03
459                     , 1.00000E-02, 1.50000E-02, 2.00000E-02
460                     , 3.00000E-02, 3.45614E-02, 3.45614E-02
461                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
462                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
463                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
464                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
465                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
466                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
467                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
468                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
469
470   return Interpolate(energyMeV,en,mu,kN);
471
472 }
473
474 //_____________________________________________________________________________
475 Double_t AliTRDsim::GetMuBu(Double_t energyMeV)
476 {
477   //
478   // Returns the photon absorbtion cross section for isobutane
479   //
480
481   const Int_t kN = 36;
482
483   Double_t mu[kN] = { 0.38846E+03, 0.12291E+03, 0.53225E+02
484                     , 0.16091E+02, 0.69114E+01, 0.36541E+01
485                     , 0.22282E+01, 0.11149E+01, 0.72887E+00
486                     , 0.45053E+00, 0.38167E+00, 0.33920E+00
487                     , 0.32155E+00, 0.30949E+00, 0.29960E+00
488                     , 0.28317E+00, 0.26937E+00, 0.24228E+00
489                     , 0.22190E+00, 0.19289E+00, 0.17288E+00
490                     , 0.15789E+00, 0.14602E+00, 0.12829E+00
491                     , 0.11533E+00, 0.10310E+00, 0.93790E-01
492                     , 0.80117E-01, 0.63330E-01, 0.53229E-01
493                     , 0.46390E-01, 0.41425E-01, 0.34668E-01
494                     , 0.30267E-01, 0.23910E-01, 0.20509E-01 };
495
496   Double_t en[kN] = { 0.10000E-02, 0.15000E-02, 0.20000E-02
497                     , 0.30000E-02, 0.40000E-02, 0.50000E-02
498                     , 0.60000E-02, 0.80000E-02, 0.10000E-01
499                     , 0.15000E-01, 0.20000E-01, 0.30000E-01
500                     , 0.40000E-01, 0.50000E-01, 0.60000E-01
501                     , 0.80000E-01, 0.10000E+00, 0.15000E+00
502                     , 0.20000E+00, 0.30000E+00, 0.40000E+00
503                     , 0.50000E+00, 0.60000E+00, 0.80000E+00
504                     , 0.10000E+01, 0.12500E+01, 0.15000E+01
505                     , 0.20000E+01, 0.30000E+01, 0.40000E+01
506                     , 0.50000E+01, 0.60000E+01, 0.80000E+01
507                     , 0.10000E+02, 0.15000E+02, 0.20000E+02 };
508
509   return Interpolate(energyMeV,en,mu,kN);
510
511 }
512
513 //_____________________________________________________________________________
514 Double_t AliTRDsim::GetMuMy(Double_t energyMeV)
515 {
516   //
517   // Returns the photon absorbtion cross section for mylar
518   //
519
520   const Int_t kN = 36;
521
522   Double_t mu[kN] = { 2.911E+03, 9.536E+02, 4.206E+02
523                     , 1.288E+02, 5.466E+01, 2.792E+01
524                     , 1.608E+01, 6.750E+00, 3.481E+00
525                     , 1.132E+00, 5.798E-01, 3.009E-01
526                     , 2.304E-01, 2.020E-01, 1.868E-01
527                     , 1.695E-01, 1.586E-01, 1.406E-01
528                     , 1.282E-01, 1.111E-01, 9.947E-02
529                     , 9.079E-02, 8.395E-02, 7.372E-02
530                     , 6.628E-02, 5.927E-02, 5.395E-02
531                     , 4.630E-02, 3.715E-02, 3.181E-02
532                     , 2.829E-02, 2.582E-02, 2.257E-02
533                     , 2.057E-02, 1.789E-02, 1.664E-02 };
534
535   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
536                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
537                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
538                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
539                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
540                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
541                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
542                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
543                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
544                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
545                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
546                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
547
548   return Interpolate(energyMeV,en,mu,kN);
549
550 }
551
552 //_____________________________________________________________________________
553 Double_t AliTRDsim::GetMuN2(Double_t energyMeV)
554 {
555   //
556   // Returns the photon absorbtion cross section for nitrogen
557   //
558
559   const Int_t kN = 36;
560
561   Double_t mu[kN] = { 3.311E+03, 1.083E+03, 4.769E+02
562                     , 1.456E+02, 6.166E+01, 3.144E+01
563                     , 1.809E+01, 7.562E+00, 3.879E+00
564                     , 1.236E+00, 6.178E-01, 3.066E-01
565                     , 2.288E-01, 1.980E-01, 1.817E-01
566                     , 1.639E-01, 1.529E-01, 1.353E-01
567                     , 1.233E-01, 1.068E-01, 9.557E-02
568                     , 8.719E-02, 8.063E-02, 7.081E-02
569                     , 6.364E-02, 5.693E-02, 5.180E-02
570                     , 4.450E-02, 3.579E-02, 3.073E-02
571                     , 2.742E-02, 2.511E-02, 2.209E-02
572                     , 2.024E-02, 1.782E-02, 1.673E-02 };
573
574   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
575                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
576                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
577                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
578                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
579                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
580                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
581                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
582                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
583                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
584                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
585                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
586
587   return Interpolate(energyMeV,en,mu,kN);
588
589 }
590
591 //_____________________________________________________________________________
592 Double_t AliTRDsim::GetMuO2(Double_t energyMeV)
593 {
594   //
595   // Returns the photon absorbtion cross section for oxygen
596   //
597
598   const Int_t kN = 36;
599
600   Double_t mu[kN] = { 4.590E+03, 1.549E+03, 6.949E+02
601                     , 2.171E+02, 9.315E+01, 4.790E+01
602                     , 2.770E+01, 1.163E+01, 5.952E+00
603                     , 1.836E+00, 8.651E-01, 3.779E-01
604                     , 2.585E-01, 2.132E-01, 1.907E-01
605                     , 1.678E-01, 1.551E-01, 1.361E-01
606                     , 1.237E-01, 1.070E-01, 9.566E-02
607                     , 8.729E-02, 8.070E-02, 7.087E-02
608                     , 6.372E-02, 5.697E-02, 5.185E-02
609                     , 4.459E-02, 3.597E-02, 3.100E-02
610                     , 2.777E-02, 2.552E-02, 2.263E-02
611                     , 2.089E-02, 1.866E-02, 1.770E-02 };
612
613   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
614                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
615                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
616                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
617                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
618                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
619                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
620                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
621                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
622                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
623                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
624                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
625
626   return Interpolate(energyMeV,en,mu,kN);
627
628 }
629
630 //_____________________________________________________________________________
631 Double_t AliTRDsim::GetMuHe(Double_t energyMeV)
632 {
633   //
634   // Returns the photon absorbtion cross section for helium
635   //
636
637   const Int_t kN = 36;
638
639   Double_t mu[kN] = { 6.084E+01, 1.676E+01, 6.863E+00
640                     , 2.007E+00, 9.329E-01, 5.766E-01
641                     , 4.195E-01, 2.933E-01, 2.476E-01
642                     , 2.092E-01, 1.960E-01, 1.838E-01
643                     , 1.763E-01, 1.703E-01, 1.651E-01
644                     , 1.562E-01, 1.486E-01, 1.336E-01
645                     , 1.224E-01, 1.064E-01, 9.535E-02
646                     , 8.707E-02, 8.054E-02, 7.076E-02
647                     , 6.362E-02, 5.688E-02, 5.173E-02
648                     , 4.422E-02, 3.503E-02, 2.949E-02
649                     , 2.577E-02, 2.307E-02, 1.940E-02
650                     , 1.703E-02, 1.363E-02, 1.183E-02 };
651
652   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
653                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
654                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
655                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
656                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
657                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
658                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
659                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
660                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
661                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
662                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
663                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
664
665   return Interpolate(energyMeV,en,mu,kN);
666
667 }
668
669 //_____________________________________________________________________________
670 Double_t AliTRDsim::GetMuAi(Double_t energyMeV)
671 {
672   //
673   // Returns the photon absorbtion cross section for air
674   // Implemented by Oliver Busch
675   //
676
677   const Int_t kN = 38;
678
679   Double_t mu[kN] = { 0.35854E+04, 0.11841E+04, 0.52458E+03,
680                       0.16143E+03, 0.14250E+03, 0.15722E+03,
681                       0.77538E+02, 0.40099E+02, 0.23313E+02,
682                       0.98816E+01, 0.51000E+01, 0.16079E+01,
683                       0.77536E+00, 0.35282E+00, 0.24790E+00,
684                       0.20750E+00, 0.18703E+00, 0.16589E+00,
685                       0.15375E+00, 0.13530E+00, 0.12311E+00,
686                       0.10654E+00, 0.95297E-01, 0.86939E-01,
687                       0.80390E-01, 0.70596E-01, 0.63452E-01,
688                       0.56754E-01, 0.51644E-01, 0.44382E-01,
689                       0.35733E-01, 0.30721E-01, 0.27450E-01,
690                       0.25171E-01, 0.22205E-01, 0.20399E-01,
691                       0.18053E-01, 0.18057E-01 };
692
693
694
695   Double_t en[kN] = { 0.10000E-02, 0.15000E-02, 0.20000E-02,
696                       0.30000E-02, 0.32029E-02, 0.32029E-02,
697                       0.40000E-02, 0.50000E-02, 0.60000E-02,
698                       0.80000E-02, 0.10000E-01, 0.15000E-01,
699                       0.20000E-01, 0.30000E-01, 0.40000E-01,
700                       0.50000E-01, 0.60000E-01, 0.80000E-01,
701                       0.10000E+00, 0.15000E+00, 0.20000E+00,
702                       0.30000E+00, 0.40000E+00, 0.50000E+00,
703                       0.60000E+00, 0.80000E+00, 0.10000E+01,
704                       0.12500E+01, 0.15000E+01, 0.20000E+01,
705                       0.30000E+01, 0.40000E+01, 0.50000E+01,
706                       0.60000E+01, 0.80000E+01, 0.10000E+02,
707                       0.15000E+02, 0.20000E+02 };
708
709   return Interpolate(energyMeV,en,mu,kN);
710
711 }
712
713 //_____________________________________________________________________________
714 Double_t AliTRDsim::Interpolate(Double_t energyMeV
715                               , Double_t *en, Double_t *mu, Int_t n)
716 {
717   //
718   // Interpolates the photon absorbtion cross section 
719   // for a given energy <energyMeV>.
720   //
721
722   Double_t de    = 0;
723   Int_t    index = 0;
724   Int_t    istat = Locate(en,n,energyMeV,index,de);
725   if (istat == 0) {
726     return (mu[index] - de * (mu[index]   - mu[index+1]) 
727                            / (en[index+1] - en[index]  ));
728   }
729   else {
730     return 0.0; 
731   }
732
733 }
734
735 //_____________________________________________________________________________
736 Int_t AliTRDsim::Locate(Double_t *xv, Int_t n, Double_t xval
737                       , Int_t &kl, Double_t &dx) 
738 {
739   //
740   // Locates a point (xval) in a 1-dim grid (xv(n))
741   //
742
743   if (xval >= xv[n-1]) return  1;
744   if (xval <  xv[0])   return -1;
745
746   Int_t km;
747   Int_t kh = n - 1;
748
749   kl = 0;
750   while (kh - kl > 1) {
751     if (xval < xv[km = (kl+kh)/2]) kh = km; 
752     else                           kl = km;
753   }
754   if (xval < xv[kl] || xval > xv[kl+1] || kl >= n-1) {
755     printf("Locate failed xv[%d] %f xval %f xv[%d] %f!!!\n"
756           ,kl,xv[kl],xval,kl+1,xv[kl+1]);
757     exit(1);
758   }
759
760   dx = xval - xv[kl];
761
762   return 0;
763
764 }