]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONClusterStoreV1.cxx
ALIROOT-5420 Changes for CDH v3
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterStoreV1.cxx
index 7ad5453baa444246d35e97c2e1916186fa41f179..95b6e96ad019e61235cccbf2d4aec25c4553bd2c 100644 (file)
@@ -15,6 +15,7 @@
 
 // $Id$
 
+//-----------------------------------------------------------------------------
 /// \class AliMUONClusterStoreV1
 ///
 /// Implementation of VClusterStore.
@@ -25,6 +26,7 @@
 ///
 /// \author Laurent Aphecetche, Subatech
 ///
+//-----------------------------------------------------------------------------
 
 #include "AliMUONClusterStoreV1.h"
 
@@ -52,7 +54,6 @@ fClusters(new TObjArray(AliMpConstants::NofChambers()))
   for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
   {
     TClonesArray* tca = new TClonesArray("AliMUONRawCluster",100);
-    tca->SetOwner(kTRUE);
     fClusters->AddAt(tca,i);
   }
   AliDebug(1,"");
@@ -85,18 +86,48 @@ AliMUONClusterStoreV1::~AliMUONClusterStoreV1()
 }
 
 //_____________________________________________________________________________
-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;
 }
 
 //_____________________________________________________________________________
@@ -164,8 +195,8 @@ AliMUONClusterStoreV1::Connect(TTree& tree, Bool_t alone) const
 }
 
 //_____________________________________________________________________________
-AliMUONRawCluster*
-AliMUONClusterStoreV1::Remove(AliMUONRawCluster& cluster)
+AliMUONVCluster*
+AliMUONClusterStoreV1::Remove(AliMUONVCluster& cluster)
 {
   /// Remove a cluster
   Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
@@ -175,7 +206,7 @@ AliMUONClusterStoreV1::Remove(AliMUONRawCluster& cluster)
   {
     array->Compress();
   }
-  return static_cast<AliMUONRawCluster*>(o);
+  return static_cast<AliMUONVCluster*>(o);
 }
 
 //_____________________________________________________________________________
@@ -219,3 +250,4 @@ AliMUONClusterStoreV1::GetSize() const
   }
   return n;
 }
+