]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MFT/AliMFTClusterFinder.cxx
Reverting previous commit and going back to rev.64119Subversion Repositories:
[u/mrichter/AliRoot.git] / MFT / AliMFTClusterFinder.cxx
index ca22b2e87e180c04699df103eaf6b9f1758784b9..11ecb667283e9f7a23d05ff31a9c86ea6c1da4fc 100644 (file)
@@ -53,24 +53,45 @@ AliMFTClusterFinder::AliMFTClusterFinder() :
   
   for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) fClustersPerPlane[iPlane] = NULL;
   fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
+  fDigitsInCluster -> SetOwner(kTRUE);
 
 }
 
 //====================================================================================================================================================
 
 AliMFTClusterFinder::~AliMFTClusterFinder() {
-
+  
   AliDebug(1, "Deleting AliMFTClusterFinder...");
+  
+  for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) {
+    if (fClustersPerPlane[iPlane]) fClustersPerPlane[iPlane]->Delete(); delete fClustersPerPlane[iPlane]; fClustersPerPlane[iPlane] = 0x0;
+  }
+  if (fDigitsInCluster) fDigitsInCluster->Delete(); delete fDigitsInCluster; fDigitsInCluster = NULL;
+  delete fSegmentation; fSegmentation=NULL;
+  
+  AliDebug(1, "... done!");
+  
+}
 
-  for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) delete fClustersPerPlane[iPlane];
+//====================================================================================================================================================
 
+void AliMFTClusterFinder::Clear(const Option_t* /*opt*/) {
+  
+  AliDebug(1, "Clearing AliMFTClusterFinder...");
+  
+  for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) {
+    if(fClustersPerPlane[iPlane]) fClustersPerPlane[iPlane]->Clear("C"); 
+  }
+  if(fDigitsInCluster) fDigitsInCluster->Clear("C");   
+  fSegmentation->Clear("C"); 
+  
   AliDebug(1, "... done!");
-
+  
 }
 
 //====================================================================================================================================================
 
-void AliMFTClusterFinder::Init(Char_t *nameGeomFile) {
+void AliMFTClusterFinder::Init(const Char_t *nameGeomFile) {
 
   fSegmentation = new AliMFTSegmentation(nameGeomFile);
   fNPlanes = fSegmentation -> GetNPlanes();
@@ -86,7 +107,7 @@ void AliMFTClusterFinder::StartEvent() {
   AliDebug(1, "Starting Event...");
   
   for (Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
-    fClustersPerPlane[iPlane]->Clear();
+    fClustersPerPlane[iPlane]->Delete();
   }
 
   AliDebug(1, "... done!");
@@ -105,11 +126,13 @@ void AliMFTClusterFinder::DigitsToClusters(const TObjArray *pDigitList) {
   StartEvent(); 
   Bool_t isDigAvailableForNewCluster = kTRUE;
   
+  TClonesArray *myDigitList = 0;
+
   for (Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
 
     AliDebug(1, Form("Plane %02d", iPlane));
 
-    TClonesArray *myDigitList = (TClonesArray*) pDigitList->At(iPlane);
+    myDigitList = (TClonesArray*) pDigitList->At(iPlane);
 
     AliDebug(1, Form("myDigitList->GetEntries() = %d", myDigitList->GetEntries()));
 
@@ -146,6 +169,7 @@ void AliMFTClusterFinder::DigitsToClusters(const TObjArray *pDigitList) {
          myDigitList->Compress();
          iDig--;
          new ((*fClustersPerPlane[iPlane])[fClustersPerPlane[iPlane]->GetEntries()]) AliMFTCluster(*newCluster);
+               delete newCluster;
        }
 
       }   // end of cycle over the digits
@@ -162,6 +186,8 @@ void AliMFTClusterFinder::DigitsToClusters(const TObjArray *pDigitList) {
 
     AliDebug(1, Form("Found %d clusters in plane %02d", fClustersPerPlane[iPlane]->GetEntries(), iPlane));
 
+    myDigitList -> Delete();
+
   }  // end of cycle over the planes
 
 }
@@ -179,10 +205,9 @@ void AliMFTClusterFinder::MakeClusterBranch(TTree *treeCluster) {
   if (treeCluster) {
     for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
       AliDebug(1, Form("Setting Branch Plane_%02d for treeCluster",iPlane));
-      TBranch *branch = treeCluster->GetBranch(Form("Plane_%02d",iPlane));
-      if (branch) continue;
+      if (treeCluster->GetBranch(Form("Plane_%02d",iPlane))) continue;
       AliDebug(1, Form("Branch Plane_%02d does not exist, creating!",iPlane));
-      branch = treeCluster->Branch(Form("Plane_%02d",iPlane), &(fClustersPerPlane[iPlane])); 
+      treeCluster->Branch(Form("Plane_%02d",iPlane), &(fClustersPerPlane[iPlane])); 
     }
   }
 
@@ -219,6 +244,8 @@ void AliMFTClusterFinder::CreateClusters() {
   for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
     AliDebug(1, Form("plane %02d", iPlane));
     fClustersPerPlane[iPlane] = new TClonesArray("AliMFTCluster");
+    fClustersPerPlane[iPlane] -> SetOwner(kTRUE);
+
   }
 
 }