]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOF.cxx
New Global2Local
[u/mrichter/AliRoot.git] / TOF / AliTOF.cxx
index d6808dd489765f0c8166bdf8b1bfc3974110d51a..e8fa2e4b8cdc6e1ad03f7773167f98fd51e7fd23 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.30  2001/10/21 18:30:39  hristov
-Several pointers were set to zero in the default constructors to avoid memory management problems
-
-Revision 1.29  2001/10/17 14:19:24  hristov
-delete replaced by delete []
-
-Revision 1.28  2001/10/05 12:02:01  vicinanz
-Minor improvements on Merger and SDigitizer
-
-Revision 1.27  2001/10/02 13:03:13  vicinanz
-Minor improvements on the code
-
-Revision 1.26  2001/09/27 10:39:20  vicinanz
-SDigitizer and Merger added
-
-Revision 1.25  2001/09/07 08:37:40  hristov
-Pointers initialised to 0 in the default constructor
-
-Revision 1.24  2001/09/05 16:31:00  hristov
-The deletion of TOF folders temporarily commented out
-
-Revision 1.23  2001/08/29 12:59:01  vicinanz
-Minor changes to the Digitizer procedure
-
-Revision 1.22  2001/08/28 08:45:58  vicinanz
-TTask and TFolder structures implemented
-
-Revision 1.21  2001/05/16 14:57:24  alibrary
-New files for folders and Stack
-
-Revision 1.20  2001/05/04 10:09:47  vicinanz
-Major upgrades to the strip structure
-
-Revision 1.19  2001/03/12 17:47:25  hristov
-Changes needed on Sun with CC 5.0
-
-Revision 1.18  2001/01/26 19:57:42  hristov
-Major upgrade of AliRoot code
-
-Revision 1.17  2000/10/19 09:58:14  vicinanz
-Updated Hits2Digit procedure
-
-Revision 1.16  2000/10/02 21:28:17  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.15  2000/05/18 14:33:01  vicinanz
-Modified to be full HP compliant
-
-Revision 1.14  2000/05/15 19:32:36  fca
-Add AddHitList !!
-
-Revision 1.13  2000/05/10 16:52:18  vicinanz
-New TOF version with holes for PHOS/RICH
-
-Revision 1.11.2.1  2000/05/10 09:37:15  vicinanz
-New version with Holes for PHOS/RICH
-
-Revision 1.11  1999/11/05 22:39:06  fca
-New hits structure
-
-Revision 1.10  1999/11/01 20:41:57  fca
-Added protections against using the wrong version of FRAME
-
-Revision 1.9  1999/10/15 15:35:19  fca
-New version for frame1099 with and without holes
-
-Revision 1.9  1999/09/29 09:24:33  fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -112,34 +41,34 @@ Introduction of the Copyright and cvs Log
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <iostream.h>
-#include <strstream.h>
-#include <fstream.h>
+
+#include <Riostream.h>
+#include <Rstrstream.h>
 #include <stdlib.h>
 
+#include <TBRIK.h>
+#include <TFile.h>
+#include <TFolder.h>
+#include <TNode.h>
+#include <TObject.h>
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TTask.h>
+#include <TTree.h>
+#include <TVirtualMC.h>
+
+#include "AliConst.h"
+#include "AliLoader.h"
+#include "AliMagF.h"
+#include "AliRun.h"
 #include "AliTOF.h"
-#include "AliTOFhit.h"
-#include "AliTOFdigit.h"
-#include "AliTOFSDigit.h"
+#include "AliTOFRawDigit.h"
 #include "AliTOFRawSector.h"
 #include "AliTOFRoc.h"
-#include "AliTOFRawDigit.h"
-
-#include "TROOT.h"
-#include "TBRIK.h"
-#include "TNode.h"
-#include "TObject.h"
-#include "TSystem.h"
-#include "TTree.h"
-#include "TFile.h"
-#include "TFolder.h"
-#include "TTask.h"
-
-#include "AliRun.h"
-#include "AliMC.h"
-#include "AliMagF.h"
-#include "AliConst.h"
-
+#include "AliTOFSDigit.h"
+#include "AliTOFdigit.h"
+#include "AliTOFhit.h"
+#include "AliTOFhitT0.h"
  
 ClassImp(AliTOF)
  
@@ -149,22 +78,21 @@ AliTOF::AliTOF()
   //
   // Default constructor
   //
