]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPC.cxx
Corrections to avoid reading outside clusters array
[u/mrichter/AliRoot.git] / TPC / AliTPC.cxx
index a26ea93d8fc92095ccbba611e3749d41287f559f..99a2e1ca9d583eb681a274a88fb50f0d7dde158c 100644 (file)
@@ -53,6 +53,7 @@
 #include <TVirtualMC.h>
 #include <TString.h>
 #include <TF2.h>
+#include <TStopwatch.h>
 
 #include "AliArrayBranch.h"
 #include "AliClusters.h"
@@ -78,6 +79,8 @@
 #include "AliTrackReference.h"
 #include "AliMC.h"
 #include "AliTPCDigitizer.h"
+#include "AliTPCBuffer.h"
+#include "AliTPCDDLRawData.h"
 #include "AliTPCclustererMI.h"
 #include "AliTPCtrackerMI.h"
 #include "AliTPCpidESD.h"
@@ -336,64 +339,6 @@ void AliTPC::Clusters2Tracks() const
  }
 
 
-//_____________________________________________________________________________
-void AliTPC::Reconstruct() const
-{
-// reconstruct clusters
-
-  AliLoader* loader = GetLoader();
-  loader->LoadRecPoints("recreate");
-  loader->LoadDigits("read");
-
-  AliTPCclustererMI clusterer(fTPCParam);
-  AliRunLoader* runLoader = loader->GetRunLoader();
-  Int_t nEvents = runLoader->GetNumberOfEvents();
-
-  for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
-    runLoader->GetEvent(iEvent);
-
-    TTree* treeClusters = loader->TreeR();
-    if (!treeClusters) {
-      loader->MakeTree("R");
-      treeClusters = loader->TreeR();
-    }
-    TTree* treeDigits = loader->TreeD();
-    if (!treeDigits) {
-      Error("Reconstruct", "Can't get digits tree !");
-      return;
-    }
-
-//    clusterer.Digits2Clusters(treeDigits, treeClusters);
-    clusterer.SetInput(treeDigits);
-    clusterer.SetOutput(treeClusters);
-    clusterer.Digits2Clusters();
-         
-    loader->WriteRecPoints("OVERWRITE");
-  }
-
-  loader->UnloadRecPoints();
-  loader->UnloadDigits();
-}
-
-//_____________________________________________________________________________
-AliTracker* AliTPC::CreateTracker() const
-{
-// create a TPC tracker
-
-  return new AliTPCtrackerMI(fTPCParam);
-}
-
-//_____________________________________________________________________________
-void AliTPC::FillESD(AliESD* esd) const
-{
-// make PID
-
-  Double_t parTPC[] = {47., 0.10, 10.};
-  AliTPCpidESD tpcPID(parTPC);
-  tpcPID.MakePID(esd);
-}
-
-
 //_____________________________________________________________________________
 void AliTPC::CreateMaterials()
 {
@@ -876,7 +821,7 @@ void    AliTPC::SetActiveSectors(Int_t flag)
   else branch = TreeH()->GetBranch("TPC");
   Stat_t ntracks = TreeH()->GetEntries();
   // loop over all hits
-  cout<<"\nAliTPC::SetActiveSectors():  Got "<<ntracks<<" tracks\n";
+  if (GetDebug()) cout<<"\nAliTPC::SetActiveSectors():  Got "<<ntracks<<" tracks\n";
   
   for(Int_t track=0;track<ntracks;track++)
    {
@@ -916,6 +861,107 @@ void AliTPC::Digits2Clusters(Int_t /*eventnumber*/) const
   "Dummy function !  Call AliTPCclusterer::Digits2Clusters(...) instead !");
 }
 
