]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODCaloCells.h
avoid fixed numner of detector names (15) for selection
[u/mrichter/AliRoot.git] / STEER / AliAODCaloCells.h
index 091bb5d05e1912f3c156e5fae7187e3e043cdd1f..18da2b09d80854bb09550db34bd72e777170f941 100644 (file)
@@ -23,6 +23,8 @@ class AliAODCaloCells : public TNamed
 
   AliAODCaloCells();
   AliAODCaloCells(const char* name, const char* title, AODCells_t ttype=kUndef);
+  AliAODCaloCells(const AliAODCaloCells& cells); 
+  AliAODCaloCells& operator=(const AliAODCaloCells& cells);
   
   virtual ~AliAODCaloCells();
   
@@ -35,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;
 
@@ -48,9 +51,6 @@ class AliAODCaloCells : public TNamed
   Bool_t      fIsSorted;     //! true if cell arrays are sorted by index
   Char_t      fType;         // Cell type
   
- private:
-  AliAODCaloCells(const AliAODCaloCells& tow); 
-  AliAODCaloCells& operator=(const AliAODCaloCells& tow);
   
   ClassDef(AliAODCaloCells, 1);
 };
@@ -107,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