-  fFGeom = 0;
-  fDTask = 0;
-  fReTask = 0;
+  fFGeom = 0x0;
+  fDTask = 0x0;
+  fReTask = 0x0;
   fIshunt   = 0;
   fSDigits       = 0 ;
+  fNSDigits = 0;
   fDigits        = 0 ;
-  fReconParticles = 0;
+  fReconParticles = 0x0;
   fName="TOF";
-  fMerger = 0;
-/* fp
-  CreateTOFFolders();
-*/
+  fMerger = 0x0;
+  fTZero = kFALSE;
 }
  
 //_____________________________________________________________________________
-AliTOF::AliTOF(const char *name, const char *title)
+AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
        : AliDetector(name,title)
 {
   //
@@ -174,12 +102,39 @@ AliTOF::AliTOF(const char *name, const char *title)
   //
 
   // Initialization of hits, sdigits and digits array
-  //
-  fHits   = new TClonesArray("AliTOFhit",  1000);
-  gAlice->AddHitList(fHits);
+  // added option for time zero analysis
+  fFGeom = 0x0; //skowron
+  fDTask = 0x0;
+  fReTask= 0x0;
+  fReconParticles= 0x0;
+  fMerger = 0x0;
+
+  if (strstr(option,"tzero")){
+    fHits   = new TClonesArray("AliTOFhitT0",  1000);
+    fTZero = kTRUE;
+    cout << "tzero option requires AliTOFv4T0 as TOF version (check Your Config.C)" << endl;
+  }else{
+    fHits   = new TClonesArray("AliTOFhit",  1000);
+    fTZero = kFALSE;
+  }
+  if (gAlice==0) {
+     Fatal("AliTOF","gAlice==0 !");
+  }
+  if (gAlice->GetHitLists())
+     gAlice->AddHitList(fHits);
+  else Error("AliTOF","gAlice->GetHitLists()==0");
+
   fIshunt  = 0;
   fSDigits       = new TClonesArray("AliTOFSDigit",  1000);
   fDigits        = new TClonesArray("AliTOFdigit",  1000);
+  fNSDigits = 0;
+
+  fFGeom = 0x0;
+  fDTask = 0x0;
+  fReTask = 0x0;
+  fReconParticles = 0x0;
+  fMerger = 0x0;
+
   //
   // Digitization parameters
   //
@@ -229,10 +184,7 @@ AliTOF::AliTOF(const char *name, const char *title)
                       // (TARODA)
   fNTdc       = 32;   // number of Tdc (Time to Digital Converter)
   fNPadXRoc   = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
-  /* fp 25 Sept 2001
-  // Create TOF Folder Structure
-  CreateTOFFolders();
-  */ 
+  
 }
 
 //_____________________________________________________________________________
@@ -305,7 +257,7 @@ AliTOF::~AliTOF()
     }
   if (fSDigits)
     {
-      fSDigits->Delete ();
+      fSDigits->Delete();
       delete fSDigits;
       fSDigits = 0;
     }
@@ -328,7 +280,18 @@ void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
   TClonesArray &lhits = *fHits;
   new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
 }
