]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDsim.cxx
Check PHOS and EMCAL clusters
[u/mrichter/AliRoot.git] / TRD / AliTRDsim.cxx
index 5e4e537d206469067008ade372b3518d36d6fe71..dfed138b5864c14c4c0a171802ecc53ed96e1be8 100644 (file)
@@ -1,3 +1,4 @@
+
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.8  2001/01/26 19:56:57  hristov
-Major upgrade of AliRoot code
-
-Revision 1.7  2000/12/20 13:00:45  cblume
-Modifications for the HP-compiler
-
-Revision 1.6  2000/12/12 10:20:10  cblume
-Initialize fSepctrum = 0 in ctors
-
-Revision 1.5  2000/10/15 23:40:01  cblume
-Remove AliTRDconst
-
-Revision 1.4  2000/10/06 16:49:46  cblume
-Made Getters const
-
-Revision 1.3.2.1  2000/09/18 13:45:30  cblume
-New class AliTRDsim that simulates TR photons
-
-Revision 1.2  1999/09/29 09:24:35  fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -47,6 +25,7 @@ Introduction of the Copyright and cvs Log
 //   17.07.1998 - A.Andronic                                                 //
 //   08.12.1998 - simplified version                                         //
 //   11.07.2000 - Adapted code to aliroot environment (C.Blume)              //
+//   04.06.2004 - Momentum dependent parameters implemented (CBL)            //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -72,6 +51,8 @@ AliTRDsim::AliTRDsim():TObject()
 
   fSpectrum = 0;
   fSigma    = 0;
+  fNFoils   = 0;
+  fNFoilsUp = 0;
 
   Init();
 
@@ -94,6 +75,8 @@ AliTRDsim::AliTRDsim(AliModule *mod, Int_t foil, Int_t gap)
 
   fSpectrum = 0;
   fSigma    = 0;
+  fNFoils   = 0;
+  fNFoilsUp = 0;
 
   Init();
 
@@ -113,7 +96,7 @@ AliTRDsim::AliTRDsim(AliModule *mod, Int_t foil, Int_t gap)
 }
 
 //_____________________________________________________________________________
-AliTRDsim::AliTRDsim(const AliTRDsim &s)
+AliTRDsim::AliTRDsim(const AliTRDsim &s):TObject(s)
 {
   //
   // AliTRDsim copy constructor
@@ -130,8 +113,10 @@ AliTRDsim::~AliTRDsim()
   // AliTRDsim destructor
   //
 
-  if (fSpectrum) delete fSpectrum;
-  if (fSigma)    delete fSigma;
+  //  if (fSpectrum) delete fSpectrum;
+  if (fSigma)    delete [] fSigma;
+  if (fNFoils)   delete [] fNFoils;
+  if (fNFoilsUp) delete [] fNFoilsUp;
 
 }
 
@@ -148,13 +133,12 @@ AliTRDsim &AliTRDsim::operator=(const AliTRDsim &s)
 }
 
 //_____________________________________________________________________________
-void AliTRDsim::Copy(TObject &s)
+void AliTRDsim::Copy(TObject &s) const
 {
   //
   // Copy function
   //
 
-  ((AliTRDsim &) s).fNFoils     = fNFoils;
   ((AliTRDsim &) s).fFoilThick  = fFoilThick;
   ((AliTRDsim &) s).fFoilDens   = fFoilDens;
   ((AliTRDsim &) s).fFoilOmega  = fFoilOmega;
@@ -172,7 +156,19 @@ void AliTRDsim::Copy(TObject &s)
   ((AliTRDsim &) s).fSpLower    = fSpLower;
   ((AliTRDsim &) s).fSpUpper    = fSpUpper;
 
-  if (((AliTRDsim &) s).fSigma) delete ((AliTRDsim &) s).fSigma;
+  if (((AliTRDsim &) s).fNFoils) delete [] ((AliTRDsim &) s).fNFoils;
+  ((AliTRDsim &) s).fNFoils   = new Int_t[fNFoilsDim];
+  for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
+    ((AliTRDsim &) s).fNFoils[iFoil] = fNFoils[iFoil];
+  }  
+
+  if (((AliTRDsim &) s).fNFoilsUp) delete [] ((AliTRDsim &) s).fNFoilsUp;
+  ((AliTRDsim &) s).fNFoilsUp = new Double_t[fNFoilsDim];
+  for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
+    ((AliTRDsim &) s).fNFoilsUp[iFoil] = fNFoilsUp[iFoil];
+  }  
+
+  if (((AliTRDsim &) s).fSigma)  delete [] ((AliTRDsim &) s).fSigma;
   ((AliTRDsim &) s).fSigma = new Double_t[fSpNBins];
   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
     ((AliTRDsim &) s).fSigma[iBin] = fSigma[iBin];
