Geometry builder classes moved from base to sim.
[u/mrichter/AliRoot.git] / MUON / AliMUON2DMap.cxx
CommitLineData
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
9d5f6a64 23///
24/// Basic implementation of AliMUONV2DStore container using
25/// AliMpExMap internally.
26/// What we store is a "double" map : an AliMpExMap of AliMpExMaps
27///
f6e5d0e9 28
29ClassImp(AliMUON2DMap)
30
31//_____________________________________________________________________________
32AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true))
33{
e5cc543e 34 //
35 // ctor.
36 //
f6e5d0e9 37}
38
9d5f6a64 39//_____________________________________________________________________________
40AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other)
41: AliMUONV2DStore(),
42fMap(0x0)
43{
44 other.CopyTo(*this);
45}
884a73f1 46
9d5f6a64 47//_____________________________________________________________________________
48AliMUON2DMap&
49AliMUON2DMap::operator=(const AliMUON2DMap& other)
50{
51 other.CopyTo(*this);
52 return *this;
884a73f1 53}
54
f6e5d0e9 55//_____________________________________________________________________________
56AliMUON2DMap::~AliMUON2DMap()
57{
e5cc543e 58 //
59 // dtor. we delete the map, which will delete the objects, as we're owner.
60 //
f6e5d0e9 61 delete fMap;
62}
63
9d5f6a64 64//_____________________________________________________________________________
65void
66AliMUON2DMap::CopyTo(AliMUON2DMap&) const
884a73f1 67{
9d5f6a64 68 //
69 // Copy this into dest.
70 //
71 AliFatal("Implement me if needed");
72}
884a73f1 73
f6e5d0e9 74//_____________________________________________________________________________
75TObject*
76AliMUON2DMap::Get(Int_t i, Int_t j) const
77{
e5cc543e 78 //
79 // Return the value at position (i,j).
80 //
f6e5d0e9 81 TObject* o = fMap->GetValue(i);
82 if ( o )
83 {
84 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
85 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
86 return m->GetValue(j);
87 }
88 return 0x0;
89}
90
91//_____________________________________________________________________________
f6e5d0e9 92void
93AliMUON2DMap::Print(Option_t*) const
94{
e5cc543e 95 //
96 // Not implemented (yet?)
97 //
f6e5d0e9 98}
99
100//_____________________________________________________________________________
101Bool_t
102AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
103{
e5cc543e 104 //
105 // Set the object at position (i,j).
106 // If replace==kTRUE, we don't care if there's an object there already,
107 // otherwise we might refuse to set if the (i,j) location is already
108 // filled (in which case we return kFALSE).
109
f6e5d0e9 110 TObject* o = fMap->GetValue(i);
111 if ( !o )
112 {
113 AliMpExMap* m = new AliMpExMap(true);
114 fMap->Add(i,m);
115 o = fMap->GetValue(i);
f6e5d0e9 116 }
117 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
118 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
119 o = m->GetValue(j);
120 if ( !o || ( o && replace ) )
121 {
122 if ( IsOwner() )
123 {
124 delete o;
125 }
126 m->Add(j,object);
127 }
128 else if ( o && !replace )
129 {
130 AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j));
131 return kFALSE;
132 }
133 return kTRUE;
134}
135
136
137
138
139