]>
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" | |
21 | #include "AliMpExMap.h" | |
22 | ||
23 | #include <cassert> | |
24 | ||
25 | ClassImp(AliMUON2DMap) | |
26 | ||
27 | //_____________________________________________________________________________ | |
28 | AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true)) | |
29 | { | |
30 | } | |
31 | ||
32 | //_____________________________________________________________________________ | |
33 | AliMUON2DMap::~AliMUON2DMap() | |
34 | { | |
35 | delete fMap; | |
36 | } | |
37 | ||
38 | //_____________________________________________________________________________ | |
39 | TObject* | |
40 | AliMUON2DMap::Get(Int_t i, Int_t j) const | |
41 | { | |
42 | TObject* o = fMap->GetValue(i); | |
43 | if ( o ) | |
44 | { | |
45 | AliMpExMap* m = dynamic_cast<AliMpExMap*>(o); | |
46 | if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); | |
47 | return m->GetValue(j); | |
48 | } | |
49 | return 0x0; | |
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | Bool_t | |
54 | AliMUON2DMap::IsOwner() const | |
55 | { | |
56 | return kTRUE; | |
57 | } | |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | void | |
61 | AliMUON2DMap::Print(Option_t*) const | |
62 | { | |
63 | ||
64 | } | |
65 | ||
66 | //_____________________________________________________________________________ | |
67 | Bool_t | |
68 | AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace) | |
69 | { | |
70 | TObject* o = fMap->GetValue(i); | |
71 | if ( !o ) | |
72 | { | |
73 | AliMpExMap* m = new AliMpExMap(true); | |
74 | fMap->Add(i,m); | |
75 | o = fMap->GetValue(i); | |
76 | assert(m==o); | |
77 | } | |
78 | AliMpExMap* m = dynamic_cast<AliMpExMap*>(o); | |
79 | if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); | |
80 | o = m->GetValue(j); | |
81 | if ( !o || ( o && replace ) ) | |
82 | { | |
83 | if ( IsOwner() ) | |
84 | { | |
85 | delete o; | |
86 | } | |
87 | m->Add(j,object); | |
88 | } | |
89 | else if ( o && !replace ) | |
90 | { | |
91 | AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j)); | |
92 | return kFALSE; | |
93 | } | |
94 | return kTRUE; | |
95 | } | |
96 | ||
97 | ||
98 | ||
99 | ||
100 |