//_____________________________________________________________________________
AliMUONPreClusterFinder::AliMUONPreClusterFinder()
: AliMUONVClusterFinder(),
- fClusters(0x0),
+ fClusters("AliMUONCluster"),
fPads(0x0),
fDetElemId(0),
fArea(),
AliMUONPreClusterFinder::~AliMUONPreClusterFinder()
{
/// dtor : note we're owner of the clusters, but not of the pads
- delete fClusters;
}
//_____________________________________________________________________________
const AliMpArea& area)
{
/// Prepare for clustering, by giving access to segmentations and digit lists
-
- delete fClusters;
- fClusters = new TClonesArray("AliMUONCluster");
+ fClusters.Clear("C");
+
fPads = pads;
fDetElemId = detElemId;
fArea = area;
AliMUONPad* pad;
while ( ( pad = static_cast<AliMUONPad*>(next())) )
{
- AliMpArea padArea(pad->Position(),pad->Dimensions());
+ AliMpArea padArea(pad->X(), pad->Y(), pad->DX(), pad->DY());
if (fArea.Overlap(padArea)) return pad;
}
}
+//_____________________________________________________________________________
+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
+ fClusters.Remove(cluster);
+ fClusters.Compress();
+}
+
//_____________________________________________________________________________
AliMUONCluster*
AliMUONPreClusterFinder::NextCluster()
{
/// Builds the next cluster, and returns it.
-// AliCodeTimerAuto("pre-clustering")
+// AliCodeTimerAuto("pre-clustering",0)
// 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() )
if ( ShouldAbort() )
{
- AliError("Aborting clustering of that DE because we've got too many pads");
- fClusters->Remove(cluster);
- fClusters->Compress();
+ AliError(Form("Aborting clustering of DE %d because we've got too many pads",fDetElemId));
+ RemoveCluster(cluster);
return 0x0;
}
}
// 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();
}