//***********************************************************************
//
-// It consist of a TObjectArray of
+// It consist of a TClonesArray of
// AliITSpListItem objects
// This array can be accessed via 2 indexed
// it is used at digitization level by
//
// ***********************************************************************
-#include <TObjArray.h>
-
#include "AliITSpList.h"
#include "AliITSpListItem.h"
fNi = imax;
fNj = jmax;
- fEnteries = 0;
- fa = new TObjArray(fNi*fNj); // elements are zeroed by
- // TObjArray creator
+ fEntries = 0;
+ fa = new TClonesArray("AliITSpListItem",fNi*fNj);
}
//______________________________________________________________________
AliITSpList::~AliITSpList(){
// Return:
// a properly destroyed class
- for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
- delete fa->At(i);
- fa->AddAt(0,i); // zero content
- } // end for i && if
+ if(fa){
+ fa->Delete();
+ delete fa;
+ fa = 0;
+ }
fNi = 0;
fNj = 0;
- delete fa;
- fa = 0;
- fEnteries = 0;
+
+ fEntries = 0;
}
//______________________________________________________________________
void AliITSpList::ClearMap(){
- // Delete all AliITSpListItems and zero TObjArray.
+ // Delete all AliITSpListItems and zero TClonesArray.
// Inputs:
// none.
// Outputs:
// A zeroed AliITSpList class.
fa->Delete();
- /*
- for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
- delete fa->At(i);
- fa->AddAt(0,i); // zero content
- } // end for i && if
- */
- fEnteries = 0;
+ fEntries = 0;
}
//______________________________________________________________________
void AliITSpList::DeleteHit(Int_t i,Int_t j){
- // Delete a particular AliITSpListItems and zero TObjArray.
+ // Delete a particular AliITSpListItems.
// Inputs:
// Int_t i Row number
// Int_t j Columns number
Int_t k = GetIndex(i,j);
if(fa->At(k)!=0){
- delete fa->At(k);
- fa->AddAt(0,k); // zero content
+ fa->RemoveAt(k);
} // end for i && if
- if(k==fEnteries-1) fEnteries--;
+ if(k==fEntries-1) fEntries--;
}
//______________________________________________________________________
AliITSpList& AliITSpList::operator=(const AliITSpList &source){
if(this == &source) return *this;
if(this->fa!=0){ // if this->fa exists delete it first.
- for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
- delete fa->At(i);
- fa->AddAt(0,i); // zero content
- } // end for i && if
- delete this->fa;
+ fa->Delete();
+ delete fa;
+ fa = 0;
} // end if this->fa!=0
this->fNi = source.fNi;
this->fNj = source.fNj;
- this->fa = new TObjArray(*(source.fa));
- this->fEnteries = source.fEnteries;
+ this->fa = new TClonesArray(*(source.fa));
+ this->fEntries = source.fEntries;
return *this;
}
fNi = source.fNi;
fNj = source.fNj;
- fa = new TObjArray(*(source.fa));
- fEnteries = source.fEnteries;
+ fa = new TClonesArray(*(source.fa));
+ fEntries = source.fEntries;
}
//______________________________________________________________________
void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
// Return:
// none.
Int_t index = pl->GetIndex();
-
+ TClonesArray &rfa = *fa;
if( fa->At( index ) == 0 ) { // most create AliITSpListItem
- fa->AddAt(new AliITSpListItem(-2,-1,pl->GetModule(),index,0.0),index);
+ new(rfa[index])AliITSpListItem(-2,-1,pl->GetModule(),index,0.0);
} // end if
((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
- if(index>=fEnteries) fEnteries = index +1;
+ if(index>=fEntries) fEntries = index +1;
}
//______________________________________________________________________
void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
Double_t signal){
- // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
+ // Adds a Signal value to the TClonesArray at i,j.
+ // Creates the AliITSpListItem
// if needed.
// Inputs:
// Int_t i Row number for this signal
// Return:
// none.
Int_t index = GetIndex(i,j);
-
- if(GetpListItem(index)==0){ // most create AliITSpListItem
- fa->AddAt(new AliITSpListItem(trk,ht,mod,index,signal),index);
+ TClonesArray &rfa = *fa;
+ if(GetpListItem(index)==0){ // must create AliITSpListItem
+ new(rfa[index])AliITSpListItem(trk,ht,mod,index,signal);
}else{ // AliITSpListItem exists, just add signal to it.
GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
} // end if
- if(index>=fEnteries) fEnteries = index +1;
+ if(index>=fEntries) fEntries = index +1;
}
//______________________________________________________________________
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
+ // Adds a noise value to the TClonesArray at i,j.
+ // Creates the AliITSpListItem
// if needed.
// Inputs:
// Int_t i Row number for this noise
// Return:
// none.
Int_t index = GetIndex(i,j);
-
+ TClonesArray &rfa = *fa;
if(GetpListItem(index)==0){ // most create AliITSpListItem
- fa->AddAt(new AliITSpListItem(mod,index,noise),index);
+ new(rfa[index]) AliITSpListItem(mod,index,noise);
}else{ // AliITSpListItem exists, just add signal to it.
GetpListItem(index)->AddNoise(mod,index,noise);
} // end if
- if(index>=fEnteries) fEnteries = index +1;
+ if(index>=fEntries) fEntries = index +1;
}
//______________________________________________________________________
void AliITSpList::GetCell(Int_t index,Int_t &i,Int_t &j) const {
}
//______________________________________________________________________
Int_t AliITSpList::GetIndex(Int_t i, Int_t j) const {
- // returns the TObjArray index for a given set of map indexes.
+ // returns the TClonesArray index for a given set of map indexes.
if(i<0||i>=fNi || j<0||j>=fNj){
Warning("GetIndex","Index out of range 0<i=%d<%d and 0<0j=%d<%d",i,fNi,j,fNj);
return -1;
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
+#include "TClonesArray.h"
#include "AliITSMap.h"
#include "AliITSpListItem.h"
-class TObjArray;
-// class AliITSpListItem;
class AliITSpList: public AliITSMap {
// returns the max index value.
Int_t GetMaxIndex() const {return fNi*fNj;}
// returns the largest non-zero entry kept in the array fa.
- Int_t GetEntries() const {return fEnteries;}
+ Int_t GetEntries() const {return fEntries;}
// returns the max number of track/hit entries per cell.
- Int_t GetNEnteries() const {return AliITSpListItem::GetMaxKept();}
- // for a give TObjArray index it returns the corresponding map index
+ Int_t GetNEntries() const {return AliITSpListItem::GetMaxKept();}
+ // for a given TClonesArray index it returns the corresponding map index
void GetMapIndex(Int_t index,Int_t &i,Int_t &j) const {
i = index/fNj;j = index - fNj*i;
if(i<0||i>=fNi || j<0||j>=fNj){i=-1;j=-1; return;}
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.
void AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise);
- // Delete all AliITSpListItems and zero the TObjArray
+ // Delete all AliITSpListItems and zero the TClonesArray
virtual void ClearMap();
- // Delete a particular AliITSpListItem in the TObjArray.
+ // Delete a particular AliITSpListItem in the TClonesArray.
virtual void DeleteHit(Int_t i,Int_t j);
- // returns hit index in TObjArray
+ // returns hit index in TClonesArray
virtual Int_t GetHitIndex(Int_t i,Int_t j) const {return GetIndex(i,j);}
// returns "hit" AliITSpListItem as a TObject.
TObject * GetHit(Int_t i,Int_t j){return (TObject*)GetpListItem(i,j);}
// tests hit status.
virtual FlagType TestHit(Int_t i,Int_t j){if(GetpListItem(i,j)==0) return kEmpty;
else if(GetSignal(i,j)<=0) return kUnused; else return kUsed;}
- // Returns the pointer to the TObjArray of pList Items
- TObjArray * GetpListItems(){return fa;}
- // returns the pList Item stored in the TObject array
+ // Returns the pointer to the TClonesArray of pList Items
+ TClonesArray * GetpListItems(){return fa;}
+ // returns the pList Item stored in the TClonesArray
AliITSpListItem* GetpListItem(Int_t index){
if(fa!=0)return (AliITSpListItem*) (fa->At(index));
else return 0;}
Warning(method,"This method is not implemented for this class");}
// data members
Int_t fNi,fNj; // The max index in i,j.
- TObjArray *fa; // array of pList items
- Int_t fEnteries; // keepts track of the number of non-zero entries.
+ TClonesArray *fa; // array of pList items
+ Int_t fEntries; // keepts track of the number of non-zero entries.
ClassDef(AliITSpList,3) // list of signals and track numbers
};