]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Improving TClonesArray handling - using TClonesArray::Clear() instead of
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Apr 2008 15:06:07 +0000 (15:06 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Apr 2008 15:06:07 +0000 (15:06 +0000)
deleting and using static TClonesArray instances.

TOF/AliTOFClusterFinder.cxx
TOF/AliTOFDigitizer.cxx
TOF/AliTOFQADataMakerSim.cxx
TOF/AliTOFReconstructor.cxx

index bf2947c47740a8e95d78755e38f7bb5187e9812a..75c8f50e0a4bbb90a51bfd49cec55d451489478a 100644 (file)
@@ -250,7 +250,9 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
     return;
   }
 
-  TClonesArray *digits = new TClonesArray("AliTOFdigit",10000);
+  TClonesArray staticdigits("AliTOFdigit",10000);
+  staticdigits.Clear();
+  TClonesArray *digits =&staticdigits;
   branch->SetAddress(&digits);
 
   ResetRecpoint();
@@ -311,8 +313,6 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
   AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
               stopwatch.RealTime(),stopwatch.CpuTime()));
 
-  digits->Delete();
-  delete digits;
 }
 
 //______________________________________________________________________________
@@ -339,7 +339,9 @@ void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree
     return;
   }
 
-  TClonesArray *digits = new TClonesArray("AliTOFdigit",10000);
+  TClonesArray staticdigits("AliTOFdigit",10000);
+  staticdigits.Clear();
+  TClonesArray *digits = & staticdigits;
   branch->SetAddress(&digits);
 
   ResetRecpoint();
@@ -392,8 +394,6 @@ void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree
   AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
               stopwatch.RealTime(),stopwatch.CpuTime()));
 
-  digits->Delete();
-  delete digits;
 }
 //______________________________________________________________________________
 
index bd7f394554afe0f2ca02d8ace15f5a9177f21233..4491819fcfd35a72dc2c25e832f2a38a6a3b6c6a 100644 (file)
@@ -61,8 +61,8 @@ ClassImp(AliTOFDigitizer)
 //___________________________________________
   AliTOFDigitizer::AliTOFDigitizer()  :
     AliDigitizer(),
-    fDigits(0x0),
-    fSDigitsArray(0x0),
+    fDigits(new TClonesArray("AliTOFdigit",4000)),
+    fSDigitsArray(new TClonesArray("AliTOFSDigit",1000)),
   fhitMap(0x0),
   fCalib(new AliTOFcalib())
 {
@@ -73,8 +73,8 @@ ClassImp(AliTOFDigitizer)
 //___________________________________________
 AliTOFDigitizer::AliTOFDigitizer(AliRunDigitizer* manager): 
   AliDigitizer(manager), 
-  fDigits(0x0),
-  fSDigitsArray(0x0),
+  fDigits(new TClonesArray("AliTOFdigit",4000)),
+  fSDigitsArray(new TClonesArray("AliTOFSDigit",1000)),
   fhitMap(0x0),
   fCalib(new AliTOFcalib())
 {
@@ -110,6 +110,16 @@ AliTOFDigitizer::~AliTOFDigitizer()
 {
   // Destructor
   delete fCalib;
+  if (fDigits){
+    fDigits->Delete();
+    delete fDigits;
+    fDigits=0x0;
+  }
+  if (fSDigitsArray){
+    fSDigitsArray->Delete();
+    delete fSDigitsArray;
+    fSDigitsArray=0x0;
+  }
 }
 
 //---------------------------------------------------------------------
@@ -135,8 +145,6 @@ void AliTOFDigitizer::Exec(Option_t* /*option*/)
   //Make branches
   char branchname[20];
   sprintf (branchname, "%s", tof->GetName ());
-
-  fDigits=new TClonesArray("AliTOFdigit",4000);
  
   AliRunLoader* outrl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
   if (outrl == 0x0)
@@ -205,8 +213,7 @@ void AliTOFDigitizer::Exec(Option_t* /*option*/)
  
   outgime->WriteDigits("OVERWRITE");
   outgime->UnloadDigits();
-  fDigits->Delete();
-  delete fDigits;
+  fDigits->Clear();
 
 }
 
@@ -301,6 +308,10 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile )
   // SDigits from different files are assumed to
   // be created with the same simulation parameters.
   
+  // creating the TClonesArray to store the digits
+  static TClonesArray sdigitsClonesArray("AliTOFSDigit",  1000); 
+  sdigitsClonesArray.Clear();
+
   // get the treeS from manager
   AliRunLoader* rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
   if (rl == 0x0)
@@ -333,8 +344,7 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile )
       }
    } 
   // get the branch TOF inside the treeS
-  TClonesArray * sdigitsDummyContainer= new TClonesArray("AliTOFSDigit",  1000); 
-
+  TClonesArray * sdigitsDummyContainer=&sdigitsClonesArray;
   // check if the branch exist
   TBranch* tofBranch=currentTreeS->GetBranch("TOF");
 
@@ -382,12 +392,9 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile )
       } // if (hitMap->TestHit(vol) != kEmpty)
       
     } // for (Int_t k=0; k<ndig; k++)
-    sdigitsDummyContainer->Delete();
 
   } // end loop on entries
 
-  delete sdigitsDummyContainer;
-
 }
 
 
index 772d374686244e20278d8f4fc8d4905fd0d924e8..84f54a639f31074eed9d259a8177cedc8bbc351f 100644 (file)
@@ -190,8 +190,12 @@ void AliTOFQADataMakerSim::MakeHits(TTree * hitTree)
     return;
   }
 
-  TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
-  TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
+  static TClonesArray statichits("AliTOFhitT0", 1000);
+  statichits.Clear();
+  TClonesArray *hits = &statichits;
+  static TClonesArray staticdummy("AliTOFhitT0", 1000);
+  staticdummy.Clear();
+  TClonesArray *dummy = &staticdummy;
   branch->SetAddress(&dummy);
   Int_t index = 0 ;  
   for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
@@ -203,8 +207,6 @@ void AliTOFQADataMakerSim::MakeHits(TTree * hitTree)
     } 
   }    
 
-  dummy->Delete();
-  delete dummy;
   MakeHits(hits) ; 
 
 }
index e4669690251d182a4792e67ab358252cea9b02c1..3ab262005abd2e9e59e2169acaedfdb18e22469e 100644 (file)
@@ -97,7 +97,7 @@ void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
 {
 // reconstruct clusters from Raw Data
 
-  AliTOFClusterFinder tofClus(fTOFcalib);
+  static AliTOFClusterFinder tofClus(fTOFcalib);
   tofClus.Digits2RecPoints(rawReader, clustersTree);
 
 }
@@ -109,7 +109,7 @@ void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
 // reconstruct clusters from Raw Data
 
   AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree")); 
-  AliTOFClusterFinder tofClus(fTOFcalib);
+  static AliTOFClusterFinder tofClus(fTOFcalib);
   tofClus.Digits2RecPoints(digitsTree, clustersTree);
 
 }