/[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.1.1.1 by pam-fi, Wed May 27 13:30:01 2009 UTC revision 1.6 by pam-fi, Tue Mar 9 18:02:10 2010 UTC
# Line 20  const int CUTOK = -1; Line 20  const int CUTOK = -1;
20   */   */
21  enum DETECTORCODE {  enum DETECTORCODE {
22    TRK = 1, ///< Code for Tracker    TRK = 1, ///< Code for Tracker
23    CALO = 2, ///< Code for Calorimeter    CALO = 2, ///< Code for Calorimeter level2
24    TOF = 4, ///< Code for ToF    TOF = 4, ///< Code for ToF
25    AC = 8, ///< Code for AntiCoincidence    ANT = 8, ///< Code for AntiCoincidence
26    TRIG = 16, ///< Code for Trigger    TRG = 16, ///< Code for Trigger
27    ORB = 32, ///< Code for Orbital Info    ORB = 32, ///< Code for Orbital Info
28    ALL = 63 ///< Code for All the detectors    DEFAULT = 63, ///< TRK, CALO, TOF, ANT, TRG, ORB
29      ND = 64, ///< Code for Neutron Detector
30      CALO_L1 = 128
31    ///< Code for Calorimeter level1
32    };
33    
34    /*! @enum TOFLAYERS Flags to identify layers. */
35    enum TOFLAYERS {
36      S11 = 1, ///< S11.
37      S12 = 2, ///< S12.
38      S21 = 4, ///< S21.
39      S22 = 8, ///< S22.
40      S31 = 16, ///< S31.
41      S32 = 32
42    ///< S32.
43    };
44    
45    /*! @var TOFNPADLAYER
46     * The number of pads in each ToF layer. S11 corresponds to element 0, S12 to element 1 and so on.
47     */
48    const int TOFNPADLAYER[6] = { 8, 6, 2, 2, 3, 3 };
49    
50    /*! @brief A simple matrix class.
51     *
52     *  This class defines a matrix built by STL vectors. It is basically a variable-dimension
53     *  vector of vectors. It is intended as a container and not for algebraic manipulations.
54     *  The class provides a standard access operator [] and a resize method.
55     */
56    template<class T>
57    class SimpleMatrix {
58    
59    public:
60      /*! @brief Constructor
61       *
62       * The constructor will build an nRows x nCols matrix, initialized with a default value. If T
63       * is a class with no default constructor, a default value for T must be provided, which will
64       * be replicated in every matrix element.
65       *
66       * @param nRows The number of rows.
67       * @param nCols The number of columns
68       * @param elements The initialization value for the matrix elements.
69       */
70      SimpleMatrix(unsigned int nRows = 0, unsigned int nCols = 0, T elements = T()) :
71        _matrix(nRows, std::vector<T>(nCols, elements)) {
72    
73      }
74    
75      /*! @brief Standard accessor.
76       *
77       * @param i The desired row.
78       * @return The i-th row (a vector).
79       */
80      std::vector<T>& operator[](int i) {
81        return _matrix[i];
82      }
83    
84      /*! @brief Returns the number of rows.
85       *
86       * @return The number of rows.
87       */
88      unsigned int GetNRows() {
89        return _matrix.size();
90      }
91    
92      /*! @brief Returns the number of columns.
93       *
94       * @return The number of columns.
95       */
96      unsigned int GetNCols() {
97        return _matrix[0].size();
98      }
99    
100      /*! @brief Resizes the matrix.
101       *
102       * If new rows or columns are added, they are initialized to the default value; if T
103       * is a class with no default constructor, a default value for T must be provided, which will
104       * be replicated in every new matrix element. No modification
105       * is done to existing elements (except for those that will be eventually removed).
106       *
107       * @param nRows The new number of rows.
108       * @param nCols The new number of columns.
109       * @param elements The initialization value for the new matrix elements.
110       */
111      void Resize(unsigned int nRows, unsigned int nCols, T elements = T()) {
112    
113        _matrix.resize(nRows, std::vector<T>(nCols, elements));
114        for (unsigned int i = 0; i < _matrix.size(); i++)
115          _matrix[i].resize(nCols, elements);
116      }
117    
118    private:
119    
120      std::vector<std::vector<T> > _matrix;
121  };  };
122    
123  #endif /* COMMONDEFS_H_ */  #endif /* COMMONDEFS_H_ */

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23