]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Update the Print methods (Laurent)
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Apr 2007 09:13:43 +0000 (09:13 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Apr 2007 09:13:43 +0000 (09:13 +0000)
MUON/AliMUONV1DStore.cxx
MUON/AliMUONV1DStore.h
MUON/AliMUONV2DStore.cxx
MUON/AliMUONV2DStore.h

index 377c9337448bc75b5059b8a2b169698e4ec5a177..ccfc549ffa09d704a935a9cd925a1a3b5717333b 100644 (file)
@@ -19,9 +19,6 @@
 
 #include "AliMUONVDataIterator.h"
 #include "AliMUONObjectPair.h"
-#include "AliMpIntPair.h"
-#include "AliMpHelper.h"
-#include <TMap.h>
 #include <TString.h>
 #include <Riostream.h>
 
@@ -51,39 +48,25 @@ AliMUONV1DStore::~AliMUONV1DStore()
 /// Destructor
 }
 
+//_____________________________________________________________________________
 void
 AliMUONV1DStore::Print(Option_t* opt) const
 {
   /// Printout
-  /// opt is used to filter which i you want to see
-  /// e.g opt="I=12;opt=Full" to see complete values, but only for i=12
-  /// Warning : decoding of opt format is not really bullet-proof (yet?)
+  /// Si AliMUONVCalibParam concrete implementation for the meaning of opt
   
   AliMUONVDataIterator* it = this->Iterator();
   
   AliMUONObjectPair* pair;
   
-  TMap* m = AliMpHelper::Decode(opt);
-  
-  TString si;  
-  Bool_t selectI = AliMpHelper::Decode(*m,"i",si);
-  TString sopt;
-  AliMpHelper::Decode(*m,"opt",sopt);
-  
-  m->DeleteAll();
-  delete m;
-  
   while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next() ) ) )
   {
-    AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
-    Int_t i = ip->GetFirst();
-    if ( selectI && i != si.Atoi() ) continue;
-    cout << Form("[%d]",i) << endl;
     TObject* o = pair->Second();
     if (o) 
     {
-      o->Print(sopt.Data());
+      o->Print(opt);
     }
+    if ( it->IsOwner() ) delete pair;
   }
   
   delete it;
index 60b1052beb9f8436a7b20cd34a92af194cd6820f..78c5254f68a332df2e870730b4f4fa0a236e3560 100644 (file)
@@ -3,7 +3,7 @@
 
 // $Id$
 
-/// \ingroup base
+/// \ingroup calib
 /// \class AliMUONV1DStore
 /// \brief Generic container indexed by a single integer.
 /// 
index efd431ebe8b0b542e66f468237963cc7a4ceed3c..577043f85e00364cc89aacb8752718bfb8c05c98 100644 (file)
 ClassImp(AliMUONV2DStore)
 /// \endcond
 
-#include "AliMpIntPair.h"
+#include "AliLog.h"
 #include "AliMUONObjectPair.h"
-#include "AliMpHelper.h"
 #include "AliMUONVDataIterator.h"
-#include "Riostream.h"
-#include "TMap.h"
-#include "TObjArray.h"
-#include "TObjString.h"
-#include "TString.h"
+#include "AliMpIntPair.h"
+#include <TMap.h>
+#include <TString.h>
+#include <TObjString.h>
+#include <TObjArray.h>
+#include <Riostream.h>
+
+namespace
+{
+  //_____________________________________________________________________________
+  void Decode(TMap& m, const TString& s, const char* sep)
+{
+    /// Fills the map m with (key,value) extracted from s
+    /// where s is of the form :
+    /// key1=value1;key2=value2;key3=value3
+    
+    TString ss(s);
+    ss.ToUpper();
+    
+    m.SetOwner(true);
+    
+    TObjArray* a = ss.Tokenize(sep);
+    TIter next(a);
+    TObjString* o;
+    
+    while ( ( o = static_cast<TObjString*>(next()) ) )
+    {
+      TString& os(o->String());
+      TObjArray* b = os.Tokenize("=");
+      if (b->GetEntries()==2)
+      {
+        m.Add(b->At(0),b->At(1));
+      }
+    }
+}
+
+//_____________________________________________________________________________
+Bool_t FindValue(const TMap& m, const TString& key, TString& value)
+{
+  /// Find value corresponding to key in map m.
+  /// Return false if key not found.
+  
+  TString skey(key);
+  skey.ToUpper();
+  value = "";
+  TPair* p = static_cast<TPair*>(m.FindObject(skey));
+  if (p) 
+  {
+    value = (static_cast<TObjString*>(p->Value()))->String();
+    return kTRUE;
+  }
+  return kFALSE;
+}
+
+}
 
 //_____________________________________________________________________________
 AliMUONV2DStore::AliMUONV2DStore()
