]>
Commit | Line | Data |
---|---|---|
fb4e90e0 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2004, 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 | #include <Riostream.h> | |
1e8fc3eb | 16 | #include <TMath.h> |
17 | #include "AliLog.h" | |
fb4e90e0 | 18 | #include "AliITSpListItem.h" |
19 | // ************************************************************************ | |
20 | // the data member "fa" of the AliITSpList class | |
21 | // is a TObjectArray of AliITSpListItem objects | |
22 | // each AliITSpListItem object contains information related to | |
23 | // the digitization such signal, noise, module number,... | |
24 | // plus some info related to the simulation (hits/track) | |
25 | // in order to allow efficiency studies | |
26 | //************************************************************************ | |
27 | ClassImp(AliITSpListItem) | |
28 | //______________________________________________________________________ | |
29 | AliITSpListItem::AliITSpListItem(){ | |
30 | // Default constructor | |
31 | // Inputs: | |
32 | // none. | |
33 | // Outputs: | |
34 | // none. | |
35 | // Return: | |
36 | // A zeroed/empty AliITSpListItem class. | |
37 | ||
38 | fmodule = -1; | |
39 | findex = -1; | |
40 | for(Int_t i=0;i<this->fgksize;i++){ | |
41 | this->fTrack[i] = -2; | |
42 | this->fHits[i] = -1; | |
43 | this->fSignal[i] = 0.0; | |
44 | } // end if i | |
45 | fTsignal = 0.0; | |
46 | fNoise = 0.0; | |
47 | fSignalAfterElect = 0.0; | |
48 | } | |
49 | //______________________________________________________________________ | |
50 | AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){ | |
51 | // Standard noise constructor | |
52 | // Inputs: | |
53 | // Int_t module The module where this noise occurred | |
54 | // Int_t index The cell index where this noise occurred | |
55 | // Double_t noise The value of the noise. | |
56 | // Outputs: | |
57 | // none. | |
58 | // Return: | |
59 | // A setup and noise filled AliITSpListItem class. | |
60 | ||
61 | this->fmodule = module; | |
62 | this->findex = index; | |
63 | for(Int_t i=0;i<this->fgksize;i++){ | |
64 | this->fTrack[i] = -2; | |
65 | this->fSignal[i] = 0.0; | |
66 | this->fHits[i] = -1; | |
67 | } // end if i | |
68 | this->fTsignal = 0.0; | |
69 | this->fSignalAfterElect = 0.0; | |
70 | this->fNoise = noise; | |
71 | } | |
72 | //______________________________________________________________________ | |
73 | AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module, | |
74 | Int_t index,Double_t signal){ | |
75 | // Standard signal constructor | |
76 | // Inputs: | |
77 | // Int_t track The track number which produced this signal | |
78 | // Int_t hit The hit number which produced this signal | |
79 | // Int_t module The module where this signal occurred | |
80 | // Int_t index The cell index where this signal occurred | |
81 | // Double_t signal The value of the signal (ionization) | |
82 | // Outputs: | |
83 | // none. | |
84 | // Return: | |
85 | // A setup and signal filled AliITSpListItem class. | |
86 | ||
87 | this->fmodule = module; | |
88 | this->findex = index; | |
89 | this->fTrack[0] = track; | |
90 | this->fHits[0] = hit; | |
91 | this->fSignal[0] = signal; | |
92 | for(Int_t i=1;i<this->fgksize;i++){ | |
93 | this->fTrack[i] = -2; | |
94 | this->fSignal[i] = 0.0; | |
95 | this->fHits[i] = -1; | |
96 | } // end if i | |
97 | this->fTsignal = signal; | |
98 | this->fNoise = 0.0; | |
99 | this->fSignalAfterElect = 0.0; | |
100 | } | |
101 | //______________________________________________________________________ | |
102 | AliITSpListItem::~AliITSpListItem(){ | |
103 | // Destructor | |
104 | // Inputs: | |
105 | // none. | |
106 | // Outputs: | |
107 | // none. | |
108 | // Return: | |
109 | // A properly destroyed AliITSpListItem class. | |
110 | ||
111 | } | |
112 | //______________________________________________________________________ | |
113 | AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){ | |
114 | // = operator | |
115 | // Inputs: | |
116 | // AliITSpListItem &source A AliITSpListItem Object | |
117 | // Outputs: | |
118 | // none. | |
119 | // Return: | |
120 | // A copied AliITSpListItem object | |
121 | Int_t i; | |
122 | ||
123 | if(this == &source) return *this; | |
124 | ||
125 | this->fmodule = source.fmodule; | |
126 | this->findex = source.findex; | |
127 | for(i=0;i<this->fgksize;i++){ | |
128 | this->fTrack[i] = source.fTrack[i]; | |
129 | this->fSignal[i] = source.fSignal[i]; | |
130 | this->fHits[i] = source.fHits[i]; | |
131 | } // end if i | |
132 | this->fTsignal = source.fTsignal; | |
133 | this->fNoise = source.fNoise; | |
134 | this->fSignalAfterElect = source.fSignalAfterElect; | |
135 | /* | |
136 | cout <<"this fTrack[0-9]="; | |
137 | for(i=0;i<this->fgksize;i++) cout <<this->fTrack[i]<<","; | |
138 | cout <<" fHits[0-9]="; | |
139 | for(i=0;i<this->fgksize;i++) cout <<this->fHits[i]<<","; | |
140 | cout <<" fSignal[0-9]="; | |
141 | for(i=0;i<this->fgksize;i++) cout <<this->fSignal[i]<<","; | |
142 | cout << endl; | |
143 | cout <<"source fTrack[0-9]="; | |
144 | for(i=0;i<this->fgksize;i++) cout <<source.fTrack[i]<<","; | |
145 | cout <<" fHits[0-9]="; | |
146 | for(i=0;i<this->fgksize;i++) cout <<source.fHits[i]<<","; | |
147 | cout <<" fSignal[0-9]="; | |
148 | for(i=0;i<this->fgksize;i++) cout <<source.fSignal[i]<<","; | |
149 | cout << endl; | |
150 | */ | |
151 | return *this; | |
152 | } | |
153 | //______________________________________________________________________ | |
154 | AliITSpListItem::AliITSpListItem(AliITSpListItem &source) : TObject(source){ | |
155 | // Copy operator | |
156 | // Inputs: | |
157 | // AliITSpListItem &source A AliITSpListItem Object | |
158 | // Outputs: | |
159 | // none. | |
160 | // Return: | |
161 | // A copied AliITSpListItem object | |
162 | ||
163 | *this = source; | |
164 | } | |
165 | //______________________________________________________________________ | |
166 | void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module, | |
167 | Int_t index,Double_t signal){ | |
168 | // Adds this track number and signal to the pList and orders them | |
169 | // Inputs: | |
170 | // Int_t track The track number which produced this signal | |
171 | // Int_t hit The hit number which produced this signal | |
172 | // Int_t module The module where this signal occurred | |
173 | // Int_t index The cell index where this signal occurred | |
174 | // Double_t signal The value of the signal (ionization) | |
175 | // Outputs: | |
176 | // none. | |
177 | // Return: | |
178 | // none. | |
179 | Int_t i,j,trk,hts; | |
180 | Double_t sig; | |
181 | Bool_t flg=kFALSE; | |
182 | ||
1e8fc3eb | 183 | if (TMath::Abs(signal)>2147483647.0) { |
184 | //PH 2147483647 is the max. integer | |
185 | //PH This apparently is a problem which needs investigation | |
186 | AliWarning(Form("Too big or too small signal value %f",signal)); | |
187 | signal = TMath::Sign((Double_t)2147483647,signal); | |
188 | } | |
fb4e90e0 | 189 | if(findex!=index || fmodule!=module) |
190 | Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d", | |
191 | index,findex,module,fmodule); | |
192 | fTsignal += signal; // Keep track of sum signal. | |
193 | ||
194 | // for(i=0;i<fgksize;i++) if( track==fTrack[i] && hit==fHits[i] ){ | |
195 | for(i=0;i<fgksize;i++) if( track==fTrack[i] ){ | |
196 | fSignal[i] += signal; | |
197 | flg = kTRUE; | |
198 | } // end for i & if. | |
199 | //cout << "track="<<track<<endl; | |
200 | if(flg){ // resort arrays. | |
201 | for(i=1;i<fgksize;i++){ | |
202 | j = i; | |
203 | while(j>0 && fSignal[j]>fSignal[j-1]){ | |
204 | trk = fTrack[j-1]; | |
205 | hts = fHits[j-1]; | |
206 | sig = fSignal[j-1]; | |
207 | fTrack[j-1] = fTrack[j]; | |
208 | fHits[j-1] = fHits[j]; | |
209 | fSignal[j-1] = fSignal[j]; | |
210 | fTrack[j] = trk; | |
211 | fHits[j] = hts; | |
212 | fSignal[j] = sig; | |
213 | //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<< | |
214 | // j<<"]="<<fTrack[j]<<endl; | |
215 | j--; | |
216 | } // end while | |
217 | } // end if i | |
218 | return; | |
219 | } // end if added to existing and resorted array | |
220 | ||
221 | // new entry add it in order. | |
222 | // if this signal is <= smallest then don't add it. | |
223 | if(signal <= fSignal[fgksize-1]) return; | |
224 | for(i=fgksize-2;i>=0;i--){ | |
225 | if(signal > fSignal[i]){ | |
226 | fSignal[i+1] = fSignal[i]; | |
227 | fTrack[i+1] = fTrack[i]; | |
228 | fHits[i+1] = fHits[i]; | |
229 | }else{ | |
230 | fSignal[i+1] = signal; | |
231 | fTrack[i+1] = track; | |
232 | fHits[i+1] = hit; | |
233 | return; // put it in the right place, now exit. | |
234 | } // end if | |
235 | //cout << "$fTrack["<<i+1<<"]="<<fTrack[i+1]<< " fTrack["<<i<<"]=" | |
236 | //<<fTrack[i]<< " fHits["<<i+1<<"]="<<fHits[i+1]<< " fHits["<<i<<"]=" | |
237 | //<<fHits[i]<< " fSignal["<<i+1<<"]="<<fSignal[i+1]<< " fSignal["<<i | |
238 | //<<"]="<<fSignal[i]<<endl; | |
239 | } // end if; end for i | |
240 | // Still haven't found the right place. Must be at top of list. | |
241 | fSignal[0] = signal; | |
242 | fTrack[0] = track; | |
243 | fHits[0] = hit; | |
244 | //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0] | |
245 | //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl; | |
246 | return; | |
247 | } | |
248 | //______________________________________________________________________ | |
249 | void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){ | |
250 | // Adds noise to this existing list. | |
251 | // Inputs: | |
252 | // Int_t module The module where this noise occurred | |
253 | // Int_t index The cell index where this noise occurred | |
254 | // Double_t noise The value of the noise. | |
255 | // Outputs: | |
256 | // none. | |
257 | // Return: | |
258 | // none. | |
259 | ||
260 | if(findex!=index || fmodule!=module) | |
261 | Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d", | |
262 | index,findex,module,fmodule); | |
263 | fNoise += noise; // Keep track of sum signal. | |
264 | } | |
265 | //______________________________________________________________________ | |
266 | void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){ | |
267 | // Adds signal after electronics to this existing list. | |
268 | // Inputs: | |
269 | // Int_t module The module where this noise occurred | |
270 | // Int_t index The cell index where this noise occurred | |
271 | // Double_t signal The value of the signal. | |
272 | // Outputs: | |
273 | // none. | |
274 | // Return: | |
275 | // none. | |
276 | ||
277 | if(findex!=index || fmodule!=module) | |
278 | Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d " | |
279 | "!= fmodule=%d",index,findex,module,fmodule); | |
280 | fSignalAfterElect += signal; // Keep track of sum signal. | |
281 | } | |
282 | //______________________________________________________________________ | |
283 | void AliITSpListItem::Add(AliITSpListItem *pl){ | |
284 | // Adds the contents of pl to this | |
285 | // pl could come from different module and index | |
286 | // Inputs: | |
287 | // AliITSpListItem *pl an AliITSpListItem to be added to this class. | |
288 | // Outputs: | |
289 | // none. | |
290 | // Return: | |
291 | // none. | |
292 | Int_t i; | |
293 | Double_t sig = 0.0; | |
294 | Double_t sigT = 0.0; | |
295 | ||
296 | for(i=0;i<pl->GetNsignals();i++){ | |
297 | sig = pl->GetSignal(i); | |
298 | if( sig <= 0.0 ) break; // no more signals | |
299 | AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig); | |
300 | sigT += sig; | |
301 | } // end for i | |
302 | fTsignal += (pl->fTsignal - sigT); | |
303 | fNoise += pl->fNoise; | |
304 | return; | |
305 | } | |
306 | //______________________________________________________________________ | |
307 | void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){ | |
308 | // Adds the contents of pl to this with track number off set given by | |
309 | // fileIndex. | |
310 | // Inputs: | |
311 | // Int_t fileIndex track number offset value | |
312 | // AliITSpListItem *pl an AliITSpListItem to be added to this class. | |
313 | // Outputs: | |
314 | // none. | |
315 | // Return: | |
316 | // none. | |
317 | Int_t i,trk; | |
318 | Double_t sig = 0.0; | |
319 | ||
320 | Int_t module = pl->GetModule(); | |
321 | Int_t index = pl->GetIndex(); | |
322 | for(i=0;i<pl->GetNsignals();i++){ | |
323 | sig = pl->GetSignal(i); | |
324 | if( sig <= 0.0 ) break; // no more signals | |
325 | trk = pl->GetTrack(i); | |
326 | trk += fileIndex; | |
327 | AddSignal(trk,pl->GetHit(i),module,index,sig); | |
328 | } // end for i | |
329 | fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise); | |
330 | fNoise = pl->fNoise; | |
331 | return; | |
332 | } | |
333 | //______________________________________________________________________ | |
334 | Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk) const { | |
335 | // Shift an index number to occupy the upper four bits. No longer used. | |
336 | // Inputs: | |
337 | // Int_t in The file number | |
338 | // Int_t trk The track number | |
339 | // Outputs: | |
340 | // none. | |
341 | // Return: | |
342 | // Int_t The track number with the file number in the upper bits. | |
343 | Int_t si = sizeof(Int_t) * 8; | |
344 | UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative. | |
345 | ||
346 | uin = in; | |
347 | utrk = trk; | |
348 | for(Int_t i=0;i<si-4;i++) uin *= 2; | |
349 | uin += utrk; | |
350 | in = uin; | |
351 | return in; | |
352 | } | |
353 | //______________________________________________________________________ | |
354 | void AliITSpListItem::Print(ostream *os) const { | |
355 | //Standard output format for this class | |
356 | // Inputs: | |
357 | // ostream *os The output stream | |
358 | // Outputs: | |
359 | // none. | |
360 | // Return: | |
361 | // none. | |
362 | Int_t i; | |
363 | ||
364 | *os << fmodule <<","<<findex<<","; | |
365 | *os << fgksize <<","; | |
366 | for(i=0;i<fgksize;i++) *os << fTrack[i] <<","; | |
367 | for(i=0;i<fgksize;i++) *os << fHits[i] <<","; | |
368 | for(i=0;i<fgksize;i++) *os << fSignal[i] <<","; | |
369 | *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect; | |
370 | } | |
371 | //______________________________________________________________________ | |
372 | void AliITSpListItem::Read(istream *is){ | |
373 | // Standard output streaming function. | |
374 | // Inputs: | |
375 | // istream *is The input stream | |
376 | // Outputs: | |
377 | // none. | |
378 | // Return: | |
379 | // none. | |
380 | Int_t i,iss; | |
381 | ||
382 | *is >> fmodule >> findex; | |
383 | *is >> iss; // read in fgksize | |
384 | for(i=0;i<fgksize&&i<iss;i++) *is >> fTrack[i]; | |
385 | for(i=0;i<fgksize&&i<iss;i++) *is >> fHits[i]; | |
386 | for(i=0;i<fgksize&&i<iss;i++) *is >> fSignal[i]; | |
387 | *is >> fTsignal >> fNoise >> fSignalAfterElect; | |
388 | } | |
389 | //______________________________________________________________________ | |
390 | ostream &operator<<(ostream &os,AliITSpListItem &source){ | |
391 | // Standard output streaming function. | |
392 | // Inputs: | |
393 | // ostream &os The output stream | |
394 | // AliITSpListItem &source The AliITSpListItem object to be written out. | |
395 | // Outputs: | |
396 | // none. | |
397 | // Return: | |
398 | // ostream The output stream | |
399 | ||
400 | source.Print(&os); | |
401 | return os; | |
402 | } | |
403 | //______________________________________________________________________ | |
404 | istream &operator>>(istream &os,AliITSpListItem &source){ | |
405 | // Standard output streaming function. | |
406 | // Inputs: | |
407 | // istream os The input stream | |
408 | // AliITSpListItem &source The AliITSpListItem object to be inputted | |
409 | // Outputs: | |
410 | // none. | |
411 | // Return: | |
412 | // istream The input stream. | |
413 | ||
414 | source.Read(&os); | |
415 | return os; | |
416 | } |