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