]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOF.cxx
Modifications to ITS standalone tracker: 1) improve efficiency at low pt for p-p...
[u/mrichter/AliRoot.git] / TOF / AliTOF.cxx
index 93556eb6d41491dc6675f3abe3aff4d7fdc30046..1e3ca5133870550f58465b09d50455045fe7c521 100644 (file)
@@ -12,7 +12,6 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 */
 //End_Html
 
-
-
-#include <Riostream.h>
-#include <Rstrstream.h>
-#include <stdlib.h>
-
-#include <TBRIK.h>
+#include <TClonesArray.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 <TDirectory.h>
+#include <TStopwatch.h>
 
-#include "AliLog.h"
-#include "AliConfig.h"
-#include "AliHeader.h"
 #include "AliConst.h"
 #include "AliLoader.h"
-#include "AliMagF.h"
+#include "AliLog.h"
+#include "AliMC.h"
 #include "AliRun.h"
-#include "AliTOF.h"
-#include "AliTOFGeometry.h"
-#include "AliTOFGeometryV4.h"
-#include "AliTOFGeometryV5.h"
-#include "AliTOFSDigit.h"
+
+#include "AliTOFDDLRawData.h"
+#include "AliTOFDigitizer.h"
 #include "AliTOFdigit.h"
-#include "AliTOFhit.h"
 #include "AliTOFhitT0.h"
-#include "AliMC.h"
-#include "AliTOFDigitizer.h"
-#include "AliTOFDDLRawData.h"
-#include "AliTOFcluster.h"
+#include "AliTOFhit.h"
+#include "AliTOFGeometry.h"
+#include "AliTOFSDigitizer.h"
+#include "AliTOFSDigit.h"
+#include "AliTOF.h"
+
+class AliTOFcluster;
+
+extern TFile *gFile;
+extern TROOT *gROOT;
+extern TVirtualMC *gMC;
+
+extern AliRun *gAlice;
+
 ClassImp(AliTOF)
+
 //_____________________________________________________________________________
-AliTOF::AliTOF()
+AliTOF::AliTOF():
+  fFGeom(0x0),
+  fDTask(0x0),
+  fReTask(0x0),
+  fSDigits(0x0),
+  fNSDigits(0),
+  fReconParticles(0x0),
+  fIdSens(-1),
+  fTZero(kFALSE),
+  fTOFHoles(kTRUE),
+  fTOFGeometry(0x0)
 {
   //
   // Default constructor
   //
-  fFGeom  = 0x0;
-  fDTask  = 0x0;
-  fReTask = 0x0;
+
+  //by default all sectors switched on
+  for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0;
+
+  fDigits = 0;
   fIshunt   = 0;
-  fSDigits  = 0 ;
-  fNSDigits = 0;
-  fDigits   = 0 ;
-  fReconParticles = 0x0;
-  fName="TOF";
-  fTZero  = kFALSE;
-  fTOFGeometry = 0;
+  fName = "TOF";
+
 }
  
 //_____________________________________________________________________________
 AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
