--- PamCut/CommonDefs.h 2009/05/29 08:59:40 1.2 +++ PamCut/CommonDefs.h 2010/03/10 09:10:44 1.8 @@ -22,11 +22,24 @@ TRK = 1, ///< Code for Tracker CALO = 2, ///< Code for Calorimeter level2 TOF = 4, ///< Code for ToF - AC = 8, ///< Code for AntiCoincidence - TRIG = 16, ///< Code for Trigger + ANT = 8, ///< Code for AntiCoincidence + TRG = 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 + DEFAULT = 63, ///< TRK, CALO, TOF, ANT, TRG, ORB + ND = 64, ///< Code for Neutron Detector + CALO_L1 = 128 +///< 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 @@ -34,12 +47,31 @@ */ const int TOFNPADLAYER[6] = { 8, 6, 2, 2, 3, 3 }; +/*! @var H_MASS + * Proton mass + */ +const float H_MASS = 0.93827203; // GeV (pdg.web.cern.ch) + +/*! @var HE4_MASS + * Helium 4 mass + */ +const float HE4_MASS = 3.7274; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html) + +/*! @var HE3_MASS + * Helium 3 mass + */ +const float HE3_MASS = 2.8084; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html) + +/*! @var E_MASS + * Electron mass + */ +const float E_MASS = 0.000510998; // GeV (from PDG) + /*! @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 { @@ -55,8 +87,8 @@ * @param nCols The number of columns * @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) { + SimpleMatrix(unsigned int nRows = 0, unsigned int nCols = 0, T elements = T()) : + _matrix(nRows, std::vector(nCols, elements)) { } @@ -74,7 +106,7 @@ * @return The number of rows. */ unsigned int GetNRows() { - return _nRows; + return _matrix.size(); } /*! @brief Returns the number of columns. @@ -82,13 +114,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_ */