AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUON1DMap.cxx
Go to the documentation of this file.
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 "AliMUON1DMap.h"
19 #include "AliMpExMap.h"
20 #include "AliMpExMapIterator.h"
21 
22 #include "AliLog.h"
23 
24 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
32 
36 
37 //_____________________________________________________________________________
38 AliMUON1DMap::AliMUON1DMap(TRootIOCtor*)
39 : AliMUONVStore(),
40 fMap(0x0)
41 {
43 
44 }
45 
46 //_____________________________________________________________________________
48 : AliMUONVStore(),
49  fMap(new AliMpExMap)
50 {
52 
53  if ( theSize > 0)
54  {
55  fMap->SetSize(theSize);
56  }
57  fMap->SetOwner(kTRUE);
58 }
59 
60 //_____________________________________________________________________________
62 : AliMUONVStore(),
63  fMap(new AliMpExMap(*other.fMap))
64 {
66 }
67 
68 //_____________________________________________________________________________
71 {
73  *fMap = *other.fMap;
74  return *this;
75 }
76 
77 //_____________________________________________________________________________
79 {
81  delete fMap;
82 }
83 
84 //_____________________________________________________________________________
85 Bool_t
86 AliMUON1DMap::Add(TObject* object)
87 {
89  if (!object) return kFALSE;
90  return Set(object->GetUniqueID(),object);
91 }
92 
93 //_____________________________________________________________________________
94 void
96 {
98  fMap->Clear();
99 }
100 
101 //_____________________________________________________________________________
102 AliMUON1DMap*
104 {
106  return new AliMUON1DMap(fMap->GetSize());
107 }
108 
109 //_____________________________________________________________________________
110 TObject*
112 {
114  return fMap->GetValue(i);
115 }
116 
117 //_____________________________________________________________________________
118 TObject*
119 AliMUON1DMap::FindObject(Int_t i, Int_t j) const
120 {
122 
123  UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) );
124 
125  return fMap->GetValue(uid);
126 }
127 
128 //_____________________________________________________________________________
129 TIterator*
131 {
134  return fMap->CreateIterator();
135 }
136 
137 //_____________________________________________________________________________
138 Int_t
140 {
142  return fMap->GetSize();
143 }
144 
145 //_____________________________________________________________________________
146 Bool_t
147 AliMUON1DMap::Set(Int_t i, TObject* object)
148 {
152 
153  TObject* o = FindObject(i);
154  if ( o )
155  {
156  AliError(Form("Object %p is already there for i=%d",o,i));
157  return kFALSE;
158  }
159  fMap->Add(i,object);
160  return kTRUE;
161 }
162 
virtual Bool_t Set(Int_t i, TObject *object)
virtual AliMUON1DMap * Create() const
Create an empty copy of this.
AliMUON1DMap()
Not implemented.
void SetSize(Int_t size)
Definition: AliMpExMap.cxx:321
virtual void Clear(Option_t *opt="")
Clear ourselves (i.e. Reset)
virtual TIterator * CreateIterator() const
Return an iterator to loop over the whole store.
virtual Bool_t Add(TObject *object)
Add an object to the store.
AliMpExMap * fMap
Internal array (map)
Definition: AliMUON1DMap.h:57
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetSize() const
Definition: AliMpExMap.cxx:339
virtual ~AliMUON1DMap()
virtual Int_t GetSize() const
The number of objects stored.
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:364
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:291
void SetOwner(Bool_t owner)
Definition: AliMpExMap.cxx:331
AliMUON1DMap & operator=(const AliMUON1DMap &other)
Implementation of AliMUONVStore.
Definition: AliMUON1DMap.h:21
virtual TObject * FindObject(UInt_t i) const
Find an object using a single id.
Base class for MUON data stores.
Definition: AliMUONVStore.h:22
virtual void Clear(Option_t *opt="")
Definition: AliMpExMap.cxx:258
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:356