]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUON2DMap.cxx
Adding Generate method to build a store with identical values (Laurent)
[u/mrichter/AliRoot.git] / MUON / AliMUON2DMap.cxx
index 932e3396c3ec3f44cc5ec040a0dafffcb984628d..b541f1d81730654902ad91363ca93814c7f64afb 100644 (file)
 #include "AliMUON2DMapIterator.h"
 #include "AliMpExMap.h"
 #include "AliMpIntPair.h"
+#include "AliMpManuList.h"
+#include "AliMpDEManager.h"
+#include "AliMUONConstants.h"
+#include <TList.h>
 
 /// \class AliMUON2DMap
 /// \brief Basic implementation of AliMUONV2DStore container using
@@ -35,15 +39,28 @@ ClassImp(AliMUON2DMap)
 /// \endcond
 
 //_____________________________________________________________________________
-AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true))
+AliMUON2DMap::AliMUON2DMap(Bool_t optimizeForDEManu) 
+: AliMUONV2DStore(), 
+  fMap(new AliMpExMap(true)), 
+  fOptimizeForDEManu(optimizeForDEManu)
 {
 /// Default constructor.
+    if ( fOptimizeForDEManu )
+    {
+      Int_t nDEs(0);
+      for ( Int_t i = 0; i < AliMUONConstants::NTrackingCh(); ++i )
+      {
+        nDEs += AliMpDEManager::GetNofDEInChamber(i);
+      }
+      fMap->SetSize(nDEs);
+    }
 }
 
 //_____________________________________________________________________________
 AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other)
 : AliMUONV2DStore(),
-fMap(0x0)
+fMap(0x0),
+fOptimizeForDEManu(kFALSE)
 {
  /// Copy constructor.
 
@@ -69,13 +86,23 @@ AliMUON2DMap::~AliMUON2DMap()
   delete fMap;
 }
 
+//_____________________________________________________________________________
+AliMUONV2DStore*
+AliMUON2DMap::CloneEmpty() const
+{
+  /// Create a void copy of *this. 
+  return new AliMUON2DMap(fOptimizeForDEManu);
+}
+
 //_____________________________________________________________________________
 void
-AliMUON2DMap::CopyTo(AliMUON2DMap&) const
+AliMUON2DMap::CopyTo(AliMUON2DMap& dest) const
 {
-/// Copy this into dest.
+  /// Copy this into dest.
 
-  AliFatal("Implement me if needed");
+  delete dest.fMap;
+  dest.fMap = new AliMpExMap(*fMap);
+  dest.fOptimizeForDEManu = fOptimizeForDEManu;
 }
 
 //_____________________________________________________________________________
@@ -108,10 +135,31 @@ AliMUON2DMap::Iterator() const
 }
 
 //_____________________________________________________________________________
-void
-AliMUON2DMap::Print(Option_t*) const
+AliMUONV2DStore* 
+AliMUON2DMap::Generate(const TObject& object)
 {
-/// Not implemented (yet?)
+  /// Build a complete (i.e. all detElemId,manuId couple will be there) store
+  /// but with identical values, given by object 
+  /// The returned store will be obviously optimized for DEManu.
+
+  AliMUONV2DStore* store = new AliMUON2DMap(true);
+  
+  TList* list = AliMpManuList::ManuList();
+  
+  AliMpIntPair* pair;
+  
+  TIter next(list);
+  
+  while ( ( pair = static_cast<AliMpIntPair*>(next()) ) ) 
+  {
+    Int_t detElemId = pair->GetFirst();
+    Int_t manuId = pair->GetSecond();
+    store->Set(detElemId,manuId,object.Clone(),kFALSE);
+  }
+  
+  delete list;
+  
+  return store;
 }
 
 //_____________________________________________________________________________
@@ -127,6 +175,19 @@ AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
   if ( !o )
   {
     AliMpExMap* m = new AliMpExMap(true);
+    if ( fOptimizeForDEManu ) 
+    {
+      Int_t n(AliMpManuList::NumberOfManus(i));
+      if (!n)
+      {
+        AliError(Form("This does not look right : i = %d is supposed to "
+                      "be a DetElemId with n = %d manus!",i,n));
+      }
+      else
+      {
+        m->SetSize(n);
+      }
+    }
     fMap->Add(i,m);
     o = fMap->GetValue(i);
   }