]>
Commit | Line | Data |
---|---|---|
f6e5d0e9 | 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 "AliMUON2DMap.h" | |
19 | ||
20 | #include "AliLog.h" | |
f246123b | 21 | #include "AliMUONVDataIterator.h" |
22 | #include "AliMUON2DMapIterator.h" | |
f6e5d0e9 | 23 | #include "AliMpExMap.h" |
f246123b | 24 | #include "AliMpIntPair.h" |
d91c6144 | 25 | #include "AliMpManuList.h" |
26 | #include "AliMpDEManager.h" | |
27 | #include "AliMUONConstants.h" | |
f6e5d0e9 | 28 | |
5398f946 | 29 | /// \class AliMUON2DMap |
30 | /// \brief Basic implementation of AliMUONV2DStore container using | |
9d5f6a64 | 31 | /// AliMpExMap internally. |
32 | /// What we store is a "double" map : an AliMpExMap of AliMpExMaps | |
33 | /// | |
5398f946 | 34 | /// \author Laurent Aphecetche |
f6e5d0e9 | 35 | |
5398f946 | 36 | /// \cond CLASSIMP |
f6e5d0e9 | 37 | ClassImp(AliMUON2DMap) |
5398f946 | 38 | /// \endcond |
f6e5d0e9 | 39 | |
40 | //_____________________________________________________________________________ | |
d91c6144 | 41 | AliMUON2DMap::AliMUON2DMap(Bool_t optimizeForDEManu) |
42 | : AliMUONV2DStore(), | |
43 | fMap(new AliMpExMap(true)), | |
44 | fOptimizeForDEManu(optimizeForDEManu) | |
f6e5d0e9 | 45 | { |
5398f946 | 46 | /// Default constructor. |
d91c6144 | 47 | if ( fOptimizeForDEManu ) |
48 | { | |
49 | Int_t nDEs(0); | |
50 | for ( Int_t i = 0; i < AliMUONConstants::NTrackingCh(); ++i ) | |
51 | { | |
52 | nDEs += AliMpDEManager::GetNofDEInChamber(i); | |
53 | } | |
54 | fMap->SetSize(nDEs); | |
55 | } | |
f6e5d0e9 | 56 | } |
57 | ||
9d5f6a64 | 58 | //_____________________________________________________________________________ |
59 | AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other) | |
60 | : AliMUONV2DStore(), | |
d91c6144 | 61 | fMap(0x0), |
62 | fOptimizeForDEManu(kFALSE) | |
9d5f6a64 | 63 | { |
5398f946 | 64 | /// Copy constructor. |
65 | ||
66 | other.CopyTo(*this); | |
9d5f6a64 | 67 | } |
884a73f1 | 68 | |
9d5f6a64 | 69 | //_____________________________________________________________________________ |
70 | AliMUON2DMap& | |
71 | AliMUON2DMap::operator=(const AliMUON2DMap& other) | |
72 | { | |
5398f946 | 73 | /// Assignment operator |
74 | ||
9d5f6a64 | 75 | other.CopyTo(*this); |
76 | return *this; | |
884a73f1 | 77 | } |
78 | ||
f6e5d0e9 | 79 | //_____________________________________________________________________________ |
80 | AliMUON2DMap::~AliMUON2DMap() | |
81 | { | |
5398f946 | 82 | /// Destructor. |
83 | /// We delete the map, which will delete the objects, as we're owner. | |
84 | ||
f6e5d0e9 | 85 | delete fMap; |
86 | } | |
87 | ||
d91c6144 | 88 | //_____________________________________________________________________________ |
89 | AliMUONV2DStore* | |
90 | AliMUON2DMap::CloneEmpty() const | |
91 | { | |
92 | /// Create a void copy of *this. | |
547c1de0 | 93 | return new AliMUON2DMap(fOptimizeForDEManu); |
d91c6144 | 94 | } |
95 | ||
9d5f6a64 | 96 | //_____________________________________________________________________________ |
97 | void | |
d91c6144 | 98 | AliMUON2DMap::CopyTo(AliMUON2DMap& dest) const |
884a73f1 | 99 | { |
d91c6144 | 100 | /// Copy this into dest. |
5398f946 | 101 | |
d91c6144 | 102 | delete dest.fMap; |
103 | dest.fMap = new AliMpExMap(*fMap); | |
104 | dest.fOptimizeForDEManu = fOptimizeForDEManu; | |
9d5f6a64 | 105 | } |
884a73f1 | 106 | |
f6e5d0e9 | 107 | //_____________________________________________________________________________ |
108 | TObject* | |
109 | AliMUON2DMap::Get(Int_t i, Int_t j) const | |
110 | { | |
5398f946 | 111 | /// Return the value at position (i,j). |
112 | ||
f6e5d0e9 | 113 | TObject* o = fMap->GetValue(i); |
114 | if ( o ) | |
115 | { | |
116 | AliMpExMap* m = dynamic_cast<AliMpExMap*>(o); | |
117 | if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); | |
118 | return m->GetValue(j); | |
119 | } | |
120 | return 0x0; | |
121 | } | |
122 | ||
f6e5d0e9 | 123 | //_____________________________________________________________________________ |
f246123b | 124 | AliMUONVDataIterator* |
125 | AliMUON2DMap::Iterator() const | |
126 | { | |
127 | // Create and return an iterator on this map | |
128 | // Returned iterator must be deleted by user. | |
129 | if ( fMap ) | |
130 | { | |
131 | return new AliMUON2DMapIterator(*fMap); | |
132 | } | |
133 | return 0x0; | |
134 | } | |
135 | ||
f6e5d0e9 | 136 | //_____________________________________________________________________________ |
137 | Bool_t | |
138 | AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace) | |
139 | { | |
5398f946 | 140 | /// Set the object at position (i,j). |
141 | /// If replace==kTRUE, we don't care if there's an object there already, | |
142 | /// otherwise we might refuse to set if the (i,j) location is already | |
143 | /// filled (in which case we return kFALSE). | |
e5cc543e | 144 | |
f6e5d0e9 | 145 | TObject* o = fMap->GetValue(i); |
146 | if ( !o ) | |
147 | { | |
148 | AliMpExMap* m = new AliMpExMap(true); | |
d91c6144 | 149 | if ( fOptimizeForDEManu ) |
150 | { | |
151 | Int_t n(AliMpManuList::NumberOfManus(i)); | |
152 | if (!n) | |
153 | { | |
154 | AliError(Form("This does not look right : i = %d is supposed to " | |
155 | "be a DetElemId with n = %d manus!",i,n)); | |
156 | } | |
157 | else | |
158 | { | |
159 | m->SetSize(n); | |
160 | } | |
161 | } | |
f6e5d0e9 | 162 | fMap->Add(i,m); |
163 | o = fMap->GetValue(i); | |
f6e5d0e9 | 164 | } |
165 | AliMpExMap* m = dynamic_cast<AliMpExMap*>(o); | |
166 | if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); | |
167 | o = m->GetValue(j); | |
168 | if ( !o || ( o && replace ) ) | |
169 | { | |
170 | if ( IsOwner() ) | |
171 | { | |
172 | delete o; | |
173 | } | |
174 | m->Add(j,object); | |
175 | } | |
176 | else if ( o && !replace ) | |
177 | { | |
178 | AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j)); | |
179 | return kFALSE; | |
180 | } | |
181 | return kTRUE; | |
182 | } | |
183 | ||
184 | ||
185 | ||
186 | ||
187 |