+
+//_____________________________________________________________________________
+void AliTPC::Digits2Raw()
+{
+// convert digits of the current event to raw data
+
+  static const Int_t kThreshold = 0;
+  static const Bool_t kCompress = kTRUE;
+
+  fLoader->LoadDigits();
+  TTree* digits = fLoader->TreeD();
+  if (!digits) {
+    Error("Digits2Raw", "no digits tree");
+    return;
+  }
+
+  AliSimDigits digarr;
+  AliSimDigits* digrow = &digarr;
+  digits->GetBranch("Segment")->SetAddress(&digrow);
+
+  const char* fileName = "AliTPCDDL.dat";
+  AliTPCBuffer* buffer  = new AliTPCBuffer(fileName);
+  //Verbose level
+  // 0: Silent
+  // 1: cout messages
+  // 2: txt files with digits 
+  //BE CAREFUL, verbose level 2 MUST be used only for debugging and
+  //it is highly suggested to use this mode only for debugging digits files
+  //reasonably small, because otherwise the size of the txt files can reach
+  //quickly several MB wasting time and disk space.
+  buffer->SetVerbose(0);
+
+  Int_t nEntries = Int_t(digits->GetEntries());
+  Int_t previousSector = -1;
+  Int_t subSector = 0;
+  for (Int_t i = 0; i < nEntries; i++) {
+    digits->GetEntry(i);
+    Int_t sector, row;
+    fTPCParam->AdjustSectorRow(digarr.GetID(), sector, row);
+    if(previousSector != sector) {
+      subSector = 0;
+      previousSector = sector;
+    }
+
+    if (sector < 36) { //inner sector [0;35]
+      if (row != 30) {
+       //the whole row is written into the output file
+       buffer->WriteRowBinary(kThreshold, digrow, 0, 0, 0, 
+                              sector, subSector, row);
+      } else {
+       //only the pads in the range [37;48] are written into the output file
+       buffer->WriteRowBinary(kThreshold, digrow, 37, 48, 1, 
+                              sector, subSector, row);
+       subSector = 1;
+       //only the pads outside the range [37;48] are written into the output file
+       buffer->WriteRowBinary(kThreshold, digrow, 37, 48, 2, 
+                              sector, subSector, row);
+      }//end else
+
+    } else { //outer sector [36;71]
+      if (row == 54) subSector = 2;
+      if ((row != 27) && (row != 76)) {
+       buffer->WriteRowBinary(kThreshold, digrow, 0, 0, 0,
+                              sector, subSector, row);
+      } else if (row == 27) {
+         //only the pads outside the range [43;46] are written into the output file
+         buffer->WriteRowBinary(kThreshold, digrow, 43, 46, 2,
+                                sector, subSector, row);
+         subSector = 1;
+         //only the pads in the range [43;46] are written into the output file
+         buffer->WriteRowBinary(kThreshold, digrow, 43, 46, 1,
+                                sector, subSector, row);
+      } else if (row == 76) {
+         //only the pads outside the range [33;88] are written into the output file
+         buffer->WriteRowBinary(kThreshold, digrow, 33, 88, 2,
+                                sector, subSector, row);
+         subSector = 3;
+         //only the pads in the range [33;88] are written into the output file
+         buffer->WriteRowBinary(kThreshold, digrow, 33, 88, 1,
+                                sector, subSector, row);
+      }
+    }//end else
+  }//end for
+
+  delete buffer;
+  fLoader->UnloadDigits();
+
+  AliTPCDDLRawData rawWriter;
+  rawWriter.SetVerbose(0);
+
+  rawWriter.RawData(fileName);
+  gSystem->Unlink(fileName);
+
+  if (kCompress) {
+    Info("Digits2Raw", "compressing raw data");
+    rawWriter.RawDataCompDecompress(kTRUE);
+    gSystem->Unlink("Statistics");
+  }
+}
+
+
 extern Double_t SigmaY2(Double_t, Double_t, Double_t);
 extern Double_t SigmaZ2(Double_t, Double_t);
 //_____________________________________________________________________________
@@ -989,7 +1035,7 @@ void AliTPC::Hits2Clusters(Int_t /*eventn*/)
   
   cout<<"fTPCParam->GetTitle() = "<<fTPCParam->GetTitle()<<endl;
   
-  AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::fgkRunLoaderName);
+  AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::GetRunLoaderName());
   rl->CdGAFile();
   //fTPCParam->Write(fTPCParam->GetTitle());
 
@@ -1110,7 +1156,7 @@ void AliTPC::Hits2Clusters(Int_t /*eventn*/)
 
   } // end of loop over sectors  
 
-  cerr<<"Number of made clusters : "<<nclusters<<"                        \n";
+  //  cerr<<"Number of made clusters : "<<nclusters<<"                        \n";
   fLoader->WriteRecPoints("OVERWRITE");
   
   
@@ -1434,12 +1480,12 @@ void AliTPC::SetDefaults(){
   // setting the defaults
   //
    
-   cerr<<"Setting default parameters...\n";
+  //   cerr<<"Setting default parameters...\n";
 
   // Set response functions
 
   //
-  AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::fgkRunLoaderName);
+  AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::GetRunLoaderName());
   rl->CdGAFile();
   AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60");
   if(param){
@@ -1530,7 +1576,7 @@ void AliTPC::Hits2Digits(Int_t eventnumber)
  //----------------------------------------------------
  // Loop over all sectors for a single event
  //----------------------------------------------------
-  AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::fgkRunLoaderName);
+  AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::GetRunLoaderName());
   rl->GetEvent(eventnumber);
   if (fLoader->TreeH() == 0x0)
    {
@@ -1567,7 +1613,7 @@ void AliTPC::Hits2Digits(Int_t eventnumber)
 
   fDigitsSwitch=0; // standard digits
 
-  cerr<<"Digitizing TPC -- normal digits...\n";
+  //  cerr<<"Digitizing TPC -- normal digits...\n";
 
  for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) 
   if (IsSectorActive(isec)) 
@@ -1638,7 +1684,7 @@ void AliTPC::Hits2SDigits2(Int_t eventnumber)
 
   SetDigitsArray(arr);
 
-  cerr<<"Digitizing TPC -- summable digits...\n"; 
+  //  cerr<<"Digitizing TPC -- summable digits...\n"; 
 
   fDigitsSwitch=1; // summable digits