-       : AliDetector(name,title)
+       : 
+  AliDetector(name,title),
+  fFGeom(0x0),
+  fDTask(0x0),
+  fReTask(0x0),
+  fSDigits(0x0),
+  fNSDigits(0),
+  fReconParticles(0x0),
+  fIdSens(-1),
+  fTZero(kFALSE),
+  fTOFHoles(kTRUE),
+  fTOFGeometry(0x0)
 {
   //
   // AliTOF standard constructor
@@ -110,16 +122,16 @@ AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
 
   // Initialization of hits, sdigits and digits array
   // added option for time zero analysis
-  fFGeom  = 0x0; //skowron
-  fDTask  = 0x0;
-  fReTask = 0x0;
-  fReconParticles= 0x0;
+  //skowron
   fTOFGeometry = new AliTOFGeometry();
 
+  //by default all sectors switched on
+  for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0;
+
   if (strstr(option,"tzero")){
     fHits   = new TClonesArray("AliTOFhitT0",  1000);
     fTZero = kTRUE;
-    AliWarning("tzero option requires AliTOFv4T0/AliTOFv5T0 as TOF version (check Your Config.C)");
+    //    AliWarning("tzero option requires AliTOFv4T0/AliTOFv5T0 as TOF version (check Your Config.C)");
   }else{
     fHits   = new TClonesArray("AliTOFhit",  1000);
     fTZero = kFALSE;
@@ -127,28 +139,25 @@ AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
   if (gAlice==0) {
      AliFatal("gAlice==0 !");
   }
-  if (gAlice->GetMCApp()->GetHitLists())
-     gAlice->GetMCApp()->AddHitList(fHits);
+
+  AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
+
+  if (mcApplication->GetHitLists())
+     mcApplication->AddHitList(fHits);
   else AliError("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;
 
   //
   // Digitization parameters
   //
   // (Transfer Functions to be inserted here)
   //
-  SetMarkerColor(7);
-  SetMarkerStyle(2);
-  SetMarkerSize(0.4);
+  //PH  SetMarkerColor(7);
+  //PH  SetMarkerStyle(2);
+  //PH  SetMarkerSize(0.4);
 
 // Strip Parameters
   //fGapA    =   4.; //cm  Gap beetween tilted strip in A-type plate
@@ -160,6 +169,25 @@ AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
 
 }
 
+//____________________________________________________________________________
+void AliTOF::SetTOFSectors(Int_t *sectors)
+{
+  // Setter for partial/full TOF configuration
+
+  for(Int_t isec=0;isec<18;isec++){
+    fTOFSectors[isec]=sectors[isec];
+  }
+}
+//____________________________________________________________________________
+void AliTOF::GetTOFSectors(Int_t *sectors) const
+{
+  // Getter for partial/full TOF configuration
+
+  for(Int_t isec=0;isec<18;isec++){
+    sectors[isec]=fTOFSectors[isec];
+  }
+}
+
 //_____________________________________________________________________________
 void AliTOF::CreateTOFFolders()
 {
@@ -267,7 +295,7 @@ void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
 }
 
 //_____________________________________________________________________________
-void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
+void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Int_t *digits)
 {
   //
   // Add a TOF digit
@@ -278,7 +306,7 @@ void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
 }
 
 //_____________________________________________________________________________
-void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
+void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Int_t *digits)
 {
      
 //
@@ -352,9 +380,18 @@ void AliTOF::CreateGeometry()
 
   Float_t xTof, yTof;
 
-  if (IsVersion()==7) {
+  if (IsVersion()==8) {
 
-    xTof = fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm,  x-dimension of FTOA volume
+    xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm,  x-dimension of FTOA volume
+    yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm,  y-dimension of FTOA volume
+    Float_t zTof = fTOFGeometry->ZlenA();             // cm,  z-dimension of FTOA volume
+    
+    //  TOF module internal definitions
+    TOFpc(xTof, yTof, zTof);
+
+  } else if (IsVersion()==7) {
+
+    xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm,  x-dimension of FTOA volume
     yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm,  y-dimension of FTOA volume
     Float_t zTof = fTOFGeometry->ZlenA();             // cm,  z-dimension of FTOA volume
     
@@ -410,15 +447,6 @@ void AliTOF::DrawModule() const
   gMC->Gdopt("hide","off");
 }
 
-//_____________________________________________________________________________
-Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t )
-{
-  //
-  // Returns distance from mouse pointer to detector, default version
-  //
-  return 9999;
-}
-
 //___________________________________________
 void AliTOF::ResetHits ()
 {
@@ -455,7 +483,7 @@ void AliTOF::Init()
   /*
   // Save the geometry
   TDirectory* saveDir = gDirectory;
-  gAlice->GetRunLoader()->CdGAFile();
+  AliRunLoader::Instance()->CdGAFile();
   fTOFGeometry->Write("TOFGeometry");
   saveDir->cd();
   */
@@ -541,7 +569,7 @@ void AliTOF::Hits2SDigits()
 // Use the TOF SDigitizer to make TOF SDigits
 //
 
-//  cout<<"AliTOF::Hits2SDigits> start...\n";
+//  AliInfo("Start...");
   
   AliRunLoader * rl = fLoader->GetRunLoader();
   AliTOFSDigitizer sd((rl->GetFileName()).Data());
@@ -559,10 +587,9 @@ void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2)
 //
 
   if ((evNumber2-evNumber1)==1) 
-      AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1))
-  else if ((evNumber2-evNumber1)>1)
-      AliDebug(1, Form("I am making sdigits for the events from the " 
-                      "%dth to the %dth", evNumber1, evNumber2-1));
+    AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1));
+  if ((evNumber2-evNumber1)>1)
+    AliDebug(1, Form("I am making sdigits for the events from the %dth to the %dth", evNumber1, evNumber2-1));
  
   AliRunLoader * rl = fLoader->GetRunLoader();
   AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
