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

Contents of /PamCut/CommonDefs.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Thu Mar 11 19:17:44 2010 UTC (14 years, 8 months ago) by pam-fi
Branch: MAIN
CVS Tags: Root_V8, BeforeMergingFromV8_1
Branch point for: V8
Changes since 1.8: +3 -0 lines
File MIME type: text/plain
Aliases for positive and negative signs added.

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 const float POSITIVE = 1.0; ///< Positive sign alias
18 const float NEGATIVE = -1.0; ///< Negative sign alias
19
20 /*! @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 CALO = 2, ///< Code for Calorimeter level2
27 TOF = 4, ///< Code for ToF
28 ANT = 8, ///< Code for AntiCoincidence
29 TRG = 16, ///< Code for Trigger
30 ORB = 32, ///< Code for Orbital Info
31 DEFAULT = 63, ///< TRK, CALO, TOF, ANT, TRG, ORB
32 ND = 64, ///< Code for Neutron Detector
33 CALO_L1 = 128
34 ///< Code for Calorimeter level1
35 };
36
37 /*! @enum TOFLAYERS Flags to identify layers. */
38 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 /*! @var TOFNPADLAYER
49 * The number of pads in each ToF layer. S11 corresponds to element 0, S12 to element 1 and so on.
50 */
51 const int TOFNPADLAYER[6] = { 8, 6, 2, 2, 3, 3 };
52
53 /*! @var H_MASS
54 * Proton mass
55 */
56 const float H_MASS = 0.93827203; // GeV (pdg.web.cern.ch)
57
58 /*! @var HE4_MASS
59 * Helium 4 mass
60 */
61 const float HE4_MASS = 3.7274; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html)
62
63 /*! @var HE3_MASS
64 * Helium 3 mass
65 */
66 const float HE3_MASS = 2.8084; // GeV (http://hyperphysics.phy-astr.gsu.edu/Hbase/pertab/He.html)
67
68 /*! @var E_MASS
69 * Electron mass
70 */
71 const float E_MASS = 0.000510998; // GeV (from PDG)
72
73 /*! @brief A simple matrix class.
74 *
75 * This class defines a matrix built by STL vectors. It is basically a variable-dimension
76 * vector of vectors. It is intended as a container and not for algebraic manipulations.
77 * The class provides a standard access operator [] and a resize method.
78 */
79 template<class T>
80 class SimpleMatrix {
81
82 public:
83 /*! @brief Constructor
84 *
85 * The constructor will build an nRows x nCols matrix, initialized with a default value. If T
86 * is a class with no default constructor, a default value for T must be provided, which will
87 * be replicated in every matrix element.
88 *
89 * @param nRows The number of rows.
90 * @param nCols The number of columns
91 * @param elements The initialization value for the matrix elements.
92 */
93 SimpleMatrix(unsigned int nRows = 0, unsigned int nCols = 0, T elements = T()) :
94 _matrix(nRows, std::vector<T>(nCols, elements)) {
95
96 }
97
98 /*! @brief Standard accessor.
99 *
100 * @param i The desired row.
101 * @return The i-th row (a vector).
102 */
103 std::vector<T>& operator[](int i) {
104 return _matrix[i];
105 }
106
107 /*! @brief Returns the number of rows.
108 *
109 * @return The number of rows.
110 */
111 unsigned int GetNRows() {
112 return _matrix.size();
113 }
114
115 /*! @brief Returns the number of columns.
116 *
117 * @return The number of columns.
118 */
119 unsigned int GetNCols() {
120 return _matrix[0].size();
121 }
122
123 /*! @brief Resizes the matrix.
124 *
125 * If new rows or columns are added, they are initialized to the default value; if T
126 * is a class with no default constructor, a default value for T must be provided, which will
127 * be replicated in every new matrix element. No modification
128 * is done to existing elements (except for those that will be eventually removed).
129 *
130 * @param nRows The new number of rows.
131 * @param nCols The new number of columns.
132 * @param elements The initialization value for the new matrix elements.
133 */
134 void Resize(unsigned int nRows, unsigned int nCols, T elements = T()) {
135
136 _matrix.resize(nRows, std::vector<T>(nCols, elements));
137 for (unsigned int i = 0; i < _matrix.size(); i++)
138 _matrix[i].resize(nCols, elements);
139 }
140
141 private:
142
143 std::vector<std::vector<T> > _matrix;
144 };
145
146 #endif /* COMMONDEFS_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23