#include <IMACalibBlock.h>
Public Member Functions | |
void | Fill (std::map< int, double >::const_iterator, std::map< int, double >::const_iterator, double pTk, double pSubtract, double sigma=1.) |
insert an entry | |
IMACalibBlock (const int) | |
ctor | |
void | reset () |
reset the chi2 matrices | |
int | solve (int usingBlockSolver, double min, double max) |
solve the chi2 linear system | |
~IMACalibBlock () | |
dtor | |
Private Member Functions | |
void | complete () |
complete the triangolar chi2 matrix to a sym one | |
int | evalX2Size () |
give the size of a chi2 matrix | |
void | fillMap (const CLHEP::HepVector &result) |
fill the coefficients map from the CLHEP vector solution | |
void | riempiMtr (const std::vector< double > &piena, CLHEP::HepMatrix &vuota) |
copy a vector into a CLHEP object | |
void | riempiVtr (const std::vector< double > &pieno, CLHEP::HepVector &vuoto) |
copy a vector into a CLHEP object | |
Private Attributes | |
std::vector< double > | m_kaliMatrix |
matrix for the chi2 inversion | |
std::vector< double > | m_kaliVector |
vector for the chi2 inversion |
Definition at line 26 of file IMACalibBlock.h.
IMACalibBlock::IMACalibBlock | ( | const int | numberOfElements | ) |
ctor
Definition at line 18 of file IMACalibBlock.cc.
References reset().
: VEcalCalibBlock (numberOfElements) , m_kaliVector (m_numberOfElements) , m_kaliMatrix (evalX2Size ()) { reset () ; }
IMACalibBlock::~IMACalibBlock | ( | ) |
void IMACalibBlock::complete | ( | ) | [private] |
complete the triangolar chi2 matrix to a sym one
Definition at line 80 of file IMACalibBlock.cc.
References i, j, m_kaliMatrix, and VEcalCalibBlock::m_numberOfElements.
Referenced by solve().
{ int bef; int aft; for (unsigned int i=0; i<m_numberOfElements;++i) { for (unsigned int j=i+1; j< m_numberOfElements; ++j) { bef = (i*m_numberOfElements+j); aft = (j*m_numberOfElements +i); m_kaliMatrix.at(aft) = m_kaliMatrix.at(bef) ; } //LP second loop over xtals } //LP first loop over xtals return ; }
int IMACalibBlock::evalX2Size | ( | ) | [inline, private] |
give the size of a chi2 matrix
Definition at line 147 of file IMACalibBlock.cc.
References VEcalCalibBlock::m_numberOfElements.
{ return m_numberOfElements* m_numberOfElements; }
void IMACalibBlock::Fill | ( | std::map< int, double >::const_iterator | MapBegin, |
std::map< int, double >::const_iterator | MapEnd, | ||
double | pTk, | ||
double | pSubtract, | ||
double | sigma = 1. |
||
) | [virtual] |
insert an entry
Implements VEcalCalibBlock.
Definition at line 39 of file IMACalibBlock.cc.
References m_kaliMatrix, m_kaliVector, and VEcalCalibBlock::m_numberOfElements.
{ // std::cerr<<"\n\nfaccio il fill!\n"; double inverror = 1./sigma ; //LP fist loop over energies for (std::map<int,double>::const_iterator itMap1 =MapBegin ; itMap1 !=MapEnd ; ++itMap1) { // std::cerr<<"numero "<<itMap1->first<<" vale "<<itMap1->second<<"\t"; for (std::map<int,double>::const_iterator itMap2 = itMap1 ; itMap2 !=MapEnd ; ++itMap2) { //LP calculate the chi square value double dummy = itMap1->second * itMap2->second; dummy *= inverror ; //LP fill the calib matrix m_kaliMatrix.at(itMap1->first*m_numberOfElements +itMap2->first) += dummy ; } //LP second loop over xtals //LP calculate the vector value double dummy = pTk ; dummy -= pSubtract ; //LP borders dummy *= itMap1->second ; dummy *= inverror ; //LP fill the calib vector m_kaliVector.at(itMap1->first) += dummy ; } //LP first loop over energies return ; }
void IMACalibBlock::fillMap | ( | const CLHEP::HepVector & | result | ) | [private] |
fill the coefficients map from the CLHEP vector solution
Definition at line 221 of file IMACalibBlock.cc.
References i, VEcalCalibBlock::m_coefficients, and VEcalCalibBlock::m_numberOfElements.
Referenced by solve().
{ for (unsigned int i=0; i < m_numberOfElements; ++i) { m_coefficients[i] = result[i] ; } return ; }
void IMACalibBlock::reset | ( | void | ) | [virtual] |
reset the chi2 matrices
Implements VEcalCalibBlock.
Definition at line 196 of file IMACalibBlock.cc.
References m_kaliMatrix, and m_kaliVector.
Referenced by IMACalibBlock().
{ for (std::vector<double>::iterator vecIt = m_kaliVector.begin () ; vecIt != m_kaliVector.end (); ++vecIt) { *vecIt = 0. ; } for (std::vector<double>::iterator vecIt = m_kaliMatrix.begin () ; vecIt != m_kaliMatrix.end (); ++vecIt) { *vecIt = 0. ; } }
void IMACalibBlock::riempiMtr | ( | const std::vector< double > & | piena, |
CLHEP::HepMatrix & | vuota | ||
) | [private] |
copy a vector into a CLHEP object
Definition at line 158 of file IMACalibBlock.cc.
References i, edm::detail::isnan(), j, VEcalCalibBlock::m_numberOfElements, and max().
Referenced by solve().
{ unsigned int max = m_numberOfElements ; assert (piena.size () == max * max) ; assert (vuota.num_row () == int(max)) ; assert (vuota.num_col () == int(max)) ; for (unsigned int i = 0 ; i < max ; ++i) for (unsigned int j = 0 ; j < max ; ++j) if (std::isnan (piena[i*max + j])) vuota[i][j] = 0. ; else vuota[i][j] = piena[i*max + j] ; return ; }
void IMACalibBlock::riempiVtr | ( | const std::vector< double > & | pieno, |
CLHEP::HepVector & | vuoto | ||
) | [private] |
copy a vector into a CLHEP object
Definition at line 178 of file IMACalibBlock.cc.
References i, edm::detail::isnan(), VEcalCalibBlock::m_numberOfElements, and max().
Referenced by solve().
int IMACalibBlock::solve | ( | int | usingBlockSolver, |
double | min, | ||
double | max | ||
) | [virtual] |
solve the chi2 linear system
Implements VEcalCalibBlock.
Definition at line 102 of file IMACalibBlock.cc.
References complete(), fillMap(), i, m_kaliMatrix, m_kaliVector, VEcalCalibBlock::m_numberOfElements, query::result, riempiMtr(), and riempiVtr().
{ complete () ; // TH1F vettore ("vettore","vettore",10,-0.1,9.9); // TH1F matrice ("matrice","matrice",100,-0.1,99.9); CLHEP::HepMatrix kaliMatrix (m_numberOfElements,m_numberOfElements) ; // for (std::vector<double>::iterator it = m_kaliVector.begin(); // it!= m_kaliVector.end();++it) // vettore.Fill(it-m_kaliVector.begin(),*it); riempiMtr (m_kaliMatrix , kaliMatrix) ; // for (std::vector<double>::iterator it = m_kaliMatrix.begin(); // it!= m_kaliMatrix.end();++it) // matrice.Fill(it-m_kaliMatrix.begin(),*it); // TFile f ("fileInteressante.root","RECREATE"); // vettore.Write(); // matrice.Write(); CLHEP::HepVector kaliVector (m_numberOfElements) ; riempiVtr (m_kaliVector , kaliVector) ; //PG linear system solution CLHEP::HepVector result = CLHEP::solve (kaliMatrix,kaliVector) ; for (int i = 0 ; i < kaliVector.num_row () ; ++i) if (result.normsq () < min * kaliVector.num_row () || result.normsq () > max * kaliVector.num_row ()) { if (usingBlockSolver) { edm::LogWarning ("IML") << "using blocSlover " << std::endl ; BlockSolver() (kaliMatrix,kaliVector,result) ; } else { edm::LogWarning ("IML") <<"coeff out of range " <<std::endl; for (int i = 0 ; i < kaliVector.num_row () ; ++i) result[i] = 1. ; } } fillMap(result); return 0; }
std::vector<double> IMACalibBlock::m_kaliMatrix [private] |
matrix for the chi2 inversion
Definition at line 63 of file IMACalibBlock.h.
Referenced by complete(), Fill(), reset(), and solve().
std::vector<double> IMACalibBlock::m_kaliVector [private] |
vector for the chi2 inversion
Definition at line 61 of file IMACalibBlock.h.