AliPhysics  vAN-20151016 (8d2b0e8)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEmcalTriggerDataGrid.h
Go to the documentation of this file.
1 #ifndef ALIEMCALTRIGGERDATAGRID_H
2 #define ALIEMCALTRIGGERDATAGRID_H
3 /* Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice */
5 
6 #include <TObject.h>
7 #include <exception>
8 #include <sstream>
9 #include <string>
10 
17 template<typename T>
18 class AliEmcalTriggerDataGrid : public TObject {
19 public:
24  class UninitException : public std::exception{
25  public:
30  std::exception()
31  {}
35  virtual ~UninitException() throw() {}
36 
41  virtual const char *what() const throw() { return "Trigger channel map not initialized"; }
42  };
43 
48  class OutOfBoundsException : public std::exception{
49  public:
53  enum Direction_t {
54  kColDir = 0,
55  kRowDir = 1,
56  kUndef = 2
57  };
62  std::exception(),
63  fMessage(),
64  fDir(kUndef),
65  fSize(0),
66  fIndex()
67  {
68  }
75  OutOfBoundsException(Direction_t dir, int index, int size):
76  std::exception(),
77  fMessage(""),
78  fDir(dir),
79  fSize(size),
80  fIndex(index)
81  {
82  std::stringstream errormessage;
83  errormessage << "Out-of-bounds access in " << fDir << "Direction: Element " << fIndex << ", Size " << fSize;
84  fMessage = errormessage.str();
85  }
89  virtual ~OutOfBoundsException() throw() {}
90 
95  const char *what() const throw() { return fMessage.c_str(); }
96 
101  int GetSize() const { return fSize; }
102 
107  int GetIndex() const { return fIndex;}
108 
113  Direction_t GetDirection() const { return fDir; }
114 
115  private:
116  std::string fMessage;
118  int fSize;
119  int fIndex;
120  };
121 
126 
133  AliEmcalTriggerDataGrid(Int_t cols, Int_t rows);
134 
142 
151 
158  const T &operator()(Int_t col, Int_t row) const;
159 
166  T &operator()(Int_t col, Int_t row);
167 
171  virtual ~AliEmcalTriggerDataGrid();
172 
176  void Reset();
177 
178 
179  Bool_t IsAllocated() const { return fValues != NULL; }
180 
181  void Allocate(Int_t ncols, Int_t nrows);
182 
191  void SetADC(Int_t col, Int_t row, const T &adc);
192 
201  const T &GetADC(Int_t col, Int_t row) const;
202 
207  Int_t GetNumberOfCols() const { return fNCols; }
208 
213  Int_t GetNumberOfRows() const { return fNRows; }
214 
215 protected:
222  Int_t GetIndex(Int_t col, Int_t row) const;
223 
224  Int_t fNCols;
225  Int_t fNRows;
226  T *fValues;
227 
229  ClassDef(AliEmcalTriggerDataGrid, 1);
231 };
232 
233 
234 #endif
Exception class handling access to non-existing container element.
AliEmcalTriggerDataGrid< T > & operator=(const AliEmcalTriggerDataGrid< T > &ref)
const T & GetADC(Int_t col, Int_t row) const
T * fValues
Array of Trigger ADC values.
Int_t fNRows
Number of rows.
Int_t GetIndex(Int_t col, Int_t row) const
std::string fMessage
Error message, accessible via "what".
void SetADC(Int_t col, Int_t row, const T &adc)
const T & operator()(Int_t col, Int_t row) const
Error handling for uninitialized grid.
Container for ADC / Amplitudes from the EMCAL triggers.
void Allocate(Int_t ncols, Int_t nrows)
OutOfBoundsException(Direction_t dir, int index, int size)
int fSize
size of the container in direction
Int_t fNCols
Number of columns.