// $Id$
+//-----------------------------------------------------------------------------
/// \class AliMUONClusterStoreV1
///
/// Implementation of VClusterStore.
///
/// \author Laurent Aphecetche, Subatech
///
+//-----------------------------------------------------------------------------
#include "AliMUONClusterStoreV1.h"
for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
{
TClonesArray* tca = new TClonesArray("AliMUONRawCluster",100);
- tca->SetOwner(kTRUE);
fClusters->AddAt(tca,i);
}
AliDebug(1,"");
}
//_____________________________________________________________________________
-Bool_t
-AliMUONClusterStoreV1::Add(const AliMUONRawCluster& cluster)
+AliMUONVCluster* AliMUONClusterStoreV1::CreateCluster(Int_t /*chamberId*/, Int_t detElemId, Int_t /*clusterIndex*/) const
+{
+ /// Create a cluster
+ AliMUONVCluster* vCluster = new AliMUONRawCluster();
+ (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
+ return vCluster;
+}
+
+//_____________________________________________________________________________
+AliMUONVCluster*
+AliMUONClusterStoreV1::Add(const AliMUONVCluster& vCluster)
{
/// Add a cluster to this store
- Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
+ const AliMUONRawCluster* cluster = dynamic_cast<const AliMUONRawCluster*>(&vCluster);
+
+ if (!cluster)
+ {
+ AliError(Form("Cluster is not of the expected type (%s vs AliMUONRawCluster)",
+ vCluster.ClassName()));
+ return 0x0;
+ }
+
+ Int_t iChamber = AliMpDEManager::GetChamberId(cluster->GetDetElemId());
TClonesArray* array = ChamberClusters(iChamber);
if (!array)
{
- return kFALSE;
+ return 0x0;
}
- new((*array)[array->GetLast()+1]) AliMUONRawCluster(cluster);
- return kTRUE;
+
+ return new((*array)[array->GetLast()+1]) AliMUONRawCluster(*cluster);
+}
+
+//_____________________________________________________________________________
+AliMUONVCluster* AliMUONClusterStoreV1::Add(Int_t chamberId, Int_t detElemId, Int_t /*clusterIndex*/)
+{
+ /// Add a cluster to this store
+ TClonesArray* array = ChamberClusters(chamberId);
+ if (!array) return 0x0;
+
+ AliMUONVCluster* vCluster = static_cast<AliMUONVCluster*> (new((*array)[array->GetLast()+1]) AliMUONRawCluster());
+ (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
+ return vCluster;
}
//_____________________________________________________________________________
}
//_____________________________________________________________________________
-AliMUONRawCluster*
-AliMUONClusterStoreV1::Remove(AliMUONRawCluster& cluster)
+AliMUONVCluster*
+AliMUONClusterStoreV1::Remove(AliMUONVCluster& cluster)
{
/// Remove a cluster
Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
{
array->Compress();
}
- return static_cast<AliMUONRawCluster*>(o);
+ return static_cast<AliMUONVCluster*>(o);
}
//_____________________________________________________________________________
Int_t
AliMUONClusterStoreV1::GetSize() const
{
- return fClusters->GetLast()+1;
+ /// Return the number of clusters we hold
+ Int_t n(0);
+ for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
+ {
+ n += ChamberClusters(i)->GetLast()+1;
+ }
+ return n;
}
+