]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON2DMap.cxx
Additional protection and warning message.
[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
23#include <cassert>
24
25ClassImp(AliMUON2DMap)
26
27//_____________________________________________________________________________
28AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true))
29{
e5cc543e 30 //
31 // ctor.
32 //
f6e5d0e9 33}
34
35//_____________________________________________________________________________
36AliMUON2DMap::~AliMUON2DMap()
37{
e5cc543e 38 //
39 // dtor. we delete the map, which will delete the objects, as we're owner.
40 //
f6e5d0e9 41 delete fMap;
42}
43
44//_____________________________________________________________________________
45TObject*
46AliMUON2DMap::Get(Int_t i, Int_t j) const
47{
e5cc543e 48 //
49 // Return the value at position (i,j).
50 //
f6e5d0e9 51 TObject* o = fMap->GetValue(i);
52 if ( o )
53 {
54 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
55 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
56 return m->GetValue(j);
57 }
58 return 0x0;
59}
60
f6e5d0e9 61//_____________________________________________________________________________
62void
63AliMUON2DMap::Print(Option_t*) const
64{
e5cc543e 65 //
66 // Not implemented (yet?)
67 //
f6e5d0e9 68}
69
70//_____________________________________________________________________________
71Bool_t
72AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
73{
e5cc543e 74 //
75 // Set the object at position (i,j).
76 // If replace==kTRUE, we don't care if there's an object there already,
77 // otherwise we might refuse to set if the (i,j) location is already
78 // filled (in which case we return kFALSE).
79
f6e5d0e9 80 TObject* o = fMap->GetValue(i);
81 if ( !o )
82 {
83 AliMpExMap* m = new AliMpExMap(true);
84 fMap->Add(i,m);
85 o = fMap->GetValue(i);
86 assert(m==o);
87 }
88 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
89 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
90 o = m->GetValue(j);
91 if ( !o || ( o && replace ) )
92 {
93 if ( IsOwner() )
94 {
95 delete o;
96 }
97 m->Add(j,object);
98 }
99 else if ( o && !replace )
100 {
101 AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j));
102 return kFALSE;
103 }
104 return kTRUE;
105}
106
107
108
109
110