CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/TopQuarkAnalysis/TopHitFit/src/matutil.cc

Go to the documentation of this file.
00001 //
00002 // $Id: matutil.cc,v 1.1 2011/05/26 09:47:00 mseidel Exp $
00003 //
00004 // File: src/matutil.cc
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 // CMSSW File      : src/matutil.cc
00010 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
00011 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
00012 //
00013 
00038 #include "TopQuarkAnalysis/TopHitFit/interface/matutil.h"
00039 #include <cassert>
00040 
00041 
00042 namespace hitfit {
00043 
00044 
00045 Row_Vector::Row_Vector (int cols)
00046 //
00047 // Purpose: Constructor.
00048 //          Does not initialize the vector.
00049 //
00050 // Inputs:
00051 //   cols -        The length of the vector.
00052 //
00053   : Matrix (1, cols)
00054 {
00055 }
00056 
00057 
00058 Row_Vector::Row_Vector (int cols, int /*init*/)
00059 //
00060 // Purpose: Constructor.
00061 //          Initializes the vector to 0.
00062 //
00063 // Inputs:
00064 //   cols -        The length of the vector.
00065 //   init -        Dummy.  Should be 0.
00066 //
00067   : Matrix (1, cols, 0)
00068 {
00069 }
00070 
00071 
00072 Row_Vector::Row_Vector (const Matrix& m)
00073 //
00074 // Purpose: Copy constructor.
00075 //          Raises an assertion if M does not have exactly one row.
00076 //
00077 // Inputs:
00078 //   m -           The matrix to copy.
00079 //                 Must have exactly one row.
00080 //
00081   : Matrix (m)
00082 {
00083   assert (m.num_row() == 1);
00084 }
00085 
00086 
00087 const double& Row_Vector::operator() (int col) const
00088 //
00089 // Purpose: Element access.
00090 //
00091 // Inputs:
00092 //   col -         The column to access.  Indexing starts with 1.
00093 //
00094 // Returns:
00095 //   Const reference to the selected element.
00096 //
00097 {
00098   return HepMatrix::operator() (1, col);
00099 }
00100 
00101 
00102 double& Row_Vector::operator() (int col)
00103 //
00104 // Purpose: Element access.
00105 //
00106 // Inputs:
00107 //   col -         The column to access.  Indexing starts with 1.
00108 //
00109 // Returns:
00110 //   Reference to the selected element.
00111 //
00112 {
00113   return HepMatrix::operator() (1, col);
00114 }
00115 
00116 
00117 const double& Row_Vector::operator() (int row, int col) const
00118 //
00119 // Purpose: Element access.
00120 //
00121 // Inputs:
00122 //   row -         The row to access.  Indexing starts with 1.
00123 //   col -         The column to access.  Indexing starts with 1.
00124 //
00125 // Returns:
00126 //   Const reference to the selected element.
00127 //
00128 {
00129   return HepMatrix::operator() (row, col);
00130 }
00131 
00132 
00133 double& Row_Vector::operator() (int row, int col)
00134 //
00135 // Purpose: Element access.
00136 //
00137 // Inputs:
00138 //   row -         The row to access.  Indexing starts with 1.
00139 //   col -         The column to access.  Indexing starts with 1.
00140 //
00141 // Returns:
00142 //   Reference to the selected element.
00143 //
00144 {
00145   return HepMatrix::operator() (row, col);
00146 }
00147 
00148 
00149 Row_Vector& Row_Vector::operator= (const Matrix& m)
00150 //
00151 // Purpose: Assignment operator.
00152 //          Raises an assertion if M does not have exactly one row.
00153 //
00154 // Inputs:
00155 //   m -           The matrix to copy.
00156 //                 Must have exactly one row.
00157 //
00158 // Returns:
00159 //   This object.
00160 //
00161 {
00162   assert (m.num_row() == 1);
00163   *((Matrix*)this) = m;
00164   return *this;
00165 }
00166 
00167 
00168 void clear (CLHEP::HepGenMatrix& m)
00169 //
00170 // Purpose: Reset the matrix M to zero.
00171 //
00172 // Inputs:
00173 //   m -           The matrix to reset.
00174 //
00175 {
00176   int nrow = m.num_row();
00177   int ncol = m.num_col();
00178   for (int i=1; i <= nrow; i++)
00179     for (int j=1; j <= ncol; j++)
00180       m(i, j) = 0;
00181 }
00182 
00183 
00184 double scalar (const CLHEP::HepGenMatrix& m)
00185 //
00186 // Purpose: Return the 1x1 matrix M as a scalar.
00187 //          Raise an assertion if M is not 1x1.
00188 //
00189 // Inputs:
00190 //   m -           The matrix to convert.
00191 //                 Must be 1x1.
00192 //
00193 // Returns:
00194 //   m(1,1)
00195 //
00196 {
00197   assert (m.num_row() == 1 && m.num_col() == 1);
00198   return m (1, 1);
00199 }
00200 
00201 
00202 } // namespace hitfit