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 | 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.)
 insert an entry More...
 
 IMACalibBlock (const int)
 ctor More...
 
void reset ()
 reset the chi2 matrices More...
 
int solve (int usingBlockSolver, double min, double max)
 solve the chi2 linear system More...
 
 ~IMACalibBlock ()
 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 26 of file IMACalibBlock.h.

Constructor & Destructor Documentation

IMACalibBlock::IMACalibBlock ( const int  numberOfElements)

ctor

Date:
2012/12/06 09:46:42
Revision:
1.12
Id:
IMACalibBlock.cc,v 1.12 2012/12/06 09:46:42 eulisse Exp
Author
Author:
eulisse

Definition at line 19 of file IMACalibBlock.cc.

References reset().

19  :
20  VEcalCalibBlock (numberOfElements) ,
23 {
24  reset () ;
25 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:61
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:63
int evalX2Size()
give the size of a chi2 matrix
void reset()
reset the chi2 matrices
unsigned int m_numberOfElements
The only parameter!
VEcalCalibBlock(int numberOfElements)
ctor
IMACalibBlock::~IMACalibBlock ( )

dtor

Definition at line 31 of file IMACalibBlock.cc.

32 {
33 }

Member Function Documentation

void IMACalibBlock::complete ( )
private

complete the triangolar chi2 matrix to a sym one

Definition at line 81 of file IMACalibBlock.cc.

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

Referenced by solve().

82 {
83  int bef;
84  int aft;
85  for (unsigned int i=0; i<m_numberOfElements;++i)
86  {
87  for (unsigned int j=i+1; j< m_numberOfElements; ++j)
88  {
89  bef = (i*m_numberOfElements+j);
90  aft = (j*m_numberOfElements +i);
91  m_kaliMatrix.at(aft) = m_kaliMatrix.at(bef) ;
92  } //LP second loop over xtals
93  } //LP first loop over xtals
94 
95  return ;
96  }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:63
unsigned int m_numberOfElements
The only parameter!
int IMACalibBlock::evalX2Size ( )
inlineprivate

give the size of a chi2 matrix

Definition at line 148 of file IMACalibBlock.cc.

References VEcalCalibBlock::m_numberOfElements.

149  {
150 
152  }
unsigned int m_numberOfElements
The only parameter!
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 40 of file IMACalibBlock.cc.

References m_kaliMatrix, m_kaliVector, VEcalCalibBlock::m_numberOfElements, and hitfit::return.

45 {
46 // std::cerr<<"\n\nfaccio il fill!\n";
47  double inverror = 1./sigma ;
48  //LP fist loop over energies
49  for (std::map<int,double>::const_iterator itMap1 =MapBegin ;
50  itMap1 !=MapEnd ;
51  ++itMap1)
52  {
53 // std::cerr<<"numero "<<itMap1->first<<" vale "<<itMap1->second<<"\t";
54  for (std::map<int,double>::const_iterator itMap2 = itMap1 ;
55  itMap2 !=MapEnd ;
56  ++itMap2)
57  {
58  //LP calculate the chi square value
59  double dummy = itMap1->second * itMap2->second;
60  dummy *= inverror ;
61  //LP fill the calib matrix
62  m_kaliMatrix.at(itMap1->first*m_numberOfElements +itMap2->first) += dummy ;
63  } //LP second loop over xtals
64 
65  //LP calculate the vector value
66  double dummy = pTk ;
67  dummy -= pSubtract ; //LP borders
68  dummy *= itMap1->second ;
69  dummy *= inverror ;
70  //LP fill the calib vector
71  m_kaliVector.at(itMap1->first) += dummy ;
72  } //LP first loop over energies
73  return ;
74 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:61
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:63
unsigned int m_numberOfElements
The only parameter!
void IMACalibBlock::fillMap ( const CLHEP::HepVector &  result)
private

fill the coefficients map from the CLHEP vector solution

Definition at line 222 of file IMACalibBlock.cc.

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

Referenced by solve().

223 {
224 
225  for (unsigned int i=0; i < m_numberOfElements; ++i)
226  {
227  m_coefficients[i] = result[i] ;
228  }
229 
230  return ;
231 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
std::map< unsigned int, float > m_coefficients
map of coefficients
unsigned int m_numberOfElements
The only parameter!
void IMACalibBlock::reset ( void  )
virtual

reset the chi2 matrices

Implements VEcalCalibBlock.

Definition at line 197 of file IMACalibBlock.cc.

References m_kaliMatrix, and m_kaliVector.

Referenced by MatrixReader.MatrixReader::__init__(), BeautifulSoup.BeautifulStoneSoup::__init__(), IMACalibBlock(), and MatrixReader.MatrixReader::showRaw().

198 {
199 
200  for (std::vector<double>::iterator vecIt = m_kaliVector.begin () ;
201  vecIt != m_kaliVector.end ();
202  ++vecIt)
203  {
204  *vecIt = 0. ;
205  }
206 
207  for (std::vector<double>::iterator vecIt = m_kaliMatrix.begin () ;
208  vecIt != m_kaliMatrix.end ();
209  ++vecIt)
210  {
211  *vecIt = 0. ;
212  }
213 
214 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:61
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:63
void IMACalibBlock::riempiMtr ( const std::vector< double > &  piena,
CLHEP::HepMatrix &  vuota 
)
private

copy a vector into a CLHEP object

Definition at line 159 of file IMACalibBlock.cc.

References i, edm::isNotFinite(), j, VEcalCalibBlock::m_numberOfElements, max(), and hitfit::return.

Referenced by solve().

161  {
162  unsigned int max = m_numberOfElements ;
163 
164  assert (piena.size () == max * max) ;
165  assert (vuota.num_row () == int(max)) ;
166  assert (vuota.num_col () == int(max)) ;
167  for (unsigned int i = 0 ; i < max ; ++i)
168  for (unsigned int j = 0 ; j < max ; ++j)
169  if (edm::isNotFinite (piena[i*max + j])) vuota[i][j] = 0. ;
170  else vuota[i][j] = piena[i*max + j] ;
171 
172  return ;
173  }
int i
Definition: DBlmapReader.cc:9
bool isNotFinite(T x)
Definition: isFinite.h:10
const T & max(const T &a, const T &b)
int j
Definition: DBlmapReader.cc:9
unsigned int m_numberOfElements
The only parameter!
void IMACalibBlock::riempiVtr ( const std::vector< double > &  pieno,
CLHEP::HepVector &  vuoto 
)
private

copy a vector into a CLHEP object

Definition at line 179 of file IMACalibBlock.cc.

References i, edm::isNotFinite(), VEcalCalibBlock::m_numberOfElements, max(), and hitfit::return.

Referenced by solve().

181  {
182 
183  int max = m_numberOfElements ;
184  assert (vuoto.num_row () == max) ;
185  for (int i = 0 ; i < max ; ++i)
186  if (edm::isNotFinite (pieno[i])) vuoto[i] = 0. ;
187  else vuoto[i] = pieno[i] ;
188 
189  return ;
190  }
int i
Definition: DBlmapReader.cc:9
bool isNotFinite(T x)
Definition: isFinite.h:10
const T & max(const T &a, const T &b)
unsigned int m_numberOfElements
The only parameter!
int IMACalibBlock::solve ( int  usingBlockSolver,
double  min,
double  max 
)
virtual

solve the chi2 linear system

Implements VEcalCalibBlock.

Definition at line 103 of file IMACalibBlock.cc.

References complete(), fillMap(), i, m_kaliMatrix, m_kaliVector, VEcalCalibBlock::m_numberOfElements, query::result, riempiMtr(), and riempiVtr().

104 {
105  complete () ;
106 // TH1F vettore ("vettore","vettore",10,-0.1,9.9);
107 // TH1F matrice ("matrice","matrice",100,-0.1,99.9);
108  CLHEP::HepMatrix kaliMatrix (m_numberOfElements,m_numberOfElements) ;
109 // for (std::vector<double>::iterator it = m_kaliVector.begin();
110 // it!= m_kaliVector.end();++it)
111 // vettore.Fill(it-m_kaliVector.begin(),*it);
112  riempiMtr (m_kaliMatrix , kaliMatrix) ;
113 // for (std::vector<double>::iterator it = m_kaliMatrix.begin();
114 // it!= m_kaliMatrix.end();++it)
115 // matrice.Fill(it-m_kaliMatrix.begin(),*it);
116 // TFile f ("fileInteressante.root","RECREATE");
117 // vettore.Write();
118 // matrice.Write();
119  CLHEP::HepVector kaliVector (m_numberOfElements) ;
120  riempiVtr (m_kaliVector , kaliVector) ;
121  //PG linear system solution
122  CLHEP::HepVector result = CLHEP::solve (kaliMatrix,kaliVector) ;
123  for (int i = 0 ; i < kaliVector.num_row () ; ++i)
124  if (result.normsq () < min * kaliVector.num_row () ||
125  result.normsq () > max * kaliVector.num_row ())
126  {
127  if (usingBlockSolver)
128  {
129  edm::LogWarning ("IML") << "using blocSlover " << std::endl ;
130  BlockSolver() (kaliMatrix,kaliVector,result) ;
131  }
132  else
133  {
134  edm::LogWarning ("IML") <<"coeff out of range " <<std::endl;
135  for (int i = 0 ; i < kaliVector.num_row () ; ++i)
136  result[i] = 1. ;
137  }
138  }
139  fillMap(result);
140  return 0;
141 }
int i
Definition: DBlmapReader.cc:9
#define min(a, b)
Definition: mlp_lapack.h:161
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:61
void riempiMtr(const std::vector< double > &piena, CLHEP::HepMatrix &vuota)
copy a vector into a CLHEP object
const T & max(const T &a, const T &b)
tuple result
Definition: query.py:137
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:63
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:25
unsigned int m_numberOfElements
The only parameter!
void fillMap(const CLHEP::HepVector &result)
fill the coefficients map from the CLHEP vector solution
void complete()
complete the triangolar chi2 matrix to a sym one

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().