]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSpList.cxx
Example macro for the creation of tags (P.Christakoglou)
[u/mrichter/AliRoot.git] / ITS / AliITSpList.cxx
... / ...
CommitLineData
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
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
27#include <TObjArray.h>
28
29#include "AliITSpList.h"
30#include "AliITSpListItem.h"
31
32
33//______________________________________________________________________
34
35ClassImp(AliITSpList)
36//______________________________________________________________________
37AliITSpList::AliITSpList(){
38 // Default constructor
39 // Inputs:
40 // none.
41 // Outputs:
42 // none.
43 // Return:
44 // A zeroed/empty AliITSpList class.
45
46 fNi = 0;
47 fNj = 0;
48 fa = 0;
49}
50//______________________________________________________________________
51AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
52 // Standard constructor
53 // Inputs:
54 // none.
55 // Outputs:
56 // none.
57 // Return:
58 // A setup AliITSpList class.
59
60 fNi = imax;
61 fNj = jmax;
62 fEnteries = 0;
63 fa = new TObjArray(fNi*fNj); // elements are zeroed by
64 // TObjArray creator
65}
66//______________________________________________________________________
67AliITSpList::~AliITSpList(){
68 // Default destructor
69 // Inputs:
70 // none.
71 // Outputs:
72 // none.
73 // Return:
74 // a properly destroyed class
75
76 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
77 delete fa->At(i);
78 fa->AddAt(0,i); // zero content
79 } // end for i && if
80 fNi = 0;
81 fNj = 0;
82 delete fa;
83 fa = 0;
84 fEnteries = 0;
85}
86
87//______________________________________________________________________
88void AliITSpList::ClearMap(){
89 // Delete all AliITSpListItems and zero TObjArray.
90 // Inputs:
91 // none.
92 // Outputs:
93 // none.
94 // Return:
95 // A zeroed AliITSpList class.
96
97 fa->Delete();
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 */
104 fEnteries = 0;
105}
106//______________________________________________________________________
107void AliITSpList::DeleteHit(Int_t i,Int_t j){
108 // Delete a particular AliITSpListItems and zero TObjArray.
109 // Inputs:
110 // Int_t i Row number
111 // Int_t j Columns number
112 // Outputs:
113 // none.
114 // Return:
115 // none.
116 Int_t k = GetIndex(i,j);
117
118 if(fa->At(k)!=0){
119 delete fa->At(k);
120 fa->AddAt(0,k); // zero content
121 } // end for i && if
122 if(k==fEnteries-1) fEnteries--;
123}
124//______________________________________________________________________
125AliITSpList& AliITSpList::operator=(const AliITSpList &source){
126 // = operator
127 // Inputs:
128 // const AliITSpList &source A AliITSpList object.
129 // Outputs:
130 // none.
131 // Return:
132 // A copied AliITSpList object.
133
134 if(this == &source) return *this;
135
136 if(this->fa!=0){ // if this->fa exists delete it first.
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;
142 } // end if this->fa!=0
143 this->fNi = source.fNi;
144 this->fNj = source.fNj;
145 this->fa = new TObjArray(*(source.fa));
146 this->fEnteries = source.fEnteries;
147
148 return *this;
149}
150//______________________________________________________________________
151AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source){
152 // Copy constructor
153
154 fNi = source.fNi;
155 fNj = source.fNj;
156 fa = new TObjArray(*(source.fa));
157 fEnteries = source.fEnteries;
158}
159//______________________________________________________________________
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
177 ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
178 if(index>=fEnteries) fEnteries = index +1;
179}
180//______________________________________________________________________
181void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
182 Double_t signal){
183 // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
184 // if needed.
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.
196 Int_t index = GetIndex(i,j);
197
198 if(GetpListItem(index)==0){ // most create AliITSpListItem
199 fa->AddAt(new AliITSpListItem(trk,ht,mod,index,signal),index);
200 }else{ // AliITSpListItem exists, just add signal to it.
201 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
202 } // end if
203 if(index>=fEnteries) fEnteries = index +1;
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.
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.
217 Int_t index = GetIndex(i,j);
218
219 if(GetpListItem(index)==0){ // most create AliITSpListItem
220 fa->AddAt(new AliITSpListItem(mod,index,noise),index);
221 }else{ // AliITSpListItem exists, just add signal to it.
222 GetpListItem(index)->AddNoise(mod,index,noise);
223 } // end if
224 if(index>=fEnteries) fEnteries = index +1;
225}
226//______________________________________________________________________
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;
234 return;
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 }
250}