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 **************************************************************************/
22 #include "AliEMCALFixedWindowClusterInfo.h"
24 ClassImp(AliEMCALFixedWindowClusterInfo)
26 //___________________________________________________________________________________________________________
27 AliEMCALFixedWindowClusterInfo::AliEMCALFixedWindowClusterInfo()
31 fIndexes(new TArrayI()),
38 //___________________________________________________________________________________________________________
39 AliEMCALFixedWindowClusterInfo::AliEMCALFixedWindowClusterInfo(const char* name, Int_t size)
42 fIds(new TArrayI(size)),
43 fIndexes(new TArrayI(size)),
44 fPhi(new TArrayI(size)),
45 fEta(new TArrayI(size))
55 //___________________________________________________________________________________________________________
56 AliEMCALFixedWindowClusterInfo::AliEMCALFixedWindowClusterInfo(const TString& name, Int_t size)
59 fIds(new TArrayI(size)),
60 fIndexes(new TArrayI(size)),
61 fPhi(new TArrayI(size)),
62 fEta(new TArrayI(size))
72 //___________________________________________________________________________________________________________
73 AliEMCALFixedWindowClusterInfo::~AliEMCALFixedWindowClusterInfo()
83 //___________________________________________________________________________________________________________
84 Bool_t AliEMCALFixedWindowClusterInfo::GetInfoFromId(Int_t idclus, Int_t &index, Int_t &eta, Int_t &phi) const
86 // Search for the unique ID and return index, eta and phi
88 Int_t i = GetPositionFromId(idclus);
90 index = fIndexes->At(i);
98 //___________________________________________________________________________________________________________
99 Bool_t AliEMCALFixedWindowClusterInfo::GetInfoFromIndex(Int_t index, Int_t &idclus, Int_t &eta, Int_t &phi) const
101 // Search for the index and return unique ID, eta and phi
103 Int_t i = GetPositionFromIndex(index);
105 idclus = fIds->At(i);
113 //___________________________________________________________________________________________________________
114 Bool_t AliEMCALFixedWindowClusterInfo::SetIndexFromId(Int_t idclus, Int_t index)
116 // Search for the unique ID and set index
118 Int_t i = GetPositionFromId(idclus);
120 fIndexes->AddAt(index, i);
126 //___________________________________________________________________________________________________________
127 void AliEMCALFixedWindowClusterInfo::Add(Int_t idclus, Int_t index, Int_t eta, Int_t phi)
129 // Add a new element to the arrays; if necessary expand the arrays
131 if (fLastPos >= fIds->GetSize())
132 Expand(fIds->GetSize() * 2 + 1);
134 fIds->AddAt(idclus, fLastPos);
135 fIndexes->AddAt(index, fLastPos);
136 fPhi->AddAt(phi, fLastPos);
137 fEta->AddAt(eta, fLastPos);
141 //___________________________________________________________________________________________________________
142 Bool_t AliEMCALFixedWindowClusterInfo::RemoveId(Int_t idclus)
144 // Search for the unique ID and remove the corresponding element from the arrays
146 Int_t i = GetPositionFromId(idclus);
149 fIndexes->AddAt(-1, i);
157 //___________________________________________________________________________________________________________
158 Bool_t AliEMCALFixedWindowClusterInfo::RemoveIndex(Int_t index)
160 // Search for and index and remove the corresponding element from the arrays
162 Int_t i = GetPositionFromIndex(index);
165 fIndexes->AddAt(-1, i);
173 //___________________________________________________________________________________________________________
174 void AliEMCALFixedWindowClusterInfo::Expand(Int_t size)
178 Int_t oldsize = fIds->GetSize();
185 for (Int_t i = oldsize; i < size; i++){
187 fIndexes->AddAt(-1, i);
193 //___________________________________________________________________________________________________________
194 void AliEMCALFixedWindowClusterInfo::Clear(Option_t* option)
205 //___________________________________________________________________________________________________________
206 Int_t AliEMCALFixedWindowClusterInfo::GetSize() const
208 // Return the size of the arrays
210 return fIds->GetSize();
213 //___________________________________________________________________________________________________________
214 Bool_t AliEMCALFixedWindowClusterInfo::ContainsId(Int_t idclus) const
216 // Search for the unique ID and return whether or not it exists
218 if(GetPositionFromId(idclus) > -1)
224 //___________________________________________________________________________________________________________
225 Bool_t AliEMCALFixedWindowClusterInfo::ContainsIndex(Int_t index) const
227 // Search for the index and return whether or not it exists
229 if(GetPositionFromIndex(index) > -1)
235 //___________________________________________________________________________________________________________
236 Int_t AliEMCALFixedWindowClusterInfo::GetPositionFromId(Int_t idclus) const
238 // Return the the position corresponding to a given unique ID
240 for (Int_t i = 0; i < fLastPos; i++){
241 if (fIds->At(i) == idclus)
247 //___________________________________________________________________________________________________________
248 Int_t AliEMCALFixedWindowClusterInfo::GetPositionFromIndex(Int_t index) const
250 // Return the the position corresponding to a given index
252 for (Int_t i = 0; i < fLastPos; i++){
253 if (fIndexes->At(i) == index)
259 //___________________________________________________________________________________________________________
260 Int_t AliEMCALFixedWindowClusterInfo::GetLastElementPosition() const
262 // Return the position of the last non-empty element in the arrays