CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
IMACalibBlock Class Reference

#include <IMACalibBlock.h>

Inheritance diagram for IMACalibBlock:
VEcalCalibBlock

Public Member Functions

void Fill (std::map< int, double >::const_iterator, std::map< int, double >::const_iterator, double pTk, double pSubtract, double sigma=1.) override
 insert an entry More...
 
 IMACalibBlock (const int)
 ctor More...
 
void reset () override
 reset the chi2 matrices More...
 
int solve (int usingBlockSolver, double min, double max) override
 solve the chi2 linear system More...
 
 ~IMACalibBlock () override
 dtor More...
 
- Public Member Functions inherited from VEcalCalibBlock
float at (const unsigned int index)
 retrieve the coefficients More...
 
 VEcalCalibBlock (int numberOfElements)
 ctor More...
 
virtual ~VEcalCalibBlock ()
 dtor More...
 

Private Member Functions

void complete ()
 complete the triangolar chi2 matrix to a sym one More...
 
int evalX2Size ()
 give the size of a chi2 matrix More...
 
void fillMap (const CLHEP::HepVector &result)
 fill the coefficients map from the CLHEP vector solution More...
 
void riempiMtr (const std::vector< double > &piena, CLHEP::HepMatrix &vuota)
 copy a vector into a CLHEP object More...
 
void riempiVtr (const std::vector< double > &pieno, CLHEP::HepVector &vuoto)
 copy a vector into a CLHEP object More...
 

Private Attributes

std::vector< double > m_kaliMatrix
 matrix for the chi2 inversion More...
 
std::vector< double > m_kaliVector
 vector for the chi2 inversion More...
 

Additional Inherited Members

- Protected Attributes inherited from VEcalCalibBlock
std::map< unsigned int, float > m_coefficients
 map of coefficients More...
 
unsigned int m_numberOfElements
 The only parameter! More...
 

Detailed Description

Definition at line 22 of file IMACalibBlock.h.

Constructor & Destructor Documentation

◆ IMACalibBlock()

IMACalibBlock::IMACalibBlock ( const int  numberOfElements)

ctor

Definition at line 14 of file IMACalibBlock.cc.

References reset().

16  reset();
17 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:55
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:57
int evalX2Size()
give the size of a chi2 matrix
unsigned int m_numberOfElements
The only parameter!
void reset() override
reset the chi2 matrices
VEcalCalibBlock(int numberOfElements)
ctor

◆ ~IMACalibBlock()

IMACalibBlock::~IMACalibBlock ( )
override

dtor

Definition at line 21 of file IMACalibBlock.cc.

21 {}

Member Function Documentation

◆ complete()

void IMACalibBlock::complete ( )
private

complete the triangolar chi2 matrix to a sym one

Definition at line 56 of file IMACalibBlock.cc.

References mps_fire::i, dqmiolumiharvest::j, m_kaliMatrix, and VEcalCalibBlock::m_numberOfElements.

Referenced by solve().

56  {
57  int bef;
58  int aft;
59  for (unsigned int i = 0; i < m_numberOfElements; ++i) {
60  for (unsigned int j = i + 1; j < m_numberOfElements; ++j) {
61  bef = (i * m_numberOfElements + j);
62  aft = (j * m_numberOfElements + i);
63  m_kaliMatrix.at(aft) = m_kaliMatrix.at(bef);
64  } //LP second loop over xtals
65  } //LP first loop over xtals
66 
67  return;
68 }
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:57
unsigned int m_numberOfElements
The only parameter!

◆ evalX2Size()

int IMACalibBlock::evalX2Size ( )
inlineprivate

give the size of a chi2 matrix

Definition at line 108 of file IMACalibBlock.cc.

References VEcalCalibBlock::m_numberOfElements.

unsigned int m_numberOfElements
The only parameter!

◆ Fill()

void IMACalibBlock::Fill ( std::map< int, double >::const_iterator  MapBegin,
std::map< int, double >::const_iterator  MapEnd,
double  pTk,
double  pSubtract,
double  sigma = 1. 
)
overridevirtual

insert an entry

Implements VEcalCalibBlock.

