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

Annotation of /PamCut/CommonDefs.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download)
Thu Jul 8 14:00:24 2010 UTC (14 years, 4 months ago) by pam-fi
Branch: MAIN
CVS Tags: MergedFromV8_1, V9, HEAD
Changes since 1.9: +19 -1 lines
File MIME type: text/plain
Merged from branch V8 (tag MergedToHEAD_1). Tag before the merge: BeforeMergingFromV8_1.

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 pam-fi 1.9 const float POSITIVE = 1.0; ///< Positive sign alias
18     const float NEGATIVE = -1.0; ///< Negative sign alias
19    
20 pam-fi 1.1 /*! @enum DETECTORCODE
21     * The values for each detector correspond to a binary code associated to that detector.
22     * These can be arithmetically added to create a binary code for a set of detectors.
23     */
24     enum DETECTORCODE {
25     TRK = 1, ///< Code for Tracker
26 pam-fi 1.2 CALO = 2, ///< Code for Calorimeter level2
27 pam-fi 1.1 TOF = 4, ///< Code for ToF
28 pam-fi 1.6 ANT = 8, ///< Code for AntiCoincidence
29     TRG = 16, ///< Code for Trigger
30 pam-fi 1.1 ORB = 32, ///< Code for Orbital Info
31 pam-fi 1.6 DEFAULT = 63, ///< TRK, CALO, TOF, ANT, TRG, ORB
32     ND = 64, ///< Code for Neutron Detector
33     CALO_L1 = 128
34 pam-fi 1.3 ///< Code for Calorimeter level1
35 pam-fi 1.2 };
36    
37 pam-fi 1.10 /*! @enum TOFLAYERS Flags to identify TOF layers. */
38 pam-fi 1.4 enum TOFLAYERS {
39     S11 = 1, ///< S11.
40     S12 = 2, ///< S12.
41     S21 = 4, ///< S21.
42     S22 = 8, ///< S22.
43     S31 = 16, ///< S31.
44     S32 = 32
45     ///< S32.
46     };
47    
48 pam-fi 1.10 /*! @enum TRKLAYERS Flags to identify Tracker layers. */
49     enum TRKLAYERS {
50     T1X = 1, ///< T1X.
51     T2X = 2, ///< T2X.
52     T3X = 4, ///< T3X.
53     T4X = 8, ///< T4X.
54     T5X = 16, ///< T5X.
55     T6X = 32, ///< T6X.
56     TX = 63, ///< All the X layers
57     T1Y = 64, ///< T1Y.
58     T2Y = 128, ///< T2Y.
59     T3Y = 256, ///< T3Y.
60     T4Y = 512, ///< T4Y.
61     T5Y = 1024, ///< T5Y.
62     T6Y = 2048, ///< T6Y.
63     TY = 4032
64     ///< All the Y layers
65     };
66 pam-fi 1.2 /*! @var TOFNPADLAYER
67     * The number of pads in each ToF layer. S11 corresponds to element 0, S12 to element 1 and so on.
68     */
69     const int TOFNPADLAYER[6] = { 8, 6, 2, 2, 3, 3 };
70    
71 pam-fi 1.7 /*! @var H_MASS
72     * Proton mass
73     */
74 pam-fi 1.8 const float H_MASS = 0.93827203; // GeV (pdg.web.cern.ch)
75 pam-fi 1.7
76     /*! @var HE4_MASS
77     * Helium 4 mass
78     */
79 pam-fi 1.8 const float HE4_MASS = 3.7274; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html)
80 pam-fi 1.7
81     /*! @var HE3_MASS
82     * Helium 3 mass
83     */
84 pam-fi 1.8 const float HE3_MASS = 2.8084; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html)
85 pam-fi 1.7
86     /*! @var E_MASS
87     * Electron mass
88     */
89 pam-fi 1.8 const float E_MASS = 0.000510998; // GeV (from PDG)
90 pam-fi 1.7
91 pam-fi 1.2 /*! @brief A simple matrix class.
92     *
93     * This class defines a matrix built by STL vectors. It is basically a variable-dimension
94 pam-fi 1.3 * vector of vectors. It is intended as a container and not for algebraic manipulations.
95     * The class provides a standard access operator [] and a resize method.
96 pam-fi 1.2 */
97     template<class T>
98     class SimpleMatrix {
99    
100     public:
101     /*! @brief Constructor
102     *
103     * The constructor will build an nRows x nCols matrix, initialized with a default value. If T
104     * is a class with no default constructor, a default value for T must be provided, which will
105     * be replicated in every matrix element.
106     *
107     * @param nRows The number of rows.
108     * @param nCols The number of columns
109     * @param elements The initialization value for the matrix elements.
110     */
111 pam-fi 1.5 SimpleMatrix(unsigned int nRows = 0, unsigned int nCols = 0, T elements = T()) :
112 pam-fi 1.3 _matrix(nRows, std::vector<T>(nCols, elements)) {
113 pam-fi 1.2
114     }
115    
116     /*! @brief Standard accessor.
117     *
118     * @param i The desired row.
119     * @return The i-th row (a vector).
120     */
121     std::vector<T>& operator[](int i) {
122     return _matrix[i];
123     }
124    
125     /*! @brief Returns the number of rows.
126     *
127     * @return The number of rows.
128     */
129     unsigned int GetNRows() {
130 pam-fi 1.3 return _matrix.size();
131 pam-fi 1.2 }
132    
133     /*! @brief Returns the number of columns.
134     *
135     * @return The number of columns.
136     */
137     unsigned int GetNCols() {
138 pam-fi 1.3 return _matrix[0].size();
139     }
140    
141     /*! @brief Resizes the matrix.
142     *
143     * If new rows or columns are added, they are initialized to the default value; if T
144     * is a class with no default constructor, a default value for T must be provided, which will
145     * be replicated in every new matrix element. No modification
146     * is done to existing elements (except for those that will be eventually removed).
147     *
148     * @param nRows The new number of rows.
149     * @param nCols The new number of columns.
150     * @param elements The initialization value for the new matrix elements.
151     */
152     void Resize(unsigned int nRows, unsigned int nCols, T elements = T()) {
153    
154     _matrix.resize(nRows, std::vector<T>(nCols, elements));
155     for (unsigned int i = 0; i < _matrix.size(); i++)
156     _matrix[i].resize(nCols, elements);
157 pam-fi 1.2 }
158    
159     private:
160    
161     std::vector<std::vector<T> > _matrix;
162 pam-fi 1.1 };
163    
164     #endif /* COMMONDEFS_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23