]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSpList.cxx
Commenting out unused variables (FedoraCore3, gcc 3.4.2)
[u/mrichter/AliRoot.git] / ITS / AliITSpList.cxx
CommitLineData
2134176d 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/* $Id$ */
16
fb4e90e0 17//***********************************************************************
18//
19// It consist of a TObjectArray of
20// AliITSpListItem objects
21// This array can be accessed via 2 indexed
22// it is used at digitization level by
23// all the 3 ITS subdetectors
24//
25// ***********************************************************************
26
2134176d 27#include <TObjArray.h>
2134176d 28
29#include "AliITSpList.h"
fb4e90e0 30#include "AliITSpListItem.h"
31
2134176d 32
33//______________________________________________________________________
34
35ClassImp(AliITSpList);
36//______________________________________________________________________
37AliITSpList::AliITSpList(){
38 // Default constructor
c7d528c6 39 // Inputs:
40 // none.
41 // Outputs:
42 // none.
43 // Return:
44 // A zeroed/empty AliITSpList class.
2134176d 45
46 fNi = 0;
47 fNj = 0;
48 fa = 0;
49}
50//______________________________________________________________________
51AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
52 // Standard constructor
c7d528c6 53 // Inputs:
54 // none.
55 // Outputs:
56 // none.
57 // Return:
58 // A setup AliITSpList class.
2134176d 59
60 fNi = imax;
61 fNj = jmax;
9ce4d38b 62 fEnteries = 0;
2134176d 63 fa = new TObjArray(fNi*fNj); // elements are zeroed by
64 // TObjArray creator
65}
66//______________________________________________________________________
67AliITSpList::~AliITSpList(){
68 // Default destructor
c7d528c6 69 // Inputs:
70 // none.
71 // Outputs:
72 // none.
73 // Return:
74 // a properly destroyed class
2134176d 75
76 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
c7d528c6 77 delete fa->At(i);
78 fa->AddAt(0,i); // zero content
2134176d 79 } // end for i && if
80 fNi = 0;
81 fNj = 0;
82 delete fa;
83 fa = 0;
9ce4d38b 84 fEnteries = 0;
2134176d 85}
fb4e90e0 86
2134176d 87//______________________________________________________________________
88void AliITSpList::ClearMap(){
89 // Delete all AliITSpListItems and zero TObjArray.
c7d528c6 90 // Inputs:
91 // none.
92 // Outputs:
93 // none.
94 // Return:
95 // A zeroed AliITSpList class.
2134176d 96
9ce4d38b 97 fa->Delete();
cab0142f 98 /*
99 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
100 delete fa->At(i);
101 fa->AddAt(0,i); // zero content
102 } // end for i && if
103 */
9ce4d38b 104 fEnteries = 0;
2134176d 105}
106//______________________________________________________________________
107void AliITSpList::DeleteHit(Int_t i,Int_t j){
108 // Delete a particular AliITSpListItems and zero TObjArray.
c7d528c6 109 // Inputs:
110 // Int_t i Row number
111 // Int_t j Columns number
112 // Outputs:
113 // none.
114 // Return:
115 // none.
2134176d 116 Int_t k = GetIndex(i,j);
117
118 if(fa->At(k)!=0){
c7d528c6 119 delete fa->At(k);
120 fa->AddAt(0,k); // zero content
2134176d 121 } // end for i && if
9ce4d38b 122 if(k==fEnteries-1) fEnteries--;
2134176d 123}
124//______________________________________________________________________
125AliITSpList& AliITSpList::operator=(const AliITSpList &source){
126 // = operator
c7d528c6 127 // Inputs:
128 // const AliITSpList &source A AliITSpList object.
129 // Outputs:
130 // none.
131 // Return:
132 // A copied AliITSpList object.
2134176d 133
134 if(this == &source) return *this;
135
136 if(this->fa!=0){ // if this->fa exists delete it first.
c7d528c6 137 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
138 delete fa->At(i);
139 fa->AddAt(0,i); // zero content
140 } // end for i && if
141 delete this->fa;
2134176d 142 } // end if this->fa!=0
143 this->fNi = source.fNi;
144 this->fNj = source.fNj;
145 this->fa = new TObjArray(*(source.fa));
9ce4d38b 146 this->fEnteries = source.fEnteries;
2134176d 147
148 return *this;
149}
150//______________________________________________________________________
fb4e90e0 151AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source){
152 // Copy constructor
2134176d 153
fb4e90e0 154 fNi = source.fNi;
155 fNj = source.fNj;
156 fa = new TObjArray(*(source.fa));
157 fEnteries = source.fEnteries;
2134176d 158}
159//______________________________________________________________________
c7d528c6 160void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
161 // Adds the contents of pl to the list with track number off set given by
162 // fileIndex.
163 // Creates the AliITSpListItem if needed.
164 // Inputs:
165 // Int_t fileIndex track number offset value
166 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
167 // Outputs:
168 // none.
169 // Return:
170 // none.
171 Int_t index = pl->GetIndex();
172
173 if( fa->At( index ) == 0 ) { // most create AliITSpListItem
174 fa->AddAt(new AliITSpListItem(-2,-1,pl->GetModule(),index,0.0),index);
175 } // end if
176
cab0142f 177 ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
9ce4d38b 178 if(index>=fEnteries) fEnteries = index +1;
c7d528c6 179}
180//______________________________________________________________________
2134176d 181void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
c7d528c6 182 Double_t signal){
2134176d 183 // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
184 // if needed.
c7d528c6 185 // Inputs:
186 // Int_t i Row number for this signal
187 // Int_t j Column number for this signal
188 // Int_t trk Track number creating this signal
189 // Int_t ht Hit number creating this signal
190 // Int_t mod The module where this signal is in
191 // Double_t signal The signal (ionization)
192 // Outputs:
193 // none.
194 // Return:
195 // none.
9ce4d38b 196 Int_t index = GetIndex(i,j);
2134176d 197
9ce4d38b 198 if(GetpListItem(index)==0){ // most create AliITSpListItem
cab0142f 199 fa->AddAt(new AliITSpListItem(trk,ht,mod,index,signal),index);
2134176d 200 }else{ // AliITSpListItem exists, just add signal to it.
9ce4d38b 201 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
2134176d 202 } // end if
9ce4d38b 203 if(index>=fEnteries) fEnteries = index +1;
2134176d 204}
205//______________________________________________________________________
206void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
207 // Adds a noise value to the TObjArray at i,j. Creates the AliITSpListItem
208 // if needed.
c7d528c6 209 // Inputs:
210 // Int_t i Row number for this noise
211 // Int_t j Column number for this noise
212 // Double_t noise The noise signal value.
213 // Outputs:
214 // none.
215 // Return:
216 // none.
9ce4d38b 217 Int_t index = GetIndex(i,j);
2134176d 218
9ce4d38b 219 if(GetpListItem(index)==0){ // most create AliITSpListItem
220 fa->AddAt(new AliITSpListItem(mod,index,noise),index);
2134176d 221 }else{ // AliITSpListItem exists, just add signal to it.
9ce4d38b 222 GetpListItem(index)->AddNoise(mod,index,noise);
2134176d 223 } // end if
9ce4d38b 224 if(index>=fEnteries) fEnteries = index +1;
2134176d 225}
226//______________________________________________________________________
fb4e90e0 227void AliITSpList::GetCell(Int_t index,Int_t &i,Int_t &j) const {
228 // returns the i,j index numbers from the linearized index computed
229 // with GetIndex
230 if(index<0 || index>=fNi*fNj){
231 Warning("GetCell","Index out of range 0<=index=%d<%d",
232 index,fNi*fNj);
233 i=-1;j=-1;
2134176d 234 return;
fb4e90e0 235 } // end if
236 i = index/fNj;
237 j = index - fNj*i;
238 return;
239}
240//______________________________________________________________________
241Int_t AliITSpList::GetIndex(Int_t i, Int_t j) const {
242 // returns the TObjArray index for a given set of map indexes.
243 if(i<0||i>=fNi || j<0||j>=fNj){
244 Warning("GetIndex","Index out of range 0<i=%d<%d and 0<0j=%d<%d",i,fNi,j,fNj);
245 return -1;
246 }
247 else {
248 return fNj*i+j;
249 }
2134176d 250}