]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPreClusterFinder.cxx
New: Sorting pedestal values ordered by Buspatch and Manu (by default sorting is...
[u/mrichter/AliRoot.git] / MUON / AliMUONPreClusterFinder.cxx
index c35aa88773bbc86f6ce9bfa52dc9e5c9dce02c85..4f7d69eb6486a844e3919e15162289954b3e98c2 100644 (file)
@@ -17,6 +17,8 @@
 
 #include "AliMUONPreClusterFinder.h"
 
+#include "AliCodeTimer.h"
+
 #include "AliMUONCluster.h"
 #include "AliMUONPad.h"
 #include "AliMUONVDigit.h"
@@ -104,8 +106,12 @@ AliMUONPreClusterFinder::AddPad(AliMUONCluster& cluster, AliMUONPad* pad)
 {
   /// Add a pad to a cluster
   
-  if ( cluster.Multiplicity() > 500 ) 
+  if ( cluster.IsMonoCathode() && cluster.Multiplicity() > 199 ) 
   {
+    /// FIXME : we should at that point really find a better way to remove "bad" preclusters,
+    /// like e.g. computing the charge dispersion (the lower, the most probably we have noise cluster)
+    /// and/or mean charge per pad (if too close to LowestPadCharge, again that's a noise cluster...
+    /// *BUT* this needs carefull testing !
     fShouldAbort = kTRUE;
     return;
   }
@@ -187,35 +193,59 @@ AliMUONPreClusterFinder::GetNextPad(Int_t cathode) const
   }
 }
 
+//_____________________________________________________________________________
+AliMUONCluster* 
+AliMUONPreClusterFinder::NewCluster()
+{
+  /// Create a new (empty) cluster
+  Int_t id = fClusters.GetLast()+1;
+  AliMUONCluster* cluster = new (fClusters[id]) AliMUONCluster;
+  cluster->SetUniqueID(id);
+  return cluster;
+}
+
+//_____________________________________________________________________________
+void 
+AliMUONPreClusterFinder::RemoveCluster(AliMUONCluster* cluster)
+{
+  /// Remove a cluster
+  /// Note that we are *not* releasing the pads, so they won't be used further on
+  fClusters.Remove(cluster);
+  fClusters.Compress();
+}
+
 //_____________________________________________________________________________
 AliMUONCluster* 
 AliMUONPreClusterFinder::NextCluster()
 {
   /// Builds the next cluster, and returns it.
-//  AliCodeTimerAuto("pre-clustering")
   
   // Start a new cluster
-  Int_t id = fClusters.GetLast()+1;
-  AliMUONCluster* cluster = new (fClusters[id]) AliMUONCluster;
-  cluster->SetUniqueID(id);
   
   AliMUONPad* pad = GetNextPad(0);
   
+  AliMUONCluster* cluster(0x0);
+  
   if (!pad) // protection against no pad in first cathode, which might happen
   {
     // try other cathode
     pad = GetNextPad(1);
     if (!pad) 
     {
-      // we are done.
       return 0x0;
     }
-    // Builds (recursively) a cluster on second cathode only
-    AddPad(*cluster,pad);
+    else
+    {
+      cluster = NewCluster();
+      // Builds (recursively) a cluster on second cathode only
+      AddPad(*cluster,pad);
+    }
   }
   else
   {
     // Builds (recursively) a cluster on first cathode only
+    
+    cluster = NewCluster();
     AddPad(*cluster,pad);
     
     if ( !ShouldAbort() ) 
@@ -237,10 +267,9 @@ AliMUONPreClusterFinder::NextCluster()
   
   if ( ShouldAbort() ) 
   {
-    AliError("Aborting clustering of that DE because we've got too many pads");
-    fClusters.Remove(cluster);
-    fClusters.Compress();
-    return 0x0;
+    AliCodeTimerAuto(Form("Skipping a precluster in DE %d because it got too many pads",fDetElemId),0);
+    RemoveCluster(cluster);
+    return NextCluster();
   }
   
   if ( cluster->Multiplicity() <= 1 )
@@ -252,8 +281,7 @@ AliMUONPreClusterFinder::NextCluster()
     }
     // else only 1 pad (not suspicious, but kind of useless, probably noise)
     // so we remove it from our list
-    fClusters.Remove(cluster);
-    fClusters.Compress();
+    RemoveCluster(cluster);
     // then proceed further
     return NextCluster();
   }