From: morsch Date: Fri, 18 Sep 2009 08:52:19 +0000 (+0000) Subject: Method GetCellPosition added. X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=b4620c80f739967530ed56ca9e0e3f9877101dd0 Method GetCellPosition added. --- diff --git a/STEER/AliAODCaloCells.h b/STEER/AliAODCaloCells.h index 89631fc16ba..18da2b09d80 100644 --- a/STEER/AliAODCaloCells.h +++ b/STEER/AliAODCaloCells.h @@ -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 &litude) 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