+
+//_____________________________________________________________________________
+void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
+{
+  //
+  // Add a TOF hit
+  // new with placement used
+  //
+  TClonesArray &lhits = *fHits;
+  new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
+}
+
 //_____________________________________________________________________________
 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
 {
@@ -357,36 +320,46 @@ void AliTOF::SetTreeAddress ()
 {
   // Set branch address for the Hits and Digits Tree.
   char branchname[30];
+  
+  if (fLoader->TreeH())
+   {
+     if (fHits == 0x0)
+      {
+        if (fTZero) fHits   = new TClonesArray("AliTOFhitT0", 1000);
+        else fHits   = new TClonesArray("AliTOFhit", 1000);
+      }
+   }
   AliDetector::SetTreeAddress ();
 
   TBranch *branch;
-  TTree *treeD = gAlice->TreeD ();
-
+  TTree *treeD = fLoader->TreeD();
 
   if (treeD)
     {
-      if (fDigits)
-       {
-         branch = treeD->GetBranch (branchname);
-         if (branch)
-           branch->SetAddress (&fDigits);
-       }
-
+      branch = treeD->GetBranch (branchname);
+      if (branch)
+       {
+         if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit",  1000); 
+         branch->SetAddress (&fDigits);
+       }
     }
-//  if (fSDigits)
-    //  fSDigits->Clear ();
 
-  if (gAlice->TreeS () && fSDigits)
+  if (fLoader->TreeS () )
     {
-      branch = gAlice->TreeS ()->GetBranch ("TOF");
-      if (branch)
-       branch->SetAddress (&fSDigits);
+      branch = fLoader->TreeS ()->GetBranch ("TOF");
+      if (branch) {
+        if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit",  1000);
+        branch->SetAddress (&fSDigits);
+      }
     }
 
-  if (gAlice->TreeR() && fReconParticles) 
+  if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
     {
-      branch = gAlice->TreeR()->GetBranch("TOF"); 
-      if (branch) branch->SetAddress(&fReconParticles) ;
+      branch = fLoader->TreeR()->GetBranch("TOF"); 
+      if (branch) 
+       {
+         branch->SetAddress(&fReconParticles) ;
+       }
     }   
 }
 
@@ -458,20 +431,21 @@ void AliTOF::CreateMaterials()
 {
   //
   // Defines TOF materials for all versions
-  // Authors :   Maxim Martemianov, Boris Zagreev (ITEP) 
-  //            18/09/98 
-  // Revision: F. Pierella 5-3-2001
-  // Bologna University
+  // Revision: F. Pierella 18-VI-2002
   //
+
   Int_t   isxfld = gAlice->Field()->Integ();
   Float_t sxmgmx = gAlice->Field()->Max();
   //
-  //--- Quartz (SiO2) 
+  //--- Quartz (SiO2) to simulate float glass
+  //    density tuned to have correct float glass 
+  //    radiation length
   Float_t   aq[2] = { 28.0855,15.9994 };
   Float_t   zq[2] = { 14.,8. };
   Float_t   wq[2] = { 1.,2. };
-  Float_t   dq = 2.20;
+  Float_t   dq = 2.55; // std value: 2.2
   Int_t nq = -2;
+
   // --- Freon C2F4H2 (TOF-TDR pagg.)
   // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
   Float_t afre[3]  = {12.011,18.998,1.007};
@@ -518,12 +492,14 @@ void AliTOF::CreateMaterials()
   Float_t wmatg10[4] = { .259,.288,.248,.205 };
   Float_t densg10  = 1.7;
   Int_t nlmatg10 = -4;
-  // --- DME 
-  Float_t adme[5] = { 12.,1.,16.,19.,79. };
-  Float_t zdme[5] = {  6.,1., 8., 9.,35. };
-  Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
-  Float_t densdme  = .00205;
-  Int_t nlmatdme = 5;
+
+  // plexiglass CH2=C(CH3)CO2CH3
+  Float_t aplex[3] = { 12.,1.,16.};
+  Float_t zplex[3] = {  6.,1., 8.};
+  Float_t wmatplex[3] = {5.,8.,2.};
+  Float_t densplex  =1.16;
+  Int_t nplex = -3;
+
   // ---- ALUMINA (AL203) 
   Float_t aal[2] = { 27.,16.};
   Float_t zal[2] = { 13., 8.};
@@ -536,6 +512,12 @@ void AliTOF::CreateMaterials()
   Float_t wwa[2] = {  2.,  1. };
   Float_t dwa    = 1.0;
   Int_t nwa = -2;
+
+// stainless steel
+  Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
+  Float_t zsteel[4] = { 26.,24.,28.,14. };
+  Float_t wsteel[4] = { .715,.18,.1,.005 };
+
   //
   //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
   AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
@@ -543,15 +525,16 @@ void AliTOF::CreateMaterials()
   AliMaterial( 3, "C  $",  12.01,  6.0, 2.265,18.8, 74.4);
   AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
   AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
-  AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
+  AliMixture ( 6, "PLE$", aplex, zplex, densplex, nplex, wmatplex);
   AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
   AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
   AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
   AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
   AliMixture (11, "Mylar$",  amy, zmy, dmy, nmy, wmy);
   AliMixture (12, "Freon$",  afre, zfre, densfre, nfre, wfre);
-  AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
+  AliMixture (13, "Glass$", aq, zq, dq, nq, wq);
   AliMixture (14, "Water$",  awa, zwa, dwa, nwa, wwa);
+  AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
 
   Float_t epsil, stmin, deemax, stemax;
  
@@ -572,7 +555,7 @@ void AliTOF::CreateMaterials()
   AliMedium( 3, "C  $"  ,  3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
   AliMedium( 4, "Pol$"  ,  4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
   AliMedium( 5, "G10$"  ,  5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
-  AliMedium( 6, "DME$"  ,  6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
+  AliMedium( 6, "PLE$"  ,  6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
   AliMedium( 7, "CO2$"  ,  7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
   AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
   AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
@@ -583,6 +566,7 @@ void AliTOF::CreateMaterials()
   AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
   AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
   AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
+  AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
 }
 
 //_____________________________________________________________________________
@@ -621,7 +605,7 @@ void AliTOF::Init()
 }
 
 //____________________________________________________________________________
-void AliTOF::MakeBranch(Option_t* option, const char *file)
+void AliTOF::MakeBranch(Option_t* option)
 {
  //
  // Initializes the Branches of the TOF inside the 
@@ -630,7 +614,17 @@ void AliTOF::MakeBranch(Option_t* option, const char *file)
  // Branch inside TreeH. Here we add the branches in 
  // TreeD, TreeS and TreeR.
  //
-  AliDetector::MakeBranch(option,file);
+  const char *oH = strstr(option,"H");
+  if (fLoader->TreeH() && oH)
+   {
+     if (fHits == 0x0)
+      {
+        if (fTZero) fHits   = new TClonesArray("AliTOFhitT0", 1000);
+        else fHits   = new TClonesArray("AliTOFhit", 1000);
+      }
+   }
+  
+  AliDetector::MakeBranch(option);
 
   Int_t buffersize = 4000;
   Char_t branchname[10];
@@ -640,39 +634,19 @@ void AliTOF::MakeBranch(Option_t* option, const char *file)
   const char *oS = strstr(option,"S");
   const char *oR = strstr(option,"R");
 
-  if (oD)
-  //
-  // one branch for TOF digits
-  // 
-
-
-  if (fDigits && gAlice->TreeD() && oD){
-             MakeBranchInTree(gAlice->TreeD(), 
-                              branchname, &fDigits,buffersize, file) ;
+  if (fLoader->TreeD() && oD){
+    if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit",  1000); 
+    MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
   }
 
-  if (oS)
-  //
-  // one branch for TOF sdigits
-  //
-
-
-  if (fSDigits && gAlice->TreeS() && oS){
-             MakeBranchInTree(gAlice->TreeS(),
-                              branchname, &fSDigits,buffersize, file) ;
+  if (fLoader->TreeS() && oS){
+    if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit",  1000);
+    MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
   }
 
-  if (oR)
-  //
-  // one branch for TOF reconstructed particles
-  //
-
-
-  if (fReconParticles && gAlice->TreeR() && oR){
-             MakeBranchInTree(gAlice->TreeR(),
-                              branchname, &fReconParticles,buffersize, file) ;
+  if (fReconParticles && fLoader->TreeR() && oR){
+    MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
   }
-
 }
 
 //____________________________________________________________________________
@@ -747,9 +721,9 @@ void AliTOF::Hits2SDigits()
   cout<<"ALiTOF::Hits2SDigits> start...\n";
   //#endif
   
-  char * fileSDigits = 0 ;
+  //char * fileSDigits = 0 ;
   char * fileHeader = 0;
-  AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
+  AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader) ;
 
   sd->Exec("") ;
   sd->Print("");
@@ -925,7 +899,7 @@ void AliTOF::Raw2Digits(Int_t evNumber)
           if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
           if (nStrip<=fNStripC+fNStripB+fNStripA)   nPlate = 3;
           if (nStrip<=fNStripC+fNStripB)            nPlate = 2;
-          if (nStrip<=fNStripC)                     nPlate=1;
+          if (nStrip<=fNStripC)                     nPlate = 1;
           vol[1] = nPlate;
           switch (nPlate){
           case 1: break;
@@ -958,3 +932,20 @@ void AliTOF::Raw2Digits(Int_t evNumber)
   tD->Write(0,TObject::kOverwrite);
 } 
 
+////////////////////////////////////////////////////////////////////////
+void AliTOF::RecreateSDigitsArray() {
+//
+// delete TClonesArray fSDigits and create it again
+//  needed for backward compatability with PPR test production
+//
+  delete fSDigits;
+  fSDigits       = new TClonesArray("AliTOFSDigit",  1000);
+}
+////////////////////////////////////////////////////////////////////////
+void AliTOF::CreateSDigitsArray() {
+//
+// create TClonesArray fSDigits
+//  needed for backward compatability with PPR test production
+//
+  fSDigits       = new TClonesArray("AliTOFSDigit",  1000);
+}