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

Annotation of /PamCut/CommonDefs.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Wed Mar 10 08:54:44 2010 UTC (14 years, 8 months ago) by pam-fi
Branch: MAIN
Changes since 1.6: +20 -0 lines
File MIME type: text/plain
Constants for some particle masses added.

1 pam-fi 1.1 /*
2     * CommonDefs.h
3     *
4     * Created on: 10-mar-2009
5     * Author: Nicola Mori
6     */
7    
8     /*! @file CommonDefs.h A header file with all the common definitions for the PamCut framework.
9     */
10    
11     #ifndef COMMONDEFS_H_
12     #define COMMONDEFS_H_
13    
14     /*! @brief The implementations of PamCut::Check() must return this value if the event satisfy the cut*/
15     const int CUTOK = -1;
16    
17     /*! @enum DETECTORCODE
18     * The values for each detector correspond to a binary code associated to that detector.
19     * These can be arithmetically added to create a binary code for a set of detectors.
20     */
21     enum DETECTORCODE {
22     TRK = 1, ///< Code for Tracker
23 pam-fi 1.2 CALO = 2, ///< Code for Calorimeter level2
24 pam-fi 1.1 TOF = 4, ///< Code for ToF
25 pam-fi 1.6 ANT = 8, ///< Code for AntiCoincidence
26     TRG = 16, ///< Code for Trigger
27 pam-fi 1.1 ORB = 32, ///< Code for Orbital Info
28 pam-fi 1.6 DEFAULT = 63, ///< TRK, CALO, TOF, ANT, TRG, ORB
29     ND = 64, ///< Code for Neutron Detector
30     CALO_L1 = 128
31 pam-fi 1.3 ///< Code for Calorimeter level1
32 pam-fi 1.2 };
33    
34 pam-fi 1.4 /*! @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 pam-fi 1.2 /*! @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 pam-fi 1.7 /*! @var H_MASS
51     * Proton mass
52     */
53     const Float_t H_MASS = 0.93827203; // GeV (pdg.web.cern.ch)
54    
55     /*! @var HE4_MASS
56     * Helium 4 mass
57     */
58     const Float_t HE4_MASS = 3.7274; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html)
59    
60     /*! @var HE3_MASS
61     * Helium 3 mass
62     */
63     const Float_t HE3_MASS = 2.8084; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html)
64    
65     /*! @var E_MASS
66     * Electron mass
67     */
68     const Float_t E_MASS = 0.000510998; // GeV (from PDG)
69    
70 pam-fi 1.2 /*! @brief A simple matrix class.
71     *
72     * This class defines a matrix built by STL vectors. It is basically a variable-dimension
73 pam-fi 1.3 * vector of vectors. It is intended as a container and not for algebraic manipulations.
74     * The class provides a standard access operator [] and a resize method.
75 pam-fi 1.2 */
76     template<class T>
77     class SimpleMatrix {
78    
79     public:
80     /*! @brief Constructor
81     *
82     * The constructor will build an nRows x nCols matrix, initialized with a default value. If T
83     * is a class with no default constructor, a default value for T must be provided, which will
84     * be replicated in every matrix element.
85     *
86     * @param nRows The number of rows.
87     * @param nCols The number of columns
88     * @param elements The initialization value for the matrix elements.
89     */
90 pam-fi 1.5 SimpleMatrix(unsigned int nRows = 0, unsigned int nCols = 0, T elements = T()) :
91 pam-fi 1.3 _matrix(nRows, std::vector<T>(nCols, elements)) {
92 pam-fi 1.2
93     }
94    
95     /*! @brief Standard accessor.
96     *
97     * @param i The desired row.
98     * @return The i-th row (a vector).
99     */
100     std::vector<T>& operator[](int i) {
101     return _matrix[i];
102     }
103    
104     /*! @brief Returns the number of rows.
105     *
106     * @return The number of rows.
107     */
108     unsigned int GetNRows() {
109 pam-fi 1.3 return _matrix.size();
110 pam-fi 1.2 }
111    
112     /*! @brief Returns the number of columns.
113     *
114     * @return The number of columns.
115     */
116     unsigned int GetNCols() {
117 pam-fi 1.3 return _matrix[0].size();
118     }
119    
120     /*! @brief Resizes the matrix.
121     *
122     * If new rows or columns are added, they are initialized to the default value; if T
123     * is a class with no default constructor, a default value for T must be provided, which will
124     * be replicated in every new matrix element. No modification
125     * is done to existing elements (except for those that will be eventually removed).
126     *
127     * @param nRows The new number of rows.
128     * @param nCols The new number of columns.
129     * @param elements The initialization value for the new matrix elements.
130     */
131     void Resize(unsigned int nRows, unsigned int nCols, T elements = T()) {
132    
133     _matrix.resize(nRows, std::vector<T>(nCols, elements));
134     for (unsigned int i = 0; i < _matrix.size(); i++)
135     _matrix[i].resize(nCols, elements);
136 pam-fi 1.2 }
137    
138     private:
139    
140     std::vector<std::vector<T> > _matrix;
141 pam-fi 1.1 };
142    
143     #endif /* COMMONDEFS_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23