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