]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/ESD/AliESDMuonCluster.cxx
In AddTaskPHOSPi0Flow.C set Cent. Bin past event buffers/lists,
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDMuonCluster.cxx
index 7ee9e304e56801eb5bc084483fdd39e565da2111..c03cfc06acf60e036c948602fbbf51aa99349add 100644 (file)
@@ -23,6 +23,7 @@
 /// \author Philippe Pillot, Subatech
 //-----------------------------------------------------------------------------
 
+#include "AliESDEvent.h"
 #include "AliESDMuonCluster.h"
 #include "AliESDMuonPad.h"
 
@@ -31,6 +32,8 @@
 #include <TClonesArray.h>
 #include <Riostream.h>
 
+using std::endl;
+using std::cout;
 /// \cond CLASSIMP
 ClassImp(AliESDMuonCluster)
 /// \endcond
@@ -41,6 +44,8 @@ AliESDMuonCluster::AliESDMuonCluster()
   fCharge(0.),
   fChi2(0.),
   fPads(0x0),
+  fNPads(0),
+  fPadsId(0x0),
   fLabel(-1)
 {
   /// default constructor
@@ -54,6 +59,8 @@ AliESDMuonCluster::AliESDMuonCluster (const AliESDMuonCluster& cluster)
   fCharge(cluster.fCharge),
   fChi2(cluster.fChi2),
   fPads(0x0),
+  fNPads(cluster.fNPads),
+  fPadsId(0x0),
   fLabel(cluster.fLabel)
 {
   /// Copy constructor
@@ -71,6 +78,8 @@ AliESDMuonCluster::AliESDMuonCluster (const AliESDMuonCluster& cluster)
       pad = (AliESDMuonPad*) cluster.fPads->After(pad);
     }
   }
+  
+  if (cluster.fPadsId) fPadsId = new TArrayI(*(cluster.fPadsId));
 }
 
 //_____________________________________________________________________________
@@ -101,6 +110,8 @@ AliESDMuonCluster& AliESDMuonCluster::operator=(const AliESDMuonCluster& cluster
     }
   } else fPads = 0x0;
   
+  SetPadsId(cluster.fNPads, cluster.GetPadsId());
+  
   return *this;
 }
 
@@ -109,50 +120,62 @@ AliESDMuonCluster::~AliESDMuonCluster()
 {
   /// Destructor
   delete fPads;
+  delete fPadsId;
 }
 
 //__________________________________________________________________________
-void AliESDMuonCluster::Clear(Option_t* /*opt*/)
+void AliESDMuonCluster::Clear(Option_t* opt)
 {
   /// Clear arrays
-  delete fPads;
-  fPads = 0x0;
+  if (opt && opt[0] == 'C') {
+    if (fPads) fPads->Clear("C");
+  } else {
+    delete fPads; fPads = 0x0;
+  }
+  delete fPadsId; fPadsId = 0x0;
+  fNPads = 0;
 }
 
 //_____________________________________________________________________________
-Int_t AliESDMuonCluster::GetNPads() const
+void AliESDMuonCluster::AddPadId(UInt_t padId)
 {
-  // return the number of pads associated to the cluster
-  if (!fPads) return 0;
-  
-  return fPads->GetEntriesFast();
+  /// Add the given pad Id to the list associated to the cluster
+  if (!fPadsId) fPadsId = new TArrayI(10);
+  if (fPadsId->GetSize() <= fNPads) fPadsId->Set(fNPads+10);
+  fPadsId->AddAt(static_cast<Int_t>(padId), fNPads++);
 }
 
 //_____________________________________________________________________________
-TClonesArray& AliESDMuonCluster::GetPads() const
+void AliESDMuonCluster::SetPadsId(Int_t nPads, const UInt_t *padsId)
 {
-  // return the array of pads associated to the cluster
-  if (!fPads) fPads = new TClonesArray("AliESDMuonPad",10);
+  /// Fill the list pads'Id associated to the cluster with the given list
   
-  return *fPads;
-}
-
-//_____________________________________________________________________________
-void AliESDMuonCluster::AddPad(const AliESDMuonPad &pad)
-{
-  // add a pad to the TClonesArray of pads associated to the cluster
-  if (!fPads) fPads = new TClonesArray("AliESDMuonPad",10);
+  if (nPads <= 0 || !padsId) {
+    delete fPadsId;
+    fPadsId = 0x0;
+    fNPads = 0;
+    return;
+  }
+  
+  if (!fPadsId) fPadsId = new TArrayI(nPads, reinterpret_cast<const Int_t*>(padsId));
+  else fPadsId->Set(nPads, reinterpret_cast<const Int_t*>(padsId));
+  fNPads = nPads;
   
-  new ((*fPads)[fPads->GetEntriesFast()]) AliESDMuonPad(pad);
 }
 
 //_____________________________________________________________________________
-Bool_t AliESDMuonCluster::PadsStored() const
+void AliESDMuonCluster::MovePadsToESD(AliESDEvent &esd)
 {
-  // return kTRUE if the pads associated to the cluster are registered
-  if (GetNPads() == 0) return kFALSE;
-  
-  return kTRUE;
+  /// move the pads to the new ESD structure
+  if (!fPads) return;
+  for (Int_t i = 0; i < fPads->GetEntriesFast(); i++) {
+    AliESDMuonPad *pad = static_cast<AliESDMuonPad*>(fPads->UncheckedAt(i));
+    AliESDMuonPad *newPad = esd.NewMuonPad();
+    *newPad = *pad;
+    AddPadId(newPad->GetUniqueID());
+  }
+  delete fPads;
+  fPads = 0x0;
 }
 
 //_____________________________________________________________________________
@@ -171,10 +194,7 @@ void AliESDMuonCluster::Print(Option_t */*option*/) const
   
   if (PadsStored()) {
     cout<<"  pad infos:"<<endl;
-    for (Int_t iPad=0; iPad<GetNPads(); iPad++) {
-      cout<<"  ";
-      ( (AliESDMuonPad*) fPads->UncheckedAt(iPad) )->Print();
-    }
+    for (Int_t iPad=0; iPad<GetNPads(); iPad++) cout<<"  "<<GetPadId(iPad)<<endl;
   }
 }