]>
Commit | Line | Data |
---|---|---|
6cc447df | 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 | ||
5398f946 | 20 | /// \class AliMUONV2DStore |
9d5f6a64 | 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 | /// | |
5398f946 | 28 | /// \author Laurent Aphecetche |
9d5f6a64 | 29 | |
5398f946 | 30 | /// \cond CLASSIMP |
6cc447df | 31 | ClassImp(AliMUONV2DStore) |
5398f946 | 32 | /// \endcond |
6cc447df | 33 | |
1b9f295e | 34 | #include "AliMpIntPair.h" |
35 | #include "AliMUONObjectPair.h" | |
36 | #include "AliMUONVDataIterator.h" | |
37 | #include "Riostream.h" | |
38 | #include "TMap.h" | |
39 | #include "TObjArray.h" | |
40 | #include "TObjString.h" | |
41 | #include "TString.h" | |
42 | ||
9d5f6a64 | 43 | //_____________________________________________________________________________ |
44 | AliMUONV2DStore::AliMUONV2DStore() | |
45 | { | |
5398f946 | 46 | /// Default constructor |
9d5f6a64 | 47 | } |
48 | ||
6cc447df | 49 | //_____________________________________________________________________________ |
50 | AliMUONV2DStore::~AliMUONV2DStore() | |
51 | { | |
5398f946 | 52 | /// Destructor |
6cc447df | 53 | } |
54 | ||
1b9f295e | 55 | TMap* Decode(const TString& s) |
56 | { | |
57 | TString ss(s); | |
58 | ss.ToUpper(); | |
59 | ||
60 | TMap* m = new TMap; | |
61 | m->SetOwner(true); | |
62 | ||
63 | TObjArray* a = ss.Tokenize(";"); | |
64 | TIter next(a); | |
65 | TObjString* o; | |
66 | ||
67 | while ( ( o = static_cast<TObjString*>(next()) ) ) | |
68 | { | |
69 | TString& os(o->String()); | |
70 | TObjArray* b = os.Tokenize("="); | |
71 | if (b->GetEntries()==2) | |
72 | { | |
73 | m->Add(b->At(0),b->At(1)); | |
74 | } | |
75 | } | |
76 | return m; | |
77 | } | |
6cc447df | 78 | |
1b9f295e | 79 | Bool_t Decode(const TMap& m, const TString& key, TString& value) |
80 | { | |
81 | TString skey(key); | |
82 | skey.ToUpper(); | |
83 | value = ""; | |
84 | TPair* p = static_cast<TPair*>(m.FindObject(skey)); | |
85 | if (p) | |
86 | { | |
87 | value = (static_cast<TObjString*>(p->Value()))->String(); | |
88 | return kTRUE; | |
89 | } | |
90 | return kFALSE; | |
91 | } | |
92 | ||
93 | //_____________________________________________________________________________ | |
94 | void | |
95 | AliMUONV2DStore::Print(Option_t* opt) const | |
96 | { | |
97 | /// Printout | |
98 | /// opt is used to filter which (i,j) couple you want to see | |
99 | /// e.g opt="I=12;J=1;opt=Full" to see complete values, but only for the | |
100 | /// (12,1) pair. | |
101 | /// Warning : decoding of opt format is not really bullet-proof (yet?) | |
102 | ||
103 | AliMUONVDataIterator* it = this->Iterator(); | |
104 | ||
105 | AliMUONObjectPair* pair; | |
106 | ||
107 | TMap* m = Decode(opt); | |
108 | ||
109 | TString si; | |
110 | Bool_t selectI = Decode(*m,"i",si); | |
111 | TString sj; | |
112 | Bool_t selectJ = Decode(*m,"j",sj); | |
113 | TString sopt; | |
114 | Decode(*m,"opt",sopt); | |
115 | ||
116 | m->DeleteAll(); | |
117 | delete m; | |
118 | ||
119 | while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next() ) ) ) | |
120 | { | |
121 | AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First()); | |
122 | Int_t i = ip->GetFirst(); | |
123 | Int_t j = ip->GetSecond(); | |
124 | if ( selectI && i != si.Atoi() ) continue; | |
125 | if ( selectJ && j != sj.Atoi() ) continue; | |
126 | cout << Form("[%d,%d]",i,j) << endl; | |
127 | TObject* o = pair->Second(); | |
128 | if (o) | |
129 | { | |
130 | o->Print(sopt.Data()); | |
131 | } | |
132 | } | |
133 | ||
134 | delete it; | |
135 | } | |
6cc447df | 136 | |
137 |