1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 #include <TObjArray.h>
25 #include "AliITSpList.h"
27 //______________________________________________________________________
29 ClassImp(AliITSpList);
30 //______________________________________________________________________
31 AliITSpList::AliITSpList(){
32 // Default constructor
38 // A zeroed/empty AliITSpList class.
44 //______________________________________________________________________
45 AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
46 // Standard constructor
52 // A setup AliITSpList class.
57 fa = new TObjArray(fNi*fNj); // elements are zeroed by
60 //______________________________________________________________________
61 AliITSpList::~AliITSpList(){
68 // a properly destroyed class
70 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
72 fa->AddAt(0,i); // zero content
80 //______________________________________________________________________
81 void AliITSpList::ClearMap(){
82 // Delete all AliITSpListItems and zero TObjArray.
88 // A zeroed AliITSpList class.
92 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
94 fa->AddAt(0,i); // zero content
99 //______________________________________________________________________
100 void AliITSpList::DeleteHit(Int_t i,Int_t j){
101 // Delete a particular AliITSpListItems and zero TObjArray.
103 // Int_t i Row number
104 // Int_t j Columns number
109 Int_t k = GetIndex(i,j);
113 fa->AddAt(0,k); // zero content
115 if(k==fEnteries-1) fEnteries--;
117 //______________________________________________________________________
118 AliITSpList& AliITSpList::operator=(const AliITSpList &source){
121 // const AliITSpList &source A AliITSpList object.
125 // A copied AliITSpList object.
127 if(this == &source) return *this;
129 if(this->fa!=0){ // if this->fa exists delete it first.
130 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
132 fa->AddAt(0,i); // zero content
135 } // end if this->fa!=0
136 this->fNi = source.fNi;
137 this->fNj = source.fNj;
138 this->fa = new TObjArray(*(source.fa));
139 this->fEnteries = source.fEnteries;
143 //______________________________________________________________________
144 AliITSpList::AliITSpList(AliITSpList &source){
147 // AliITSpList &source A AliITSpList Object
151 // A copied AliITSpList object
155 //______________________________________________________________________
156 void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
157 // Adds the contents of pl to the list with track number off set given by
159 // Creates the AliITSpListItem if needed.
161 // Int_t fileIndex track number offset value
162 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
167 Int_t index = pl->GetIndex();
169 if( fa->At( index ) == 0 ) { // most create AliITSpListItem
170 fa->AddAt(new AliITSpListItem(-2,-1,pl->GetModule(),index,0.0),index);
173 ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
174 if(index>=fEnteries) fEnteries = index +1;
176 //______________________________________________________________________
177 void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
179 // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
182 // Int_t i Row number for this signal
183 // Int_t j Column number for this signal
184 // Int_t trk Track number creating this signal
185 // Int_t ht Hit number creating this signal
186 // Int_t mod The module where this signal is in
187 // Double_t signal The signal (ionization)
192 Int_t index = GetIndex(i,j);
194 if(GetpListItem(index)==0){ // most create AliITSpListItem
195 fa->AddAt(new AliITSpListItem(trk,ht,mod,index,signal),index);
196 }else{ // AliITSpListItem exists, just add signal to it.
197 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
199 if(index>=fEnteries) fEnteries = index +1;
201 //______________________________________________________________________
202 void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
203 // Adds a noise value to the TObjArray at i,j. Creates the AliITSpListItem
206 // Int_t i Row number for this noise
207 // Int_t j Column number for this noise
208 // Double_t noise The noise signal value.
213 Int_t index = GetIndex(i,j);
215 if(GetpListItem(index)==0){ // most create AliITSpListItem
216 fa->AddAt(new AliITSpListItem(mod,index,noise),index);
217 }else{ // AliITSpListItem exists, just add signal to it.
218 GetpListItem(index)->AddNoise(mod,index,noise);
220 if(index>=fEnteries) fEnteries = index +1;
222 //______________________________________________________________________
224 ClassImp(AliITSpListItem)
225 //______________________________________________________________________
226 AliITSpListItem::AliITSpListItem(){
227 // Default constructor
233 // A zeroed/empty AliITSpListItem class.
237 for(Int_t i=0;i<this->fkSize;i++){
238 this->fTrack[i] = -2;
240 this->fSignal[i] = 0.0;
244 fSignalAfterElect = 0.0;
246 //______________________________________________________________________
247 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){
248 // Standard noise constructor
250 // Int_t module The module where this noise occurred
251 // Int_t index The cell index where this noise occurred
252 // Double_t noise The value of the noise.
256 // A setup and noise filled AliITSpListItem class.
258 this->fmodule = module;
259 this->findex = index;
260 for(Int_t i=0;i<this->fkSize;i++){
261 this->fTrack[i] = -2;
262 this->fSignal[i] = 0.0;
265 this->fTsignal = 0.0;
266 this->fSignalAfterElect = 0.0;
267 this->fNoise = noise;
269 //______________________________________________________________________
270 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
271 Int_t index,Double_t signal){
272 // Standard signal constructor
274 // Int_t track The track number which produced this signal
275 // Int_t hit The hit number which produced this signal
276 // Int_t module The module where this signal occurred
277 // Int_t index The cell index where this signal occurred
278 // Double_t signal The value of the signal (ionization)
282 // A setup and signal filled AliITSpListItem class.
284 this->fmodule = module;
285 this->findex = index;
286 this->fTrack[0] = track;
287 this->fHits[0] = hit;
288 this->fSignal[0] = signal;
289 for(Int_t i=1;i<this->fkSize;i++){
290 this->fTrack[i] = -2;
291 this->fSignal[i] = 0.0;
294 this->fTsignal = signal;
296 this->fSignalAfterElect = 0.0;
298 //______________________________________________________________________
299 AliITSpListItem::~AliITSpListItem(){
306 // A properly destroyed AliITSpListItem class.
310 for(Int_t i=0;i<=this->GetNsignals();i++){
312 this->fSignal[i] = 0.0;
315 this->fTsignal = 0.0;
319 //______________________________________________________________________
320 AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
323 // AliITSpListItem &source A AliITSpListItem Object
327 // A copied AliITSpListItem object
329 if(this == &source) return *this;
331 this->fmodule = source.fmodule;
332 this->findex = source.findex;
333 for(Int_t i=0;i<this->fkSize;i++){
334 this->fTrack[i] = source.fTrack[i];
335 this->fSignal[i] = source.fSignal[i];
336 this->fHits[i] = source.fHits[i];
338 this->fTsignal = source.fTsignal;
339 this->fNoise = source.fNoise;
340 this->fSignalAfterElect = source.fSignalAfterElect;
344 //______________________________________________________________________
345 AliITSpListItem::AliITSpListItem(AliITSpListItem &source){
348 // AliITSpListItem &source A AliITSpListItem Object
352 // A copied AliITSpListItem object
356 //______________________________________________________________________
357 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
358 Int_t index,Double_t signal){
359 // Adds this track number and signal to the pList and orders them
361 // Int_t track The track number which produced this signal
362 // Int_t hit The hit number which produced this signal
363 // Int_t module The module where this signal occurred
364 // Int_t index The cell index where this signal occurred
365 // Double_t signal The value of the signal (ionization)
374 if(findex!=index || fmodule!=module)
375 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
376 index,findex,module,fmodule);
377 fTsignal += signal; // Keep track of sum signal.
379 for(i=0;i<fkSize;i++) if( track==fTrack[i] && hit==fHits[i] ){
380 fSignal[i] += signal;
383 if(flg){ // resort arrays.
384 for(i=1;i<fkSize;i++){
386 while(j>0 && fSignal[j]>fSignal[j-1]){
390 fTrack[j-1] = fTrack[j];
391 fHits[j-1] = fHits[j];
392 fSignal[j-1] = fSignal[j];
400 } // end if added to existing and resorted array
402 // new entry add it in order.
403 // if this signal is <= smallest then don't add it.
404 if(signal <= fSignal[fkSize-1]) return;
405 for(i=fkSize-2;i>=0;i--){
406 if(signal > fSignal[i]){
407 fSignal[i+1] = fSignal[i];
408 fTrack[i+1] = fTrack[i];
409 fHits[i+1] = fHits[i];
411 fSignal[i+1] = signal;
414 return; // put it in the right place, now exit.
416 } // end if; end for i
417 // Still haven't found the right place. Must be at top of list.
423 //______________________________________________________________________
424 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
425 // Adds noise to this existing list.
427 // Int_t module The module where this noise occurred
428 // Int_t index The cell index where this noise occurred
429 // Double_t noise The value of the noise.
435 if(findex!=index || fmodule!=module)
436 Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d",
437 index,findex,module,fmodule);
438 fNoise += noise; // Keep track of sum signal.
440 //______________________________________________________________________
441 void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
442 // Adds signal after electronics to this existing list.
444 // Int_t module The module where this noise occurred
445 // Int_t index The cell index where this noise occurred
446 // Double_t signal The value of the signal.
452 if(findex!=index || fmodule!=module)
453 Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d "
454 "!= fmodule=%d",index,findex,module,fmodule);
455 fSignalAfterElect += signal; // Keep track of sum signal.
457 //______________________________________________________________________
458 void AliITSpListItem::Add(AliITSpListItem *pl){
459 // Adds the contents of pl to this
460 // pl could come from different module and index
462 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
471 for(i=0;i<pl->GetNsignals();i++){
472 sig = pl->GetSignal(i);
473 if( sig <= 0.0 ) break; // no more signals
474 AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig);
477 fTsignal += (pl->fTsignal - sigT);
478 fNoise += pl->fNoise;
481 //______________________________________________________________________
482 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
483 // Adds the contents of pl to this with track number off set given by
486 // Int_t fileIndex track number offset value
487 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
495 Int_t module = pl->GetModule();
496 Int_t index = pl->GetIndex();
497 for(i=0;i<pl->GetNsignals();i++){
498 sig = pl->GetSignal(i);
499 if( sig <= 0.0 ) break; // no more signals
500 trk = pl->GetTrack(i);
502 AddSignal(trk,pl->GetHit(i),module,index,sig);
504 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
508 //______________________________________________________________________
509 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk){
510 // Shift an index number to occupy the upper four bits. No longer used.
512 // Int_t in The file number
513 // Int_t trk The track number
517 // Int_t The track number with the file number in the upper bits.
518 Int_t si = sizeof(Int_t) * 8;
519 UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative.
523 for(Int_t i=0;i<si-4;i++) uin *= 2;
528 //______________________________________________________________________
529 void AliITSpListItem::Print(ostream *os){
530 //Standard output format for this class
532 // ostream *os The output stream
539 *os << fmodule <<","<<findex<<",";
541 for(i=0;i<fkSize;i++) *os << fTrack[i] <<",";
542 for(i=0;i<fkSize;i++) *os << fHits[i] <<",";
543 for(i=0;i<fkSize;i++) *os << fSignal[i] <<",";
544 *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect;
546 //______________________________________________________________________
547 void AliITSpListItem::Read(istream *is){
548 // Standard output streaming function.
550 // istream *is The input stream
557 *is >> fmodule >> findex;
558 *is >> iss; // read in fkSize
559 for(i=0;i<fkSize&&i<iss;i++) *is >> fTrack[i];
560 for(i=0;i<fkSize&&i<iss;i++) *is >> fHits[i];
561 for(i=0;i<fkSize&&i<iss;i++) *is >> fSignal[i];
562 *is >> fTsignal >> fNoise >> fSignalAfterElect;
564 //______________________________________________________________________
565 ostream &operator<<(ostream &os,AliITSpListItem &source){
566 // Standard output streaming function.
568 // ostream &os The output stream
569 // AliITSpListItem &source The AliITSpListItem object to be written out.
573 // ostream The output stream
578 //______________________________________________________________________
579 istream &operator>>(istream &os,AliITSpListItem &source){
580 // Standard output streaming function.
582 // istream os The input stream
583 // AliITSpListItem &source The AliITSpListItem object to be inputted
587 // istream The input stream.