]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDv1.cxx
Transition to NewIO
[u/mrichter/AliRoot.git] / TRD / AliTRDv1.cxx
index 951f5692ca34af3139b9310be41fbfbd0f8ae5b5..2207e0b5a49d6f2de7280f4ada335a589badab7e 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.30  2001/05/21 16:45:47  hristov
-Last minute changes (C.Blume)
-
-Revision 1.29  2001/05/16 14:57:28  alibrary
-New files for folders and Stack
-
-Revision 1.28  2001/05/07 08:03:22  cblume
-Generate also hits in the amplification region
-
-Revision 1.27  2001/03/30 14:40:15  cblume
-Update of the digitization parameter
-
-Revision 1.26  2000/11/30 17:38:08  cblume
-Changes to get in line with new STEER and EVGEN
-
-Revision 1.25  2000/11/15 14:30:16  cblume
-Fixed bug in calculating detector no. of extra hit
-
-Revision 1.24  2000/11/10 14:58:36  cblume
-Introduce additional hit with amplitude 0 at the chamber borders
-
-Revision 1.23  2000/11/01 14:53:21  cblume
-Merge with TRD-develop
-
-Revision 1.17.2.5  2000/10/15 23:40:01  cblume
-Remove AliTRDconst
-
-Revision 1.17.2.4  2000/10/06 16:49:46  cblume
-Made Getters const
-
-Revision 1.17.2.3  2000/10/04 16:34:58  cblume
-Replace include files by forward declarations
-
-Revision 1.17.2.2  2000/09/18 13:50:17  cblume
-Include TR photon generation and adapt to new AliTRDhit
-
-Revision 1.22  2000/06/27 13:08:50  cblume
-Changed to Copy(TObject &A) to appease the HP-compiler
-
-Revision 1.21  2000/06/09 11:10:07  cblume
-Compiler warnings and coding conventions, next round
-
-Revision 1.20  2000/06/08 18:32:58  cblume
-Make code compliant to coding conventions
-
-Revision 1.19  2000/06/07 16:27:32  cblume
-Try to remove compiler warnings on Sun and HP
-
-Revision 1.18  2000/05/08 16:17:27  cblume
-Merge TRD-develop
-
-Revision 1.17.2.1  2000/05/08 14:59:16  cblume
-Made inline function non-virtual. Bug fix in setting sensitive chamber
-
-Revision 1.17  2000/02/28 19:10:26  cblume
-Include the new TRD classes
-
-Revision 1.16.4.1  2000/02/28 18:04:35  cblume
-Change to new hit version, introduce geometry class, and move digitization and clustering to AliTRDdigitizer/AliTRDclusterizerV1
-
-Revision 1.16  1999/11/05 22:50:28  fca
-Do not use Atan, removed from ROOT too
-
-Revision 1.15  1999/11/02 17:20:19  fca
-initialise nbytes before using it
-
-Revision 1.14  1999/11/02 17:15:54  fca
-Correct ansi scoping not accepted by HP compilers
-
-Revision 1.13  1999/11/02 17:14:51  fca
-Correct ansi scoping not accepted by HP compilers
-
-Revision 1.12  1999/11/02 16:35:56  fca
-New version of TRD introduced
-
-Revision 1.11  1999/11/01 20:41:51  fca
-Added protections against using the wrong version of FRAME
-
-Revision 1.10  1999/09/29 09:24:35  fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -113,21 +30,20 @@ Introduction of the Copyright and cvs Log
 
 #include <stdlib.h> 
 
-#include <TMath.h>
-#include <TVector.h>
-#include <TRandom.h>
 #include <TF1.h>
 #include <TLorentzVector.h>
+#include <TMath.h>
+#include <TRandom.h>
+#include <TVector.h>
+#include <TVirtualMC.h>
 
-#include "AliRun.h"
-#include "AliMC.h"
 #include "AliConst.h"
-
-#include "AliTRDv1.h"
+#include "AliRun.h"
+#include "AliTRDgeometry.h"
 #include "AliTRDhit.h"
 #include "AliTRDmatrix.h"
-#include "AliTRDgeometry.h"
 #include "AliTRDsim.h"
+#include "AliTRDv1.h"
 
 ClassImp(AliTRDv1)
  
@@ -304,27 +220,37 @@ void AliTRDv1::CreateTRhit(Int_t det)
       // Take the absorbtion in the entrance window into account
       Double_t muMy = fTR->GetMuMy(energyMeV);
       sigma = muMy * fFoilDensity;
