//***********************************************************************
//
-// 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"
//______________________________________________________________________
-ClassImp(AliITSpList);
+ClassImp(AliITSpList)
//______________________________________________________________________
-AliITSpList::AliITSpList(){
+AliITSpList::AliITSpList():
+fNi(0),
+fNj(0),
+fa(0),
+fEntries(0){
// Default constructor
// Inputs:
// none.
// Return:
// A zeroed/empty AliITSpList class.
- fNi = 0;
- fNj = 0;
- fa = 0;
}
//______________________________________________________________________
-AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
+AliITSpList::AliITSpList(Int_t imax,Int_t jmax):
+fNi(imax),
+fNj(jmax),
+fa(new AliITSpListItem[imax*jmax]),
+fEntries(0){
// Standard constructor
// Inputs:
// none.
// Return:
// A setup AliITSpList class.
- fNi = imax;
- fNj = jmax;
- fEnteries = 0;
- fa = new TObjArray(fNi*fNj); // elements are zeroed by
- // TObjArray creator
}
//______________________________________________________________________
AliITSpList::~AliITSpList(){
// Default destructor
- // Inputs:
- // none.
- // Outputs:
- // none.
- // 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
- fNi = 0;
- fNj = 0;
- delete fa;
- fa = 0;
- fEnteries = 0;
+ delete [] fa;
+ fNi = 0;
+ fNj = 0;
+ fEntries = 0;
}
//______________________________________________________________________
void AliITSpList::ClearMap(){
- // Delete all AliITSpListItems and zero TObjArray.
+ // Delete all AliITSpListItems and zero TClonesArray.
// Inputs:
// none.
// Outputs:
// none.
// Return:
// 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;
+ for(Int_t i=0; i<fEntries; i++)(fa[i]).MarkUnused();
+ 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
// Return:
// none.
Int_t k = GetIndex(i,j);
-
- if(fa->At(k)!=0){
- delete fa->At(k);
- fa->AddAt(0,k); // zero content
- } // end for i && if
- if(k==fEnteries-1) fEnteries--;
+ if((fa[k]).IsUsed())(fa[k]).MarkUnused();
+ if(k==fEntries-1) fEntries--;
}
//______________________________________________________________________
AliITSpList& AliITSpList::operator=(const AliITSpList &source){
// 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;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;
- } // end if this->fa!=0
- this->fNi = source.fNi;
- this->fNj = source.fNj;
- this->fa = new TObjArray(*(source.fa));
- this->fEnteries = source.fEnteries;
-
- return *this;
+ this->~AliITSpList();
+ new(this) AliITSpList(source);
+ return *this;
}
//______________________________________________________________________
-AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source){
+AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source),
+fNi(source.fNi),
+fNj(source.fNj),
+fa(new AliITSpListItem[fNi*fNj]),
+fEntries(source.fEntries){
// Copy constructor
-
- fNi = source.fNi;
- fNj = source.fNj;
- fa = new TObjArray(*(source.fa));
- fEnteries = source.fEnteries;
+ for(Int_t i=0; i<fEntries; i++)(fa[i]).Build(source.fa[i]);
}
//______________________________________________________________________
void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
// 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);
- if(index>=fEnteries) fEnteries = index +1;
+ AliITSpListItem &lit = fa[index];
+ if(!lit.IsUsed())lit.Build(-2,-1,pl->GetModule(),index,0.);
+ lit.AddTo(fileIndex,pl);
+ 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);
- }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<0) return;
+ AliITSpListItem &lit = fa[index];
+ if(!lit.IsUsed()){
+ lit.Build(trk,ht,mod,index,signal);
+ }
+ else {
+ lit.AddSignal(trk,ht,mod,index,signal);
+ }
+ 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);
-
- if(GetpListItem(index)==0){ // most create AliITSpListItem
- fa->AddAt(new AliITSpListItem(mod,index,noise),index);
- }else{ // AliITSpListItem exists, just add signal to it.
- GetpListItem(index)->AddNoise(mod,index,noise);
- } // end if
- if(index>=fEnteries) fEnteries = index +1;
+ if (index<0) return;
+ AliITSpListItem &lit = fa[index];
+ if(!lit.IsUsed()){
+ lit.Build(mod,index,noise);
+ }
+ else {
+ lit.AddNoise(mod,index,noise);
+ }
+ if(index>=fEntries) fEntries = index +1;
}
//______________________________________________________________________
void AliITSpList::GetCell(Int_t index,Int_t &i,Int_t &j) const {
j = index - fNj*i;
return;
}
-//______________________________________________________________________
-Int_t AliITSpList::GetIndex(Int_t i, Int_t j) const {
- // returns the TObjArray 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;
- }
- else {
- return fNj*i+j;
- }
-}