@@ -579,7 +606,7 @@ AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
 }
 
 //___________________________________________________________________________
-Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
+Bool_t AliTOF::CheckOverlap(Int_t* vol, Int_t* digit,Int_t Track)
 {
 //
 // Checks if 2 or more hits belong to the same pad.
@@ -603,8 +630,8 @@ Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
       if (vol[i]!=vol2[i]) idem=kFALSE;}
 
     if (idem){  // same pad fired
-      Float_t tdc2 = digit[0];
-      Float_t tdc1 = currentDigit->GetTdc();
+      Int_t tdc2 = digit[0];
+      Int_t tdc1 = currentDigit->GetTdc();
 
       // we separate two digits on the same pad if
       // they are separated in time by at least 25 ns
@@ -624,7 +651,7 @@ Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
        overlap = kTRUE;
        return overlap;
       } else 
-               overlap= kFALSE;
+       overlap= kFALSE;
 
     } // close if (idem) -> two digits on the same TOF pad
 
@@ -639,6 +666,9 @@ void AliTOF::Digits2Raw()
 // Starting from the TOF digits, writes the Raw Data objects
 //
 
+  TStopwatch stopwatch;
+  stopwatch.Start();
+
   fLoader->LoadDigits();
 
   TTree* digits = fLoader->TreeD();
@@ -647,22 +677,23 @@ void AliTOF::Digits2Raw()
     return;
   }
   
-  //AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
-  fRunLoader->CdGAFile();
-  TFile *in=(TFile*)gFile;
-  in->cd();
-  AliTOFGeometry *geometry  = (AliTOFGeometry*)in->Get("TOFgeometry");
-
-  AliTOFDDLRawData rawWriter(geometry);
-  //AliTOFDDLRawData rawWriter;
+  AliTOFDDLRawData rawWriter;
   rawWriter.SetVerbose(0);
+  if (rawWriter.GetPackedAcquisitionMode()) {
+    if(rawWriter.GetMatchingWindow()>8192)
+      AliWarning(Form("You are running in packing mode and the matching window is %.2f ns, i.e. greater than 199.8848 ns",
+                     rawWriter.GetMatchingWindow()*AliTOFGeometry::TdcBinWidth()*1.e-03));
+  }
   
-  AliInfo("Formatting raw data for TOF");
+  AliDebug(1,"Formatting raw data for TOF");
   digits->GetEvent(0);
   rawWriter.RawDataTOF(digits->GetBranch("TOF"));  
 
   fLoader->UnloadDigits();
   
+  AliDebug(1, Form("Execution time to write TOF raw data : R:%.2fs C:%.2fs",
+                  stopwatch.RealTime(),stopwatch.CpuTime()));
+
 }
 
 //____________________________________________________________________________
@@ -671,8 +702,7 @@ 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);
+  fSDigits->Clear();
 }
 //____________________________________________________________________________
 void AliTOF::CreateSDigitsArray() {