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