CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TopQuarkAnalysis/TopHitFit/interface/matutil.h

Go to the documentation of this file.
00001 //
00002 // $Id: matutil.h,v 1.1 2011/05/26 09:46:53 mseidel Exp $
00003 //
00004 // File: hitfit/matutil.h
00005 // Purpose: Define matrix types for the hitfit package, and supply a few
00006 //          additional operations.
00007 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
00008 //
00009 // This file defines the types `Matrix', `Column_Vector', `Row_Vector',
00010 // and `Diagonal_Matrix', to be used in hitfit code.  These are based
00011 // on the corresponding CLHEP matrix classes (except that we need
00012 // to create our own row vector class, since CLHEP doesn't have that
00013 // concept).  We also provide a handful of operations that are missing
00014 // in CLHEP.
00015 //
00016 // CMSSW File      : interface/matutil.h
00017 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
00018 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
00019 //
00020 
00021 
00050 #ifndef HITFIT_MATUTIL_H
00051 #define HITFIT_MATUTIL_H
00052 
00053 // We want bounds checking.
00054 #define MATRIX_BOUND_CHECK
00055 
00056 //#include "CLHEP/config/CLHEP.h"
00057 #include "CLHEP/Matrix/Matrix.h"
00058 #include "CLHEP/Matrix/Vector.h"
00059 #include "CLHEP/Matrix/DiagMatrix.h"
00060 
00061 
00062 namespace hitfit {
00063 
00064 
00065 // We use these CLHEP classes as-is.
00066 typedef CLHEP::HepMatrix Matrix;
00067 typedef CLHEP::HepVector Column_Vector;
00068 typedef CLHEP::HepDiagMatrix Diagonal_Matrix;
00069 
00070 
00071 // CLHEP doesn't have a row-vector class, so make our own.
00072 // This is only a simple wrapper around Matrix that tries to constrain
00073 // the shape to a row vector.  It will raise an assertion if you try
00074 // to assign to it something that isn't a row vector.
00084 class Row_Vector
00085   : public Matrix
00086 //
00087 // Purpose: Simple Row_Vector wrapper for CLHEP matrix class.
00088 //
00089 {
00090 public:
00091    // Constructor.  Gives an uninitialized 1 x cols matrix.
00098   explicit Row_Vector (int cols);
00099 
00100    // Constructor.  Gives a 1 x cols matrix, initialized to zero.
00101    // The INIT argument is just a dummy; give it a value of 0.
00110   explicit Row_Vector (int cols, int init);
00111 
00112   // Copy constructor.  Will raise an assertion if M doesn't have
00113   // exactly one row.
00120   Row_Vector (const Matrix& m);
00121 
00122   // Element access.
00123   // ** Note that the indexing starts from (1). **
00129   const double & operator() (int col) const;
00130 
00136   double & operator() (int col);
00137 
00138   // Element access.
00139   // ** Note that the indexing starts from (1,1). **
00147   const double & operator()(int row, int col) const;
00148 
00156   double & operator()(int row, int col);
00157 
00158   // Assignment.  Will raise an assertion if M doesn't have
00159   // exactly one row.
00166   Row_Vector& operator= (const Matrix& m);
00167 };
00168 
00169 
00170 // Additional operations.
00171 
00172 
00173 // Reset all elements of a matrix to 0.
00179 void clear (CLHEP::HepGenMatrix& m);
00180 
00181 // Check that M has dimensions 1x1.  If so, return the single element
00182 // as a scalar.  Otherwise, raise an assertion failure.
00189 double scalar (const CLHEP::HepGenMatrix& m);
00190 
00191 
00192 } // namespace hitfit
00193 
00194 
00195 
00196 #endif // not HITFIT_MATUTIL_H
00197