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 |
AC = 8, ///< Code for AntiCoincidence |
26 |
TRIG = 16, ///< Code for Trigger |
TRIG = 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 |
ALL = 63, ///< Sum of all the above codes |
29 |
|
CALO_L1 = 64 |
30 |
|
///< Code for Calorimeter level1 |
31 |
|
}; |
32 |
|
|
33 |
|
/*! @var TOFNPADLAYER |
34 |
|
* The number of pads in each ToF layer. S11 corresponds to element 0, S12 to element 1 and so on. |
35 |
|
*/ |
36 |
|
const int TOFNPADLAYER[6] = { 8, 6, 2, 2, 3, 3 }; |
37 |
|
|
38 |
|
/*! @brief A simple matrix class. |
39 |
|
* |
40 |
|
* This class defines a matrix built by STL vectors. It is basically a variable-dimension |
41 |
|
* vector of vectors. It is intended as a container and not for algebraic manipulations. |
42 |
|
* The class provides a standard access operator [] and a resize method. |
43 |
|
*/ |
44 |
|
template<class T> |
45 |
|
class SimpleMatrix { |
46 |
|
|
47 |
|
public: |
48 |
|
/*! @brief Constructor |
49 |
|
* |
50 |
|
* The constructor will build an nRows x nCols matrix, initialized with a default value. If T |
51 |
|
* is a class with no default constructor, a default value for T must be provided, which will |
52 |
|
* be replicated in every matrix element. |
53 |
|
* |
54 |
|
* @param nRows The number of rows. |
55 |
|
* @param nCols The number of columns |
56 |
|
* @param elements The initialization value for the matrix elements. |
57 |
|
*/ |
58 |
|
SimpleMatrix(unsigned int nRows, unsigned int nCols, T elements = T()) : |
59 |
|
_matrix(nRows, std::vector<T>(nCols, elements)) { |
60 |
|
|
61 |
|
} |
62 |
|
|
63 |
|
/*! @brief Standard accessor. |
64 |
|
* |
65 |
|
* @param i The desired row. |
66 |
|
* @return The i-th row (a vector). |
67 |
|
*/ |
68 |
|
std::vector<T>& operator[](int i) { |
69 |
|
return _matrix[i]; |
70 |
|
} |
71 |
|
|
72 |
|
/*! @brief Returns the number of rows. |
73 |
|
* |
74 |
|
* @return The number of rows. |
75 |
|
*/ |
76 |
|
unsigned int GetNRows() { |
77 |
|
return _matrix.size(); |
78 |
|
} |
79 |
|
|
80 |
|
/*! @brief Returns the number of columns. |
81 |
|
* |
82 |
|
* @return The number of columns. |
83 |
|
*/ |
84 |
|
unsigned int GetNCols() { |
85 |
|
return _matrix[0].size(); |
86 |
|
} |
87 |
|
|
88 |
|
/*! @brief Resizes the matrix. |
89 |
|
* |
90 |
|
* If new rows or columns are added, they are initialized to the default value; if T |
91 |
|
* is a class with no default constructor, a default value for T must be provided, which will |
92 |
|
* be replicated in every new matrix element. No modification |
93 |
|
* is done to existing elements (except for those that will be eventually removed). |
94 |
|
* |
95 |
|
* @param nRows The new number of rows. |
96 |
|
* @param nCols The new number of columns. |
97 |
|
* @param elements The initialization value for the new matrix elements. |
98 |
|
*/ |
99 |
|
void Resize(unsigned int nRows, unsigned int nCols, T elements = T()) { |
100 |
|
|
101 |
|
_matrix.resize(nRows, std::vector<T>(nCols, elements)); |
102 |
|
for (unsigned int i = 0; i < _matrix.size(); i++) |
103 |
|
_matrix[i].resize(nCols, elements); |
104 |
|
} |
105 |
|
|
106 |
|
private: |
107 |
|
|
108 |
|
std::vector<std::vector<T> > _matrix; |
109 |
}; |
}; |
110 |
|
|
111 |
#endif /* COMMONDEFS_H_ */ |
#endif /* COMMONDEFS_H_ */ |