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

Definition at line 21 of file BlockSolver.h.

Member Function Documentation

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

Definition at line 7 of file BlockSolver.cc.

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

10 {
11  double threshold = matrix.trace () /
12  static_cast<double> (matrix.num_row ()) ;
13  std::vector<int> holes ;
14  // loop over the matrix rows
15  for (int row = 0 ; row < matrix.num_row () ; ++row)
16  {
17  double sumAbs = 0. ;
18  for (int col = 0 ; col < matrix.num_col () ; ++col)
19  sumAbs += fabs (matrix[row][col]) ;
20  if (sumAbs < threshold) holes.push_back (row) ;
21  } // loop over the matrix rows
22 
23  int dim = matrix.num_col () - holes.size () ;
24 
25  if (holes.size () == 0) //PG exceptional case!
26  {
27  for (int i = 0 ; i < result.num_row () ; ++i)
28  result[i] = 1. ;
29  }
30  else if (dim > 0)
31  {
32  CLHEP::HepMatrix solution (dim, dim, 0) ;
33  CLHEP::HepVector input (dim, 0) ;
34  shrink (matrix, solution, vector, input, holes) ;
35  CLHEP::HepVector output = solve (solution,input) ;
36  pour (result, output, holes) ;
37  }
38  return holes.size () ;
39 }
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:46
static std::string const input
Definition: EdmProvDump.cc:44
tuple result
Definition: mps_fire.py:84
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:88
void BlockSolver::pour ( CLHEP::HepVector &  result,
const CLHEP::HepVector &  output,
const std::vector< int > &  where 
)
private

pour results in bigger vector

Definition at line 88 of file BlockSolver.cc.

References reco::return().

Referenced by operator()().

91 {
92  std::vector<int>::const_iterator whereCols = where.begin () ;
93  int readingIndex = 0 ;
94  //PG loop over the output crystals
95  for (int xtal = 0 ; xtal < result.num_row () ; ++xtal)
96  {
97  if (xtal == *whereCols)
98  {
99  result[xtal] = 1. ;
100  ++whereCols ;
101  }
102  else
103  {
104  result[xtal] = output[readingIndex] ;
105  ++readingIndex ;
106  }
107  } //PG loop over the output crystals
108 
109  return ;
110 }
tuple result
Definition: mps_fire.py:84
return(e1-e2)*(e1-e2)+dp *dp
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 46 of file BlockSolver.cc.

References cuy::col, and reco::return().

Referenced by operator()().

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