]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSpList.cxx
Protection against missing timestamps
[u/mrichter/AliRoot.git] / ITS / AliITSpList.cxx
index 61b9ba599c0138bbe79e29d932955e8fa9d4aaa6..c9e85eea895b9e3b44ecf0a3a8da3604902c45be 100644 (file)
 
 ClassImp(AliITSpList)
 //______________________________________________________________________
-AliITSpList::AliITSpList(){
+AliITSpList::AliITSpList():
+fNi(0),
+fNj(0),
+fa(0),
+fEntries(0){
     // Default constructor
     // Inputs:
     //    none.
@@ -41,12 +45,13 @@ AliITSpList::AliITSpList(){
     // 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.
@@ -55,30 +60,15 @@ AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
     // Return:
     //    A setup AliITSpList class.
 
-    fNi = imax;
-    fNj = jmax;
-    fEntries = 0;
-    fa = new TClonesArray("AliITSpListItem",fNi*fNj);
 }
 //______________________________________________________________________
 AliITSpList::~AliITSpList(){
     // Default destructor
-    // Inputs:
-    //    none.
-    // Outputs:
-    //    none.
-    // Return:
-    //    a properly destroyed class
-
-  if(fa){
-    fa->Delete();
-    delete fa;
-    fa = 0;
-  }
-    fNi = 0;
-    fNj = 0;
 
-    fEntries = 0;
+  delete [] fa;
+  fNi = 0;
+  fNj = 0;
+  fEntries = 0;
 }
 
 //______________________________________________________________________
@@ -90,9 +80,8 @@ void AliITSpList::ClearMap(){
     //    none.
     // Return:
     //    A zeroed AliITSpList class.
-
-    fa->Delete();
-    fEntries = 0;
+  for(Int_t i=0; i<fEntries; i++)(fa[i]).MarkUnused();
+  fEntries = 0;
 }
 //______________________________________________________________________
 void AliITSpList::DeleteHit(Int_t i,Int_t j){
@@ -105,10 +94,7 @@ void AliITSpList::DeleteHit(Int_t i,Int_t j){
     // Return:
     //    none.
     Int_t k = GetIndex(i,j);
-
-    if(fa->At(k)!=0){
-      fa->RemoveAt(k);
-    } // end for i && if
+    if((fa[k]).IsUsed())(fa[k]).MarkUnused();
     if(k==fEntries-1) fEntries--;
 }
 //______________________________________________________________________
@@ -121,28 +107,18 @@ 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.
-      fa->Delete();
-      delete fa;
-      fa = 0;
-    } // end if this->fa!=0
-    this->fNi = source.fNi;
-    this->fNj = source.fNj;
-    this->fa = new TClonesArray(*(source.fa));
-    this->fEntries = source.fEntries;
-
-    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 TClonesArray(*(source.fa));
-  fEntries = source.fEntries;
+  for(Int_t i=0; i<fEntries; i++)(fa[i]).Build(source.fa[i]);
 }
 //______________________________________________________________________
 void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
@@ -157,12 +133,9 @@ 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
-      new(rfa[index])AliITSpListItem(-2,-1,pl->GetModule(),index,0.0);
-    } // end if
-    ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
+    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;
 }
 //______________________________________________________________________
@@ -183,12 +156,14 @@ void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
     // Return:
     //    none.
     Int_t index = GetIndex(i,j);
-    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<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;
 }
 //______________________________________________________________________
@@ -205,12 +180,14 @@ void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
     // Return:
     //    none.
     Int_t index = GetIndex(i,j);
-    TClonesArray &rfa = *fa;
-    if(GetpListItem(index)==0){ // most create AliITSpListItem
-      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<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;
 }
 //______________________________________________________________________
@@ -227,14 +204,3 @@ 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 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;
-  }
-  else {
-    return fNj*i+j;
-  }
-}