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