]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONV2DStore.cxx
efd431ebe8b0b542e66f468237963cc7a4ceed3c
[u/mrichter/AliRoot.git] / MUON / AliMUONV2DStore.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15
16 // $Id$
17
18 #include "AliMUONV2DStore.h"
19
20 /// \class AliMUONV2DStore
21 /// Defines an interface equivalent to a 2D array of TObject, indexed
22 /// by a pair of integers (somehow a matrix, 
23 /// except that indices are not necessarily sequential).
24 /// 
25 /// It's extremely simple and hopefully allow many implementations.
26 /// It also makes the object ownership self-evident.
27 ///
28 /// \author Laurent Aphecetche
29
30 /// \cond CLASSIMP
31 ClassImp(AliMUONV2DStore)
32 /// \endcond
33
34 #include "AliMpIntPair.h"
35 #include "AliMUONObjectPair.h"
36 #include "AliMpHelper.h"
37 #include "AliMUONVDataIterator.h"
38 #include "Riostream.h"
39 #include "TMap.h"
40 #include "TObjArray.h"
41 #include "TObjString.h"
42 #include "TString.h"
43
44 //_____________________________________________________________________________
45 AliMUONV2DStore::AliMUONV2DStore()
46 {
47 /// Default constructor
48 }
49
50 //_____________________________________________________________________________
51 AliMUONV2DStore::~AliMUONV2DStore()
52 {
53 /// Destructor
54 }
55
56 //_____________________________________________________________________________
57 void
58 AliMUONV2DStore::Print(Option_t* opt) const
59 {
60   /// Printout
61   /// opt is used to filter which (i,j) couple you want to see
62   /// e.g opt="I=12;J=1;opt=Full" to see complete values, but only for the 
63   /// (12,1) pair.
64   /// Warning : decoding of opt format is not really bullet-proof (yet?)
65   
66   AliMUONVDataIterator* it = this->Iterator();
67   
68   AliMUONObjectPair* pair;
69   
70   TMap* m = AliMpHelper::Decode(opt);
71   
72   TString si;  
73   Bool_t selectI = AliMpHelper::Decode(*m,"i",si);
74   TString sj;
75   Bool_t selectJ = AliMpHelper::Decode(*m,"j",sj);
76   TString sopt;
77   AliMpHelper::Decode(*m,"opt",sopt);
78   
79   m->DeleteAll();
80   delete m;
81   
82   while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next() ) ) )
83   {
84     AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
85     Int_t i = ip->GetFirst();
86     Int_t j = ip->GetSecond();
87     if ( selectI && i != si.Atoi() ) continue;
88     if ( selectJ && j != sj.Atoi() ) continue;
89     cout << Form("[%d,%d]",i,j) << endl;
90     TObject* o = pair->Second();
91     if (o) 
92     {
93       o->Print(sopt.Data());
94     }
95   }
96   
97   delete it;
98 }
99
100