/[PAMELA software]/PamCut/CommonDefs.h
ViewVC logotype

Diff of /PamCut/CommonDefs.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by pam-fi, Fri May 29 08:59:40 2009 UTC revision 1.4 by pam-fi, Wed Aug 5 14:06:44 2009 UTC
# Line 26  enum DETECTORCODE { Line 26  enum DETECTORCODE {
26    TRIG = 16, ///< Code for Trigger    TRIG = 16, ///< Code for Trigger
27    ORB = 32, ///< Code for Orbital Info    ORB = 32, ///< Code for Orbital Info
28    ALL = 63, ///< Sum of all the above codes    ALL = 63, ///< Sum of all the above codes
29    CALO_L1 = 64 ///< Code for Calorimeter level1    CALO_L1 = 64
30    ///< Code for Calorimeter level1
31    };
32    
33    /*! @enum TOFLAYERS Flags to identify layers. */
34    enum TOFLAYERS {
35      S11 = 1, ///< S11.
36      S12 = 2, ///< S12.
37      S21 = 4, ///< S21.
38      S22 = 8, ///< S22.
39      S31 = 16, ///< S31.
40      S32 = 32
41    ///< S32.
42  };  };
43    
44  /*! @var TOFNPADLAYER  /*! @var TOFNPADLAYER
# Line 37  const int TOFNPADLAYER[6] = { 8, 6, 2, 2 Line 49  const int TOFNPADLAYER[6] = { 8, 6, 2, 2
49  /*! @brief A simple matrix class.  /*! @brief A simple matrix class.
50   *   *
51   *  This class defines a matrix built by STL vectors. It is basically a variable-dimension   *  This class defines a matrix built by STL vectors. It is basically a variable-dimension
52   *  vector of vectors; the dimension is defined at construction and cannot be changed in   *  vector of vectors. It is intended as a container and not for algebraic manipulations.
53   *  current implementation. It is intended as a container and not for algebraic manipulations.   *  The class provides a standard access operator [] and a resize method.
  *  The class provides a standard access operator [].  
54   */   */
55  template<class T>  template<class T>
56  class SimpleMatrix {  class SimpleMatrix {
# Line 56  public: Line 67  public:
67     * @param elements The initialization value for the matrix elements.     * @param elements The initialization value for the matrix elements.
68     */     */
69    SimpleMatrix(unsigned int nRows, unsigned int nCols, T elements = T()) :    SimpleMatrix(unsigned int nRows, unsigned int nCols, T elements = T()) :
70      _matrix(nRows, std::vector<T>(nCols, elements)), _nRows(nRows), _nCols(nCols) {      _matrix(nRows, std::vector<T>(nCols, elements)) {
71    
72    }    }
73    
# Line 74  public: Line 85  public:
85     * @return The number of rows.     * @return The number of rows.
86     */     */
87    unsigned int GetNRows() {    unsigned int GetNRows() {
88      return _nRows;      return _matrix.size();
89    }    }
90    
91    /*! @brief Returns the number of columns.    /*! @brief Returns the number of columns.
# Line 82  public: Line 93  public:
93     * @return The number of columns.     * @return The number of columns.
94     */     */
95    unsigned int GetNCols() {    unsigned int GetNCols() {
96      return _nCols;      return _matrix[0].size();
97      }
98    
99      /*! @brief Resizes the matrix.
100       *
101       * If new rows or columns are added, they are initialized to the default value; if T
102       * is a class with no default constructor, a default value for T must be provided, which will
103       * be replicated in every new matrix element. No modification
104       * is done to existing elements (except for those that will be eventually removed).
105       *
106       * @param nRows The new number of rows.
107       * @param nCols The new number of columns.
108       * @param elements The initialization value for the new matrix elements.
109       */
110      void Resize(unsigned int nRows, unsigned int nCols, T elements = T()) {
111    
112        _matrix.resize(nRows, std::vector<T>(nCols, elements));
113        for (unsigned int i = 0; i < _matrix.size(); i++)
114          _matrix[i].resize(nCols, elements);
115    }    }
116    
117  private:  private:
118    
119    std::vector<std::vector<T> > _matrix;    std::vector<std::vector<T> > _matrix;
   unsigned int _nRows, _nCols;  
120  };  };
121    
122  #endif /* COMMONDEFS_H_ */  #endif /* COMMONDEFS_H_ */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23