LCOV - code coverage report
Current view: top level - TRD/TRDsim - AliTRDsimTR.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 195 336 58.0 %
Date: 2016-06-14 17:26:59 Functions: 19 29 65.5 %

          Line data    Source code
       1             : 
       2             : /**************************************************************************
       3             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       4             :  *                                                                        *
       5             :  * Author: The ALICE Off-line Project.                                    *
       6             :  * Contributors are mentioned in the code where appropriate.              *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          *
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : /* $Id$ */
      18             : 
      19             : ////////////////////////////////////////////////////////////////////////////
      20             : //                                                                        //
      21             : //  TRD simulation - multimodule (regular rad.)                           //
      22             : //  after: M. CASTELLANO et al., COMP. PHYS. COMM. 51 (1988) 431          //
      23             : //                             + COMP. PHYS. COMM. 61 (1990) 395          //
      24             : //                                                                        //
      25             : //   17.07.1998 - A.Andronic                                              //
      26             : //   08.12.1998 - simplified version                                      //
      27             : //   11.07.2000 - Adapted code to aliroot environment (C.Blume)           //
      28             : //   04.06.2004 - Momentum dependent parameters implemented (CBL)         //
      29             : //                                                                        //
      30             : ////////////////////////////////////////////////////////////////////////////
      31             : 
      32             : #include <TH1.h>
      33             : #include <TRandom.h>
      34             : #include <TMath.h>
      35             : #include <TVirtualMC.h>
      36             : #include <TVirtualMCStack.h>
      37             : 
      38             : #include "AliModule.h"
      39             : 
      40             : #include "AliTRDsimTR.h"
      41             : #include "AliLog.h"
      42             : 
      43          12 : ClassImp(AliTRDsimTR)
      44             : 
      45             : //_____________________________________________________________________________
      46             : AliTRDsimTR::AliTRDsimTR()
      47          13 :   :TObject()
      48          13 :   ,fNFoilsDim(0)
      49          13 :   ,fNFoils(0)
      50          13 :   ,fNFoilsUp(0)
      51          13 :   ,fFoilThick(0)
      52          13 :   ,fGapThick(0)
      53          13 :   ,fFoilDens(0)
      54          13 :   ,fGapDens(0)
      55          13 :   ,fFoilOmega(0)
      56          13 :   ,fGapOmega()
      57          13 :   ,fFoilZ(0)
      58          13 :   ,fGapZ(0)
      59          13 :   ,fFoilA(0)
      60          13 :   ,fGapA(0)
      61          13 :   ,fTemp(0)
      62          13 :   ,fSpNBins(0)
      63          13 :   ,fSpRange(0)
      64          13 :   ,fSpBinWidth(0)
      65          13 :   ,fSpLower(0)
      66          13 :   ,fSpUpper(0)
      67          13 :   ,fSigma(0)
      68          13 :   ,fSpectrum(0)
      69          65 : {
      70             :   //
      71             :   // AliTRDsimTR default constructor
      72             :   // 
      73             : 
      74          13 :   Init();
      75             : 
      76          26 : }
      77             : 
      78             : //_____________________________________________________________________________
      79             : AliTRDsimTR::AliTRDsimTR(AliModule *mod, Int_t foil, Int_t gap)
      80           0 :   :TObject()
      81           0 :   ,fNFoilsDim(0)
      82           0 :   ,fNFoils(0)
      83           0 :   ,fNFoilsUp(0)
      84           0 :   ,fFoilThick(0)
      85           0 :   ,fGapThick(0)
      86           0 :   ,fFoilDens(0)
      87           0 :   ,fGapDens(0)
      88           0 :   ,fFoilOmega(0)
      89           0 :   ,fGapOmega()
      90           0 :   ,fFoilZ(0)
      91           0 :   ,fGapZ(0)
      92           0 :   ,fFoilA(0)
      93           0 :   ,fGapA(0)
      94           0 :   ,fTemp(0)
      95           0 :   ,fSpNBins(0)
      96           0 :   ,fSpRange(0)
      97           0 :   ,fSpBinWidth(0)
      98           0 :   ,fSpLower(0)
      99           0 :   ,fSpUpper(0)
     100           0 :   ,fSigma(0)
     101           0 :   ,fSpectrum(0)
     102           0 : {
     103             :   //
     104             :   // AliTRDsimTR constructor. Takes the material properties of the radiator
     105             :   // foils and the gas in the gaps from AliModule <mod>.
     106             :   // The default number of foils is 100 with a thickness of 20 mu. The 
     107             :   // thickness of the gaps is 500 mu.
     108             :   //
     109             : 
     110           0 :   Float_t aFoil;
     111           0 :   Float_t zFoil;
     112           0 :   Float_t rhoFoil;
     113             : 
     114           0 :   Float_t aGap;
     115           0 :   Float_t zGap;
     116           0 :   Float_t rhoGap;
     117             : 
     118           0 :   Float_t rad;
     119           0 :   Float_t abs;
     120             : 
     121           0 :   Char_t  name[21];
     122             : 
     123           0 :   Init();
     124             : 
     125           0 :   mod->AliGetMaterial(foil,name,aFoil,zFoil,rhoFoil,rad,abs);
     126           0 :   mod->AliGetMaterial(gap ,name,aGap ,zGap ,rhoGap ,rad,abs);
     127             : 
     128           0 :   fFoilDens  = rhoFoil;
     129           0 :   fFoilA     = aFoil;
     130           0 :   fFoilZ     = zFoil;
     131           0 :   fFoilOmega = Omega(fFoilDens,fFoilZ,fFoilA);
     132             : 
     133           0 :   fGapDens   = rhoGap;
     134           0 :   fGapA      = aGap;
     135           0 :   fGapZ      = zGap;
     136           0 :   fGapOmega  = Omega(fGapDens ,fGapZ ,fGapA );
     137             : 
     138           0 : }
     139             : 
     140             : //_____________________________________________________________________________
     141             : AliTRDsimTR::AliTRDsimTR(const AliTRDsimTR &s)
     142           0 :   :TObject(s)
     143           0 :   ,fNFoilsDim(s.fNFoilsDim)
     144           0 :   ,fNFoils(0)
     145           0 :   ,fNFoilsUp(0)
     146           0 :   ,fFoilThick(s.fFoilThick)
     147           0 :   ,fGapThick(s.fGapThick)
     148           0 :   ,fFoilDens(s.fFoilDens)
     149           0 :   ,fGapDens(s.fGapDens)
     150           0 :   ,fFoilOmega(s.fFoilOmega)
     151           0 :   ,fGapOmega(s.fGapOmega)
     152           0 :   ,fFoilZ(s.fFoilZ)
     153           0 :   ,fGapZ(s.fGapZ)
     154           0 :   ,fFoilA(s.fFoilA)
     155           0 :   ,fGapA(s.fGapA)
     156           0 :   ,fTemp(s.fTemp)
     157           0 :   ,fSpNBins(s.fSpNBins)
     158           0 :   ,fSpRange(s.fSpRange)
     159           0 :   ,fSpBinWidth(s.fSpBinWidth)
     160           0 :   ,fSpLower(s.fSpLower)
     161           0 :   ,fSpUpper(s.fSpUpper)
     162           0 :   ,fSigma(0)
     163           0 :   ,fSpectrum(0)
     164           0 : {
     165             :   //
     166             :   // AliTRDsimTR copy constructor
     167             :   //
     168             : 
     169           0 :   fNFoils   = new Int_t[fNFoilsDim];
     170           0 :   for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
     171           0 :     fNFoils[iFoil]   = ((AliTRDsimTR &) s).fNFoils[iFoil];
     172             :   }  
     173             : 
     174           0 :   fNFoilsUp = new Double_t[fNFoilsDim];
     175           0 :   for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
     176           0 :     fNFoilsUp[iFoil] = ((AliTRDsimTR &) s).fNFoilsUp[iFoil];
     177             :   }  
     178             : 
     179           0 :   fSigma    = new Double_t[fSpNBins];
     180           0 :   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
     181           0 :     fSigma[iBin]     = ((AliTRDsimTR &) s).fSigma[iBin];
     182             :   }  
     183             : 
     184           0 : }
     185             : 
     186             : //_____________________________________________________________________________
     187             : AliTRDsimTR::~AliTRDsimTR() 
     188          78 : {
     189             :   //
     190             :   // AliTRDsimTR destructor
     191             :   //
     192             : 
     193          13 :   if (fSigma) {
     194          26 :     delete [] fSigma;
     195          13 :     fSigma    = 0;
     196          13 :   }
     197             : 
     198          13 :   if (fNFoils) {
     199          26 :     delete [] fNFoils;
     200          13 :     fNFoils   = 0;
     201          13 :   }
     202             : 
     203          13 :   if (fNFoilsUp) {
     204          26 :     delete [] fNFoilsUp;
     205          13 :     fNFoilsUp = 0;
     206          13 :   }
     207             : 
     208          13 :   if (fSpectrum) {
     209          26 :     delete fSpectrum;
     210          13 :     fSpectrum = 0;
     211          13 :   }
     212             : 
     213          39 : }
     214             : 
     215             : //_____________________________________________________________________________
     216             : AliTRDsimTR &AliTRDsimTR::operator=(const AliTRDsimTR &s)
     217             : {
     218             :   //
     219             :   // Assignment operator
     220             :   //
     221             : 
     222           0 :   if (this != &s) ((AliTRDsimTR &) s).Copy(*this);
     223           0 :   this->Init();
     224             : 
     225           0 :   return *this;
     226             : 
     227             : }
     228             : 
     229             : //_____________________________________________________________________________
     230             : void AliTRDsimTR::Copy(TObject &s) const
     231             : {
     232             :   //
     233             :   // Copy function
     234             :   //
     235             : 
     236           0 :   ((AliTRDsimTR &) s).fFoilThick  = fFoilThick;
     237           0 :   ((AliTRDsimTR &) s).fFoilDens   = fFoilDens;
     238           0 :   ((AliTRDsimTR &) s).fFoilOmega  = fFoilOmega;
     239           0 :   ((AliTRDsimTR &) s).fFoilZ      = fFoilZ;
     240           0 :   ((AliTRDsimTR &) s).fFoilA      = fFoilA;
     241           0 :   ((AliTRDsimTR &) s).fGapThick   = fGapThick;
     242           0 :   ((AliTRDsimTR &) s).fGapDens    = fGapDens;
     243           0 :   ((AliTRDsimTR &) s).fGapOmega   = fGapOmega;
     244           0 :   ((AliTRDsimTR &) s).fGapZ       = fGapZ;
     245           0 :   ((AliTRDsimTR &) s).fGapA       = fGapA;
     246           0 :   ((AliTRDsimTR &) s).fTemp       = fTemp;
     247           0 :   ((AliTRDsimTR &) s).fSpNBins    = fSpNBins;
     248           0 :   ((AliTRDsimTR &) s).fSpRange    = fSpRange;
     249           0 :   ((AliTRDsimTR &) s).fSpBinWidth = fSpBinWidth;
     250           0 :   ((AliTRDsimTR &) s).fSpLower    = fSpLower;
     251           0 :   ((AliTRDsimTR &) s).fSpUpper    = fSpUpper;
     252             : 
     253           0 :   if (((AliTRDsimTR &) s).fNFoils) {
     254           0 :     delete [] ((AliTRDsimTR &) s).fNFoils;
     255             :   }
     256           0 :   ((AliTRDsimTR &) s).fNFoils   = new Int_t[fNFoilsDim];
     257           0 :   for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
     258           0 :     ((AliTRDsimTR &) s).fNFoils[iFoil]   = fNFoils[iFoil];
     259             :   }  
     260             : 
     261           0 :   if (((AliTRDsimTR &) s).fNFoilsUp) {
     262           0 :     delete [] ((AliTRDsimTR &) s).fNFoilsUp;
     263             :   }
     264           0 :   ((AliTRDsimTR &) s).fNFoilsUp = new Double_t[fNFoilsDim];
     265           0 :   for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
     266           0 :     ((AliTRDsimTR &) s).fNFoilsUp[iFoil] = fNFoilsUp[iFoil];
     267             :   }  
     268             : 
     269           0 :   if (((AliTRDsimTR &) s).fSigma) {
     270           0 :     delete [] ((AliTRDsimTR &) s).fSigma;
     271             :   }
     272           0 :   ((AliTRDsimTR &) s).fSigma    = new Double_t[fSpNBins];
     273           0 :   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
     274           0 :     ((AliTRDsimTR &) s).fSigma[iBin]     = fSigma[iBin];
     275             :   }  
     276             : 
     277           0 : }
     278             : 
     279             : //_____________________________________________________________________________
     280             : void AliTRDsimTR::Init()
     281             : {
     282             :   //
     283             :   // Initialization 
     284             :   // The default radiator are prolypropilene foils of 10 mu thickness
     285             :   // with gaps of 80 mu filled with N2.
     286             :   // 
     287             : 
     288          26 :   fNFoilsDim   = 7;
     289             : 
     290          13 :   if (fNFoils) {
     291           0 :     delete [] fNFoils;
     292             :   }
     293          13 :   fNFoils      = new Int_t[fNFoilsDim];
     294          13 :   fNFoils[0]   = 170;
     295          13 :   fNFoils[1]   = 225;
     296          13 :   fNFoils[2]   = 275;
     297          13 :   fNFoils[3]   = 305;
     298          13 :   fNFoils[4]   = 325;
     299          13 :   fNFoils[5]   = 340;
     300          13 :   fNFoils[6]   = 350;
     301             : 
     302          13 :   if (fNFoilsUp) {
     303           0 :     delete [] fNFoilsUp;
     304             :   }
     305          13 :   fNFoilsUp    = new Double_t[fNFoilsDim];
     306          13 :   fNFoilsUp[0] = 1.25;
     307          13 :   fNFoilsUp[1] = 1.75;
     308          13 :   fNFoilsUp[2] = 2.50;
     309          13 :   fNFoilsUp[3] = 3.50;
     310          13 :   fNFoilsUp[4] = 4.50;
     311          13 :   fNFoilsUp[5] = 5.50;
     312          13 :   fNFoilsUp[6] = 10000.0;
     313             : 
     314          13 :   fFoilThick  = 0.0013;
     315          13 :   fFoilDens   = 0.92;   
     316          13 :   fFoilZ      = 5.28571;
     317          13 :   fFoilA      = 10.4286;
     318          13 :   fFoilOmega  = Omega(fFoilDens,fFoilZ,fFoilA);
     319             : 
     320          13 :   fGapThick   = 0.0060;
     321          13 :   fGapDens    = 0.00125;  
     322          13 :   fGapZ       = 7.0;
     323          13 :   fGapA       = 14.00674;
     324          13 :   fGapOmega   = Omega(fGapDens ,fGapZ ,fGapA );
     325             : 
     326          13 :   fTemp       = 293.16;
     327             : 
     328          13 :   fSpNBins    = 200;
     329          13 :   fSpRange    = 100;
     330          13 :   fSpBinWidth = fSpRange / fSpNBins;
     331          13 :   fSpLower    = 1.0 - 0.5 * fSpBinWidth;
     332          13 :   fSpUpper    = fSpLower + fSpRange;
     333             : 
     334          13 :   if (fSpectrum) delete fSpectrum;
     335          26 :   fSpectrum   = new TH1D("TRspectrum","TR spectrum",fSpNBins,fSpLower,fSpUpper);
     336          13 :   fSpectrum->SetDirectory(0);
     337             : 
     338             :   // Set the sigma values 
     339          13 :   SetSigma();
     340             : 
     341          13 : }
     342             : 
     343             : //_____________________________________________________________________________
     344             : Int_t AliTRDsimTR::CreatePhotons(Int_t pdg, Float_t p
     345             :                              , Int_t &nPhoton, Float_t *ePhoton)
     346             : {
     347             :   //
     348             :   // Create TRD photons for a charged particle of type <pdg> with the total 
     349             :   // momentum <p>. 
     350             :   // Number of produced TR photons:       <nPhoton>
     351             :   // Energies of the produced TR photons: <ePhoton>
     352             :   //
     353             : 
     354             :   // PDG codes
     355             :   const Int_t kPdgEle  =  11;
     356             :   const Int_t kPdgMuon =  13;
     357             :   const Int_t kPdgPion = 211;
     358             :   const Int_t kPdgKaon = 321;
     359             : 
     360             :   Float_t  mass        = 0;
     361         792 :   switch (TMath::Abs(pdg)) {
     362             :   case kPdgEle:
     363             :     mass      =  5.11e-4;
     364         396 :     break;
     365             :   case kPdgMuon:
     366             :     mass      =  0.10566;
     367           0 :     break;
     368             :   case kPdgPion:
     369             :     mass      =  0.13957;
     370           0 :     break;
     371             :   case kPdgKaon:
     372             :     mass      =  0.4937;
     373           0 :     break;
     374             :   default:
     375           0 :     return 0;
     376             :     break;
     377             :   };
     378             : 
     379             :   // Calculate the TR photons
     380         396 :   return TrPhotons(p, mass, nPhoton, ePhoton);
     381             : 
     382         396 : }
     383             : 
     384             : //_____________________________________________________________________________
     385             : Int_t AliTRDsimTR::TrPhotons(Float_t p, Float_t mass
     386             :                          , Int_t &nPhoton, Float_t *ePhoton)
     387             : {
     388             :   //
     389             :   // Produces TR photons using a parametric model for regular radiator. Photons
     390             :   // with energy larger than 15 keV are included in the MC stack and tracked by VMC
     391             :   // machinary.
     392             :   //
     393             :   // Input parameters:
     394             :   // p    - parent momentum [GeV/c]
     395             :   // mass - parent mass
     396             :   //
     397             :   // Output :
     398             :   // nPhoton - number of photons which have to be processed by custom code
     399             :   // ePhoton - energy of this photons in keV.
     400             :   //   
     401             : 
     402             :   const Double_t kAlpha  = 0.0072973;
     403             :   const Int_t    kSumMax = 30;
     404             :         
     405         792 :   Double_t tau   = fGapThick / fFoilThick;
     406             : 
     407             :   // Calculate gamma
     408         396 :   Double_t gamma = TMath::Sqrt(p*p + mass*mass) / mass;
     409             : 
     410             :   // Select the number of foils corresponding to momentum
     411         396 :   Int_t    foils = SelectNFoils(p);
     412             : 
     413         396 :   fSpectrum->Reset();
     414             : 
     415             :   // The TR spectrum
     416             :   Double_t csi1;
     417             :   Double_t csi2;
     418             :   Double_t rho1;
     419             :   Double_t rho2;
     420             :   Double_t sigma;
     421             :   Double_t sum;
     422             :   Double_t nEqu;
     423             :   Double_t thetaN;
     424             :   Double_t aux;
     425             :   Double_t energyeV;
     426             :   Double_t energykeV;
     427      159192 :   for (Int_t iBin = 1; iBin <= fSpNBins; iBin++) {
     428             : 
     429       79200 :     energykeV = fSpectrum->GetBinCenter(iBin);
     430       79200 :     energyeV  = energykeV * 1.0e3;
     431             : 
     432       79200 :     sigma     = Sigma(energykeV);
     433             : 
     434       79200 :     csi1      = fFoilOmega / energyeV;
     435       79200 :     csi2      = fGapOmega  / energyeV;
     436             : 
     437       79200 :     rho1      = 2.5 * energyeV * fFoilThick * 1.0e4 
     438       79200 :                                * (1.0 / (gamma*gamma) + csi1*csi1);
     439             :     rho2      = 2.5 * energyeV * fFoilThick * 1.0e4 
     440       79200 :                                * (1.0 / (gamma*gamma) + csi2 *csi2);
     441             : 
     442             :     // Calculate the sum
     443             :     sum = 0.0;
     444     4910400 :     for (Int_t n = 1; n <= kSumMax; n++) {
     445     2376000 :       thetaN = (TMath::Pi() * 2.0 * n - (rho1 + tau * rho2)) / (1.0 + tau);
     446     2376000 :       if (thetaN < 0.0) {
     447             :         thetaN = 0.0;
     448     2130291 :       }
     449     2376000 :       aux   = 1.0 / (rho1 + thetaN) - 1.0 / (rho2 + thetaN);
     450     2376000 :       sum  += thetaN * (aux*aux) * (1.0 - TMath::Cos(rho1 + thetaN));
     451             :     }
     452             : 
     453             :     // Equivalent number of foils
     454       79200 :     nEqu = (1.0 - TMath::Exp(-foils * sigma)) / (1.0 - TMath::Exp(-sigma));
     455             : 
     456             :     // dN / domega
     457       79200 :     fSpectrum->SetBinContent(iBin,4.0 * kAlpha * nEqu * sum /  (energykeV * (1.0 + tau)));
     458             : 
     459             :   }
     460             : 
     461             :   // <nTR> (binsize corr.)
     462         396 :   Float_t nTr     = fSpBinWidth * fSpectrum->Integral();
     463             :   // Number of TR photons from Poisson distribution with mean <nTr>
     464         396 :   Int_t   nPhCand = gRandom->Poisson(nTr);
     465             :   
     466             :   // Link the MC stack and get info about parent electron
     467         396 :   TVirtualMCStack *stack = TVirtualMC::GetMC()->GetStack();
     468         396 :   Int_t    track = stack->GetCurrentTrackNumber();
     469         396 :   Double_t px, py, pz, ptot;
     470         396 :   TVirtualMC::GetMC()->TrackMomentum(px,py,pz,ptot);
     471         396 :   ptot = TMath::Sqrt(px*px+py*py+pz*pz);
     472         396 :   px /= ptot;
     473         396 :   py /= ptot;
     474         396 :   pz /= ptot;
     475             : 
     476             :   // Current position of electron
     477         396 :   Double_t x;
     478         396 :   Double_t y;
     479         396 :   Double_t z; 
     480         396 :   TVirtualMC::GetMC()->TrackPosition(x,y,z);
     481         396 :   Double_t t = TVirtualMC::GetMC()->TrackTime();  
     482             : 
     483             :   // Counter for TR analysed in custom code (e < 15keV)
     484         396 :   nPhoton = 0;  
     485             : 
     486         846 :   for (Int_t iPhoton = 0; iPhoton < nPhCand; iPhoton++) {
     487             : 
     488             :     // Energy of the TR photon
     489          27 :     Double_t e = fSpectrum->GetRandom();
     490             : 
     491             :     // Put TR photon on particle stack
     492          27 :     if (e > 15.0) { 
     493             : 
     494           7 :       e *= 1.0e-6; // Convert it to GeV
     495             : 
     496           7 :       Int_t phtrack;
     497          14 :       stack->PushTrack(1                 // Must be 1
     498             :                       ,track             // Identifier of the parent track, -1 for a primary
     499             :                       ,22                // Particle code.
     500           7 :                       ,px*e              // 4 momentum (The photon is generated on the same  
     501           7 :                       ,py*e              // direction as the parent. For irregular radiator one
     502           7 :                       ,pz*e              // can calculate also the angle but this is a secondary
     503             :                       ,e                 // order effect)
     504           7 :                       ,x,y,z,t           // 4 vertex    
     505             :                       ,0.0,0.0,0.0       // Polarisation
     506             :                       ,kPFeedBackPhoton  // Production mechanism (there is no TR in G3 so one
     507             :                                          // has to make some convention)
     508             :                       ,phtrack           // On output the number of the track stored
     509             :                       ,1.0
     510             :                       ,1);
     511             : 
     512           7 :     }
     513             :     // Custom treatment of TR photons
     514             :     else {
     515             :   
     516          20 :       ePhoton[nPhoton++] = e;
     517             : 
     518             :     }
     519             : 
     520             :   }
     521             : 
     522         396 :   return 1;
     523             : 
     524         396 : }
     525             : 
     526             : //_____________________________________________________________________________
     527             : void AliTRDsimTR::SetSigma() 
     528             : {
     529             :   //
     530             :   // Sets the absorbtion crosssection for the energies of the TR spectrum
     531             :   //
     532             : 
     533          26 :   if (fSigma) {
     534           0 :     delete [] fSigma;
     535             :   }
     536          13 :   fSigma = new Double_t[fSpNBins];
     537             : 
     538        5226 :   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
     539        2600 :     Double_t energykeV = iBin * fSpBinWidth + 1.0;
     540        2600 :     fSigma[iBin]       = Sigma(energykeV);
     541             :   }
     542             : 
     543          13 : }
     544             : 
     545             : //_____________________________________________________________________________
     546             : Double_t AliTRDsimTR::Sigma(Double_t energykeV)
     547             : {
     548             :   //
     549             :   // Calculates the absorbtion crosssection for a one-foil-one-gap-radiator
     550             :   //
     551             : 
     552             :   // keV -> MeV
     553      163600 :   Double_t energyMeV = energykeV * 0.001;
     554       81800 :   if (energyMeV >= 0.001) {
     555      163600 :     return(GetMuPo(energyMeV) * fFoilDens * fFoilThick +
     556       81800 :            GetMuAi(energyMeV) * fGapDens  * fGapThick  * GetTemp());
     557             :   }
     558             :   else {
     559           0 :     return 1.0e6;
     560             :   }
     561             : 
     562       81800 : }
     563             : 
     564             : //_____________________________________________________________________________
     565             : Double_t AliTRDsimTR::GetMuPo(Double_t energyMeV)
     566             : {
     567             :   //
     568             :   // Returns the photon absorbtion cross section for polypropylene
     569             :   //
     570             : 
     571             :   const Int_t kN = 36;
     572             : 
     573      163600 :   Double_t mu[kN] = { 1.894E+03, 5.999E+02, 2.593E+02
     574             :                     , 7.743E+01, 3.242E+01, 1.643E+01
     575             :                     , 9.432E+00, 3.975E+00, 2.088E+00
     576             :                     , 7.452E-01, 4.315E-01, 2.706E-01
     577             :                     , 2.275E-01, 2.084E-01, 1.970E-01
     578             :                     , 1.823E-01, 1.719E-01, 1.534E-01
     579             :                     , 1.402E-01, 1.217E-01, 1.089E-01
     580             :                     , 9.947E-02, 9.198E-02, 8.078E-02
     581             :                     , 7.262E-02, 6.495E-02, 5.910E-02   
     582             :                     , 5.064E-02, 4.045E-02, 3.444E-02
     583             :                     , 3.045E-02, 2.760E-02, 2.383E-02
     584             :                     , 2.145E-02, 1.819E-02, 1.658E-02 };
     585             : 
     586       81800 :   Double_t en[kN] = { 1.000E-03, 1.500E-03, 2.000E-03
     587             :                     , 3.000E-03, 4.000E-03, 5.000E-03
     588             :                     , 6.000E-03, 8.000E-03, 1.000E-02
     589             :                     , 1.500E-02, 2.000E-02, 3.000E-02
     590             :                     , 4.000E-02, 5.000E-02, 6.000E-02
     591             :                     , 8.000E-02, 1.000E-01, 1.500E-01
     592             :                     , 2.000E-01, 3.000E-01, 4.000E-01
     593             :                     , 5.000E-01, 6.000E-01, 8.000E-01
     594             :                     , 1.000E+00, 1.250E+00, 1.500E+00
     595             :                     , 2.000E+00, 3.000E+00, 4.000E+00
     596             :                     , 5.000E+00, 6.000E+00, 8.000E+00
     597             :                     , 1.000E+01, 1.500E+01, 2.000E+01 };
     598             : 
     599      163600 :   return Interpolate(energyMeV,en,mu,kN);
     600             : 
     601       81800 : }
     602             : 
     603             : //_____________________________________________________________________________
     604             : Double_t AliTRDsimTR::GetMuCO(Double_t energyMeV)
     605             : {
     606             :   //
     607             :   // Returns the photon absorbtion cross section for CO2
     608             :   //
     609             : 
     610             :   const Int_t kN = 36;
     611             : 
     612          38 :   Double_t mu[kN] = { 0.39383E+04, 0.13166E+04, 0.58750E+03
     613             :                     , 0.18240E+03, 0.77996E+02, 0.40024E+02
     614             :                     , 0.23116E+02, 0.96997E+01, 0.49726E+01
     615             :                     , 0.15543E+01, 0.74915E+00, 0.34442E+00
     616             :                     , 0.24440E+00, 0.20589E+00, 0.18632E+00
     617             :                     , 0.16578E+00, 0.15394E+00, 0.13558E+00
     618             :                     , 0.12336E+00, 0.10678E+00, 0.95510E-01
     619             :                     , 0.87165E-01, 0.80587E-01, 0.70769E-01
     620             :                     , 0.63626E-01, 0.56894E-01, 0.51782E-01
     621             :                     , 0.44499E-01, 0.35839E-01, 0.30825E-01
     622             :                     , 0.27555E-01, 0.25269E-01, 0.22311E-01
     623             :                     , 0.20516E-01, 0.18184E-01, 0.17152E-01 };
     624             : 
     625          19 :   Double_t en[kN] = { 0.10000E-02, 0.15000E-02, 0.20000E-02
     626             :                     , 0.30000E-02, 0.40000E-02, 0.50000E-02
     627             :                     , 0.60000E-02, 0.80000E-02, 0.10000E-01
     628             :                     , 0.15000E-01, 0.20000E-01, 0.30000E-01
     629             :                     , 0.40000E-01, 0.50000E-01, 0.60000E-01
     630             :                     , 0.80000E-01, 0.10000E+00, 0.15000E+00
     631             :                     , 0.20000E+00, 0.30000E+00, 0.40000E+00
     632             :                     , 0.50000E+00, 0.60000E+00, 0.80000E+00
     633             :                     , 0.10000E+01, 0.12500E+01, 0.15000E+01
     634             :                     , 0.20000E+01, 0.30000E+01, 0.40000E+01
     635             :                     , 0.50000E+01, 0.60000E+01, 0.80000E+01
     636             :                     , 0.10000E+02, 0.15000E+02, 0.20000E+02 };
     637             : 
     638          38 :   return Interpolate(energyMeV,en,mu,kN);
     639             : 
     640          19 : }
     641             : 
     642             : //_____________________________________________________________________________
     643             : Double_t AliTRDsimTR::GetMuXe(Double_t energyMeV)
     644             : {
     645             :   //
     646             :   // Returns the photon absorbtion cross section for xenon
     647             :   //
     648             : 
     649             :   const Int_t kN = 48;
     650             : 
     651          38 :   Double_t mu[kN] = { 9.413E+03, 8.151E+03, 7.035E+03
     652             :                     , 7.338E+03, 4.085E+03, 2.088E+03
     653             :                     , 7.780E+02, 3.787E+02, 2.408E+02
     654             :                     , 6.941E+02, 6.392E+02, 6.044E+02
     655             :                     , 8.181E+02, 7.579E+02, 6.991E+02
     656             :                     , 8.064E+02, 6.376E+02, 3.032E+02
     657             :                     , 1.690E+02, 5.743E+01, 2.652E+01
     658             :                     , 8.930E+00, 6.129E+00, 3.316E+01
     659             :                     , 2.270E+01, 1.272E+01, 7.825E+00
     660             :                     , 3.633E+00, 2.011E+00, 7.202E-01
     661             :                     , 3.760E-01, 1.797E-01, 1.223E-01
     662             :                     , 9.699E-02, 8.281E-02, 6.696E-02
     663             :                     , 5.785E-02, 5.054E-02, 4.594E-02
     664             :                     , 4.078E-02, 3.681E-02, 3.577E-02
     665             :                     , 3.583E-02, 3.634E-02, 3.797E-02
     666             :                     , 3.987E-02, 4.445E-02, 4.815E-02 };
     667             : 
     668          19 :   Double_t en[kN] = { 1.00000E-03, 1.07191E-03, 1.14900E-03
     669             :                     , 1.14900E-03, 1.50000E-03, 2.00000E-03
     670             :                     , 3.00000E-03, 4.00000E-03, 4.78220E-03
     671             :                     , 4.78220E-03, 5.00000E-03, 5.10370E-03
     672             :                     , 5.10370E-03, 5.27536E-03, 5.45280E-03
     673             :                     , 5.45280E-03, 6.00000E-03, 8.00000E-03
     674             :                     , 1.00000E-02, 1.50000E-02, 2.00000E-02
     675             :                     , 3.00000E-02, 3.45614E-02, 3.45614E-02
     676             :                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
     677             :                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
     678             :                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
     679             :                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
     680             :                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
     681             :                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
     682             :                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
     683             :                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
     684             : 
     685          38 :  return Interpolate(energyMeV,en,mu,kN);
     686             : 
     687          19 : }
     688             : 
     689             : //_____________________________________________________________________________
     690             : Double_t AliTRDsimTR::GetMuAr(Double_t energyMeV)
     691             : {
     692             :   //
     693             :   // Returns the photon absorbtion cross section for argon
     694             :   //
     695             : 
     696             :   const Int_t kN = 38;
     697             : 
     698           0 :   Double_t mu[kN] = { 3.184E+03, 1.105E+03, 5.120E+02
     699             :                     , 1.703E+02, 1.424E+02, 1.275E+03
     700             :                     , 7.572E+02, 4.225E+02, 2.593E+02
     701             :                     , 1.180E+02, 6.316E+01, 1.983E+01
     702             :                     , 8.629E+00, 2.697E+00, 1.228E+00
     703             :                     , 7.012E-01, 4.664E-01, 2.760E-01
     704             :                     , 2.043E-01, 1.427E-01, 1.205E-01
     705             :                     , 9.953E-02, 8.776E-02, 7.958E-02
     706             :                     , 7.335E-02, 6.419E-02, 5.762E-02
     707             :                     , 5.150E-02, 4.695E-02, 4.074E-02
     708             :                     , 3.384E-02, 3.019E-02, 2.802E-02
     709             :                     , 2.667E-02, 2.517E-02, 2.451E-02
     710             :                     , 2.418E-02, 2.453E-02 };
     711             : 
     712           0 :   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03  
     713             :                     , 3.00000E-03, 3.20290E-03, 3.20290E-03  
     714             :                     , 4.00000E-03, 5.00000E-03, 6.00000E-03  
     715             :                     , 8.00000E-03, 1.00000E-02, 1.50000E-02  
     716             :                     , 2.00000E-02, 3.00000E-02, 4.00000E-02  
     717             :                     , 5.00000E-02, 6.00000E-02, 8.00000E-02  
     718             :                     , 1.00000E-01, 1.50000E-01, 2.00000E-01  
     719             :                     , 3.00000E-01, 4.00000E-01, 5.00000E-01  
     720             :                     , 6.00000E-01, 8.00000E-01, 1.00000E+00  
     721             :                     , 1.25000E+00, 1.50000E+00, 2.00000E+00  
     722             :                     , 3.00000E+00, 4.00000E+00, 5.00000E+00  
     723             :                     , 6.00000E+00, 8.00000E+00, 1.00000E+01  
     724             :                     , 1.50000E+01, 2.00000E+01 };
     725             : 
     726           0 :   return Interpolate(energyMeV,en,mu,kN);
     727             : 
     728           0 : }
     729             : 
     730             : //_____________________________________________________________________________
     731             : Double_t AliTRDsimTR::GetMuMy(Double_t energyMeV)
     732             : {
     733             :   //
     734             :   // Returns the photon absorbtion cross section for mylar
     735             :   //
     736             : 
     737             :   const Int_t kN = 36;
     738             : 
     739          40 :   Double_t mu[kN] = { 2.911E+03, 9.536E+02, 4.206E+02
     740             :                     , 1.288E+02, 5.466E+01, 2.792E+01
     741             :                     , 1.608E+01, 6.750E+00, 3.481E+00
     742             :                     , 1.132E+00, 5.798E-01, 3.009E-01
     743             :                     , 2.304E-01, 2.020E-01, 1.868E-01
     744             :                     , 1.695E-01, 1.586E-01, 1.406E-01
     745             :                     , 1.282E-01, 1.111E-01, 9.947E-02
     746             :                     , 9.079E-02, 8.395E-02, 7.372E-02
     747             :                     , 6.628E-02, 5.927E-02, 5.395E-02
     748             :                     , 4.630E-02, 3.715E-02, 3.181E-02
     749             :                     , 2.829E-02, 2.582E-02, 2.257E-02
     750             :                     , 2.057E-02, 1.789E-02, 1.664E-02 };
     751             : 
     752          20 :   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
     753             :                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
     754             :                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
     755             :                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
     756             :                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
     757             :                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
     758             :                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
     759             :                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
     760             :                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
     761             :                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
     762             :                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
     763             :                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
     764             : 
     765          40 :   return Interpolate(energyMeV,en,mu,kN);
     766             : 
     767          20 : }
     768             : 
     769             : //_____________________________________________________________________________
     770             : Double_t AliTRDsimTR::GetMuN2(Double_t energyMeV)
     771             : {
     772             :   //
     773             :   // Returns the photon absorbtion cross section for nitrogen
     774             :   //
     775             : 
     776             :   const Int_t kN = 36;
     777             : 
     778           0 :   Double_t mu[kN] = { 3.311E+03, 1.083E+03, 4.769E+02
     779             :                     , 1.456E+02, 6.166E+01, 3.144E+01
     780             :                     , 1.809E+01, 7.562E+00, 3.879E+00
     781             :                     , 1.236E+00, 6.178E-01, 3.066E-01
     782             :                     , 2.288E-01, 1.980E-01, 1.817E-01
     783             :                     , 1.639E-01, 1.529E-01, 1.353E-01
     784             :                     , 1.233E-01, 1.068E-01, 9.557E-02
     785             :                     , 8.719E-02, 8.063E-02, 7.081E-02
     786             :                     , 6.364E-02, 5.693E-02, 5.180E-02
     787             :                     , 4.450E-02, 3.579E-02, 3.073E-02
     788             :                     , 2.742E-02, 2.511E-02, 2.209E-02
     789             :                     , 2.024E-02, 1.782E-02, 1.673E-02 };
     790             : 
     791           0 :   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
     792             :                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
     793             :                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
     794             :                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
     795             :                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
     796             :                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
     797             :                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
     798             :                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
     799             :                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
     800             :                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
     801             :                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
     802             :                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
     803             : 
     804           0 :   return Interpolate(energyMeV,en,mu,kN);
     805             : 
     806           0 : }
     807             : 
     808             : //_____________________________________________________________________________
     809             : Double_t AliTRDsimTR::GetMuO2(Double_t energyMeV)
     810             : {
     811             :   //
     812             :   // Returns the photon absorbtion cross section for oxygen
     813             :   //
     814             : 
     815             :   const Int_t kN = 36;
     816             : 
     817           0 :   Double_t mu[kN] = { 4.590E+03, 1.549E+03, 6.949E+02
     818             :                     , 2.171E+02, 9.315E+01, 4.790E+01
     819             :                     , 2.770E+01, 1.163E+01, 5.952E+00
     820             :                     , 1.836E+00, 8.651E-01, 3.779E-01
     821             :                     , 2.585E-01, 2.132E-01, 1.907E-01
     822             :                     , 1.678E-01, 1.551E-01, 1.361E-01
     823             :                     , 1.237E-01, 1.070E-01, 9.566E-02
     824             :                     , 8.729E-02, 8.070E-02, 7.087E-02
     825             :                     , 6.372E-02, 5.697E-02, 5.185E-02
     826             :                     , 4.459E-02, 3.597E-02, 3.100E-02
     827             :                     , 2.777E-02, 2.552E-02, 2.263E-02
     828             :                     , 2.089E-02, 1.866E-02, 1.770E-02 };
     829             : 
     830           0 :   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
     831             :                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
     832             :                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
     833             :                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
     834             :                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
     835             :                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
     836             :                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
     837             :                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
     838             :                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
     839             :                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
     840             :                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
     841             :                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
     842             : 
     843           0 :   return Interpolate(energyMeV,en,mu,kN);
     844             : 
     845           0 : }
     846             : 
     847             : //_____________________________________________________________________________
     848             : Double_t AliTRDsimTR::GetMuHe(Double_t energyMeV)
     849             : {
     850             :   //
     851             :   // Returns the photon absorbtion cross section for helium
     852             :   //
     853             : 
     854             :   const Int_t kN = 36;
     855             : 
     856           0 :   Double_t mu[kN] = { 6.084E+01, 1.676E+01, 6.863E+00
     857             :                     , 2.007E+00, 9.329E-01, 5.766E-01
     858             :                     , 4.195E-01, 2.933E-01, 2.476E-01
     859             :                     , 2.092E-01, 1.960E-01, 1.838E-01
     860             :                     , 1.763E-01, 1.703E-01, 1.651E-01
     861             :                     , 1.562E-01, 1.486E-01, 1.336E-01
     862             :                     , 1.224E-01, 1.064E-01, 9.535E-02
     863             :                     , 8.707E-02, 8.054E-02, 7.076E-02
     864             :                     , 6.362E-02, 5.688E-02, 5.173E-02
     865             :                     , 4.422E-02, 3.503E-02, 2.949E-02
     866             :                     , 2.577E-02, 2.307E-02, 1.940E-02
     867             :                     , 1.703E-02, 1.363E-02, 1.183E-02 };
     868             : 
     869           0 :   Double_t en[kN] = { 1.00000E-03, 1.50000E-03, 2.00000E-03
     870             :                     , 3.00000E-03, 4.00000E-03, 5.00000E-03
     871             :                     , 6.00000E-03, 8.00000E-03, 1.00000E-02
     872             :                     , 1.50000E-02, 2.00000E-02, 3.00000E-02
     873             :                     , 4.00000E-02, 5.00000E-02, 6.00000E-02
     874             :                     , 8.00000E-02, 1.00000E-01, 1.50000E-01
     875             :                     , 2.00000E-01, 3.00000E-01, 4.00000E-01
     876             :                     , 5.00000E-01, 6.00000E-01, 8.00000E-01
     877             :                     , 1.00000E+00, 1.25000E+00, 1.50000E+00
     878             :                     , 2.00000E+00, 3.00000E+00, 4.00000E+00
     879             :                     , 5.00000E+00, 6.00000E+00, 8.00000E+00
     880             :                     , 1.00000E+01, 1.50000E+01, 2.00000E+01 };
     881             : 
     882           0 :   return Interpolate(energyMeV,en,mu,kN);
     883             : 
     884           0 : }
     885             : 
     886             : //_____________________________________________________________________________
     887             : Double_t AliTRDsimTR::GetMuAi(Double_t energyMeV)
     888             : {
     889             :   //
     890             :   // Returns the photon absorbtion cross section for air
     891             :   // Implemented by Oliver Busch
     892             :   //
     893             : 
     894             :   const Int_t kN = 38;
     895             : 
     896      163600 :   Double_t mu[kN] = { 0.35854E+04, 0.11841E+04, 0.52458E+03,
     897             :                       0.16143E+03, 0.14250E+03, 0.15722E+03,
     898             :                       0.77538E+02, 0.40099E+02, 0.23313E+02,
     899             :                       0.98816E+01, 0.51000E+01, 0.16079E+01,
     900             :                       0.77536E+00, 0.35282E+00, 0.24790E+00,
     901             :                       0.20750E+00, 0.18703E+00, 0.16589E+00,
     902             :                       0.15375E+00, 0.13530E+00, 0.12311E+00,
     903             :                       0.10654E+00, 0.95297E-01, 0.86939E-01,
     904             :                       0.80390E-01, 0.70596E-01, 0.63452E-01,
     905             :                       0.56754E-01, 0.51644E-01, 0.44382E-01,
     906             :                       0.35733E-01, 0.30721E-01, 0.27450E-01,
     907             :                       0.25171E-01, 0.22205E-01, 0.20399E-01,
     908             :                       0.18053E-01, 0.18057E-01 };
     909             : 
     910             : 
     911             : 
     912       81800 :   Double_t en[kN] = { 0.10000E-02, 0.15000E-02, 0.20000E-02,
     913             :                       0.30000E-02, 0.32029E-02, 0.32029E-02,
     914             :                       0.40000E-02, 0.50000E-02, 0.60000E-02,
     915             :                       0.80000E-02, 0.10000E-01, 0.15000E-01,
     916             :                       0.20000E-01, 0.30000E-01, 0.40000E-01,
     917             :                       0.50000E-01, 0.60000E-01, 0.80000E-01,
     918             :                       0.10000E+00, 0.15000E+00, 0.20000E+00,
     919             :                       0.30000E+00, 0.40000E+00, 0.50000E+00,
     920             :                       0.60000E+00, 0.80000E+00, 0.10000E+01,
     921             :                       0.12500E+01, 0.15000E+01, 0.20000E+01,
     922             :                       0.30000E+01, 0.40000E+01, 0.50000E+01,
     923             :                       0.60000E+01, 0.80000E+01, 0.10000E+02,
     924             :                       0.15000E+02, 0.20000E+02 };
     925             : 
     926      163600 :   return Interpolate(energyMeV,en,mu,kN);
     927             : 
     928       81800 : }
     929             : 
     930             : //_____________________________________________________________________________
     931             : Double_t AliTRDsimTR::Interpolate(Double_t energyMeV
     932             :                                 , Double_t *en
     933             :                                 , const Double_t * const mu
     934             :                                 , Int_t n)
     935             : {
     936             :   //
     937             :   // Interpolates the photon absorbtion cross section 
     938             :   // for a given energy <energyMeV>.
     939             :   //
     940             : 
     941      327316 :   Double_t de    = 0;
     942      163658 :   Int_t    index = 0;
     943      163658 :   Int_t    istat = Locate(en,n,energyMeV,index,de);
     944      163658 :   if (istat == 0) {
     945      327316 :     return (mu[index] - de * (mu[index]   - mu[index+1]) 
     946      163658 :                            / (en[index+1] - en[index]  ));
     947             :   }
     948             :   else {
     949           0 :     return 0.0; 
     950             :   }
     951             : 
     952      163658 : }
     953             : 
     954             : //_____________________________________________________________________________
     955             : Int_t AliTRDsimTR::Locate(Double_t *xv, Int_t n, Double_t xval
     956             :                         , Int_t &kl, Double_t &dx) 
     957             : {
     958             :   //
     959             :   // Locates a point (xval) in a 1-dim grid (xv(n))
     960             :   //
     961             : 
     962      327316 :   if (xval >= xv[n-1]) {
     963           0 :     return  1;
     964             :   }
     965      163658 :   if (xval <  xv[0]) {
     966           0 :     return -1;
     967             :   }
     968             : 
     969             :   Int_t km;
     970             :   Int_t kh = n - 1;
     971             : 
     972      163658 :   kl = 0;
     973     1197974 :   while (kh - kl > 1) {
     974      870658 :     if (xval < xv[km = (kl+kh)/2]) {
     975             :       kh = km; 
     976      374825 :     }
     977             :     else {
     978      495833 :       kl = km;
     979             :     }
     980             :   }
     981      327316 :   if ((xval <  xv[kl])   || 
     982      163658 :       (xval >  xv[kl+1]) || 
     983      163658 :       (kl   >= n-1)) {
     984           0 :     AliFatal(Form("Locate failed xv[%d] %f xval %f xv[%d] %f!!!\n"
     985             :                  ,kl,xv[kl],xval,kl+1,xv[kl+1]));
     986           0 :     exit(1);
     987             :   }
     988             : 
     989      163658 :   dx = xval - xv[kl];
     990             : 
     991             :   return 0;
     992             : 
     993      163658 : }
     994             : 
     995             : //_____________________________________________________________________________
     996             : Int_t AliTRDsimTR::SelectNFoils(Float_t p) const
     997             : {
     998             :   //
     999             :   // Selects the number of foils corresponding to the momentum
    1000             :   //
    1001             : 
    1002         792 :   Int_t foils = fNFoils[fNFoilsDim-1];
    1003             : 
    1004         800 :   for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
    1005         400 :     if (p < fNFoilsUp[iFoil]) {
    1006         396 :       foils = fNFoils[iFoil];
    1007         396 :       break;
    1008             :     }
    1009             :   }
    1010             : 
    1011         396 :   return foils;
    1012             : 
    1013             : }

Generated by: LCOV version 1.11