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 22 of file IMACalibBlock.h.

Constructor & Destructor Documentation

IMACalibBlock::IMACalibBlock ( const int  numberOfElements)

ctor

Definition at line 15 of file IMACalibBlock.cc.

References reset().

15  :
16  VEcalCalibBlock (numberOfElements) ,
19 {
20  reset () ;
21 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:57
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:59
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 27 of file IMACalibBlock.cc.

28 {
29 }

Member Function Documentation

void IMACalibBlock::complete ( )
private

complete the triangolar chi2 matrix to a sym one

Definition at line 77 of file IMACalibBlock.cc.

References i, j, m_kaliMatrix, VEcalCalibBlock::m_numberOfElements, and reco::return().

Referenced by solve().

78 {
79  int bef;
80  int aft;
81  for (unsigned int i=0; i<m_numberOfElements;++i)
82  {
83  for (unsigned int j=i+1; j< m_numberOfElements; ++j)
84  {
85  bef = (i*m_numberOfElements+j);
86  aft = (j*m_numberOfElements +i);
87  m_kaliMatrix.at(aft) = m_kaliMatrix.at(bef) ;
88  } //LP second loop over xtals
89  } //LP first loop over xtals
90 
91  return ;
92  }
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:59
return(e1-e2)*(e1-e2)+dp *dp
unsigned int m_numberOfElements
The only parameter!
int IMACalibBlock::evalX2Size ( )
inlineprivate

give the size of a chi2 matrix

Definition at line 144 of file IMACalibBlock.cc.

References VEcalCalibBlock::m_numberOfElements.

145  {
146 
148  }
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 36 of file IMACalibBlock.cc.

References m_kaliMatrix, m_kaliVector, VEcalCalibBlock::m_numberOfElements, and reco::return().

41 {
42 // std::cerr<<"\n\nfaccio il fill!\n";
43  double inverror = 1./sigma ;
44  //LP fist loop over energies
45  for (std::map<int,double>::const_iterator itMap1 =MapBegin ;
46  itMap1 !=MapEnd ;
47  ++itMap1)
48  {
49 // std::cerr<<"numero "<<itMap1->first<<" vale "<<itMap1->second<<"\t";
50  for (std::map<int,double>::const_iterator itMap2 = itMap1 ;
51  itMap2 !=MapEnd ;
52  ++itMap2)
53  {
54  //LP calculate the chi square value
55  double dummy = itMap1->second * itMap2->second;
56  dummy *= inverror ;
57  //LP fill the calib matrix
58  m_kaliMatrix.at(itMap1->first*m_numberOfElements +itMap2->first) += dummy ;
59  } //LP second loop over xtals
60 
61  //LP calculate the vector value
62  double dummy = pTk ;
63  dummy -= pSubtract ; //LP borders
64  dummy *= itMap1->second ;
65  dummy *= inverror ;
66  //LP fill the calib vector
67  m_kaliVector.at(itMap1->first) += dummy ;
68  } //LP first loop over energies
69  return ;
70 }
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:57
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:59
return(e1-e2)*(e1-e2)+dp *dp
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 218 of file IMACalibBlock.cc.

References i, VEcalCalibBlock::m_coefficients, VEcalCalibBlock::m_numberOfElements, and reco::return().

Referenced by solve().

219 {
220 
221  for (unsigned int i=0; i < m_numberOfElements; ++i)
222  {
223  m_coefficients[i] = result[i] ;
224  }
225 
226  return ;
227 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
std::map< unsigned int, float > m_coefficients
map of coefficients
return(e1-e2)*(e1-e2)+dp *dp
unsigned int m_numberOfElements
The only parameter!
void IMACalibBlock::reset ( void  )
virtual

reset the chi2 matrices

Implements VEcalCalibBlock.

Definition at line 193 of file IMACalibBlock.cc.

References m_kaliMatrix, and m_kaliVector.

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

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

copy a vector into a CLHEP object

Definition at line 155 of file IMACalibBlock.cc.

References assert(), i, edm::isNotFinite(), j, VEcalCalibBlock::m_numberOfElements, bookConverter::max, and reco::return().

Referenced by solve().

157  {
158  unsigned int max = m_numberOfElements ;
159 
160  assert (piena.size () == max * max) ;
161  assert (vuota.num_row () == int(max)) ;
162  assert (vuota.num_col () == int(max)) ;
163  for (unsigned int i = 0 ; i < max ; ++i)
164  for (unsigned int j = 0 ; j < max ; ++j)
165  if (edm::isNotFinite (piena[i*max + j])) vuota[i][j] = 0. ;
166  else vuota[i][j] = piena[i*max + j] ;
167 
168  return ;
169  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
bool isNotFinite(T x)
Definition: isFinite.h:10
int j
Definition: DBlmapReader.cc:9
return(e1-e2)*(e1-e2)+dp *dp
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 175 of file IMACalibBlock.cc.

References assert(), i, edm::isNotFinite(), VEcalCalibBlock::m_numberOfElements, bookConverter::max, and reco::return().

Referenced by solve().

177  {
178 
179  int max = m_numberOfElements ;
180  assert (vuoto.num_row () == max) ;
181  for (int i = 0 ; i < max ; ++i)
182  if (edm::isNotFinite (pieno[i])) vuoto[i] = 0. ;
183  else vuoto[i] = pieno[i] ;
184 
185  return ;
186  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
bool isNotFinite(T x)
Definition: isFinite.h:10
return(e1-e2)*(e1-e2)+dp *dp
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 99 of file IMACalibBlock.cc.

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

100 {
101  complete () ;
102 // TH1F vettore ("vettore","vettore",10,-0.1,9.9);
103 // TH1F matrice ("matrice","matrice",100,-0.1,99.9);
104  CLHEP::HepMatrix kaliMatrix (m_numberOfElements,m_numberOfElements) ;
105 // for (std::vector<double>::iterator it = m_kaliVector.begin();
106 // it!= m_kaliVector.end();++it)
107 // vettore.Fill(it-m_kaliVector.begin(),*it);
108  riempiMtr (m_kaliMatrix , kaliMatrix) ;
109 // for (std::vector<double>::iterator it = m_kaliMatrix.begin();
110 // it!= m_kaliMatrix.end();++it)
111 // matrice.Fill(it-m_kaliMatrix.begin(),*it);
112 // TFile f ("fileInteressante.root","RECREATE");
113 // vettore.Write();
114 // matrice.Write();
115  CLHEP::HepVector kaliVector (m_numberOfElements) ;
116  riempiVtr (m_kaliVector , kaliVector) ;
117  //PG linear system solution
118  CLHEP::HepVector result = CLHEP::solve (kaliMatrix,kaliVector) ;
119  for (int i = 0 ; i < kaliVector.num_row () ; ++i)
120  if (result.normsq () < min * kaliVector.num_row () ||
121  result.normsq () > max * kaliVector.num_row ())
122  {
123  if (usingBlockSolver)
124  {
125  edm::LogWarning ("IML") << "using blocSlover " << std::endl ;
126  BlockSolver() (kaliMatrix,kaliVector,result) ;
127  }
128  else
129  {
130  edm::LogWarning ("IML") <<"coeff out of range " <<std::endl;
131  for (int i = 0 ; i < kaliVector.num_row () ; ++i)
132  result[i] = 1. ;
133  }
134  }
135  fillMap(result);
136  return 0;
137 }
int i
Definition: DBlmapReader.cc:9
float solve(float ptHyp, float val, TGraph *g)
Definition: getMaxPt.h:152
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:57
void riempiMtr(const std::vector< double > &piena, CLHEP::HepMatrix &vuota)
copy a vector into a CLHEP object
tuple result
Definition: query.py:137
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:59
T min(T a, T b)
Definition: MathUtil.h:58
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
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 59 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 57 of file IMACalibBlock.h.

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