@@ -53,6 +102,7 @@ AliMUONV2DStore::~AliMUONV2DStore()
 /// Destructor
 }
 
+
 //_____________________________________________________________________________
 void
 AliMUONV2DStore::Print(Option_t* opt) const
@@ -62,22 +112,20 @@ AliMUONV2DStore::Print(Option_t* opt) const
   /// e.g opt="I=12;J=1;opt=Full" to see complete values, but only for the 
   /// (12,1) pair.
   /// Warning : decoding of opt format is not really bullet-proof (yet?)
-  
+
   AliMUONVDataIterator* it = this->Iterator();
   
   AliMUONObjectPair* pair;
   
-  TMap* m = AliMpHelper::Decode(opt);
+  TMap m;
+  Decode(m,opt,";");
   
   TString si;  
-  Bool_t selectI = AliMpHelper::Decode(*m,"i",si);
+  Bool_t selectI = FindValue(m,"i",si);
   TString sj;
-  Bool_t selectJ = AliMpHelper::Decode(*m,"j",sj);
+  Bool_t selectJ = FindValue(m,"j",sj);
   TString sopt;
-  AliMpHelper::Decode(*m,"opt",sopt);
-  
-  m->DeleteAll();
-  delete m;
+  FindValue(m,"opt",sopt);
   
   while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next() ) ) )
   {
@@ -92,9 +140,9 @@ AliMUONV2DStore::Print(Option_t* opt) const
     {
       o->Print(sopt.Data());
     }
+    if ( it->IsOwner() ) delete pair;
   }
-  
   delete it;
-}
+}  
 
 
index 21b1d0e6f90fafbaadd2f7edb06f35b684c9ac8c..3f02dcf64641cdba0aff7a8a5f56e6471daaf7d1 100644 (file)
@@ -3,7 +3,7 @@
 
 // $Id$
 
-/// \ingroup base
+/// \ingroup calib
 /// \class AliMUONV2DStore
 /// \brief Generic container indexed by a pair of integers.
 /// 
@@ -27,20 +27,20 @@ public:
   /// Return an empty copy of self.
   virtual AliMUONV2DStore* CloneEmpty() const { return 0x0; }
   
-  /// Return iterator
-  virtual AliMUONVDataIterator* Iterator() const { return 0x0; }
-  
   /// Return the object stored at (i,j).
   virtual TObject* Get(Int_t i, Int_t j) const = 0;
+    
+  /// Whether or not this container is the owner of its contents.
+  virtual Bool_t IsOwner() const = 0;
+    
+  /// Return iterator
+  virtual AliMUONVDataIterator* Iterator() const { return 0x0; }
   
   /** Set the object stored at (i,j).
     if replace=false and there's already an object there, returns kFALSE
     */
   virtual Bool_t Set(Int_t i, Int_t j, TObject*, Bool_t replace) = 0;
   
-  /// Whether or not this container is the owner of its contents.
-  virtual Bool_t IsOwner() const = 0;
-  
   virtual void Print(Option_t* opt="") const;
   
 private: