]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPreClusterFinderV3.cxx
bugfix #83123: registration of configurations in multiple handlers. The bug caused...
[u/mrichter/AliRoot.git] / MUON / AliMUONPreClusterFinderV3.cxx
index 400c6fad8cb8278dc7062b2112c89c718fae571a..ccd65a3a86013618c159efad1099799c076429b7 100644 (file)
@@ -20,7 +20,7 @@
 #include "AliLog.h"
 #include "AliMUONCluster.h"
 #include "AliMpVSegmentation.h"
-#include "TClonesArray.h"
+#include "TObjArray.h"
 #include "AliMpArea.h"
 #include "TVector2.h"
 #include "AliMUONPad.h"
@@ -80,15 +80,15 @@ namespace
 AliMUONPreClusterFinderV3::AliMUONPreClusterFinderV3()
 : AliMUONVClusterFinder(),
   fClusters(new TClonesArray("AliMUONCluster",10)),
-  fSegmentations(0x0),
+  fkSegmentations(0x0),
+  fPads(0x0),
   fDetElemId(0),
   fIterator(0x0)
 {
     /// ctor
-    AliInfo("")
+  AliInfo("");
   for ( Int_t i = 0; i < 2; ++i )
   {
-    fPads[i] = new TClonesArray("AliMUONPad",100);
     fPreClusters[i] = new TClonesArray("AliMUONCluster",10);
   } 
 }
@@ -96,12 +96,10 @@ AliMUONPreClusterFinderV3::AliMUONPreClusterFinderV3()
 //_____________________________________________________________________________
 AliMUONPreClusterFinderV3::~AliMUONPreClusterFinderV3()
 {
-  /// dtor : note we're owner of the pads and the clusters, but not of
-  /// the remaining objects (digits, segmentations)
+  /// dtor
   delete fClusters;
   for ( Int_t i = 0; i < 2; ++i )
   {
-    delete fPads[i];
     delete fPreClusters[i];
   } 
 }
@@ -118,61 +116,37 @@ AliMUONPreClusterFinderV3::UsePad(const AliMUONPad& pad)
     return kFALSE;
   }
   
-  AliMUONPad* p = new ((*fPads[pad.Cathode()])[fPads[pad.Cathode()]->GetLast()+1]) AliMUONPad(pad); 
+  AliMUONPad* p = new AliMUONPad(pad); 
   p->SetClusterId(-1);
+  fPads[pad.Cathode()]->Add(p); 
   return kTRUE;
 }
 
 //_____________________________________________________________________________
 Bool_t
-AliMUONPreClusterFinderV3::Prepare(const AliMpVSegmentation* segmentations[2],
-                                 const AliMUONVDigitStore& digitStore)
+AliMUONPreClusterFinderV3::Prepare(Int_t detElemId,
+                                   TObjArray* pads[2],
+                                   const AliMpArea& area,
+                                   const AliMpVSegmentation* seg[2])
 {
   /// Prepare for clustering, by giving access to segmentations and digit lists
-  // FIXME : add area on which to look for clusters here.
   
-  fSegmentations = segmentations;
+  if ( area.IsValid() ) 
+  {
+    AliError("Handling of area not yet implemented for this class. Please check.");
+  }
+  
+  fkSegmentations = seg;
+  fPads = pads;
   
   fClusters->Clear("C");
   for ( Int_t i = 0; i < 2; ++i )
   {
-    fPads[i]->Clear("C");
     fPreClusters[i]->Clear("C");
   }
   
-  fDetElemId = -1;
+  fDetElemId = detElemId;
   
-  TIter next(digitStore.CreateIterator());
-  AliMUONVDigit* d;
-  
-  while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
-  {
-    Int_t ix = d->PadX();
-    Int_t iy = d->PadY();
-    Int_t cathode = d->Cathode();
-    AliMpPad pad = fSegmentations[cathode]->PadByIndices(AliMpIntPair(ix,iy));
-    TClonesArray& padArray = *(fPads[cathode]);
-    if ( fDetElemId == -1 ) 
-    {
-      fDetElemId = d->DetElemId();
-    }
-    else
-    {
-      if ( d->DetElemId() != fDetElemId ) 
-      {
-        AliError("Something is seriously wrong with DE. Aborting clustering");
-        return kFALSE;
-      }
-    }
-    
-    AliMUONPad mpad(fDetElemId,cathode,
-                    ix,iy,pad.Position().X(),pad.Position().Y(),
-                    pad.Dimensions().X(),pad.Dimensions().Y(),
-                    d->Charge());
-    if ( d->IsSaturated() ) mpad.SetSaturated(kTRUE); 
-    mpad.SetUniqueID(d->GetUniqueID());
-    new (padArray[padArray.GetLast()+1]) AliMUONPad(mpad);      
-  }
   if ( fPads[0]->GetLast() < 0 && fPads[1]->GetLast() < 0 )
   {
     // no pad at all, nothing to do...
@@ -218,12 +192,19 @@ AliMUONPreClusterFinderV3::AddPreCluster(AliMUONCluster& cluster, AliMUONCluster
   AliMUONCluster a(*preCluster);
 
   Int_t cathode = preCluster->Cathode();
+  if ( cathode < 0 ) {
+    AliError(Form("Cathod undefined: %d",cathode));
+    AliFatal("");
+    return;
+  }
+  
   if ( cathode <=1 && !fPreClusters[cathode]->Remove(preCluster) ) 
   {
     AliError(Form("Could not remove %s from preclusters[%d]",
                   preCluster->AsString().Data(),cathode));
     StdoutToAliDebug(1,DumpPreClusters());
     AliFatal("");
+    return;
   }
              
   cluster.AddCluster(a);
@@ -250,8 +231,9 @@ AliMUONPreClusterFinderV3::AddPad(AliMUONCluster& cluster, AliMUONPad* pad)
   AliMUONPad* addedPad = cluster.AddPad(*pad);
   
   Int_t cathode = pad->Cathode();
-  TClonesArray& padArray = *fPads[cathode];
-  padArray.Remove(pad);
+  TObjArray& padArray = *fPads[cathode];
+  delete padArray.Remove(pad);
+  
   TIter next(&padArray);
   AliMUONPad* testPad;
   
@@ -279,7 +261,7 @@ AliMUONPreClusterFinderV3::MakeClusters()
 {
   /// Associate (proto)preclusters to form (pre)clusters
   
-//  AliCodeTimerAuto("")
+//  AliCodeTimerAuto("",0)
   
   for ( Int_t cathode = 0; cathode < 2; ++cathode ) 
   {
@@ -304,7 +286,7 @@ AliMUONPreClusterFinderV3::MakeCathodePreClusters(Int_t cathode)
 {
   /// Build (proto)preclusters from digits on a given cathode
   
-//  AliCodeTimerAuto(Form("Cathode %d",cathode))
+//  AliCodeTimerAuto(Form("Cathode %d",cathode),0)
   
   while ( fPads[cathode]->GetLast() > 0  )
   {