]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSpList.h
Fix a Coverity warning: missing array deletion under certain circumstances (M. van...
[u/mrichter/AliRoot.git] / ITS / AliITSpList.h
index f0846677dba81a613a9ad24162e3520673168816..f4612751c51df04607a4a2b31cde4398e5bdfeb0 100644 (file)
@@ -14,6 +14,7 @@
 // ***********************************************************************
 #include "TArrayI.h"
 #include "TClonesArray.h"
+#include "AliLog.h"
 #include "AliITSMap.h"
 #include "AliITSpListItem.h"
 
@@ -107,16 +108,14 @@ class AliITSpList: public AliITSMap {
     // 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 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;}
+    AliITSpListItem* GetpListItem(Int_t index) { if((fa[index]).IsUsed())
+      return &(fa[index]);
+      else return NULL;}
     // returns the pList Item stored in the TObject array
     AliITSpListItem* GetpListItem(Int_t i,Int_t j) const {
-       if(fa!=0)return (AliITSpListItem*) (fa->At(GetIndex(i,j)));
-       else return 0;}
+      if((fa[GetIndex(i,j)]).IsUsed())return &(fa[GetIndex(i,j)]);
+      else return NULL; }
 
     // Fill pList from digits. Not functional yet
     virtual void FillMap(){NotImplemented("FillMap");}
@@ -129,18 +128,23 @@ class AliITSpList: public AliITSMap {
     // Flags a hit. Not of relavence in this case.
     virtual void FlagHit(Int_t /* i */,Int_t /* j */){NotImplemented("FlagHit");}
     virtual void GetCell(Int_t index,Int_t &i,Int_t &j) const;
+ // GetIndex returns the TClonesArray index for a given set of map indexes.
+    static Int_t GetIndex(Int_t i,Int_t j,Int_t maxj){
+      return maxj*i+j;}
 
  private:
 
 // private methods
-    Int_t GetIndex(Int_t i,Int_t j) const;
+    Int_t GetIndex(Int_t i,Int_t j) const {
+      if(i<0||i>=fNi || j<0||j>=fNj){AliWarning(Form("Index out of range 0<i=%d<%d and 0<0j=%d<%d",i,fNi,j,fNj)); return -1;}
+      return GetIndex(i,j,fNj);}
     void NotImplemented(const char *method) const {if(gDebug>0)
-         Warning(method,"This method is not implemented for this class");}
+       Warning(method,"This method is not implemented for this class");}
 // data members
     Int_t     fNi,fNj;   // The max index in i,j.
-    TClonesArray *fa;       // array of pList items
+    AliITSpListItem *fa;       // array of pList items
     Int_t     fEntries; // keepts track of the number of non-zero entries.
 
-    ClassDef(AliITSpList,4) // list of signals and track numbers
+    ClassDef(AliITSpList,5) // list of signals and track numbers
 };     
 #endif