--- PamCut/CommonDefs.h 2009/05/29 08:59:40 1.2 +++ PamCut/CommonDefs.h 2009/08/05 14:06:44 1.4 @@ -26,7 +26,19 @@ TRIG = 16, ///< Code for Trigger ORB = 32, ///< Code for Orbital Info ALL = 63, ///< Sum of all the above codes - CALO_L1 = 64 ///< Code for Calorimeter level1 + CALO_L1 = 64 +///< Code for Calorimeter level1 +}; + +/*! @enum TOFLAYERS Flags to identify layers. */ +enum TOFLAYERS { + S11 = 1, ///< S11. + S12 = 2, ///< S12. + S21 = 4, ///< S21. + S22 = 8, ///< S22. + S31 = 16, ///< S31. + S32 = 32 +///< S32. }; /*! @var TOFNPADLAYER @@ -37,9 +49,8 @@ /*! @brief A simple matrix class. * * This class defines a matrix built by STL vectors. It is basically a variable-dimension - * vector of vectors; the dimension is defined at construction and cannot be changed in - * current implementation. It is intended as a container and not for algebraic manipulations. - * The class provides a standard access operator []. + * vector of vectors. It is intended as a container and not for algebraic manipulations. + * The class provides a standard access operator [] and a resize method. */ template class SimpleMatrix { @@ -56,7 +67,7 @@ * @param elements The initialization value for the matrix elements. */ SimpleMatrix(unsigned int nRows, unsigned int nCols, T elements = T()) : - _matrix(nRows, std::vector(nCols, elements)), _nRows(nRows), _nCols(nCols) { + _matrix(nRows, std::vector(nCols, elements)) { } @@ -74,7 +85,7 @@ * @return The number of rows. */ unsigned int GetNRows() { - return _nRows; + return _matrix.size(); } /*! @brief Returns the number of columns. @@ -82,13 +93,30 @@ * @return The number of columns. */ unsigned int GetNCols() { - return _nCols; + return _matrix[0].size(); + } + + /*! @brief Resizes the matrix. + * + * If new rows or columns are added, they are initialized to the default value; if T + * is a class with no default constructor, a default value for T must be provided, which will + * be replicated in every new matrix element. No modification + * is done to existing elements (except for those that will be eventually removed). + * + * @param nRows The new number of rows. + * @param nCols The new number of columns. + * @param elements The initialization value for the new matrix elements. + */ + void Resize(unsigned int nRows, unsigned int nCols, T elements = T()) { + + _matrix.resize(nRows, std::vector(nCols, elements)); + for (unsigned int i = 0; i < _matrix.size(); i++) + _matrix[i].resize(nCols, elements); } private: std::vector > _matrix; - unsigned int _nRows, _nCols; }; #endif /* COMMONDEFS_H_ */