class AliAODCaloCells : public TNamed
{
public:
- enum AODTwrs_t {kUndef = -1,
+ enum AODCells_t {kUndef = -1,
kEMCAL,
kPHOS};
AliAODCaloCells();
- AliAODCaloCells(const char* name, const char* title, AODTwrs_t ttype=kUndef);
+ AliAODCaloCells(const char* name, const char* title, AODCells_t ttype=kUndef);
+ AliAODCaloCells(const AliAODCaloCells& cells);
+ AliAODCaloCells& operator=(const AliAODCaloCells& cells);
virtual ~AliAODCaloCells();
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;
Char_t GetType() const { return fType;}
- void SetType(AODTwrs_t ttype) { fType=ttype; }
+ void SetType(AODCells_t ttype) { fType=ttype; }
protected:
Int_t fNCells; // Number of cells
Short_t *fCellNumber; //[fNCells] array of cell numbers
- Double32_t *fAmplitude; //[fNCells][0.,600.,16] array with cell amplitudes (= energy!)
+ Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
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);
};
amplitude = fAmplitude[pos];
return kTRUE;
} else {
- Error("GetCell","Invalid cell array index %d", pos);
+ Warning("GetCell","Invalid cell array index %d", pos);
return kFALSE;
}
}
}
Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
- if (pos>=0 && pos == cellNumber) {
+ if (pos>=0 && fCellNumber[pos] == cellNumber) {
return fAmplitude[pos];
} else {
- Error("GetCellAmplitude","Wrong cell array index %d", pos);
+ Warning("GetCellAmplitude","Wrong cell array index %d", pos);
return 0.;
}
}
if (pos>=0 && pos<fNCells) {
return fAmplitude[pos];
} else {
- Error("GetAmplitude","Invalid cell array index %d", pos);
+ Warning("GetAmplitude","Invalid cell array index %d", pos);
return 0.;
}
}
if (pos>=0 && pos<fNCells) {
return fCellNumber[pos];
} else {
- Error("GetCellNumber","Invalid cell array index %d", pos);
+ Warning("GetCellNumber","Invalid cell array index %d", pos);
return fNCells;
}
}
+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