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"
25 #include "AliMpManuList.h"
26 #include "AliMpDEManager.h"
27 #include "AliMUONConstants.h"
29 /// \class AliMUON2DMap
30 /// \brief Basic implementation of AliMUONV2DStore container using
31 /// AliMpExMap internally.
32 /// What we store is a "double" map : an AliMpExMap of AliMpExMaps
34 /// \author Laurent Aphecetche
37 ClassImp(AliMUON2DMap)
40 //_____________________________________________________________________________
41 AliMUON2DMap::AliMUON2DMap(Bool_t optimizeForDEManu)
43 fMap(new AliMpExMap(true)),
44 fOptimizeForDEManu(optimizeForDEManu)
46 /// Default constructor.
47 if ( fOptimizeForDEManu )
50 for ( Int_t i = 0; i < AliMUONConstants::NTrackingCh(); ++i )
52 nDEs += AliMpDEManager::GetNofDEInChamber(i);
58 //_____________________________________________________________________________
59 AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other)
62 fOptimizeForDEManu(kFALSE)
69 //_____________________________________________________________________________
71 AliMUON2DMap::operator=(const AliMUON2DMap& other)
73 /// Assignment operator
79 //_____________________________________________________________________________
80 AliMUON2DMap::~AliMUON2DMap()
83 /// We delete the map, which will delete the objects, as we're owner.
88 //_____________________________________________________________________________
90 AliMUON2DMap::CloneEmpty() const
92 /// Create a void copy of *this.
93 return new AliMUON2DMap;
96 //_____________________________________________________________________________
98 AliMUON2DMap::CopyTo(AliMUON2DMap& dest) const
100 /// Copy this into dest.
103 dest.fMap = new AliMpExMap(*fMap);
104 dest.fOptimizeForDEManu = fOptimizeForDEManu;
107 //_____________________________________________________________________________
109 AliMUON2DMap::Get(Int_t i, Int_t j) const
111 /// Return the value at position (i,j).
113 TObject* o = fMap->GetValue(i);
116 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
117 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
118 return m->GetValue(j);
123 //_____________________________________________________________________________
124 AliMUONVDataIterator*
125 AliMUON2DMap::Iterator() const
127 // Create and return an iterator on this map
128 // Returned iterator must be deleted by user.
131 return new AliMUON2DMapIterator(*fMap);
136 //_____________________________________________________________________________
138 AliMUON2DMap::Print(Option_t*) const
140 /// Not implemented (yet?)
143 //_____________________________________________________________________________
145 AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
147 /// Set the object at position (i,j).
148 /// If replace==kTRUE, we don't care if there's an object there already,
149 /// otherwise we might refuse to set if the (i,j) location is already
150 /// filled (in which case we return kFALSE).
152 TObject* o = fMap->GetValue(i);
155 AliMpExMap* m = new AliMpExMap(true);
156 if ( fOptimizeForDEManu )
158 Int_t n(AliMpManuList::NumberOfManus(i));
161 AliError(Form("This does not look right : i = %d is supposed to "
162 "be a DetElemId with n = %d manus!",i,n));
170 o = fMap->GetValue(i);
172 AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
173 if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
175 if ( !o || ( o && replace ) )
183 else if ( o && !replace )
185 AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j));