]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Method GetCellPosition added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Sep 2009 08:52:19 +0000 (08:52 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Sep 2009 08:52:19 +0000 (08:52 +0000)
STEER/AliAODCaloCells.h

index 89631fc16bae4e59c0bc14099bb142ce9c9f28bc..18da2b09d80854bb09550db34bd72e777170f941 100644 (file)
@@ -37,6 +37,7 @@ class AliAODCaloCells : public TNamed
   Short_t GetNumberOfCells() const { return fNCells; }
   inline Bool_t   GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude) const;
   inline Double_t GetCellAmplitude(Short_t cellNumber);
+  inline Short_t  GetCellPosition(Short_t cellNumber);
   inline Double_t GetAmplitude(Short_t pos) const;
   inline Short_t  GetCellNumber(Short_t pos) const;
 
@@ -106,5 +107,30 @@ Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const
   }
 }
 
+Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber)
+{ 
+  if (!fIsSorted) {
+    Sort();
+    fIsSorted=kTRUE;
+  }
+
+   Int_t nabove, nbelow, middle;
+   Short_t pos = -1;
+
+   nabove = fNCells + 1;
+   nbelow = 0;
+   while (nabove - nbelow > 1) {
+      middle = (nabove + nbelow) / 2;
+      if (cellNumber == fCellNumber[middle-1]) {
+         pos =   middle - 1;
+         break;
+      }
+      if (cellNumber  < fCellNumber[middle-1]) nabove = middle;
+      else                                     nbelow = middle;
+   }
+
+  return pos;
+}
+
 
 #endif