]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUON2DMap.cxx
Removed declaration of not used/implemented function FixLeft()
[u/mrichter/AliRoot.git] / MUON / AliMUON2DMap.cxx
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 /// \class AliMUON2DMap
24 /// \brief Basic implementation of AliMUONV2DStore container using
25 /// AliMpExMap internally.
26 /// What we store is a "double" map : an AliMpExMap of AliMpExMaps
27 ///
28 /// \author Laurent Aphecetche
29
30 /// \cond CLASSIMP
31 ClassImp(AliMUON2DMap)
32 /// \endcond
33
34 //_____________________________________________________________________________
35 AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true))
36 {
37 /// Default constructor.
38 }
39
40 //_____________________________________________________________________________
41 AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other)
42 : AliMUONV2DStore(),
43 fMap(0x0)
44 {
45  /// Copy constructor.
46
47  other.CopyTo(*this);
48 }
49
50 //_____________________________________________________________________________
51 AliMUON2DMap&
52 AliMUON2DMap::operator=(const AliMUON2DMap& other)
53 {
54 /// Assignment operator
55
56   other.CopyTo(*this);
57   return *this;
58 }
59
60 //_____________________________________________________________________________
61 AliMUON2DMap::~AliMUON2DMap()
62 {
63 /// Destructor. 
64 /// We delete the map, which will delete the objects, as we're owner.
65
66   delete fMap;
67 }
68
69 //_____________________________________________________________________________
70 void
71 AliMUON2DMap::CopyTo(AliMUON2DMap&) const
72 {
73 /// Copy this into dest.
74
75   AliFatal("Implement me if needed");
76 }
77
78 //_____________________________________________________________________________
79 TObject* 
80 AliMUON2DMap::Get(Int_t i, Int_t j) const
81 {
82 /// Return the value at position (i,j).
83
84   TObject* o = fMap->GetValue(i);
85   if ( o )
86   {
87     AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
88     if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
89     return m->GetValue(j);
90   }
91   return 0x0;
92 }
93
94 //_____________________________________________________________________________
95 void
96 AliMUON2DMap::Print(Option_t*) const
97 {
98 /// Not implemented (yet?)
99 }
100
101 //_____________________________________________________________________________
102 Bool_t 
103 AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
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   
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);
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