]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPreClusterFinderV2.cxx
DQM configure file
[u/mrichter/AliRoot.git] / MUON / AliMUONPreClusterFinderV2.cxx
index 21f5e44dc78db0b879b36139202e53e9bb6b0b4e..e3d42f48bd974bf7dee0498f998f3bb7435dd780 100644 (file)
@@ -20,7 +20,8 @@
 #include "AliLog.h"
 #include "AliMUONCluster.h"
 #include "AliMpVSegmentation.h"
-#include "TClonesArray.h"
+#include "AliMpPad.h"
+#include "TObjArray.h"
 #include "TVector2.h"
 #include "AliMUONPad.h"
 #include "AliMUONVDigit.h"
@@ -42,26 +43,18 @@ ClassImp(AliMUONPreClusterFinderV2)
 AliMUONPreClusterFinderV2::AliMUONPreClusterFinderV2()
 : AliMUONVClusterFinder(),
   fClusters(0x0),
-  fSegmentations(0x0),
+  fkSegmentations(0x0),
+  fPads(0x0),
   fDetElemId(0)
 {
     /// ctor
-  for ( Int_t i = 0; i < 2; ++i )
-  {
-    fPads[i] = 0x0;
-  } 
 }
 
 //_____________________________________________________________________________
 AliMUONPreClusterFinderV2::~AliMUONPreClusterFinderV2()
 {
-  /// dtor : note we're owner of the pads and the clusters, but not of
-  /// the remaining objects (digits, segmentations)
+  /// dtor : note we're owner of the clusters, but not of the pads
   delete fClusters;
-  for ( Int_t i = 0; i < 2; ++i )
-  {
-    delete fPads[i];
-  }  
 }
 
 //_____________________________________________________________________________
@@ -76,62 +69,33 @@ AliMUONPreClusterFinderV2::UsePad(const AliMUONPad& pad)
     return kFALSE;
   }
   
-  new ((*fPads[pad.Cathode()])[fPads[pad.Cathode()]->GetLast()+1]) AliMUONPad(pad); 
+  fPads[pad.Cathode()]->Add(new AliMUONPad(pad)); 
   // FIXME: should set the ClusterId of that new pad to be -1
   return kTRUE;
 }
 
 //_____________________________________________________________________________
 Bool_t
-AliMUONPreClusterFinderV2::Prepare(const AliMpVSegmentation* segmentations[2],
-                                 const AliMUONVDigitStore& digitStore)
-// FIXME : add area on which to look for clusters here.
+AliMUONPreClusterFinderV2::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
   
-  fSegmentations = segmentations;
-  
-  delete fClusters;
-  fClusters = new TClonesArray("AliMUONCluster");
-  for ( Int_t i = 0; i < 2; ++i )
+  if ( area.IsValid() ) 
   {
-    delete fPads[i];
-    fPads[i] = new TClonesArray("AliMUONPad");
+    AliError("Handling of area not yet implemented for this class. Please check");
   }
   
-  fDetElemId = -1;
+  delete fClusters;
+  fClusters = new TClonesArray("AliMUONCluster");
+
+  fPads = pads;
+  fkSegmentations = seg;
   
-  TIter next(digitStore.CreateIterator());
-  AliMUONVDigit* d;
+  fDetElemId = detElemId;
   
-  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...
@@ -147,30 +111,28 @@ AliMUONPreClusterFinderV2::AddPad(AliMUONCluster& cluster, AliMUONPad* pad)
 {
   /// Add a pad to a cluster
   
-  cluster.AddPad(*pad);
-  pad->SetClusterId(cluster.GetUniqueID());
+  AliMUONPad* addedPad = cluster.AddPad(*pad);
   
   Int_t cathode = pad->Cathode();
-  TClonesArray& padArray = *fPads[cathode];
-  padArray.Remove(pad);
-  TIter next(&padArray);
+  TObjArray& padArray = *fPads[cathode];
+  delete padArray.Remove(pad);
   
   // Check neighbours
   TObjArray neighbours;
-  AliMpPad p = fSegmentations[pad->Cathode()]->PadByIndices(AliMpIntPair(pad->Ix(),pad->Iy()),kTRUE);
-  Int_t nn = fSegmentations[pad->Cathode()]->GetNeighbours(p,neighbours);
+  AliMpPad p = fkSegmentations[cathode]->PadByIndices(addedPad->Ix(),addedPad->Iy(),kTRUE);
+  Int_t nn = fkSegmentations[cathode]->GetNeighbours(p,neighbours);
   for (Int_t in = 0; in < nn; ++in) 
   {
-    AliMpPad* p = static_cast<AliMpPad*>(neighbours.At(in));
+    AliMpPad* p1 = static_cast<AliMpPad*>(neighbours.At(in));
     
-    TIter next(&padArray);
+    TIter next2(&padArray);
     AliMUONPad* p2;
     
-    while ( ( p2 = static_cast<AliMUONPad*>(next()) ) )
+    while ( ( p2 = static_cast<AliMUONPad*>(next2()) ) )
     {
-        if ( !p2->IsUsed() && p2->Ix()==p->GetIndices().GetFirst() 
-             && p2->Iy() == p->GetIndices().GetSecond() &&
-             p2->Cathode() == pad->Cathode() )
+        if ( !p2->IsUsed() && p2->Ix()==p1->GetIx() 
+             && p2->Iy() == p1->GetIy() &&
+             p2->Cathode() == cathode )
         {
           AddPad(cluster,p2);
         }
@@ -218,13 +180,13 @@ AliMUONPreClusterFinderV2::NextCluster()
   
   AliMUONPad* pad;
   TIter next(fPads[0]);
-  while (  ( pad = static_cast<AliMUONPad*>(next())) && pad->IsUsed() );
+  while (  ( pad = static_cast<AliMUONPad*>(next())) && pad->IsUsed() ) {}
 
   if (!pad) // protection against no pad in first cathode, which might happen
   {
     // try other cathode
-    TIter next(fPads[1]);
-    while (  ( pad = static_cast<AliMUONPad*>(next())) && pad->IsUsed() );
+    TIter next2(fPads[1]);
+    while (  ( pad = static_cast<AliMUONPad*>(next2())) && pad->IsUsed() ) {}
     if (!pad) 
     {
       // we are done.