Definition at line 25 of file IMACalibBlock.cc.

References m_kaliMatrix, m_kaliVector, and VEcalCalibBlock::m_numberOfElements.

29  {
30  // std::cerr<<"\n\nfaccio il fill!\n";
31  double inverror = 1. / sigma;
32  //LP fist loop over energies
33  for (std::map<int, double>::const_iterator itMap1 = MapBegin; itMap1 != MapEnd; ++itMap1) {
34  // std::cerr<<"numero "<<itMap1->first<<" vale "<<itMap1->second<<"\t";
35  for (std::map<int, double>::const_iterator itMap2 = itMap1; itMap2 != MapEnd; ++itMap2) {
36  //LP calculate the chi square value
37  double dummy = itMap1->second * itMap2->second;
38  dummy *= inverror;
39  //LP fill the calib matrix
40  m_kaliMatrix.at(itMap1->first * m_numberOfElements + itMap2->first) += dummy;
41  } //LP second loop over xtals
42 
43  //LP calculate the vector value
44  double dummy = pTk;
45  dummy -= pSubtract; //LP borders
46  dummy *= itMap1->second;
47  dummy *= inverror;
48  //LP fill the calib vector
49  m_kaliVector.at(itMap1->first) += dummy;
50  } //LP first loop over energies
51  return;
52 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:55
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:57
unsigned int m_numberOfElements
The only parameter!

◆ fillMap()

void IMACalibBlock::fillMap ( const CLHEP::HepVector &  result)
private

fill the coefficients map from the CLHEP vector solution

Definition at line 157 of file IMACalibBlock.cc.

References mps_fire::i, VEcalCalibBlock::m_coefficients, VEcalCalibBlock::m_numberOfElements, and mps_fire::result.

Referenced by solve().

157  {
158  for (unsigned int i = 0; i < m_numberOfElements; ++i) {
159  m_coefficients[i] = result[i];
160  }
161 
162  return;
163 }
std::map< unsigned int, float > m_coefficients
map of coefficients
unsigned int m_numberOfElements
The only parameter!

◆ reset()

void IMACalibBlock::reset ( void  )
overridevirtual

reset the chi2 matrices

Implements VEcalCalibBlock.

Definition at line 144 of file IMACalibBlock.cc.

References m_kaliMatrix, and m_kaliVector.

Referenced by MatrixReader.MatrixReader::__init__(), data_sources.json_list::__next__(), IMACalibBlock(), and MatrixReader.MatrixReader::showRaw().

144  {
145  for (std::vector<double>::iterator vecIt = m_kaliVector.begin(); vecIt != m_kaliVector.end(); ++vecIt) {
146  *vecIt = 0.;
147  }
148 
149  for (std::vector<double>::iterator vecIt = m_kaliMatrix.begin(); vecIt != m_kaliMatrix.end(); ++vecIt) {
150  *vecIt = 0.;
151  }
152 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:55
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:57

◆ riempiMtr()

void IMACalibBlock::riempiMtr ( const std::vector< double > &  piena,
CLHEP::HepMatrix &  vuota 
)
private

copy a vector into a CLHEP object

Definition at line 112 of file IMACalibBlock.cc.

References cms::cuda::assert(), mps_fire::i, createfilelist::int, edm::isNotFinite(), dqmiolumiharvest::j, VEcalCalibBlock::m_numberOfElements, and WZElectronSkims53X_cff::max.

Referenced by solve().

112  {
113  unsigned int max = m_numberOfElements;
114 
115  assert(piena.size() == max * max);
116  assert(vuota.num_row() == int(max));
117  assert(vuota.num_col() == int(max));
118  for (unsigned int i = 0; i < max; ++i)
119  for (unsigned int j = 0; j < max; ++j)
120  if (edm::isNotFinite(piena[i * max + j]))
121  vuota[i][j] = 0.;
122  else
123  vuota[i][j] = piena[i * max + j];
124 
125  return;
126 }
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
assert(be >=bs)
unsigned int m_numberOfElements
The only parameter!

◆ riempiVtr()

void IMACalibBlock::riempiVtr ( const std::vector< double > &  pieno,
CLHEP::HepVector &  vuoto 
)
private

copy a vector into a CLHEP object

Definition at line 130 of file IMACalibBlock.cc.

References cms::cuda::assert(), mps_fire::i, edm::isNotFinite(), VEcalCalibBlock::m_numberOfElements, and WZElectronSkims53X_cff::max.

Referenced by solve().

130  {
131  int max = m_numberOfElements;
132  assert(vuoto.num_row() == max);
133  for (int i = 0; i < max; ++i)
134  if (edm::isNotFinite(pieno[i]))
135  vuoto[i] = 0.;
136  else
137  vuoto[i] = pieno[i];
138 
139  return;
140 }
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
assert(be >=bs)
unsigned int m_numberOfElements
The only parameter!

◆ solve()

int IMACalibBlock::solve ( int  usingBlockSolver,
double  min,
double  max 
)
overridevirtual

solve the chi2 linear system

Implements VEcalCalibBlock.

Definition at line 72 of file IMACalibBlock.cc.

References complete(), fillMap(), mps_fire::i, m_kaliMatrix, m_kaliVector, VEcalCalibBlock::m_numberOfElements, WZElectronSkims53X_cff::max, SiStripPI::min, mps_fire::result, riempiMtr(), and riempiVtr().

72  {
73  complete();
74  // TH1F vettore ("vettore","vettore",10,-0.1,9.9);
75  // TH1F matrice ("matrice","matrice",100,-0.1,99.9);
76  CLHEP::HepMatrix kaliMatrix(m_numberOfElements, m_numberOfElements);
77  // for (std::vector<double>::iterator it = m_kaliVector.begin();
78  // it!= m_kaliVector.end();++it)
79  // vettore.Fill(it-m_kaliVector.begin(),*it);
80  riempiMtr(m_kaliMatrix, kaliMatrix);
81  // for (std::vector<double>::iterator it = m_kaliMatrix.begin();
82  // it!= m_kaliMatrix.end();++it)
83  // matrice.Fill(it-m_kaliMatrix.begin(),*it);
84  // TFile f ("fileInteressante.root","RECREATE");
85  // vettore.Write();
86  // matrice.Write();
87  CLHEP::HepVector kaliVector(m_numberOfElements);
88  riempiVtr(m_kaliVector, kaliVector);
89  //PG linear system solution
90  CLHEP::HepVector result = CLHEP::solve(kaliMatrix, kaliVector);
91  for (int i = 0; i < kaliVector.num_row(); ++i)
92  if (result.normsq() < min * kaliVector.num_row() || result.normsq() > max * kaliVector.num_row()) {
93  if (usingBlockSolver) {
94  edm::LogWarning("IML") << "using blocSlover " << std::endl;
95  BlockSolver()(kaliMatrix, kaliVector, result);
96  } else {
97  edm::LogWarning("IML") << "coeff out of range " << std::endl;
98  for (int i = 0; i < kaliVector.num_row(); ++i)
99  result[i] = 1.;
100  }
101  }
102  fillMap(result);
103  return 0;
104 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:55
void riempiMtr(const std::vector< double > &piena, CLHEP::HepMatrix &vuota)
copy a vector into a CLHEP object
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:57
void riempiVtr(const std::vector< double > &pieno, CLHEP::HepVector &vuoto)
copy a vector into a CLHEP object
solves at best the matrix invertion for calibration
Definition: BlockSolver.h:21
unsigned int m_numberOfElements
The only parameter!
void fillMap(const CLHEP::HepVector &result)
fill the coefficients map from the CLHEP vector solution
Log< level::Warning, false > LogWarning
void complete()
complete the triangolar chi2 matrix to a sym one

Member Data Documentation

◆ m_kaliMatrix

std::vector<double> IMACalibBlock::m_kaliMatrix
private

matrix for the chi2 inversion

Definition at line 57 of file IMACalibBlock.h.

Referenced by complete(), Fill(), reset(), and solve().

◆ m_kaliVector

std::vector<double> IMACalibBlock::m_kaliVector
private

vector for the chi2 inversion

Definition at line 55 of file IMACalibBlock.h.

Referenced by Fill(), reset(), and solve().