CMS 3D CMS Logo

IMACalibBlock Class Reference

#include <Calibration/EcalCalibAlgos/interface/IMACalibBlock.h>

Inheritance diagram for IMACalibBlock:

VEcalCalibBlock

List of all members.

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
void 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


Detailed Description

Definition at line 26 of file IMACalibBlock.h.


Constructor & Destructor Documentation

IMACalibBlock::IMACalibBlock ( const   int  ) 

ctor

Date
2008/03/10 13:29:48
Revision
1.3
Id
IMACalibBlock.cc,v 1.3 2008/03/10 13:29:48 elmer Exp

Author:
Author
elmer

Definition at line 18 of file IMACalibBlock.cc.

References reset().

00018                                                        :
00019   VEcalCalibBlock (numberOfElements) ,
00020   m_kaliVector (m_numberOfElements) , 
00021   m_kaliMatrix (evalX2Size ())
00022 {
00023   reset () ;
00024 }

IMACalibBlock::~IMACalibBlock (  ) 

dtor

Definition at line 30 of file IMACalibBlock.cc.

00031 {
00032 }


Member Function Documentation

void IMACalibBlock::complete (  )  [private]

complete the triangolar chi2 matrix to a sym one

Definition at line 78 of file IMACalibBlock.cc.

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

Referenced by solve().

00079 {
00080  int bef;
00081  int aft;
00082  for (unsigned int i=0; i<m_numberOfElements;++i)
00083   {
00084     for (unsigned int j=i+1; j< m_numberOfElements; ++j) 
00085       {
00086          bef = (i*m_numberOfElements+j);
00087          aft =  (j*m_numberOfElements +i);
00088             m_kaliMatrix.at(aft) = m_kaliMatrix.at(bef) ;
00089           } //LP second loop over xtals
00090       } //LP first loop over xtals
00091 
00092     return ;
00093   }

int IMACalibBlock::evalX2Size (  )  [inline, private]

give the size of a chi2 matrix

Definition at line 134 of file IMACalibBlock.cc.

References VEcalCalibBlock::m_numberOfElements.

00135   {
00136 
00137     return m_numberOfElements* m_numberOfElements;
00138   }

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 dummy, m_kaliMatrix, m_kaliVector, and VEcalCalibBlock::m_numberOfElements.

00044 {
00045   double inverror = 1./sigma ; 
00046   //LP fist loop over energies
00047   for (std::map<int,double>::const_iterator itMap1 =MapBegin ; 
00048        itMap1 !=MapEnd ; 
00049        ++itMap1)
00050     {
00051       for (std::map<int,double>::const_iterator itMap2 = itMap1 ; 
00052       itMap2 !=MapEnd ; 
00053       ++itMap2)  
00054         {
00055           //LP calculate the chi square value
00056           double dummy = itMap1->second * itMap2->second;
00057           dummy *= inverror ;
00058           //LP fill the calib matrix
00059           m_kaliMatrix.at(itMap1->first*m_numberOfElements +itMap2->first) += dummy ;            
00060         } //LP second loop over xtals
00061 
00062       //LP calculate the vector value
00063       double dummy = pTk ;
00064       dummy -= pSubtract ;                        //LP borders
00065       dummy *= itMap1->second ;
00066       dummy *= inverror ;
00067       //LP fill the calib vector
00068       m_kaliVector.at(itMap1->first) += dummy ;
00069     } //LP first loop over energies
00070   return ;
00071 }

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

fill the coefficients map from the CLHEP vector solution

Definition at line 206 of file IMACalibBlock.cc.

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

Referenced by solve().

00207 {
00208 
00209    for (unsigned int i=0; i < m_numberOfElements; ++i)
00210       {
00211          m_coefficients[i] = result[i] ;
00212       } 
00213 
00214    return ;
00215 }

void IMACalibBlock::reset ( void   )  [virtual]

reset the chi2 matrices

Implements VEcalCalibBlock.

Definition at line 181 of file IMACalibBlock.cc.

References m_kaliMatrix, and m_kaliVector.

Referenced by IMACalibBlock().

00182 {
00183 
00184   for (std::vector<double>::iterator vecIt = m_kaliVector.begin () ;
00185        vecIt != m_kaliVector.end ();
00186        ++vecIt)
00187     {
00188       *vecIt = 0. ;
00189     }  
00190 
00191   for (std::vector<double>::iterator vecIt = m_kaliMatrix.begin () ;
00192        vecIt != m_kaliMatrix.end ();
00193        ++vecIt)
00194     {
00195       *vecIt = 0. ;
00196     }  
00197 
00198 }

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

copy a vector into a CLHEP object

Definition at line 145 of file IMACalibBlock.cc.

References i, j, VEcalCalibBlock::m_numberOfElements, and max.

Referenced by solve().

00147   {
00148     unsigned int max = m_numberOfElements ;
00149 
00150     assert (piena.size () == max * max) ; 
00151     assert (vuota.num_row () == max) ;
00152     assert (vuota.num_col () == max) ;
00153     for (unsigned int i = 0 ; i < max ; ++i)
00154      for (unsigned int j = 0 ; j < max ; ++j)
00155        vuota[i][j] = piena[i*max + j] ; 
00156 
00157     return ;
00158   }

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

copy a vector into a CLHEP object

Definition at line 164 of file IMACalibBlock.cc.

References i, VEcalCalibBlock::m_numberOfElements, and max.

Referenced by solve().

00166   {
00167 
00168     int max = m_numberOfElements ;
00169     assert (vuoto.num_row () == max) ;
00170     for (int i = 0 ; i < max ; ++i)
00171       vuoto[i] = pieno[i] ; 
00172 
00173     return ;
00174   }

void IMACalibBlock::solve ( int  usingBlockSolver,
double  min,
double  max 
) [virtual]

solve the chi2 linear system

Implements VEcalCalibBlock.

Definition at line 100 of file IMACalibBlock.cc.

References complete(), lat::endl(), fillMap(), i, m_kaliMatrix, m_kaliVector, VEcalCalibBlock::m_numberOfElements, HLT_VtxMuL3::result, riempiMtr(), riempiVtr(), and solve().

00101 {
00102  complete () ;
00103 
00104  CLHEP::HepMatrix kaliMatrix (m_numberOfElements,m_numberOfElements) ;
00105  riempiMtr (m_kaliMatrix , kaliMatrix) ;
00106  CLHEP::HepVector kaliVector (m_numberOfElements) ;
00107  riempiVtr (m_kaliVector , kaliVector) ;
00108  //PG linear system solution
00109  CLHEP::HepVector result = CLHEP::solve (kaliMatrix,kaliVector) ;
00110  if (result.normsq () < min * kaliMatrix.num_row () ||
00111      result.normsq () > max * kaliMatrix.num_row ()) 
00112    {
00113    if (usingBlockSolver)  
00114      {
00115         edm::LogWarning ("IML") << "using  blocSlover " << std::endl ;
00116         BlockSolver() (kaliMatrix,kaliVector,result) ;
00117      }
00118    else 
00119      {
00120        edm::LogWarning ("IML") <<"coeff out of range " <<std::endl;
00121        for (int i = 0 ; i < kaliVector.num_row () ; ++i)
00122              result[i] = 1. ;
00123      }
00124    }
00125  fillMap(result);
00126  return ;
00127 }


Member Data Documentation

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.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:49 2009 for CMSSW by  doxygen 1.5.4