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