]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPC.cxx
Geometry rewritten in the TGeo modeler.
[u/mrichter/AliRoot.git] / TPC / AliTPC.cxx
index b5fc5e1f94dcfc2a028ab3816ba0211a6d8bbf43..ed18e4b47d057715abda51432c3521e5f14483ef 100644 (file)
@@ -40,7 +40,8 @@
 #include <TGeometry.h>
 #include <TInterpreter.h>
 #include <TMath.h>
-#include <TMatrix.h>
+#include <TMatrixF.h>
+#include <TVector.h>
 #include <TNode.h>
 #include <TObjectTable.h>
 #include <TParticle.h>
@@ -54,7 +55,6 @@
 #include <TF2.h>
 #include <TStopwatch.h>
 
-#include "AliArrayBranch.h"
 #include "AliDigits.h"
 #include "AliMagF.h"
 #include "AliPoints.h"
@@ -68,7 +68,7 @@
 #include "AliTPCPRF2D.h"
 #include "AliTPCParamSR.h"
 #include "AliTPCRF1D.h"
-#include "AliTPCTrackHits.h"
+//#include "AliTPCTrackHits.h"
 #include "AliTPCTrackHitsV2.h"
 #include "AliTrackReference.h"
 #include "AliMC.h"
@@ -92,7 +92,7 @@ AliTPC::AliTPC()
   fDigitsArray = 0;
   fDefaults = 0;
   fTrackHits = 0; 
-  fTrackHitsOld = 0;   
+  //  fTrackHitsOld = 0;   
 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,0,1)
   fHitType = 4; // ROOT containers
 #else
@@ -124,10 +124,10 @@ AliTPC::AliTPC(const char *name, const char *title)
   fTrackHits->SetStepPrecision(0.003);  
   fTrackHits->SetMaxDistance(100);
 
-  fTrackHitsOld = new AliTPCTrackHits;  //MI - 13.09.2000
-  fTrackHitsOld->SetHitPrecision(0.002);
-  fTrackHitsOld->SetStepPrecision(0.003);  
-  fTrackHitsOld->SetMaxDistance(100); 
+  //fTrackHitsOld = new AliTPCTrackHits;  //MI - 13.09.2000
+  //fTrackHitsOld->SetHitPrecision(0.002);
+  //fTrackHitsOld->SetStepPrecision(0.003);  
+  //fTrackHitsOld->SetMaxDistance(100); 
 
   fNoiseTable =0;
 
@@ -178,7 +178,7 @@ AliTPC::~AliTPC()
   delete fDigits;
   delete fTPCParam;
   delete fTrackHits; //MI 15.09.2000
-  delete fTrackHitsOld; //MI 10.12.2001
+  //  delete fTrackHitsOld; //MI 10.12.2001
   if (fNoiseTable) delete [] fNoiseTable;
 
 }
@@ -282,17 +282,6 @@ void AliTPC::BuildGeometry()
 
 }    
 
