1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUON2DMap.h"
21 #include "AliMUONVDataIterator.h"
22 #include "AliMUON2DMapIterator.h"
23 #include "AliMpExMap.h"
24 #include "AliMpIntPair.h"
26 /// \class AliMUON2DMap
27 /// \brief Basic implementation of AliMUONV2DStore container using
28 /// AliMpExMap internally.
29 /// What we store is a "double" map : an AliMpExMap of AliMpExMaps
31 /// \author Laurent Aphecetche
34 ClassImp(AliMUON2DMap)
37 //_____________________________________________________________________________
38 AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true))
40 /// Default constructor.
43 //_____________________________________________________________________________
44 AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other)
53 //_____________________________________________________________________________
55 AliMUON2DMap::operator=(const AliMUON2DMap& other)
57 /// Assignment operator
63 //_____________________________________________________________________________
64 AliMUON2DMap::~AliMUON2DMap()
67 /// We delete the map, which will delete the objects, as we're owner.
72 //_____________________________________________________________________________
74 AliMUON2DMap::CopyTo(AliMUON2DMap&) const
76 /// Copy this into dest.
78 AliFatal("Implement me if needed");
81 //_____________________________________________________________________________
83 AliMUON2DMap::Get(Int_t i, Int_t j) const
85 /// Return the value at position (i,j).
87 TObject* o = fMap->GetValue(i);
90 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
91 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
92 return m->GetValue(j);
97 //_____________________________________________________________________________
99 AliMUON2DMap::Iterator() const
101 // Create and return an iterator on this map
102 // Returned iterator must be deleted by user.
105 return new AliMUON2DMapIterator(*fMap);
110 //_____________________________________________________________________________
112 AliMUON2DMap::Print(Option_t*) const
114 /// Not implemented (yet?)
117 //_____________________________________________________________________________
119 AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
121 /// Set the object at position (i,j).
122 /// If replace==kTRUE, we don't care if there's an object there already,
123 /// otherwise we might refuse to set if the (i,j) location is already
124 /// filled (in which case we return kFALSE).
126 TObject* o = fMap->GetValue(i);
129 AliMpExMap* m = new AliMpExMap(true);
131 o = fMap->GetValue(i);
133 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
134 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
136 if ( !o || ( o && replace ) )
144 else if ( o && !replace )
146 AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j));