From: nilsen Date: Fri, 1 Mar 2002 21:41:50 +0000 (+0000) Subject: AliITSpList.h Increased array size from 5 to 10. Set new version number from X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=c7d528c6a438d311f25929783e93ee45fd03cf40;ds=sidebyside AliITSpList.h Increased array size from 5 to 10. Set new version number from 1 to 2. Added function AddItemTo(...). AliITSpList.cxx Improved function comments. Fixed a couple of bugs in AddSignal Added function AddItemTo(...), Set Noise hit value to -1 not -2 or 0. Fixed bug involving track number for merged events (no longer using ShiftIndex(...). Thanks Ernesto and Massimo. --- diff --git a/ITS/AliITSpList.cxx b/ITS/AliITSpList.cxx index 260c2230bf4..10e0ed32051 100644 --- a/ITS/AliITSpList.cxx +++ b/ITS/AliITSpList.cxx @@ -30,6 +30,12 @@ ClassImp(AliITSpList); //______________________________________________________________________ AliITSpList::AliITSpList(){ // Default constructor + // Inputs: + // none. + // Outputs: + // none. + // Return: + // A zeroed/empty AliITSpList class. fNi = 0; fNj = 0; @@ -38,6 +44,12 @@ AliITSpList::AliITSpList(){ //______________________________________________________________________ AliITSpList::AliITSpList(Int_t imax,Int_t jmax){ // Standard constructor + // Inputs: + // none. + // Outputs: + // none. + // Return: + // A setup AliITSpList class. fNi = imax; fNj = jmax; @@ -47,10 +59,16 @@ AliITSpList::AliITSpList(Int_t imax,Int_t jmax){ //______________________________________________________________________ AliITSpList::~AliITSpList(){ // Default destructor + // Inputs: + // none. + // Outputs: + // none. + // Return: + // a properly destroyed class for(Int_t i=0;iAt(i)!=0){ - delete fa->At(i); - fa->AddAt(0,i); // zero content + delete fa->At(i); + fa->AddAt(0,i); // zero content } // end for i && if fNi = 0; fNj = 0; @@ -60,34 +78,53 @@ AliITSpList::~AliITSpList(){ //______________________________________________________________________ void AliITSpList::ClearMap(){ // Delete all AliITSpListItems and zero TObjArray. + // Inputs: + // none. + // Outputs: + // none. + // Return: + // A zeroed AliITSpList class. for(Int_t i=0;iAt(i)!=0){ - delete fa->At(i); - fa->AddAt(0,i); // zero content + delete fa->At(i); + fa->AddAt(0,i); // zero content } // end for i && if } //______________________________________________________________________ void AliITSpList::DeleteHit(Int_t i,Int_t j){ // Delete a particular AliITSpListItems and zero TObjArray. + // Inputs: + // Int_t i Row number + // Int_t j Columns number + // Outputs: + // none. + // Return: + // none. Int_t k = GetIndex(i,j); if(fa->At(k)!=0){ - delete fa->At(k); - fa->AddAt(0,k); // zero content + delete fa->At(k); + fa->AddAt(0,k); // zero content } // end for i && if } //______________________________________________________________________ AliITSpList& AliITSpList::operator=(const AliITSpList &source){ // = operator + // Inputs: + // const AliITSpList &source A AliITSpList object. + // Outputs: + // none. + // Return: + // A copied AliITSpList object. if(this == &source) return *this; if(this->fa!=0){ // if this->fa exists delete it first. - for(Int_t i=0;iAt(i)!=0){ - delete fa->At(i); - fa->AddAt(0,i); // zero content - } // end for i && if - delete this->fa; + for(Int_t i=0;iAt(i)!=0){ + delete fa->At(i); + fa->AddAt(0,i); // zero content + } // end for i && if + delete this->fa; } // end if this->fa!=0 this->fNi = source.fNi; this->fNj = source.fNj; @@ -98,32 +135,77 @@ AliITSpList& AliITSpList::operator=(const AliITSpList &source){ //______________________________________________________________________ AliITSpList::AliITSpList(AliITSpList &source){ // Copy operator + // Inputs: + // AliITSpList &source A AliITSpList Object + // Outputs: + // none. + // Return: + // A copied AliITSpList object *this = source; } //______________________________________________________________________ +void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) { + // Adds the contents of pl to the list with track number off set given by + // fileIndex. + // Creates the AliITSpListItem if needed. + // Inputs: + // Int_t fileIndex track number offset value + // AliITSpListItem *pl an AliITSpListItem to be added to this class. + // Outputs: + // none. + // Return: + // none. + Int_t index = pl->GetIndex(); + + if( fa->At( index ) == 0 ) { // most create AliITSpListItem + fa->AddAt(new AliITSpListItem(-2,-1,pl->GetModule(),index,0.0),index); + } // end if + + ((AliITSpListItem*)(fa->At( index )))->AddTo( fileIndex, pl ); +} +//______________________________________________________________________ void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod, - Double_t signal){ + Double_t signal){ // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem // if needed. + // Inputs: + // Int_t i Row number for this signal + // Int_t j Column number for this signal + // Int_t trk Track number creating this signal + // Int_t ht Hit number creating this signal + // Int_t mod The module where this signal is in + // Double_t signal The signal (ionization) + // Outputs: + // none. + // Return: + // none. if(GetpListItem(i,j)==0){ // most create AliITSpListItem - fa->AddAt(new AliITSpListItem(trk,ht,mod,GetIndex(i,j),signal), - GetIndex(i,j)); + fa->AddAt(new AliITSpListItem(trk,ht,mod,GetIndex(i,j),signal), + GetIndex(i,j)); }else{ // AliITSpListItem exists, just add signal to it. - GetpListItem(i,j)->AddSignal(trk,ht,mod,GetIndex(i,j),signal); + GetpListItem(i,j)->AddSignal(trk,ht,mod,GetIndex(i,j),signal); } // end if } //______________________________________________________________________ void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){ // Adds a noise value to the TObjArray at i,j. Creates the AliITSpListItem // if needed. + // Inputs: + // Int_t i Row number for this noise + // Int_t j Column number for this noise + // Double_t noise The noise signal value. + // Outputs: + // none. + // Return: + // none. if(GetpListItem(i,j)==0){ // most create AliITSpListItem - fa->AddAt(new AliITSpListItem(mod,GetIndex(i,j),noise), - GetIndex(i,j)); + fa->AddAt(new AliITSpListItem(mod,GetIndex(i,j),noise), + GetIndex(i,j)); }else{ // AliITSpListItem exists, just add signal to it. - GetpListItem(i,j)->AddNoise(mod,GetIndex(i,j),noise); + GetpListItem(i,j)->AddNoise(mod,GetIndex(i,j),noise); } // end if } //______________________________________________________________________ @@ -132,13 +214,19 @@ ClassImp(AliITSpListItem) //______________________________________________________________________ AliITSpListItem::AliITSpListItem(){ // Default constructor + // Inputs: + // none. + // Outputs: + // none. + // Return: + // A zeroed/empty AliITSpListItem class. fmodule = -1; findex = -1; for(Int_t i=0;ifkSize;i++){ - this->fTrack[i] = -2; - this->fHits[i] = -2; - this->fSignal[i] = 0.0; + this->fTrack[i] = -2; + this->fHits[i] = -1; + this->fSignal[i] = 0.0; } // end if i fTsignal = 0.0; fNoise = 0.0; @@ -146,21 +234,39 @@ AliITSpListItem::AliITSpListItem(){ //______________________________________________________________________ AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){ // Standard noise constructor + // Inputs: + // Int_t module The module where this noise occurred + // Int_t index The cell index where this noise occurred + // Double_t noise The value of the noise. + // Outputs: + // none. + // Return: + // A setup and noise filled AliITSpListItem class. this->fmodule = module; this->findex = index; for(Int_t i=0;ifkSize;i++){ - this->fTrack[i] = -2; - this->fSignal[i] = 0.0; - this->fHits[i] = 0; + this->fTrack[i] = -2; + this->fSignal[i] = 0.0; + this->fHits[i] = -1; } // end if i this->fTsignal = 0.0; this->fNoise = noise; } //______________________________________________________________________ AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module, - Int_t index,Double_t signal){ + Int_t index,Double_t signal){ // Standard signal constructor + // Inputs: + // Int_t track The track number which produced this signal + // Int_t hit The hit number which produced this signal + // Int_t module The module where this signal occurred + // Int_t index The cell index where this signal occurred + // Double_t signal The value of the signal (ionization) + // Outputs: + // none. + // Return: + // A setup and signal filled AliITSpListItem class. this->fmodule = module; this->findex = index; @@ -168,39 +274,52 @@ AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module, this->fHits[0] = hit; this->fSignal[0] = signal; for(Int_t i=1;ifkSize;i++){ - this->fTrack[i] = -2; - this->fSignal[i] = 0.0; - this->fHits[i] = 0; + this->fTrack[i] = -2; + this->fSignal[i] = 0.0; + this->fHits[i] = -1; } // end if i this->fTsignal = signal; this->fNoise = 0.0; } //______________________________________________________________________ AliITSpListItem::~AliITSpListItem(){ - // Denstructor - + // Destructor + // Inputs: + // none. + // Outputs: + // none. + // Return: + // A properly destroyed AliITSpListItem class. +/* this->fmodule = 0; - this->findex =0; + this->findex = 0; for(Int_t i=0;i<=this->GetNsignals();i++){ - this->fTrack[i] = 0; - this->fSignal[i] = 0.0; - this->fHits[i] = 0; + this->fTrack[i] = 0; + this->fSignal[i] = 0.0; + this->fHits[i] = 0; } // end if i this->fTsignal = 0.0; - this->fNoise =0.0; + this->fNoise = 0.0; +*/ } //______________________________________________________________________ AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){ // = operator + // Inputs: + // AliITSpListItem &source A AliITSpListItem Object + // Outputs: + // none. + // Return: + // A copied AliITSpListItem object if(this == &source) return *this; this->fmodule = source.fmodule; this->findex = source.findex; for(Int_t i=0;ifkSize;i++){ - this->fTrack[i] = source.fTrack[i]; - this->fSignal[i] = source.fSignal[i]; - this->fHits[i] = source.fHits[i]; + this->fTrack[i] = source.fTrack[i]; + this->fSignal[i] = source.fSignal[i]; + this->fHits[i] = source.fHits[i]; } // end if i this->fTsignal = source.fTsignal; this->fNoise = source.fNoise; @@ -210,80 +329,74 @@ AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){ //______________________________________________________________________ AliITSpListItem::AliITSpListItem(AliITSpListItem &source){ // Copy operator + // Inputs: + // AliITSpListItem &source A AliITSpListItem Object + // Outputs: + // none. + // Return: + // A copied AliITSpListItem object *this = source; } //______________________________________________________________________ void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module, - Int_t index,Double_t signal){ - // Adds this track number and sinal to the pList and orders them + Int_t index,Double_t signal){ + // Adds this track number and signal to the pList and orders them + // Inputs: + // Int_t track The track number which produced this signal + // Int_t hit The hit number which produced this signal + // Int_t module The module where this signal occurred + // Int_t index The cell index where this signal occurred + // Double_t signal The value of the signal (ionization) + // Outputs: + // none. + // Return: + // none. Int_t i,j,trk,hts; Double_t sig; Bool_t flg=kFALSE; if(findex!=index || fmodule!=module) - Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d", - index,findex,module,fmodule); + Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d", + index,findex,module,fmodule); fTsignal += signal; // Keep track of sum signal. - if(signal<=fSignal[fkSize-1]) return; // smaller than smallest - for(i=0;i0){ - cout<<"AliITSpListItem::AddSignal - before sorting - signal="<0;i--){ - if(fSignal[i]>fSignal[i-1]){ - trk = fTrack[i-1]; - hts = fHits[i-1]; - sig = fSignal[i-1]; - fTrack[i-1]=fTrack[i]; - fHits[i-1]=fHits[i]; - fSignal[i-1]=fSignal[i]; - fTrack[i]=trk; - fHits[i]=hts; - fSignal[i]=sig; - } - } - /* debug printouts - if(j>0){ - cout<<"AliITSpListItem::AddSignal - after sorting\n"; - for(i=0;i0 && fSignal[j]>fSignal[j-1]){ + trk = fTrack[j-1]; + hts = fHits[j-1]; + sig = fSignal[j-1]; + fTrack[j-1] = fTrack[j]; + fHits[j-1] = fHits[j]; + fSignal[j-1] = fSignal[j]; + fTrack[j] = trk; + fHits[j] = hts; + fSignal[j] = sig; + j--; + } // end while + } // end if i + return; + } // end if added to existing and resorted array // new entry add it in order. // if this signal is <= smallest then don't add it. if(signal <= fSignal[fkSize-1]) return; for(i=fkSize-2;i>=0;i--){ - if(signal > fSignal[i]){ - fSignal[i+1] = fSignal[i]; - fTrack[i+1] = fTrack[i]; - fHits[i+1] = fHits[i]; - }else{ - fSignal[i+1] = signal; // changed m.m. - fTrack[i+1] = track; // changed m.m. - fHits[i+1] = hit; // changed m.m. - return; // put it in the right place, now exit. - } // end if + if(signal > fSignal[i]){ + fSignal[i+1] = fSignal[i]; + fTrack[i+1] = fTrack[i]; + fHits[i+1] = fHits[i]; + }else{ + fSignal[i+1] = signal; + fTrack[i+1] = track; + fHits[i+1] = hit; + return; // put it in the right place, now exit. + } // end if } // end if; end for i // Still haven't found the right place. Must be at top of list. fSignal[0] = signal; @@ -293,34 +406,57 @@ void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module, } //______________________________________________________________________ void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){ - // Addes noise to this existing list. + // Adds noise to this existing list. + // Inputs: + // Int_t module The module where this noise occurred + // Int_t index The cell index where this noise occurred + // Double_t noise The value of the noise. + // Outputs: + // none. + // Return: + // none. if(findex!=index || fmodule!=module) - Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d", - index,findex,module,fmodule); + Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d", + index,findex,module,fmodule); fNoise += noise; // Keep track of sum signal. } //______________________________________________________________________ void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){ // Adds the contents of pl to this with track number off set given by // fileIndex. + // Inputs: + // Int_t fileIndex track number offset value + // AliITSpListItem *pl an AliITSpListItem to be added to this class. + // Outputs: + // none. + // Return: + // none. Int_t i,trk; Double_t sig=0.0; - for(i=0;iGetNsignals()&&iGetNsignals();i++){ - trk = pl->GetTrack(i); - trk = pl->ShiftIndex(fileIndex,trk); - this->AddSignal(trk,pl->GetHit(i),pl->GetModule(),pl->GetIndex(),pl->GetSignal(i)); - sig += pl->GetSignal(i); + for(i=0;iGetNsignals();i++){ + trk = pl->GetTrack(i); + trk += fileIndex; + this->AddSignal(trk,pl->GetHit(i),pl->GetModule(), + pl->GetIndex(),pl->GetSignal(i)); + sig += pl->GetSignal(i); } // end for i this->fNoise += pl->fNoise; return; } //______________________________________________________________________ Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk){ - // Shift an index number to occupy the upper four bits. + // Shift an index number to occupy the upper four bits. No longer used. + // Inputs: + // Int_t in The file number + // Int_t trk The track number + // Outputs: + // none. + // Return: + // Int_t The track number with the file number in the upper bits. Int_t si = sizeof(Int_t) * 8; - UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negitive. + UInt_t uin,utrk; // use UInt_t to avoid integer overflow-> goes negative. uin = in; utrk = trk; @@ -332,6 +468,12 @@ Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk){ //______________________________________________________________________ void AliITSpListItem::Print(ostream *os){ //Standard output format for this class + // Inputs: + // ostream *os The output stream + // Outputs: + // none. + // Return: + // none. Int_t i; *os << fmodule <<","<> fmodule >> findex; @@ -356,6 +504,13 @@ void AliITSpListItem::Read(istream *is){ //______________________________________________________________________ ostream &operator<<(ostream &os,AliITSpListItem &source){ // Standard output streaming function. + // Inputs: + // ostream &os The output stream + // AliITSpListItem &source The AliITSpListItem object to be written out. + // Outputs: + // none. + // Return: + // ostream The output stream source.Print(&os); return os; @@ -363,7 +518,15 @@ ostream &operator<<(ostream &os,AliITSpListItem &source){ //______________________________________________________________________ istream &operator>>(istream &os,AliITSpListItem &source){ // Standard output streaming function. + // Inputs: + // istream os The input stream + // AliITSpListItem &source The AliITSpListItem object to be inputted + // Outputs: + // none. + // Return: + // istream The input stream. source.Read(&os); return os; } + diff --git a/ITS/AliITSpList.h b/ITS/AliITSpList.h index 17a036074c6..76777749b57 100644 --- a/ITS/AliITSpList.h +++ b/ITS/AliITSpList.h @@ -61,7 +61,7 @@ class AliITSpListItem: public TObject { void Read(istream *is); private: - static const Int_t fkSize = 5; // Array sizes + static const Int_t fkSize = 10; // Array sizes Int_t fmodule; // module number Int_t findex; // Strip/row,col number linearlized. Int_t fTrack[fkSize]; //[fkSize] track Number @@ -70,12 +70,13 @@ class AliITSpListItem: public TObject { Double_t fTsignal; // Total signal (no noise) Double_t fNoise; // Total noise, coupling, ... - ClassDef(AliITSpListItem,1) // Item list of signals and track numbers + ClassDef(AliITSpListItem,2) // Item list of signals and track numbers }; // Input and output functions for standard C++ input/output. ostream & operator<<(ostream &os,AliITSpListItem &source); istream & operator>>(istream &is,AliITSpListItem &source); + #endif #ifndef ALIITSPLISTSSD_H @@ -115,8 +116,8 @@ class AliITSpList: public AliITSMap { Int_t GetNEnteries(){return 5;} // for a give TObjArray index it returns the corresponding map index void GetMapIndex(Int_t index,Int_t &i,Int_t &j){ - if(i<0||i>=fNi || j<0||j>-fNj){i=-1;j=-1; return;} i = index/fNj;j = index - fNj*i; + if(i<0||i>=fNi || j<0||j>=fNj){i=-1;j=-1; return;} } // Returns the signal+noise for a give map coordinate Double_t GetSignal(Int_t i,Int_t j){ @@ -159,6 +160,9 @@ class AliITSpList: public AliITSMap { if(GetpListItem(i,j)==0) return 0; return GetpListItem(i,j)->GetNsignals(); } + // Adds the contents of pl to the list with track number off set given by + // fileIndex. + virtual void AddItemTo(Int_t fileIndex, AliITSpListItem *pl); // Adds a Signal value to the map. Creating and expanding arrays as needed. void AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,Double_t sig); // Adds a Noise value to the map. Creating and expanding arrays as needed.