CMS 3D CMS Logo

Functions
matrixSaver.cc File Reference
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <memory>
#include <cassert>
#include "CLHEP/Matrix/GenMatrix.h"
#include "CLHEP/Matrix/Matrix.h"
#include "CLHEP/Matrix/Vector.h"
#include "Calibration/Tools/interface/matrixSaver.h"

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &outputFile, const CLHEP::HepGenMatrix *saveMe)
 
std::istream & operator>> (std::istream &input, CLHEP::HepGenMatrix &matrix)
 

Function Documentation

◆ operator<<()

std::ostream& operator<< ( std::ostream &  outputFile,
const CLHEP::HepGenMatrix *  saveMe 
)

Definition at line 24 of file matrixSaver.cc.

References cms::cuda::assert(), cuy::col, and download_sqlite_cfg::outputFile.

24  {
25  int numRow = saveMe->num_row();
26  int numCol = saveMe->num_col();
27 
28  // write out the matrix dimensions
29  outputFile << numRow << '\t' << numCol << '\n';
30 
31  // write the elements in the file
32  for (int row = 0; row < numRow; ++row) {
33  for (int col = 0; col < numCol; ++col) {
34  assert(row < numRow);
35  assert(col < numCol);
36  outputFile << (*saveMe)[row][col] << '\t';
37  }
38  outputFile << '\n';
39  }
40 
41  return outputFile;
42 }
assert(be >=bs)
col
Definition: cuy.py:1009

◆ operator>>()

std::istream& operator>> ( std::istream &  input,
CLHEP::HepGenMatrix &  matrix 
)

Definition at line 80 of file matrixSaver.cc.

References cms::cuda::assert(), cuy::col, input, and makeMuonMisalignmentScenario::matrix.

80  {
81  int numRow = 0;
82  int numCol = 0;
83 
84  //PG read the matrix dimension
85  input >> numRow;
86  input >> numCol;
87 
88  //PG check whether the matrices have the right dimension
89  assert(numRow == matrix.num_row());
90  assert(numCol == matrix.num_col());
91 
92  //PG get the matrix elements from the file
93  for (int row = 0; row < numRow; ++row) {
94  for (int col = 0; col < numCol; ++col) {
95  input >> matrix[row][col];
96  assert(col * row < numRow * numCol);
97  }
98  }
99 
100  return input;
101 }
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
col
Definition: cuy.py:1009