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:
2011/06/30 10:10:52
Revision:
1.11
Id:
IMACalibBlock.cc,v 1.11 2011/06/30 10:10:52 muzaffar Exp
Author
Author:
muzaffar

Definition at line 18 of file IMACalibBlock.cc.

References reset().

18  :
19  VEcalCalibBlock (numberOfElements) ,
22 {
23  reset () ;
24 }
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 30 of file IMACalibBlock.cc.

31 {
32 }

Member Function Documentation

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, VEcalCalibBlock::m_numberOfElements, and hitfit::return.

Referenced by solve().

81 {
82  int bef;
83  int aft;
84  for (unsigned int i=0; i<m_numberOfElements;++i)
85  {
86  for (unsigned int j=i+1; j< m_numberOfElements; ++j)
87  {
88  bef = (i*m_numberOfElements+j);
89  aft = (j*m_numberOfElements +i);
90  m_kaliMatrix.at(aft) = m_kaliMatrix.at(bef) ;
91  } //LP second loop over xtals
92  } //LP first loop over xtals
93 
94  return ;
95  }
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 147 of file IMACalibBlock.cc.

References VEcalCalibBlock::m_numberOfElements.

148  {
149 
151  }
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 39 of file IMACalibBlock.cc.

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

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

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

Referenced by solve().

222 {
223 
224  for (unsigned int i=0; i < m_numberOfElements; ++i)
225  {
226  m_coefficients[i] = result[i] ;
227  }
228 
229  return ;
230 }
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 196 of file IMACalibBlock.cc.

References m_kaliMatrix, and m_kaliVector.

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

197 {
198 
199  for (std::vector<double>::iterator vecIt = m_kaliVector.begin () ;
200  vecIt != m_kaliVector.end ();
201  ++vecIt)
202  {
203  *vecIt = 0. ;
204  }
205 
206  for (std::vector<double>::iterator vecIt = m_kaliMatrix.begin () ;
207  vecIt != m_kaliMatrix.end ();
208  ++vecIt)
209  {
210  *vecIt = 0. ;
211  }
212 
213 }
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 158 of file IMACalibBlock.cc.

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

Referenced by solve().

160  {
161  unsigned int max = m_numberOfElements ;
162 
163  assert (piena.size () == max * max) ;
164  assert (vuota.num_row () == int(max)) ;
165  assert (vuota.num_col () == int(max)) ;
166  for (unsigned int i = 0 ; i < max ; ++i)
167  for (unsigned int j = 0 ; j < max ; ++j)
168  if (std::isnan (piena[i*max + j])) vuota[i][j] = 0. ;
169  else vuota[i][j] = piena[i*max + j] ;
170 
171  return ;
172  }
int i
Definition: DBlmapReader.cc:9
const T & max(const T &a, const T &b)
bool isnan(float x)
Definition: math.h:13
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 178 of file IMACalibBlock.cc.

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

Referenced by solve().

180  {
181 
182  int max = m_numberOfElements ;
183  assert (vuoto.num_row () == max) ;
184  for (int i = 0 ; i < max ; ++i)
185  if (std::isnan (pieno[i])) vuoto[i] = 0. ;
186  else vuoto[i] = pieno[i] ;
187 
188  return ;
189  }
int i
Definition: DBlmapReader.cc:9
const T & max(const T &a, const T &b)
bool isnan(float x)
Definition: math.h:13
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 102 of file IMACalibBlock.cc.

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

103 {
104  complete () ;
105 // TH1F vettore ("vettore","vettore",10,-0.1,9.9);
106 // TH1F matrice ("matrice","matrice",100,-0.1,99.9);
107  CLHEP::HepMatrix kaliMatrix (m_numberOfElements,m_numberOfElements) ;
108 // for (std::vector<double>::iterator it = m_kaliVector.begin();
109 // it!= m_kaliVector.end();++it)
110 // vettore.Fill(it-m_kaliVector.begin(),*it);
111  riempiMtr (m_kaliMatrix , kaliMatrix) ;
112 // for (std::vector<double>::iterator it = m_kaliMatrix.begin();
113 // it!= m_kaliMatrix.end();++it)
114 // matrice.Fill(it-m_kaliMatrix.begin(),*it);
115 // TFile f ("fileInteressante.root","RECREATE");
116 // vettore.Write();
117 // matrice.Write();
118  CLHEP::HepVector kaliVector (m_numberOfElements) ;
119  riempiVtr (m_kaliVector , kaliVector) ;
120  //PG linear system solution
121  CLHEP::HepVector result = CLHEP::solve (kaliMatrix,kaliVector) ;
122  for (int i = 0 ; i < kaliVector.num_row () ; ++i)
123  if (result.normsq () < min * kaliVector.num_row () ||
124  result.normsq () > max * kaliVector.num_row ())
125  {
126  if (usingBlockSolver)
127  {
128  edm::LogWarning ("IML") << "using blocSlover " << std::endl ;
129  BlockSolver() (kaliMatrix,kaliVector,result) ;
130  }
131  else
132  {
133  edm::LogWarning ("IML") <<"coeff out of range " <<std::endl;
134  for (int i = 0 ; i < kaliVector.num_row () ; ++i)
135  result[i] = 1. ;
136  }
137  }
138  fillMap(result);
139  return 0;
140 }
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().