1 /**************************************************************************
2 * Copyright(c) 2004-2006, 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 **************************************************************************/
16 //////////////////////////////////////////////////////////////////////
17 // Author: A.Mastroserio, C.Terrevoli //
18 // annalisa.mastroserio@cern.ch //
19 // cristina.terrevoli@ba.infn.it //
20 // This class implements the use of a list of clusters. //
21 //////////////////////////////////////////////////////////////////////
25 #include "AliITSUpgradeClusterList.h"
26 #include "AliITSUpgradeClusterListNode.h"
28 //______________________________________________________________________________
29 AliITSUpgradeClusterList::AliITSUpgradeClusterList():
34 fFastAccessArray(NULL),
37 //______________________________________________________________________________
38 AliITSUpgradeClusterList::AliITSUpgradeClusterList(AliITSUpgradeClusterListNode* first, UInt_t nrEntries):
39 fNrEntries(nrEntries),
43 fFastAccessArray(NULL),
48 //______________________________________________________________________________
49 AliITSUpgradeClusterList::AliITSUpgradeClusterList(const AliITSUpgradeClusterList& ilist):
54 fFastAccessArray(NULL),
60 //______________________________________________________________________________
61 AliITSUpgradeClusterList::~AliITSUpgradeClusterList() {
64 //______________________________________________________________________________
65 AliITSUpgradeClusterList& AliITSUpgradeClusterList::operator=(const AliITSUpgradeClusterList& ilist) {
66 // assignment operator
69 fFirst = CloneNode(ilist.fFirst);
72 fFastAccessArray=NULL;
77 //______________________________________________________________________________
78 void AliITSUpgradeClusterList::Clear() {
79 // clear the whole list
84 //______________________________________________________________________________
85 void AliITSUpgradeClusterList::ClearNode(AliITSUpgradeClusterListNode* &node) {
86 // clear this node and all children nodes
87 if (node==NULL) return;
88 ClearNode(node->Next());
94 //______________________________________________________________________________
95 AliITSUpgradeClusterList* AliITSUpgradeClusterList::Clone() const {
96 // returns a clone of the list
97 AliITSUpgradeClusterListNode *newFirst;
98 newFirst = CloneNode(fFirst);
99 AliITSUpgradeClusterList* newList = new AliITSUpgradeClusterList(newFirst,fNrEntries);
102 //______________________________________________________________________________
103 AliITSUpgradeClusterListNode* AliITSUpgradeClusterList::CloneNode(AliITSUpgradeClusterListNode* node) const {
104 if (node==NULL) return NULL;
105 else return new AliITSUpgradeClusterListNode(node->Col(),node->Row(),node->Size(),node->WidthZ(),node->WidthPhi(),node->Type(),node->Charge(),CloneNode(node->Next()));
107 //______________________________________________________________________________
108 Bool_t AliITSUpgradeClusterList::Insert(Float_t col, Float_t row, UShort_t size, UShort_t widthZ, UShort_t widthPhi, UShort_t type, UShort_t charge, Int_t digLabels[12*kMaxLab]) {
109 // insert a new node into the list (returns true if the node was not present before)
111 AliITSUpgradeClusterListNode* node = new AliITSUpgradeClusterListNode(col,row,size,widthZ,widthPhi,type,charge,NULL);
112 for(Int_t i=0; i< 12*kMaxLab; i++) node->AddDigitLabel(digLabels[i]); // adding digit label to the cluster
117 fLast->Next() = node;
122 //______________________________________________________________________________
123 void AliITSUpgradeClusterList::SetLastNode() {
124 AliITSUpgradeClusterListNode* node = fFirst;
130 if (node->Next()==NULL) {
137 //______________________________________________________________________________
138 void AliITSUpgradeClusterList::ClearFastAccess(){
139 // clears the fast access array of pointers
140 if (fFastAccessArray!=NULL) {
141 delete [] fFastAccessArray;
142 fFastAccessArray=NULL;
146 //______________________________________________________________________________
147 void AliITSUpgradeClusterList::InitFastAccess(){
148 // initializes the fast access array
149 if (fFastAccess) return;
152 fFastAccessArray = new AliITSUpgradeClusterListNode*[fNrEntries];
154 InitFastAccessNode(fFirst);
158 //______________________________________________________________________________
159 void AliITSUpgradeClusterList::InitFastAccessNode(AliITSUpgradeClusterListNode* node) {
160 // initializes the fast access array starting from node (used recursively)
161 if (node==NULL) return;
162 fFastAccessArray[fDummyIndex++] = node;
163 InitFastAccessNode(node->Next());
165 //______________________________________________________________________________
166 Float_t AliITSUpgradeClusterList::GetColIndex(UInt_t index) {
167 // returns the col of the node at position 'index' in the list
168 // returns -1 if out of bounds
169 if (index<fNrEntries) {
170 if (!fFastAccess) InitFastAccess();
171 return fFastAccessArray[index]->Col();
175 //______________________________________________________________________________
176 Float_t AliITSUpgradeClusterList::GetRowIndex(UInt_t index) {
177 // returns the row of the node at position 'index' in the list
178 // returns -1 if out of bounds
179 if (index<fNrEntries) {
180 if (!fFastAccess) InitFastAccess();
181 return fFastAccessArray[index]->Row();
185 //______________________________________________________________________________
186 UShort_t AliITSUpgradeClusterList::GetSizeIndex(UInt_t index) {
187 // returns the size of the node at position 'index' in the list
188 // returns 0 if out of bounds
189 if (index<fNrEntries) {
190 if (!fFastAccess) InitFastAccess();
191 return fFastAccessArray[index]->Size();
195 //______________________________________________________________________________
196 UShort_t AliITSUpgradeClusterList::GetWidthZIndex(UInt_t index) {
197 // returns the width z of the node at position 'index' in the list
198 // returns 0 if out of bounds
199 if (index<fNrEntries) {
200 if (!fFastAccess) InitFastAccess();
201 return fFastAccessArray[index]->WidthZ();
205 //______________________________________________________________________________
206 UShort_t AliITSUpgradeClusterList::GetWidthPhiIndex(UInt_t index) {
207 // returns the width phi of the node at position 'index' in the list
208 // returns 0 if out of bounds
209 if (index<fNrEntries) {
210 if (!fFastAccess) InitFastAccess();
211 return fFastAccessArray[index]->WidthPhi();
215 //______________________________________________________________________________
216 UShort_t AliITSUpgradeClusterList::GetTypeIndex(UInt_t index) {
217 // returns the type of the node at position 'index' in the list
218 // returns 99 if out of bounds
219 if (index<fNrEntries) {
220 if (!fFastAccess) InitFastAccess();
221 return fFastAccessArray[index]->Type();
225 //______________________________________________________________________________
226 UShort_t AliITSUpgradeClusterList::GetCharge(UInt_t index) {
227 // returns the charge of the node at position 'index' in the list
228 // returns 0 if out of bounds
229 if (index<fNrEntries) {
230 if (!fFastAccess) InitFastAccess();
231 return fFastAccessArray[index]->Charge();
235 //______________________________________________________________________________
236 Int_t * AliITSUpgradeClusterList::GetLabels(UInt_t index) {
237 // returns the charge of the node at position 'index' in the list
238 // returns 0 if out of bounds
239 if (index<fNrEntries) {
240 if (!fFastAccess) InitFastAccess();
241 return fFastAccessArray[index]->GetLabels();