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.
91 // for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
93 // fa->AddAt(0,i); // zero content
94 // } // end for i && if
97 //______________________________________________________________________
98 void AliITSpList::DeleteHit(Int_t i,Int_t j){
99 // Delete a particular AliITSpListItems and zero TObjArray.
101 // Int_t i Row number
102 // Int_t j Columns number
107 Int_t k = GetIndex(i,j);
111 fa->AddAt(0,k); // zero content
113 if(k==fEnteries-1) fEnteries--;
115 //______________________________________________________________________
116 AliITSpList& AliITSpList::operator=(const AliITSpList &source){
119 // const AliITSpList &source A AliITSpList object.
123 // A copied AliITSpList object.
125 if(this == &source) return *this;
127 if(this->fa!=0){ // if this->fa exists delete it first.
128 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
130 fa->AddAt(0,i); // zero content
133 } // end if this->fa!=0
134 this->fNi = source.fNi;
135 this->fNj = source.fNj;
136 this->fa = new TObjArray(*(source.fa));
137 this->fEnteries = source.fEnteries;
141 //______________________________________________________________________
142 AliITSpList::AliITSpList(AliITSpList &source){
145 // AliITSpList &source A AliITSpList Object
149 // A copied AliITSpList object
153 //______________________________________________________________________
154 void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
155 // Adds the contents of pl to the list with track number off set given by
157 // Creates the AliITSpListItem if needed.
159 // Int_t fileIndex track number offset value
160 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
165 Int_t index = pl->GetIndex();
167 if( fa->At( index ) == 0 ) { // most create AliITSpListItem
168 fa->AddAt(new AliITSpListItem(-2,-1,pl->GetModule(),index,0.0),index);
171 ((AliITSpListItem*)(fa->At(index)))->AddTo(fileIndex,pl);
172 if(index>=fEnteries) fEnteries = index +1;
174 //______________________________________________________________________
175 void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
177 // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
180 // Int_t i Row number for this signal
181 // Int_t j Column number for this signal
182 // Int_t trk Track number creating this signal
183 // Int_t ht Hit number creating this signal
184 // Int_t mod The module where this signal is in
185 // Double_t signal The signal (ionization)
190 Int_t index = GetIndex(i,j);
192 if(GetpListItem(index)==0){ // most create AliITSpListItem
193 fa->AddAt(new AliITSpListItem(trk,ht,mod,GetIndex(i,j),signal),index);
194 }else{ // AliITSpListItem exists, just add signal to it.
195 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
197 if(index>=fEnteries) fEnteries = index +1;
199 //______________________________________________________________________
200 void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
201 // Adds a noise value to the TObjArray at i,j. Creates the AliITSpListItem
204 // Int_t i Row number for this noise
205 // Int_t j Column number for this noise
206 // Double_t noise The noise signal value.
211 Int_t index = GetIndex(i,j);
213 if(GetpListItem(index)==0){ // most create AliITSpListItem
214 fa->AddAt(new AliITSpListItem(mod,index,noise),index);
215 }else{ // AliITSpListItem exists, just add signal to it.
216 GetpListItem(index)->AddNoise(mod,index,noise);
218 if(index>=fEnteries) fEnteries = index +1;
220 //______________________________________________________________________
222 ClassImp(AliITSpListItem)
223 //______________________________________________________________________
224 AliITSpListItem::AliITSpListItem(){
225 // Default constructor
231 // A zeroed/empty AliITSpListItem class.
235 for(Int_t i=0;i<this->fkSize;i++){
236 this->fTrack[i] = -2;
238 this->fSignal[i] = 0.0;
243 //______________________________________________________________________
244 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){
245 // Standard noise constructor
247 // Int_t module The module where this noise occurred
248 // Int_t index The cell index where this noise occurred
249 // Double_t noise The value of the noise.
253 // A setup and noise filled AliITSpListItem class.
255 this->fmodule = module;
256 this->findex = index;
257 for(Int_t i=0;i<this->fkSize;i++){
258 this->fTrack[i] = -2;
259 this->fSignal[i] = 0.0;
262 this->fTsignal = 0.0;
263 this->fNoise = noise;
265 //______________________________________________________________________
266 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
267 Int_t index,Double_t signal){
268 // Standard signal constructor
270 // Int_t track The track number which produced this signal
271 // Int_t hit The hit number which produced this signal
272 // Int_t module The module where this signal occurred
273 // Int_t index The cell index where this signal occurred
274 // Double_t signal The value of the signal (ionization)
278 // A setup and signal filled AliITSpListItem class.
280 this->fmodule = module;
281 this->findex = index;
282 this->fTrack[0] = track;
283 this->fHits[0] = hit;
284 this->fSignal[0] = signal;
285 for(Int_t i=1;i<this->fkSize;i++){
286 this->fTrack[i] = -2;
287 this->fSignal[i] = 0.0;
290 this->fTsignal = signal;
293 //______________________________________________________________________
294 AliITSpListItem::~AliITSpListItem(){
301 // A properly destroyed AliITSpListItem class.
305 for(Int_t i=0;i<=this->GetNsignals();i++){
307 this->fSignal[i] = 0.0;
310 this->fTsignal = 0.0;
314 //______________________________________________________________________
315 AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
318 // AliITSpListItem &source A AliITSpListItem Object
322 // A copied AliITSpListItem object
324 if(this == &source) return *this;
326 this->fmodule = source.fmodule;
327 this->findex = source.findex;
328 for(Int_t i=0;i<this->fkSize;i++){
329 this->fTrack[i] = source.fTrack[i];
330 this->fSignal[i] = source.fSignal[i];
331 this->fHits[i] = source.fHits[i];
333 this->fTsignal = source.fTsignal;
334 this->fNoise = source.fNoise;
338 //______________________________________________________________________
339 AliITSpListItem::AliITSpListItem(AliITSpListItem &source){
342 // AliITSpListItem &source A AliITSpListItem Object
346 // A copied AliITSpListItem object
350 //______________________________________________________________________
351 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
352 Int_t index,Double_t signal){
353 // Adds this track number and signal to the pList and orders them
355 // Int_t track The track number which produced this signal
356 // Int_t hit The hit number which produced this signal
357 // Int_t module The module where this signal occurred
358 // Int_t index The cell index where this signal occurred
359 // Double_t signal The value of the signal (ionization)
368 if(findex!=index || fmodule!=module)
369 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
370 index,findex,module,fmodule);
371 fTsignal += signal; // Keep track of sum signal.
372 for(i=0;i<fkSize;i++) if( track==fTrack[i] && hit==fHits[i]){
373 fSignal[i] += signal;
376 if(flg){ // resort arrays.
377 for(i=1;i<fkSize;i++){
379 while(j>0 && fSignal[j]>fSignal[j-1]){
383 fTrack[j-1] = fTrack[j];
384 fHits[j-1] = fHits[j];
385 fSignal[j-1] = fSignal[j];
393 } // end if added to existing and resorted array
395 // new entry add it in order.
396 // if this signal is <= smallest then don't add it.
397 if(signal <= fSignal[fkSize-1]) return;
398 for(i=fkSize-2;i>=0;i--){
399 if(signal > fSignal[i]){
400 fSignal[i+1] = fSignal[i];
401 fTrack[i+1] = fTrack[i];
402 fHits[i+1] = fHits[i];
404 fSignal[i+1] = signal;
407 return; // put it in the right place, now exit.
409 } // end if; end for i
410 // Still haven't found the right place. Must be at top of list.
416 //______________________________________________________________________
417 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
418 // Adds noise to this existing list.
420 // Int_t module The module where this noise occurred
421 // Int_t index The cell index where this noise occurred
422 // Double_t noise The value of the noise.
428 if(findex!=index || fmodule!=module)
429 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
430 index,findex,module,fmodule);
431 fNoise += noise; // Keep track of sum signal.
433 //______________________________________________________________________
434 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
435 // Adds the contents of pl to this with track number off set given by
438 // Int_t fileIndex track number offset value
439 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
447 for(i=0;i<pl->GetNsignals();i++){
448 trk = pl->GetTrack(i);
450 this->AddSignal(trk,pl->GetHit(i),pl->GetModule(),
451 pl->GetIndex(),pl->GetSignal(i));
452 sig += pl->GetSignal(i);
454 this->fNoise += pl->fNoise;
457 //______________________________________________________________________
458 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk){
459 // Shift an index number to occupy the upper four bits. No longer used.
461 // Int_t in The file number
462 // Int_t trk The track number
466 // Int_t The track number with the file number in the upper bits.
467 Int_t si = sizeof(Int_t) * 8;
468 UInt_t uin,utrk; // use UInt_t to avoid integer overflow-> goes negative.
472 for(Int_t i=0;i<si-4;i++) uin *= 2;
477 //______________________________________________________________________
478 void AliITSpListItem::Print(ostream *os){
479 //Standard output format for this class
481 // ostream *os The output stream
488 *os << fmodule <<","<<findex<<",";
490 for(i=0;i<fkSize;i++) *os << fTrack[i] <<",";
491 for(i=0;i<fkSize;i++) *os << fHits[i] <<",";
492 for(i=0;i<fkSize;i++) *os << fSignal[i] <<",";
493 *os << fTsignal <<","<< fNoise;
495 //______________________________________________________________________
496 void AliITSpListItem::Read(istream *is){
497 // Standard output streaming function.
499 // istream *is The input stream
506 *is >> fmodule >> findex;
507 *is >> iss; // read in fkSize
508 for(i=0;i<fkSize&&i<iss;i++) *is >> fTrack[i];
509 for(i=0;i<fkSize&&i<iss;i++) *is >> fHits[i];
510 for(i=0;i<fkSize&&i<iss;i++) *is >> fSignal[i];
511 *is >> fTsignal >> fNoise;
513 //______________________________________________________________________
514 ostream &operator<<(ostream &os,AliITSpListItem &source){
515 // Standard output streaming function.
517 // ostream &os The output stream
518 // AliITSpListItem &source The AliITSpListItem object to be written out.
522 // ostream The output stream
527 //______________________________________________________________________
528 istream &operator>>(istream &os,AliITSpListItem &source){
529 // Standard output streaming function.
531 // istream os The input stream
532 // AliITSpListItem &source The AliITSpListItem object to be inputted
536 // istream The input stream.