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 **************************************************************************/
19 #include <Riostream.h>
20 #include <TObjArray.h>
24 #include "AliITSpList.h"
26 //______________________________________________________________________
28 ClassImp(AliITSpList);
29 //______________________________________________________________________
30 AliITSpList::AliITSpList(){
31 // Default constructor
37 // A zeroed/empty AliITSpList class.
43 //______________________________________________________________________
44 AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
45 // Standard constructor
51 // A setup AliITSpList class.
56 fa = new TObjArray(fNi*fNj); // elements are zeroed by
59 //______________________________________________________________________
60 AliITSpList::~AliITSpList(){
67 // a properly destroyed class
69 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
71 fa->AddAt(0,i); // zero content
79 //______________________________________________________________________
80 void AliITSpList::ClearMap(){
81 // Delete all AliITSpListItems and zero TObjArray.
87 // A zeroed AliITSpList class.
91 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
93 fa->AddAt(0,i); // zero content
98 //______________________________________________________________________
99 void AliITSpList::DeleteHit(Int_t i,Int_t j){
100 // Delete a particular AliITSpListItems and zero TObjArray.
102 // Int_t i Row number
103 // Int_t j Columns number
108 Int_t k = GetIndex(i,j);
112 fa->AddAt(0,k); // zero content
114 if(k==fEnteries-1) fEnteries--;
116 //______________________________________________________________________
117 AliITSpList& AliITSpList::operator=(const AliITSpList &source){
120 // const AliITSpList &source A AliITSpList object.
124 // A copied AliITSpList object.
126 if(this == &source) return *this;
128 if(this->fa!=0){ // if this->fa exists delete it first.
129 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
131 fa->AddAt(0,i); // zero content
134 } // end if this->fa!=0
135 this->fNi = source.fNi;
136 this->fNj = source.fNj;
137 this->fa = new TObjArray(*(source.fa));
138 this->fEnteries = source.fEnteries;
142 //______________________________________________________________________
143 AliITSpList::AliITSpList(AliITSpList &source) : AliITSMap(source){
146 // AliITSpList &source A AliITSpList Object
150 // A copied AliITSpList object
154 //______________________________________________________________________
155 void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
156 // Adds the contents of pl to the list with track number off set given by
158 // Creates the AliITSpListItem if needed.
160 // Int_t fileIndex track number offset value
161 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
166 Int_t index = pl->GetIndex();
168 if( fa->At( index ) == 0 ) { // most create AliITSpListItem
169 fa->AddAt(new AliITSpListItem(-2,-1,pl->GetModule(),index,0.0),index);
172 ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
173 if(index>=fEnteries) fEnteries = index +1;
175 //______________________________________________________________________
176 void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
178 // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
181 // Int_t i Row number for this signal
182 // Int_t j Column number for this signal
183 // Int_t trk Track number creating this signal
184 // Int_t ht Hit number creating this signal
185 // Int_t mod The module where this signal is in
186 // Double_t signal The signal (ionization)
191 Int_t index = GetIndex(i,j);
193 if(GetpListItem(index)==0){ // most create AliITSpListItem
194 fa->AddAt(new AliITSpListItem(trk,ht,mod,index,signal),index);
195 }else{ // AliITSpListItem exists, just add signal to it.
196 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
198 if(index>=fEnteries) fEnteries = index +1;
200 //______________________________________________________________________
201 void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
202 // Adds a noise value to the TObjArray at i,j. Creates the AliITSpListItem
205 // Int_t i Row number for this noise
206 // Int_t j Column number for this noise
207 // Double_t noise The noise signal value.
212 Int_t index = GetIndex(i,j);
214 if(GetpListItem(index)==0){ // most create AliITSpListItem
215 fa->AddAt(new AliITSpListItem(mod,index,noise),index);
216 }else{ // AliITSpListItem exists, just add signal to it.
217 GetpListItem(index)->AddNoise(mod,index,noise);
219 if(index>=fEnteries) fEnteries = index +1;
221 //______________________________________________________________________
223 ClassImp(AliITSpListItem)
224 //______________________________________________________________________
225 AliITSpListItem::AliITSpListItem(){
226 // Default constructor
232 // A zeroed/empty AliITSpListItem class.
236 for(Int_t i=0;i<this->fkSize;i++){
237 this->fTrack[i] = -2;
239 this->fSignal[i] = 0.0;
243 fSignalAfterElect = 0.0;
245 //______________________________________________________________________
246 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){
247 // Standard noise constructor
249 // Int_t module The module where this noise occurred
250 // Int_t index The cell index where this noise occurred
251 // Double_t noise The value of the noise.
255 // A setup and noise filled AliITSpListItem class.
257 this->fmodule = module;
258 this->findex = index;
259 for(Int_t i=0;i<this->fkSize;i++){
260 this->fTrack[i] = -2;
261 this->fSignal[i] = 0.0;
264 this->fTsignal = 0.0;
265 this->fSignalAfterElect = 0.0;
266 this->fNoise = noise;
268 //______________________________________________________________________
269 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
270 Int_t index,Double_t signal){
271 // Standard signal constructor
273 // Int_t track The track number which produced this signal
274 // Int_t hit The hit number which produced this signal
275 // Int_t module The module where this signal occurred
276 // Int_t index The cell index where this signal occurred
277 // Double_t signal The value of the signal (ionization)
281 // A setup and signal filled AliITSpListItem class.
283 this->fmodule = module;
284 this->findex = index;
285 this->fTrack[0] = track;
286 this->fHits[0] = hit;
287 this->fSignal[0] = signal;
288 for(Int_t i=1;i<this->fkSize;i++){
289 this->fTrack[i] = -2;
290 this->fSignal[i] = 0.0;
293 this->fTsignal = signal;
295 this->fSignalAfterElect = 0.0;
297 //______________________________________________________________________
298 AliITSpListItem::~AliITSpListItem(){
305 // A properly destroyed AliITSpListItem class.
308 //______________________________________________________________________
309 AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
312 // AliITSpListItem &source A AliITSpListItem Object
316 // A copied AliITSpListItem object
319 if(this == &source) return *this;
321 this->fmodule = source.fmodule;
322 this->findex = source.findex;
323 for(i=0;i<this->fkSize;i++){
324 this->fTrack[i] = source.fTrack[i];
325 this->fSignal[i] = source.fSignal[i];
326 this->fHits[i] = source.fHits[i];
328 this->fTsignal = source.fTsignal;
329 this->fNoise = source.fNoise;
330 this->fSignalAfterElect = source.fSignalAfterElect;
332 cout <<"this fTrack[0-9]=";
333 for(i=0;i<this->fkSize;i++) cout <<this->fTrack[i]<<",";
334 cout <<" fHits[0-9]=";
335 for(i=0;i<this->fkSize;i++) cout <<this->fHits[i]<<",";
336 cout <<" fSignal[0-9]=";
337 for(i=0;i<this->fkSize;i++) cout <<this->fSignal[i]<<",";
339 cout <<"source fTrack[0-9]=";
340 for(i=0;i<this->fkSize;i++) cout <<source.fTrack[i]<<",";
341 cout <<" fHits[0-9]=";
342 for(i=0;i<this->fkSize;i++) cout <<source.fHits[i]<<",";
343 cout <<" fSignal[0-9]=";
344 for(i=0;i<this->fkSize;i++) cout <<source.fSignal[i]<<",";
349 //______________________________________________________________________
350 AliITSpListItem::AliITSpListItem(AliITSpListItem &source) : TObject(source){
353 // AliITSpListItem &source A AliITSpListItem Object
357 // A copied AliITSpListItem object
361 //______________________________________________________________________
362 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
363 Int_t index,Double_t signal){
364 // Adds this track number and signal to the pList and orders them
366 // Int_t track The track number which produced this signal
367 // Int_t hit The hit number which produced this signal
368 // Int_t module The module where this signal occurred
369 // Int_t index The cell index where this signal occurred
370 // Double_t signal The value of the signal (ionization)
379 if(findex!=index || fmodule!=module)
380 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
381 index,findex,module,fmodule);
382 fTsignal += signal; // Keep track of sum signal.
384 // for(i=0;i<fkSize;i++) if( track==fTrack[i] && hit==fHits[i] ){
385 for(i=0;i<fkSize;i++) if( track==fTrack[i] ){
386 fSignal[i] += signal;
389 //cout << "track="<<track<<endl;
390 if(flg){ // resort arrays.
391 for(i=1;i<fkSize;i++){
393 while(j>0 && fSignal[j]>fSignal[j-1]){
397 fTrack[j-1] = fTrack[j];
398 fHits[j-1] = fHits[j];
399 fSignal[j-1] = fSignal[j];
403 //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<<
404 // j<<"]="<<fTrack[j]<<endl;
409 } // end if added to existing and resorted array
411 // new entry add it in order.
412 // if this signal is <= smallest then don't add it.
413 if(signal <= fSignal[fkSize-1]) return;
414 for(i=fkSize-2;i>=0;i--){
415 if(signal > fSignal[i]){
416 fSignal[i+1] = fSignal[i];
417 fTrack[i+1] = fTrack[i];
418 fHits[i+1] = fHits[i];
420 fSignal[i+1] = signal;
423 return; // put it in the right place, now exit.
425 //cout << "$fTrack["<<i+1<<"]="<<fTrack[i+1]<< " fTrack["<<i<<"]="
426 //<<fTrack[i]<< " fHits["<<i+1<<"]="<<fHits[i+1]<< " fHits["<<i<<"]="
427 //<<fHits[i]<< " fSignal["<<i+1<<"]="<<fSignal[i+1]<< " fSignal["<<i
428 //<<"]="<<fSignal[i]<<endl;
429 } // end if; end for i
430 // Still haven't found the right place. Must be at top of list.
434 //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0]
435 //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl;
438 //______________________________________________________________________
439 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
440 // Adds noise to this existing list.
442 // Int_t module The module where this noise occurred
443 // Int_t index The cell index where this noise occurred
444 // Double_t noise The value of the noise.
450 if(findex!=index || fmodule!=module)
451 Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d",
452 index,findex,module,fmodule);
453 fNoise += noise; // Keep track of sum signal.
455 //______________________________________________________________________
456 void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
457 // Adds signal after electronics to this existing list.
459 // Int_t module The module where this noise occurred
460 // Int_t index The cell index where this noise occurred
461 // Double_t signal The value of the signal.
467 if(findex!=index || fmodule!=module)
468 Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d "
469 "!= fmodule=%d",index,findex,module,fmodule);
470 fSignalAfterElect += signal; // Keep track of sum signal.
472 //______________________________________________________________________
473 void AliITSpListItem::Add(AliITSpListItem *pl){
474 // Adds the contents of pl to this
475 // pl could come from different module and index
477 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
486 for(i=0;i<pl->GetNsignals();i++){
487 sig = pl->GetSignal(i);
488 if( sig <= 0.0 ) break; // no more signals
489 AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig);
492 fTsignal += (pl->fTsignal - sigT);
493 fNoise += pl->fNoise;
496 //______________________________________________________________________
497 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
498 // Adds the contents of pl to this with track number off set given by
501 // Int_t fileIndex track number offset value
502 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
510 Int_t module = pl->GetModule();
511 Int_t index = pl->GetIndex();
512 for(i=0;i<pl->GetNsignals();i++){
513 sig = pl->GetSignal(i);
514 if( sig <= 0.0 ) break; // no more signals
515 trk = pl->GetTrack(i);
517 AddSignal(trk,pl->GetHit(i),module,index,sig);
519 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
523 //______________________________________________________________________
524 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk){
525 // Shift an index number to occupy the upper four bits. No longer used.
527 // Int_t in The file number
528 // Int_t trk The track number
532 // Int_t The track number with the file number in the upper bits.
533 Int_t si = sizeof(Int_t) * 8;
534 UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative.
538 for(Int_t i=0;i<si-4;i++) uin *= 2;
543 //______________________________________________________________________
544 void AliITSpListItem::Print(ostream *os){
545 //Standard output format for this class
547 // ostream *os The output stream
554 *os << fmodule <<","<<findex<<",";
556 for(i=0;i<fkSize;i++) *os << fTrack[i] <<",";
557 for(i=0;i<fkSize;i++) *os << fHits[i] <<",";
558 for(i=0;i<fkSize;i++) *os << fSignal[i] <<",";
559 *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect;
561 //______________________________________________________________________
562 void AliITSpListItem::Read(istream *is){
563 // Standard output streaming function.
565 // istream *is The input stream
572 *is >> fmodule >> findex;
573 *is >> iss; // read in fkSize
574 for(i=0;i<fkSize&&i<iss;i++) *is >> fTrack[i];
575 for(i=0;i<fkSize&&i<iss;i++) *is >> fHits[i];
576 for(i=0;i<fkSize&&i<iss;i++) *is >> fSignal[i];
577 *is >> fTsignal >> fNoise >> fSignalAfterElect;
579 //______________________________________________________________________
580 ostream &operator<<(ostream &os,AliITSpListItem &source){
581 // Standard output streaming function.
583 // ostream &os The output stream
584 // AliITSpListItem &source The AliITSpListItem object to be written out.
588 // ostream The output stream
593 //______________________________________________________________________
594 istream &operator>>(istream &os,AliITSpListItem &source){
595 // Standard output streaming function.
597 // istream os The input stream
598 // AliITSpListItem &source The AliITSpListItem object to be inputted
602 // istream The input stream.