@@ -187,11 +183,31 @@ void AliTRDsim::Init()
 {
   //
   // Initialization 
-  // The default radiator are 100 prolypropilene foils of 13 mu thickness
-  // with gaps of 60 mu filled with CO2.
+  // The default radiator are prolypropilene foils of 10 mu thickness
+  // with gaps of 80 mu filled with N2.
   // 
 
-  fNFoils     = 100;
+  fNFoilsDim   = 7;
+
+  if (fNFoils)   delete [] fNFoils;
+  fNFoils      = new Int_t[fNFoilsDim];
+  fNFoils[0]   = 170;
+  fNFoils[1]   = 225; //250;
+  fNFoils[2]   = 275; //310;
+  fNFoils[3]   = 305; //380;
+  fNFoils[4]   = 325; //430;
+  fNFoils[5]   = 340; //490;
+  fNFoils[6]   = 350; //550;
+
+  if (fNFoilsUp) delete [] fNFoilsUp;
+  fNFoilsUp    = new Double_t[fNFoilsDim];
+  fNFoilsUp[0] = 1.25;
+  fNFoilsUp[1] = 1.75;
+  fNFoilsUp[2] = 2.50;
+  fNFoilsUp[3] = 3.50;
+  fNFoilsUp[4] = 4.50;
+  fNFoilsUp[5] = 5.50;
+  fNFoilsUp[6] = 10000.0;
 
   fFoilThick  = 0.0013;
   fFoilDens   = 0.92;   
@@ -200,9 +216,9 @@ void AliTRDsim::Init()
   fFoilOmega  = Omega(fFoilDens,fFoilZ,fFoilA);
 
   fGapThick   = 0.0060;
-  fGapDens    = 0.001977;  
-  fGapZ       = 7.45455;
-  fGapA       = 14.9091;
+  fGapDens    = 0.00125;  
+  fGapZ       = 7.0;
+  fGapA       = 14.00674;
   fGapOmega   = Omega(fGapDens ,fGapZ ,fGapA );
 
   fTemp       = 293.16;
@@ -215,6 +231,7 @@ void AliTRDsim::Init()
 
   if (fSpectrum) delete fSpectrum;
   fSpectrum   = new TH1D("TRspectrum","TR spectrum",fSpNBins,fSpLower,fSpUpper);
+  fSpectrum->SetDirectory(0);
 
   // Set the sigma values 
   SetSigma();
@@ -257,70 +274,69 @@ Int_t AliTRDsim::CreatePhotons(Int_t pdg, Float_t p
     break;
   };
 
-  // Calculate gamma
-  Double_t gamma = TMath::Sqrt(p*p + mass*mass) / mass;
-
   // Calculate the TR photons
-  return TrPhotons(gamma, nPhoton, ePhoton);
+  return TrPhotons(p, mass, nPhoton, ePhoton);
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDsim::TrPhotons(Double_t gamma, Int_t &nPhoton, Float_t *ePhoton)
+Int_t AliTRDsim::TrPhotons(Float_t p, Float_t mass
+                         , Int_t &nPhoton, Float_t *ePhoton)
 {
   //
   // Produces TR photons.
   //
 
   const Double_t kAlpha  = 0.0072973;
-  const Int_t    kSumMax = 10;
+  const Int_t    kSumMax = 30;
+       
+  Double_t tau = fGapThick / fFoilThick;
 
-  Double_t kappa = fGapThick / fFoilThick;
+  // Calculate gamma
+  Double_t gamma = TMath::Sqrt(p*p + mass*mass) / mass;
+
+  // Select the number of foils corresponding to momentum
+  Int_t    foils = SelectNFoils(p);
 
   fSpectrum->Reset();
 
   // The TR spectrum
-  Double_t stemp = 0;
-  for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
+       Double_t csi1,csi2,rho1,rho2;
+       Double_t fSigma,Sum,Nequ,theta_n,aux;
+  Double_t energyeV, energykeV;
+       for (Int_t iBin = 1; iBin <= fSpNBins; iBin++) {
+    energykeV = fSpectrum->GetBinCenter(iBin);
+    energyeV = energykeV * 1.e3;
 
-    // keV -> eV
-    Double_t energyeV = (fSpBinWidth * iBin + 1.0) * 1e3;
+    fSigma       = Sigma(energykeV);
 
-    Double_t csFoil   = fFoilOmega / energyeV;
-    Double_t csGap    = fGapOmega  / energyeV;
+    csi1 = fFoilOmega / energyeV;
+    csi2 = fGapOmega  / energyeV;
 
-    Double_t rho1     = energyeV * fFoilThick * 1e4 * 2.5 
-                                 * (1.0 / (gamma*gamma) + csFoil*csFoil);
-    Double_t rho2     = energyeV * fFoilThick * 1e4 * 2.5 
-                                 * (1.0 / (gamma*gamma) + csGap *csGap);
+    rho1 = 2.5 * energyeV * fFoilThick * 1.E4 
+                                 * (1. / (gamma*gamma) + csi1*csi1);
+    rho2 = 2.5 * energyeV * fFoilThick * 1.E4 
+                                 * (1.0 / (gamma*gamma) + csi2 *csi2);
 
     // Calculate the sum
-    Double_t sum = 0;
-    for (Int_t iSum = 0; iSum < kSumMax; iSum++) {
-      Double_t tetan = (TMath::Pi() * 2.0 * (iSum+1) - (rho1 + kappa * rho2)) 
-                     / (kappa + 1.0);
-      if (tetan < 0.0) tetan = 0.0;
-      Double_t aux   = 1.0 / (rho1 + tetan) - 1.0 / (rho2 + tetan);
-               sum  += tetan * (aux*aux) * (1.0 - TMath::Cos(rho1 + tetan));
+    Sum = 0;
+    for (Int_t n = 1; n <= kSumMax; n++) {
+      theta_n = (TMath::Pi() * 2.0 * n - (rho1 + tau * rho2)) / (1.+ tau);
+      if (theta_n < 0.) theta_n = 0.0;
+      aux   = 1. / (rho1 + theta_n) - 1. / (rho2 + theta_n);
+      Sum  += theta_n * (aux*aux) * (1.0 - TMath::Cos(rho1 + theta_n));
     }
 
-    // Absorbtion
-    Double_t conv      = 1.0 - TMath::Exp(-fNFoils * fSigma[iBin]);
+    // Equivalent number of foils
+    Nequ      = (1. - TMath::Exp(-foils * fSigma)) / (1.- TMath::Exp(-fSigma));
 
-    // eV -> keV
-    Float_t  energykeV = energyeV * 0.001;
 
     // dN / domega
-    Double_t wn        = kAlpha * 4.0 / (fSigma[iBin] * (kappa + 1.0)) 
-                                * conv * sum / energykeV;
-    fSpectrum->SetBinContent(iBin,wn);
-
-    stemp += wn;
-
+    fSpectrum->SetBinContent(iBin,4. * kAlpha * Nequ * Sum /  (energykeV * (1. + tau)));
   }
 
   // <nTR> (binsize corr.)
-  Float_t ntr = stemp * fSpBinWidth;
+  Float_t ntr = fSpBinWidth*fSpectrum->Integral();
   // Number of TR photons from Poisson distribution with mean <ntr>
   nPhoton = gRandom->Poisson(ntr);
   // Energy of the TR photons
@@ -339,7 +355,7 @@ void AliTRDsim::SetSigma()
   // Sets the absorbtion crosssection for the energies of the TR spectrum
   //
 
-  if (fSigma) delete fSigma;
+  if (fSigma) delete [] fSigma;
   fSigma = new Double_t[fSpNBins];
   for (Int_t iBin = 0; iBin < fSpNBins; iBin++) {
     Double_t energykeV = iBin * fSpBinWidth + 1.0;
@@ -356,14 +372,11 @@ Double_t AliTRDsim::Sigma(Double_t energykeV)
   // Calculates the absorbtion crosssection for a one-foil-one-gap-radiator
   //
 
-  // Gas at 0 C
-  const Double_t kTemp0 = 273.16;
-
   // keV -> MeV
   Double_t energyMeV = energykeV * 0.001;
   if (energyMeV >= 0.001) {
-    return(GetMuPo(energyMeV) * fFoilDens * fFoilThick + 
-           GetMuCO(energyMeV) * fGapDens  * fGapThick  * fTemp/kTemp0);
+    return(GetMuPo(energyMeV) * fFoilDens * fFoilThick +
+           GetMuAi(energyMeV) * fGapDens  * fGapThick  * GetTemp());
   }
   else {
     return 1e6;
@@ -691,6 +704,50 @@ Double_t AliTRDsim::GetMuHe(Double_t energyMeV)
 
 }
 
+//_____________________________________________________________________________
+Double_t AliTRDsim::GetMuAi(Double_t energyMeV)
+{
+  //
+  // Returns the photon absorbtion cross section for air
+  // Implemented by Oliver Busch
+  //
+
+  const Int_t kN = 38;
+
+  Double_t mu[kN] = { 0.35854E+04, 0.11841E+04, 0.52458E+03,
+                      0.16143E+03, 0.14250E+03, 0.15722E+03,
+                      0.77538E+02, 0.40099E+02, 0.23313E+02,
+                      0.98816E+01, 0.51000E+01, 0.16079E+01,
+                      0.77536E+00, 0.35282E+00, 0.24790E+00,
+                      0.20750E+00, 0.18703E+00, 0.16589E+00,
+                      0.15375E+00, 0.13530E+00, 0.12311E+00,
+                      0.10654E+00, 0.95297E-01, 0.86939E-01,
+                      0.80390E-01, 0.70596E-01, 0.63452E-01,
+                      0.56754E-01, 0.51644E-01, 0.44382E-01,
+                      0.35733E-01, 0.30721E-01, 0.27450E-01,
+                      0.25171E-01, 0.22205E-01, 0.20399E-01,
+                      0.18053E-01, 0.18057E-01 };
+
+
+
+  Double_t en[kN] = { 0.10000E-02, 0.15000E-02, 0.20000E-02,
+                      0.30000E-02, 0.32029E-02, 0.32029E-02,
+                      0.40000E-02, 0.50000E-02, 0.60000E-02,
+                      0.80000E-02, 0.10000E-01, 0.15000E-01,
+                      0.20000E-01, 0.30000E-01, 0.40000E-01,
+                      0.50000E-01, 0.60000E-01, 0.80000E-01,
+                      0.10000E+00, 0.15000E+00, 0.20000E+00,
+                      0.30000E+00, 0.40000E+00, 0.50000E+00,
+                      0.60000E+00, 0.80000E+00, 0.10000E+01,
+                      0.12500E+01, 0.15000E+01, 0.20000E+01,
+                      0.30000E+01, 0.40000E+01, 0.50000E+01,
+                      0.60000E+01, 0.80000E+01, 0.10000E+02,
+                      0.15000E+02, 0.20000E+02 };
+
+  return Interpolate(energyMeV,en,mu,kN);
+
+}
+
 //_____________________________________________________________________________
 Double_t AliTRDsim::Interpolate(Double_t energyMeV
                               , Double_t *en, Double_t *mu, Int_t n)
@@ -743,3 +800,23 @@ Int_t AliTRDsim::Locate(Double_t *xv, Int_t n, Double_t xval
   return 0;
 
 }
+
+//_____________________________________________________________________________
+Int_t AliTRDsim::SelectNFoils(Float_t p)
+{
+  //
+  // Selects the number of foils corresponding to the momentum
+  //
+
+  Int_t foils = fNFoils[fNFoilsDim-1];
+
+  for (Int_t iFoil = 0; iFoil < fNFoilsDim; iFoil++) {
+    if (p < fNFoilsUp[iFoil]) {
+      foils = fNFoils[iFoil];
+      break;
+    }
+  }
+
+  return foils;
+
+}