CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
BlockSolver Class Reference

solves at best the matrix invertion for calibration More...

#include <BlockSolver.h>

Public Member Functions

int operator() (const CLHEP::HepMatrix &matrix, const CLHEP::HepVector &vector, CLHEP::HepVector &result)
 

Private Member Functions

void pour (CLHEP::HepVector &result, const CLHEP::HepVector &output, const std::vector< int > &where)
 pour results in bigger vector More...
 
void shrink (const CLHEP::HepMatrix &matrix, CLHEP::HepMatrix &solution, const CLHEP::HepVector &result, CLHEP::HepVector &input, const std::vector< int > &where)
 eliminate empty columns and rows More...
 

Detailed Description

solves at best the matrix invertion for calibration

Date:
2011/06/30 10:10:52
Revision:
1.1
Id:
BlockSolver.h,v 1.1 2011/06/30 10:10:52 muzaffar Exp
Author
Author:
muzaffar

Definition at line 25 of file BlockSolver.h.

Member Function Documentation

int BlockSolver::operator() ( const CLHEP::HepMatrix &  matrix,
const CLHEP::HepVector &  vector,
CLHEP::HepVector &  result 
)
Date:
2011/06/30 10:10:52
Revision:
1.1
Id:
BlockSolver.cc,v 1.1 2011/06/30 10:10:52 muzaffar Exp
Author
Author:
muzaffar

Definition at line 11 of file BlockSolver.cc.

References cuy::col, i, LaserDQM_cfg::input, convertSQLitetoXML_cfg::output, pour(), shrink(), and dtDQMClient_cfg::threshold.

14 {
15  double threshold = matrix.trace () /
16  static_cast<double> (matrix.num_row ()) ;
17  std::vector<int> holes ;
18  // loop over the matrix rows
19  for (int row = 0 ; row < matrix.num_row () ; ++row)
20  {
21  double sumAbs = 0. ;
22  for (int col = 0 ; col < matrix.num_col () ; ++col)
23  sumAbs += fabs (matrix[row][col]) ;
24  if (sumAbs < threshold) holes.push_back (row) ;
25  } // loop over the matrix rows
26 
27  int dim = matrix.num_col () - holes.size () ;
28 
29  if (holes.size () == 0) //PG exceptional case!
30  {
31  for (int i = 0 ; i < result.num_row () ; ++i)
32  result[i] = 1. ;
33  }
34  else if (dim > 0)
35  {
36  CLHEP::HepMatrix solution (dim, dim, 0) ;
37  CLHEP::HepVector input (dim, 0) ;
38  shrink (matrix, solution, vector, input, holes) ;
39  CLHEP::HepVector output = solve (solution,input) ;
40  pour (result, output, holes) ;
41  }
42  return holes.size () ;
43 }
int i
Definition: DBlmapReader.cc:9
void shrink(const CLHEP::HepMatrix &matrix, CLHEP::HepMatrix &solution, const CLHEP::HepVector &result, CLHEP::HepVector &input, const std::vector< int > &where)
eliminate empty columns and rows
Definition: BlockSolver.cc:50
tuple result
Definition: query.py:137
int col
Definition: cuy.py:1008
void pour(CLHEP::HepVector &result, const CLHEP::HepVector &output, const std::vector< int > &where)
pour results in bigger vector
Definition: BlockSolver.cc:92
void BlockSolver::pour ( CLHEP::HepVector &  result,
const CLHEP::HepVector &  output,
const std::vector< int > &  where 
)
private

pour results in bigger vector

Definition at line 92 of file BlockSolver.cc.

References hitfit::return.

Referenced by operator()().

95 {
96  std::vector<int>::const_iterator whereCols = where.begin () ;
97  int readingIndex = 0 ;
98  //PG loop over the output crystals
99  for (int xtal = 0 ; xtal < result.num_row () ; ++xtal)
100  {
101  if (xtal == *whereCols)
102  {
103  result[xtal] = 1. ;
104  ++whereCols ;
105  }
106  else
107  {
108  result[xtal] = output[readingIndex] ;
109  ++readingIndex ;
110  }
111  } //PG loop over the output crystals
112 
113  return ;
114 }
tuple result
Definition: query.py:137
void BlockSolver::shrink ( const CLHEP::HepMatrix &  matrix,
CLHEP::HepMatrix &  solution,
const CLHEP::HepVector &  result,
CLHEP::HepVector &  input,
const std::vector< int > &  where 
)
private

eliminate empty columns and rows

Definition at line 50 of file BlockSolver.cc.

References cuy::col, and hitfit::return.

Referenced by operator()().

55 {
56 
57  int offsetRow = 0 ;
58  std::vector<int>::const_iterator whereRows = where.begin () ;
59  // loop over rows
60  for (int row = 0 ; row < matrix.num_row () ; ++row)
61  {
62  if (row == *whereRows)
63  {
64 // std::cerr << " DEBUG shr hole found " << std::endl ;
65  ++offsetRow ;
66  ++whereRows ;
67  continue ;
68  }
69  input[row-offsetRow] = result[row] ;
70  int offsetCol = 0 ;
71  std::vector<int>::const_iterator whereCols = where.begin () ;
72  // loop over columns
73  for (int col = 0 ; col < matrix.num_col () ; ++col)
74  {
75  if (col == *whereCols)
76  {
77  ++offsetCol ;
78  ++whereCols ;
79  continue ;
80  }
81  solution[row-offsetRow][col-offsetCol] = matrix[row][col] ;
82  }
83  } // loop over rows
84  return ;
85 }
tuple result
Definition: query.py:137
int col
Definition: cuy.py:1008