test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
matutil.h
Go to the documentation of this file.
1 //
2 //
3 // File: hitfit/matutil.h
4 // Purpose: Define matrix types for the hitfit package, and supply a few
5 // additional operations.
6 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
7 //
8 // This file defines the types `Matrix', `Column_Vector', `Row_Vector',
9 // and `Diagonal_Matrix', to be used in hitfit code. These are based
10 // on the corresponding CLHEP matrix classes (except that we need
11 // to create our own row vector class, since CLHEP doesn't have that
12 // concept). We also provide a handful of operations that are missing
13 // in CLHEP.
14 //
15 // CMSSW File : interface/matutil.h
16 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
17 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
18 //
19 
20 
49 #ifndef HITFIT_MATUTIL_H
50 #define HITFIT_MATUTIL_H
51 
52 // We want bounds checking.
53 #define MATRIX_BOUND_CHECK
54 
55 //#include "CLHEP/config/CLHEP.h"
56 #include "CLHEP/Matrix/Matrix.h"
57 #include "CLHEP/Matrix/Vector.h"
58 #include "CLHEP/Matrix/DiagMatrix.h"
59 
60 
61 namespace hitfit {
62 
63 
64 // We use these CLHEP classes as-is.
65 typedef CLHEP::HepMatrix Matrix;
66 typedef CLHEP::HepVector Column_Vector;
67 typedef CLHEP::HepDiagMatrix Diagonal_Matrix;
68 
69 
70 // CLHEP doesn't have a row-vector class, so make our own.
71 // This is only a simple wrapper around Matrix that tries to constrain
72 // the shape to a row vector. It will raise an assertion if you try
73 // to assign to it something that isn't a row vector.
84  : public Matrix
85 //
86 // Purpose: Simple Row_Vector wrapper for CLHEP matrix class.
87 //
88 {
89 public:
90  // Constructor. Gives an uninitialized 1 x cols matrix.
97  explicit Row_Vector (int cols);
98 
99  // Constructor. Gives a 1 x cols matrix, initialized to zero.
100  // The INIT argument is just a dummy; give it a value of 0.
109  explicit Row_Vector (int cols, int init);
110 
111  // Copy constructor. Will raise an assertion if M doesn't have
112  // exactly one row.
119  Row_Vector (const Matrix& m);
120 
121  // Element access.
122  // ** Note that the indexing starts from (1). **
128  const double & operator() (int col) const;
129 
135  double & operator() (int col);
136 
137  // Element access.
138  // ** Note that the indexing starts from (1,1). **
146  const double & operator()(int row, int col) const;
147 
155  double & operator()(int row, int col);
156 
157  // Assignment. Will raise an assertion if M doesn't have
158  // exactly one row.
165  Row_Vector& operator= (const Matrix& m);
166 };
167 
168 
169 // Additional operations.
170 
171 
172 // Reset all elements of a matrix to 0.
178 void clear (CLHEP::HepGenMatrix& m);
179 
180 // Check that M has dimensions 1x1. If so, return the single element
181 // as a scalar. Otherwise, raise an assertion failure.
188 double scalar (const CLHEP::HepGenMatrix& m);
189 
190 
191 } // namespace hitfit
192 
193 
194 
195 #endif // not HITFIT_MATUTIL_H
196 
int init
Definition: HydjetWrapper.h:67
CLHEP::HepVector Column_Vector
Definition: matutil.h:66
CLHEP::HepMatrix Matrix
Definition: matutil.h:65
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
Row_Vector & operator=(const Matrix &m)
Assignment operator, will raise an assertion if m doesn&#39;t have exactly one row.
Definition: matutil.cc:148
const double & operator()(int col) const
Direct element access, indexing starts from 1.
Definition: matutil.cc:86
Row_Vector(int cols)
Constructor, instantiate an unitialized matrix.
Definition: matutil.cc:44
CLHEP::HepDiagMatrix Diagonal_Matrix
Definition: matutil.h:67
int col
Definition: cuy.py:1008
Row-vector class. CLHEP doesn&#39;t have a row-vector class, so HitFit uses its own. This is only a simpl...
Definition: matutil.h:83
double scalar(const CLHEP::HepGenMatrix &m)
Return the matrix as a scalar. Raise an assertion if the matris is not .
Definition: matutil.cc:183