-//_____________________________________________________________________________
-Int_t AliTPC::DistancetoPrimitive(Int_t , Int_t ) const
-{
-  //
-  // Calculate distance from TPC to mouse on the display
-  // Dummy procedure
-  //
-  return 9999;
-}
-
-
 //_____________________________________________________________________________
 void AliTPC::CreateMaterials()
 {
@@ -304,7 +293,7 @@ void AliTPC::CreateMaterials()
   // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
   //-----------------------------------------------------------------
 
-  Int_t iSXFLD=gAlice->Field()->Integ();
+   Int_t iSXFLD=gAlice->Field()->Integ();
   Float_t sXMGMX=gAlice->Field()->Max();
 
   Float_t amat[5]; // atomic numbers
@@ -312,43 +301,16 @@ void AliTPC::CreateMaterials()
   Float_t wmat[5]; // proportions
 
   Float_t density;
-  Float_t apure[2];
-
-
-  //***************** Gases *************************
-  
-  //-------------------------------------------------
-  // pure gases
-  //-------------------------------------------------
-
-  // Neon
-
-
-  amat[0]= 20.18;
-  zmat[0]= 10.;  
-  density = 0.0009;
  
-  apure[0]=amat[0];
 
-  AliMaterial(20,"Ne",amat[0],zmat[0],density,999.,999.);
 
-  // Argon
-
-  amat[0]= 39.948;
-  zmat[0]= 18.;  
-  density = 0.001782;  
-
-  apure[1]=amat[0];
+  //***************** Gases *************************
 
-  AliMaterial(21,"Ar",amat[0],zmat[0],density,999.,999.);
  
-
   //--------------------------------------------------------------
-  // gases - compounds
+  // gases - air and CO2
   //--------------------------------------------------------------
 
-  Float_t amol[3];
-
   // CO2
 
   amat[0]=12.011;
@@ -357,103 +319,56 @@ void AliTPC::CreateMaterials()
   zmat[0]=6.;
   zmat[1]=8.;
 
-  wmat[0]=1.;
-  wmat[1]=2.;
+  wmat[0]=0.2729;
+  wmat[1]=0.7271;
 
   density=0.001977;
 
-  amol[0] = amat[0]*wmat[0]+amat[1]*wmat[1];
-
-  AliMixture(10,"CO2",amat,zmat,density,-2,wmat);
-  
-  // CF4
-
-  amat[0]=12.011;
-  amat[1]=18.998;
-
-  zmat[0]=6.;
-  zmat[1]=9.;
-  wmat[0]=1.;
-  wmat[1]=4.;
-  density=0.003034;
-
-  amol[1] = amat[0]*wmat[0]+amat[1]*wmat[1];
-
-  AliMixture(11,"CF4",amat,zmat,density,-2,wmat); 
-
-
-  // CH4
 
-  amat[0]=12.011;
-  amat[1]=1.;
-
-  zmat[0]=6.;
-  zmat[1]=1.;
-
-  wmat[0]=1.;
-  wmat[1]=4.;
-
-  density=0.000717;
-
-  amol[2] = amat[0]*wmat[0]+amat[1]*wmat[1];
-
-  AliMixture(12,"CH4",amat,zmat,density,-2,wmat);
+  AliMixture(10,"CO2",amat,zmat,density,2,wmat);
+  //
+  // Air
+  //
+  amat[0]=15.9994;
+  amat[1]=14.007;
+  //
+  zmat[0]=8.;
+  zmat[1]=7.;
+  //
+  wmat[0]=0.233;
+  wmat[1]=0.767;
+  //
+  density=0.001205;
 
+  AliMixture(11,"Air",amat,zmat,density,2,wmat);
+  
   //----------------------------------------------------------------
-  // gases - mixtures, ID >= 20 pure gases, <= 10 ID < 20 -compounds
+  // drift gases 
   //----------------------------------------------------------------
 
-  char namate[21]=""; 
-  density = 0.;
-  Float_t am=0;
-  Int_t nc;
-  Float_t rho,absl,x0,buf[1];
-  Int_t nbuf;
-  Float_t a,z;
-
-  for(nc = 0;nc<fNoComp;nc++) {
-    
-    // retrive material constants
-      
-    gMC->Gfmate((*fIdmate)[fMixtComp[nc]],namate,a,z,rho,x0,absl,buf,nbuf);
-
-    amat[nc] = a;
-    zmat[nc] = z;
-    
-    Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10;
-    
-    am += fMixtProp[nc]*((fMixtComp[nc]>=20) ? apure[nnc] : amol[nnc]); 
-    density += fMixtProp[nc]*rho;  // density of the mixture
-    
-  }
-  
-  // mixture proportions by weight!
-  
-  for(nc = 0;nc<fNoComp;nc++) {
-
-    Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10;
-
-    wmat[nc] = fMixtProp[nc]*((fMixtComp[nc]>=20) ? 
-                             apure[nnc] : amol[nnc])/am;
-
-  } 
 
   // Drift gases 1 - nonsensitive, 2 - sensitive
+  // Ne-CO2-N (85-10-5)
 
-  AliMixture(31,"Drift gas 1",amat,zmat,density,fNoComp,wmat);
-  AliMixture(32,"Drift gas 2",amat,zmat,density,fNoComp,wmat);
-
-
-  // Air
+  amat[0]= 20.18;
+  amat[1]=12.011;
+  amat[2]=15.9994;
+  amat[3]=14.007;
 
-  amat[0] = 14.61;
-  zmat[0] = 7.3;
-  density = 0.001205;
+  zmat[0]= 10.; 
+  zmat[1]=6.;
+  zmat[2]=8.;
+  zmat[3]=7.;
 
-  AliMaterial(24,"Air",amat[0],zmat[0],density,999.,999.); 
+  wmat[0]=0.7707;
+  wmat[1]=0.0539;
+  wmat[2]=0.1438;
+  wmat[3]=0.0316;
+  density=0.0010252;
 
+  AliMixture(12,"Ne-CO2-N-1",amat,zmat,density,4,wmat);
+  AliMixture(13,"Ne-CO2-N-2",amat,zmat,density,4,wmat);
 
   //----------------------------------------------------------------------
   //               solid materials
@@ -479,7 +394,7 @@ void AliTPC::CreateMaterials()
 
   density = 1.45;
 
-  AliMixture(34,"Kevlar",amat,zmat,density,-4,wmat);  
+  AliMixture(14,"Kevlar",amat,zmat,density,-4,wmat);  
 
   // NOMEX
 
@@ -498,10 +413,9 @@ void AliTPC::CreateMaterials()
   wmat[2] = 2.;
   wmat[3] = 2.;
 
-  density = 0.03;
-
-  
-  AliMixture(35,"NOMEX",amat,zmat,density,-4,wmat);
+  density = 0.029;
+  AliMixture(15,"NOMEX",amat,zmat,density,-4,wmat);
 
   // Makrolon C16H18O3
 
@@ -519,7 +433,25 @@ void AliTPC::CreateMaterials()
   
   density = 1.2;
 
-  AliMixture(36,"Makrolon",amat,zmat,density,-3,wmat);
+  AliMixture(16,"Makrolon",amat,zmat,density,-3,wmat);
+
+  // Tedlar C2H3F
+
+  amat[0] = 12.011;
+  amat[1] = 1.;
+  amat[2] = 18.998;
+
+  zmat[0] = 6.;
+  zmat[1] = 1.;
+  zmat[2] = 9.;
+
+  wmat[0] = 2.;
+  wmat[1] = 3.; 
+  wmat[2] = 1.;
+
+  density = 1.71;
+
+  AliMixture(17, "Tedlar",amat,zmat,density,-3,wmat);  
   
   // Mylar C5H4O2
 
@@ -537,22 +469,91 @@ void AliTPC::CreateMaterials()
 
   density = 1.39;
   
-  AliMixture(37, "Mylar",amat,zmat,density,-3,wmat); 
+  AliMixture(18, "Mylar",amat,zmat,density,-3,wmat); 
+  // material for "prepregs"
+  // Epoxy - C14 H20 O3
+  // Quartz SiO2
+  // Carbon C
+  // prepreg1 60% C-fiber, 40% epoxy (vol)
+  amat[0]=12.011;
+  amat[1]=1.;
+  amat[2]=15.994;
 
-  // SiO2 - used later for the glass fiber
+  zmat[0]=6.;
+  zmat[1]=1.;
+  zmat[2]=8.;
 
-  amat[0]=28.086;
-  amat[1]=15.9994;
+  wmat[0]=0.923;
+  wmat[1]=0.023;
+  wmat[2]=0.054;
 
-  zmat[0]=14.;
-  zmat[1]=8.;
+  density=1.859;
+
+  AliMixture(19, "Prepreg1",amat,zmat,density,3,wmat);
+
+  //prepreg2 60% glass-fiber, 40% epoxy
+
+  amat[0]=12.01;
+  amat[1]=1.;
+  amat[2]=15.994;
+  amat[3]=28.086;
+
+  zmat[0]=6.;
+  zmat[1]=1.;
+  zmat[2]=8.;
+  zmat[3]=14.;
+
+  wmat[0]=0.194;
+  wmat[1]=0.023;
+  wmat[2]=0.443;
+  wmat[3]=0.340;
+
+  density=1.82;
+
+  AliMixture(20, "Prepreg2",amat,zmat,density,4,wmat);
+
+  //prepreg3 50% glass-fiber, 50% epoxy
+
+  amat[0]=12.01;
+  amat[1]=1.;
+  amat[2]=15.994;
+  amat[3]=28.086;
+
+  zmat[0]=6.;
+  zmat[1]=1.;
+  zmat[2]=8.;
+  zmat[3]=14.;
 
-  wmat[0]=1.;
-  wmat[1]=2.;
+  wmat[0]=0.225;
+  wmat[1]=0.03;
+  wmat[2]=0.443;
+  wmat[3]=0.3;
 
+  density=1.163;
 
-  AliMixture(38,"SiO2",amat,zmat,2.2,-2,wmat); //SiO2 - quartz (rho=2.2)
+  AliMixture(21, "Prepreg3",amat,zmat,density,4,wmat);
 
+  // G10 60% SiO2 40% epoxy
+
+  amat[0]=12.01;
+  amat[1]=1.;
+  amat[2]=15.994;
+  amat[3]=28.086;
+
+  zmat[0]=6.;
+  zmat[1]=1.;
+  zmat[2]=8.;
+  zmat[3]=14.;
+
+  wmat[0]=0.194;
+  wmat[1]=0.023;
+  wmat[2]=0.443;
+  wmat[3]=0.340;
+
+  density=1.7;
+
+  AliMixture(22, "G10",amat,zmat,density,4,wmat);
   // Al
 
   amat[0] = 26.98;
@@ -560,16 +561,16 @@ void AliTPC::CreateMaterials()
 
   density = 2.7;
 
-  AliMaterial(40,"Al",amat[0],zmat[0],density,999.,999.);
+  AliMaterial(23,"Al",amat[0],zmat[0],density,999.,999.);
 
-  // Si
+  // Si (for electronics
 
   amat[0] = 28.086;
   zmat[0] = 14.;
 
   density = 2.33;
 
-  AliMaterial(41,"Si",amat[0],zmat[0],density,999.,999.);
+  AliMaterial(24,"Si",amat[0],zmat[0],density,999.,999.);
 
   // Cu
 
@@ -578,29 +579,10 @@ void AliTPC::CreateMaterials()
 
   density = 8.96;
 
-  AliMaterial(42,"Cu",amat[0],zmat[0],density,999.,999.);
-
-  // Tedlar C2H3F
-
-  amat[0] = 12.011;
-  amat[1] = 1.;
-  amat[2] = 18.998;
-
-  zmat[0] = 6.;
-  zmat[1] = 1.;
-  zmat[2] = 9.;
-
-  wmat[0] = 2.;
-  wmat[1] = 3.; 
-  wmat[2] = 1.;
-
-  density = 1.71;
-
-  AliMixture(43, "Tedlar",amat,zmat,density,-3,wmat);  
-
-
-  // Plexiglas  C5H8O2
+  AliMaterial(25,"Cu",amat[0],zmat[0],density,999.,999.);
 
+  // Epoxy - C14 H20 O3
   amat[0]=12.011;
   amat[1]=1.;
   amat[2]=15.9994;
@@ -609,17 +591,16 @@ void AliTPC::CreateMaterials()
   zmat[1]=1.;
   zmat[2]=8.;
 
-  wmat[0]=5.;
-  wmat[1]=8.;
-  wmat[2]=2.;
+  wmat[0]=14.;
+  wmat[1]=20.;
+  wmat[2]=3.;
 
-  density=1.18;
+  density=1.25;
 
-  AliMixture(44,"Plexiglas",amat,zmat,density,-3,wmat);
+  AliMixture(26,"Epoxy",amat,zmat,density,-3,wmat);
 
-  // Epoxy - C14 H20 O3
+  // Plexiglas  C5H8O2
 
-  
   amat[0]=12.011;
   amat[1]=1.;
   amat[2]=15.9994;
@@ -628,13 +609,13 @@ void AliTPC::CreateMaterials()
   zmat[1]=1.;
   zmat[2]=8.;
 
-  wmat[0]=14.;
-  wmat[1]=20.;
-  wmat[2]=3.;
+  wmat[0]=5.;
+  wmat[1]=8.;
+  wmat[2]=2.;
 
-  density=1.25;
+  density=1.18;
 
-  AliMixture(45,"Epoxy",amat,zmat,density,-3,wmat);
+  AliMixture(27,"Plexiglas",amat,zmat,density,-3,wmat);
 
   // Carbon
 
@@ -642,60 +623,48 @@ void AliTPC::CreateMaterials()
   zmat[0]=6.;
   density= 2.265;
 
-  AliMaterial(46,"C",amat[0],zmat[0],density,999.,999.);
-
-  // get epoxy
-
-  gMC->Gfmate((*fIdmate)[45],namate,amat[1],zmat[1],rho,x0,absl,buf,nbuf);
-
-  // Carbon fiber
-
-  wmat[0]=0.644; // by weight!
-  wmat[1]=0.356;
-
-  density=0.5*(1.25+2.265);
-
-  AliMixture(47,"Cfiber",amat,zmat,density,2,wmat);
+  AliMaterial(28,"C",amat[0],zmat[0],density,999.,999.);
 
-  // get SiO2
-
-  gMC->Gfmate((*fIdmate)[38],namate,amat[0],zmat[0],rho,x0,absl,buf,nbuf); 
-
-  wmat[0]=0.725; // by weight!
-  wmat[1]=0.275;
+  // Fe (steel for the inner heat screen)
+  amat[0]=55.845;
 
-  density=1.7;
+  zmat[0]=26.;
 
-  AliMixture(39,"G10",amat,zmat,density,2,wmat);
+  density=7.87;
 
+  AliMaterial(29,"Fe",amat[0],zmat[0],density,999.,999.);
  
-
-
   //----------------------------------------------------------
   // tracking media for gases
   //----------------------------------------------------------
 
-  AliMedium(0, "Air", 24, 0, iSXFLD, sXMGMX, 10., 999., .1, .01, .1);
-  AliMedium(1, "Drift gas 1", 31, 0, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
-  AliMedium(2, "Drift gas 2", 32, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
+  AliMedium(0, "Air", 11, 0, iSXFLD, sXMGMX, 10., 999., .1, .01, .1);
+  AliMedium(1, "Ne-CO2-N-1", 12, 0, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
+  AliMedium(2, "Ne-CO2-N-2", 13, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
   AliMedium(3,"CO2",10,0, iSXFLD, sXMGMX, 10., 999.,.1, .001, .001); 
 
   //-----------------------------------------------------------  
   // tracking media for solids
   //-----------------------------------------------------------
   
-  AliMedium(4,"Al",40,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
-  AliMedium(5,"Kevlar",34,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
-  AliMedium(6,"Nomex",35,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
-  AliMedium(7,"Makrolon",36,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
-  AliMedium(8,"Mylar",37,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
-  AliMedium(9,"Tedlar",43,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
-  AliMedium(10,"Cu",42,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
-  AliMedium(11,"Si",41,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
-  AliMedium(12,"G10",39,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
-  AliMedium(13,"Plexiglas",44,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
-  AliMedium(14,"Epoxy",45,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
-  AliMedium(15,"Cfiber",47,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
+  AliMedium(4,"Al",23,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+  AliMedium(5,"Kevlar",14,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+  AliMedium(6,"Nomex",15,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
+  AliMedium(7,"Makrolon",16,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
+  AliMedium(8,"Mylar",18,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+  AliMedium(9,"Tedlar",17,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+  //
+  AliMedium(10,"Prepreg1",19,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+  AliMedium(11,"Prepreg2",20,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+  AliMedium(12,"Prepreg3",21,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+  AliMedium(13,"Epoxy",26,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
+
+  AliMedium(14,"Cu",25,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
+  AliMedium(15,"Si",24,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
+  AliMedium(16,"G10",22,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
+  AliMedium(17,"Plexiglas",27,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
+  AliMedium(18,"Steel",29,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); 
     
 }
 
@@ -789,14 +758,14 @@ void    AliTPC::SetActiveSectors(Int_t flag)
     }
     
     //
-    if (fTrackHitsOld && fHitType&2) {
-      TBranch * br = TreeH()->GetBranch("fTrackHitsInfo");
-      br->GetEvent(track);
-      AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo;
-      for (UInt_t j=0;j<ar->GetSize();j++){
-       fActiveSectors[((AliTrackHitsInfo*)ar->At(j))->fVolumeID] =kTRUE;
-      } 
-    }    
+//     if (fTrackHitsOld && fHitType&2) {
+//       TBranch * br = TreeH()->GetBranch("fTrackHitsInfo");
+//       br->GetEvent(track);
+//       AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo;
+//       for (UInt_t j=0;j<ar->GetSize();j++){
+//     fActiveSectors[((AliTrackHitsInfo*)ar->At(j))->fVolumeID] =kTRUE;
+//       } 
+//     }    
   }
 }  
 
@@ -1362,10 +1331,10 @@ void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rows)
   //  and a single track signal
   //    
 
-  TMatrix *m1 = new TMatrix(0,nofPads,0,nofTbins); // integrated
-  TMatrix *m2 = new TMatrix(0,nofPads,0,nofTbins); // single
+  TMatrixF *m1 = new TMatrixF(0,nofPads,0,nofTbins); // integrated
+  TMatrixF *m2 = new TMatrixF(0,nofPads,0,nofTbins); // single
   //
-  TMatrix &total  = *m1;
+  TMatrixF &total  = *m1;
 
   //  Array of pointers to the label-signal list
 
@@ -1460,7 +1429,7 @@ void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rows)
 //_____________________________________________________________________________
 
 Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr, 
-             TMatrix *m1, TMatrix *m2,Int_t *indexRange)
+             TMatrixF *m1, TMatrixF *m2,Int_t *indexRange)
 {
 
   //---------------------------------------------------------------
@@ -1482,22 +1451,22 @@ Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr,
   Float_t label = v(0);
   Int_t centralPad = (fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3]-1)-1)/2;
 
-  Int_t nElectrons = (tv->GetNrows()-1)/4;
+  Int_t nElectrons = (tv->GetNrows()-1)/5;
   indexRange[0]=9999; // min pad
   indexRange[1]=-1; // max pad
   indexRange[2]=9999; //min time
   indexRange[3]=-1; // max time
 
-  TMatrix &signal = *m1;
-  TMatrix &total = *m2;
+  TMatrixF &signal = *m1;
+  TMatrixF &total = *m2;
   //
   //  Loop over all electrons
   //
   for(Int_t nel=0; nel<nElectrons; nel++){
-    Int_t idx=nel*4;
+    Int_t idx=nel*5;
     Float_t aval =  v(idx+4);
     Float_t eltoadcfac=aval*fTPCParam->GetTotalNormFac(); 
-    Float_t xyz[3]={v(idx+1),v(idx+2),v(idx+3)};
+    Float_t xyz[4]={v(idx+1),v(idx+2),v(idx+3),v(idx+5)};
     Int_t n = ((AliTPCParamSR*)fTPCParam)->CalcResponseFast(xyz,fCurrentIndex,fCurrentIndex[3]);
 
     Int_t *index = fTPCParam->GetResBin(0);  
@@ -1528,7 +1497,7 @@ Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr,
 }
 
 //_____________________________________________________________________________
-void AliTPC::GetList(Float_t label,Int_t np,TMatrix *m,
+void AliTPC::GetList(Float_t label,Int_t np,TMatrixF *m,
                      Int_t *indexRange, Float_t **pList)
 {
   //----------------------------------------------------------------------
@@ -1539,7 +1508,7 @@ void AliTPC::GetList(Float_t label,Int_t np,TMatrix *m,
   // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
   //-----------------------------------------------------------------
 
-  TMatrix &signal = *m;
+  TMatrixF &signal = *m;
 
   // lop over nonzero digits
 
@@ -1632,7 +1601,7 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
 
   Float_t gasgain = fTPCParam->GetGasGain();
   Int_t i;
-  Float_t xyz[4]; 
+  Float_t xyz[5]; 
 
   AliTPChit *tpcHit; // pointer to a sigle TPC hit    
   //MI change
@@ -1701,7 +1670,7 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
            if(nofElectrons[i]>0){
              TVector &v = *tracks[i];
              v(0) = previousTrack;
-             tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
+             tracks[i]->ResizeTo(5*nofElectrons[i]+1); // shrink if necessary
              row[i]->Add(tracks[i]);                     
            }
            else {
@@ -1711,7 +1680,7 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
          }
 
          nofElectrons[i]=0;
-         tracks[i] = new TVector(481); // TVectors for the next fTrack
+         tracks[i] = new TVector(601); // TVectors for the next fTrack
 
        } // end of loop over rows
               
@@ -1752,6 +1721,8 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
        TransportElectron(xyz,index);    
        Int_t rowNumber;
        fTPCParam->GetPadRow(xyz,index); 
+       // Electron track time (for pileup simulation)
+       xyz[4] = tpcHit->Time()/fTPCParam->GetTSample();
        // row 0 - cross talk from the innermost row
        // row fNRow+1 cross talk from the outermost row
        rowNumber = index[2]+1; 
@@ -1778,16 +1749,16 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
        //----------------------------------
        if(nofElectrons[rowNumber]>120){
          Int_t range = tracks[rowNumber]->GetNrows();
-         if((nofElectrons[rowNumber])>(range-1)/4){
+         if((nofElectrons[rowNumber])>(range-1)/5){
            
-           tracks[rowNumber]->ResizeTo(range+400); // Add 100 electrons
+           tracks[rowNumber]->ResizeTo(range+500); // Add 100 electrons
          }
        }
        
        TVector &v = *tracks[rowNumber];
-       Int_t idx = 4*nofElectrons[rowNumber]-3;
+       Int_t idx = 5*nofElectrons[rowNumber]-4;
        Real_t * position = &(((TVector&)v)(idx)); //make code faster
-       memcpy(position,xyz,4*sizeof(Float_t));
+       memcpy(position,xyz,5*sizeof(Float_t));
        
       } // end of loop over electrons
 
@@ -1804,7 +1775,7 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
     if(nofElectrons[i]>0){
       TVector &v = *tracks[i];
       v(0) = previousTrack;
-      tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
+      tracks[i]->ResizeTo(5*nofElectrons[i]+1); // shrink if necessary
       row[i]->Add(tracks[i]);  
     }
     else{
@@ -1864,77 +1835,7 @@ void AliTPC::ResetDigits()
   if (fDigits)   fDigits->Clear();
 }
 
-//_____________________________________________________________________________
-void AliTPC::SetSecAL(Int_t sec)
-{
-  //---------------------------------------------------
-  // Activate/deactivate selection for lower sectors
-  //---------------------------------------------------
-
-  //-----------------------------------------------------------------
-  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
-  //-----------------------------------------------------------------
-  fSecAL = sec;
-}
-
-//_____________________________________________________________________________
-void AliTPC::SetSecAU(Int_t sec)
-{
-  //----------------------------------------------------
-  // Activate/deactivate selection for upper sectors
-  //---------------------------------------------------
-
-  //-----------------------------------------------------------------
-  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
-  //-----------------------------------------------------------------
-  fSecAU = sec;
-}
-
-//_____________________________________________________________________________
-void AliTPC::SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6)
-{
-  //----------------------------------------
-  // Select active lower sectors
-  //----------------------------------------
-
-  //-----------------------------------------------------------------
-  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
-  //-----------------------------------------------------------------
-
-  fSecLows[0] = s1;
-  fSecLows[1] = s2;
-  fSecLows[2] = s3;
-  fSecLows[3] = s4;
-  fSecLows[4] = s5;
-  fSecLows[5] = s6;
-}
-
-//_____________________________________________________________________________
-void AliTPC::SetSecUps(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6,
-                       Int_t s7, Int_t s8 ,Int_t s9 ,Int_t s10, 
-                       Int_t s11 , Int_t s12)
-{
-  //--------------------------------
-  // Select active upper sectors
-  //--------------------------------
 
-  //-----------------------------------------------------------------
-  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
-  //-----------------------------------------------------------------
-
-  fSecUps[0] = s1;
-  fSecUps[1] = s2;
-  fSecUps[2] = s3;
-  fSecUps[3] = s4;
-  fSecUps[4] = s5;
-  fSecUps[5] = s6;
-  fSecUps[6] = s7;
-  fSecUps[7] = s8;
-  fSecUps[8] = s9;
-  fSecUps[9] = s10;
-  fSecUps[10] = s11;
-  fSecUps[11] = s12;
-}
 
 //_____________________________________________________________________________
 void AliTPC::SetSens(Int_t sens)
@@ -1960,23 +1861,6 @@ void AliTPC::SetSide(Float_t side=0.)
   fSide = side;
  
 }
-//____________________________________________________________________________
-void AliTPC::SetGasMixt(Int_t nc,Int_t c1,Int_t c2,Int_t c3,Float_t p1,
-                           Float_t p2,Float_t p3)
-{
-
-  // gax mixture definition
-
-  fNoComp = nc;
-  fMixtComp[0]=c1;
-  fMixtComp[1]=c2;
-  fMixtComp[2]=c3;
-
-  fMixtProp[0]=p1;
-  fMixtProp[1]=p2;
-  fMixtProp[2]=p3; 
-}
 //_____________________________________________________________________________
 
 void AliTPC::TransportElectron(Float_t *xyz, Int_t *index)
@@ -2026,6 +1910,7 @@ AliHit(shunt,track)
   fY          = hits[1];
   fZ          = hits[2];
   fQ          = hits[3];
+  fTime       = hits[4];
 }
  
 //________________________________________________________________________
@@ -2050,12 +1935,12 @@ void AliTPC::MakeBranch2(Option_t *option,const char */*file*/)
     TreeH()->Branch(branchname,"AliTPCTrackHitsV2",&fTrackHits,fBufferSize,99);
   }
 
-  if (fTrackHitsOld   && TreeH() && cH && fHitType&2) {    
-    AliDebug(1,"Making branch for Type 2 Hits");
-    AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHits",&fTrackHitsOld, 
-                                                   TreeH(),fBufferSize,99);
-    TreeH()->GetListOfBranches()->Add(branch);
-  }    
+//   if (fTrackHitsOld   && TreeH() && cH && fHitType&2) {    
+//     AliDebug(1,"Making branch for Type 2 Hits");
+//     AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHits",&fTrackHitsOld, 
+//                                                    TreeH(),fBufferSize,99);
+//     TreeH()->GetListOfBranches()->Add(branch);
+//   } 
 }
 
 void AliTPC::SetTreeAddress()
@@ -2091,15 +1976,15 @@ void AliTPC::SetTreeAddress2()
       AliDebug(1,"fHitType&4 Failed (can not find branch)");
     
   }
-  if ((treeH)&&(fHitType&2)) {
-    branch = treeH->GetBranch(branchname);
-    if (branch) {
-      branch->SetAddress(&fTrackHitsOld);
-      AliDebug(1,"fHitType&2 Setting");
-    }
-    else
-      AliDebug(1,"fHitType&2 Failed (can not find branch)");
-  }
//  if ((treeH)&&(fHitType&2)) {
+//     branch = treeH->GetBranch(branchname);
+//     if (branch) {
+//       branch->SetAddress(&fTrackHitsOld);
+//       AliDebug(1,"fHitType&2 Setting");
+//     }
+//     else
+//       AliDebug(1,"fHitType&2 Failed (can not find branch)");
+//   }
   //set address to TREETR
   
   TTree *treeTR = TreeTR();
@@ -2113,7 +1998,7 @@ void AliTPC::SetTreeAddress2()
 void AliTPC::FinishPrimary()
 {
   if (fTrackHits &&fHitType&4)      fTrackHits->FlushHitStack();  
-  if (fTrackHitsOld && fHitType&2)  fTrackHitsOld->FlushHitStack();  
+  //  if (fTrackHitsOld && fHitType&2)  fTrackHitsOld->FlushHitStack();  
 }
 
 
@@ -2132,10 +2017,10 @@ void AliTPC::AddHit2(Int_t track, Int_t *vol, Float_t *hits)
   }  
   if (fTrackHits && fHitType&4) 
     fTrackHits->AddHitKartez(vol[0],rtrack, hits[0],
-                             hits[1],hits[2],(Int_t)hits[3]);
-  if (fTrackHitsOld &&fHitType&2 ) 
-    fTrackHitsOld->AddHitKartez(vol[0],rtrack, hits[0],
-                                hits[1],hits[2],(Int_t)hits[3]);
+                             hits[1],hits[2],(Int_t)hits[3],hits[4]);
//  if (fTrackHitsOld &&fHitType&2 ) 
+//     fTrackHitsOld->AddHitKartez(vol[0],rtrack, hits[0],
+//                                 hits[1],hits[2],(Int_t)hits[3]);
   
 }
 
@@ -2150,7 +2035,7 @@ void AliTPC::ResetHits2()
   //
   //reset hits
   if (fTrackHits && fHitType&4) fTrackHits->Clear();
-  if (fTrackHitsOld && fHitType&2) fTrackHitsOld->Clear();
+  // if (fTrackHitsOld && fHitType&2) fTrackHitsOld->Clear();
 
 }   
 
@@ -2187,10 +2072,10 @@ AliHit* AliTPC::FirstHit2(Int_t track)
     fTrackHits->First();
     return fTrackHits->GetHit();
   }
-  if (fTrackHitsOld && fHitType&2) {
-    fTrackHitsOld->First();
-    return fTrackHitsOld->GetHit();
-  }
//  if (fTrackHitsOld && fHitType&2) {
+//     fTrackHitsOld->First();
+//     return fTrackHitsOld->GetHit();
+//   }
 
   else return 0;
 }
@@ -2201,10 +2086,10 @@ AliHit* AliTPC::NextHit2()
   //Return the next hit for the current track
 
 
-  if (fTrackHitsOld && fHitType&2) {
-    fTrackHitsOld->Next();
-    return fTrackHitsOld->GetHit();
-  }
+//   if (fTrackHitsOld && fHitType&2) {
+//     fTrackHitsOld->Next();
+//     return fTrackHitsOld->GetHit();
+//   }
   if (fTrackHits) {
     fTrackHits->Next();
     return fTrackHits->GetHit();
@@ -2230,14 +2115,15 @@ void AliTPC::RemapTrackHitIDs(Int_t *map)
   //
   if (!fTrackHits) return;
   
-  if (fTrackHitsOld && fHitType&2){
-    AliObjectArray * arr = fTrackHitsOld->fTrackHitsInfo;
-    for (UInt_t i=0;i<arr->GetSize();i++){
-      AliTrackHitsInfo * info = (AliTrackHitsInfo *)(arr->At(i));
-      info->fTrackID = map[info->fTrackID];
-    }
-  }
-  if (fTrackHitsOld && fHitType&4){
+//   if (fTrackHitsOld && fHitType&2){
+//     AliObjectArray * arr = fTrackHitsOld->fTrackHitsInfo;
+//     for (UInt_t i=0;i<arr->GetSize();i++){
+//       AliTrackHitsInfo * info = (AliTrackHitsInfo *)(arr->At(i));
+//       info->fTrackID = map[info->fTrackID];
+//     }
+//   }
+//  if (fTrackHitsOld && fHitType&4){
+  if (fTrackHits && fHitType&4){
     TClonesArray * arr = fTrackHits->GetArray();;
     for (Int_t i=0;i<arr->GetEntriesFast();i++){
       AliTrackHitsParamV2 * info = (AliTrackHitsParamV2 *)(arr->At(i));
@@ -2253,14 +2139,14 @@ Bool_t   AliTPC::TrackInVolume(Int_t id,Int_t track)
   //return true if current track is in volume
   //
   //  return kTRUE;
-  if (fTrackHitsOld && fHitType&2) {
-    TBranch * br = TreeH()->GetBranch("fTrackHitsInfo");
-    br->GetEvent(track);
-    AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo;
-    for (UInt_t j=0;j<ar->GetSize();j++){
-      if (  ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==id) return kTRUE;
-    } 
-  }
//  if (fTrackHitsOld && fHitType&2) {
+//     TBranch * br = TreeH()->GetBranch("fTrackHitsInfo");
+//     br->GetEvent(track);
+//     AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo;
+//     for (UInt_t j=0;j<ar->GetSize();j++){
+//       if (  ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==id) return kTRUE;
+//     } 
+//   }
 
   if (fTrackHits && fHitType&4) {
     TBranch * br1 = TreeH()->GetBranch("fVolumes");
@@ -2294,11 +2180,12 @@ void AliTPC::LoadPoints2(Int_t)
   //
   // Store x, y, z of all hits in memory
   //
-  if (fTrackHits == 0 && fTrackHitsOld==0) return;
+  //  if (fTrackHits == 0 && fTrackHitsOld==0) return;
+  if (fTrackHits == 0 ) return;
   //
   Int_t nhits =0;
   if (fHitType&4) nhits = fTrackHits->GetEntriesFast();
-  if (fHitType&2) nhits = fTrackHitsOld->GetEntriesFast();
+  //  if (fHitType&2) nhits = fTrackHitsOld->GetEntriesFast();
   
   if (nhits == 0) return;
   Int_t tracks = gAlice->GetMCApp()->GetNtrack();