-      absLength = gRandom->Exp(sigma);
-      if (absLength < AliTRDgeometry::MyThick()) continue;
+      if (sigma > 0.0) {
+        absLength = gRandom->Exp(1.0/sigma);
+        if (absLength < AliTRDgeometry::MyThick()) continue;
+      }
+      else {
+        continue;
+      }
 
       // The absorbtion cross sections in the drift gas
       if (fGasMix == 1) {
         // Gas-mixture (Xe/CO2)
         Double_t muXe = fTR->GetMuXe(energyMeV);
         Double_t muCO = fTR->GetMuCO(energyMeV);
-        sigma = (0.85 * muXe + 0.15 * muCO) * fGasDensity;
+        sigma = (0.85 * muXe + 0.15 * muCO) * fGasDensity * fTR->GetTemp();
       }
       else {
         // Gas-mixture (Xe/Isobutane) 
         Double_t muXe = fTR->GetMuXe(energyMeV);
         Double_t muBu = fTR->GetMuBu(energyMeV);
-        sigma = (0.97 * muXe + 0.03 * muBu) * fGasDensity;
+        sigma = (0.97 * muXe + 0.03 * muBu) * fGasDensity * fTR->GetTemp();
       }
 
       // The distance after which the energy of the TR photon
       // is deposited.
-      absLength = gRandom->Exp(sigma);
-      if (absLength > AliTRDgeometry::DrThick()) continue;
+      if (sigma > 0.0) {
+        absLength = gRandom->Exp(1.0/sigma);
+        if (absLength > AliTRDgeometry::DrThick()) continue;
+      }
+      else {
+        continue;
+      }
 
       // The position of the absorbtion
       Float_t posHit[3];
@@ -506,8 +432,7 @@ void AliTRDv1::StepManager()
   Int_t    qTot;
 
   Float_t  hits[3];
-  Float_t  moms[3];
-  Float_t  random[1];
+  Double_t  random[1];
   Float_t  charge;
   Float_t  aMass;
 
@@ -522,11 +447,15 @@ void AliTRDv1::StepManager()
   TString  cIdCurrent;
   TString  cIdSensDr = "J";
   TString  cIdSensAm = "K";
-  Char_t   cIdChamber[2];
+  Char_t   cIdChamber[3];
+           cIdChamber[2] = 0;
 
   TLorentzVector pos, mom;
 
   const Int_t    kNplan       = AliTRDgeometry::Nplan();
+  const Int_t    kNcham       = AliTRDgeometry::Ncham();
+  const Int_t    kNdetsec     = kNplan * kNcham;
+
   const Double_t kBig         = 1.0E+12;
 
   // Ionization energy
@@ -561,10 +490,10 @@ void AliTRDv1::StepManager()
     drRegion = kFALSE;
     amRegion = kFALSE;
     cIdCurrent = gMC->CurrentVolName();
-    if (cIdCurrent[1] == cIdSensDr) {
+    if (cIdSensDr == cIdCurrent[1]) {
       drRegion = kTRUE;
     }
-    if (cIdCurrent[1] == cIdSensAm) {
+    if (cIdSensAm == cIdCurrent[1]) {
       amRegion = kTRUE;
     }
     if (drRegion || amRegion) {
@@ -587,7 +516,7 @@ void AliTRDv1::StepManager()
       // The plane and chamber number
       cIdChamber[0] = cIdCurrent[2];
       cIdChamber[1] = cIdCurrent[3];
-      Int_t idChamber = atoi(cIdChamber);
+      Int_t idChamber = (atoi(cIdChamber) % kNdetsec);
       cha = ((Int_t) idChamber / kNplan);
       pla = ((Int_t) idChamber % kNplan);
 
@@ -619,15 +548,12 @@ void AliTRDv1::StepManager()
        // Special hits and TR photons only in the drift region
         if (drRegion) {
 
-          // Create some special hits with amplitude 0 at the entrance and
-          // exit of each chamber that contain the momentum components of the particle
+          // Create a track reference at the entrance and
+          // exit of each chamber that contain the 
+         // momentum components of the particle
           if (gMC->IsTrackEntering() || gMC->IsTrackExiting()) {
             gMC->TrackMomentum(mom);
-            moms[0] = mom[0];
-            moms[1] = mom[1];
-            moms[2] = mom[2];
-            AddHit(gAlice->CurrentTrack(),det,moms,0,kTRUE);
-            AddHit(gAlice->CurrentTrack(),det,hits,0,kTRUE); 
+            AddTrackReference(gAlice->CurrentTrack());
           }
 
           // Create the hits from TR photons
@@ -674,7 +600,7 @@ void AliTRDv1::StepManager()
       
           if (pp > 0) {
             do 
-              gMC->Rndm(random,1);
+            gMC->GetRandom()->RndmArray(1, random);
             while ((random[0] == 1.) || (random[0] == 0.));
             stepSize = - TMath::Log(random[0]) / pp; 
             gMC->SetMaxStep(stepSize);