CMS 3D CMS Logo

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

ctor

Definition at line 14 of file IMACalibBlock.cc.

16  reset();
17 }

References reset().

◆ ~IMACalibBlock()

IMACalibBlock::~IMACalibBlock ( )
override

dtor

Definition at line 21 of file IMACalibBlock.cc.

21 {}

Member Function Documentation

◆ complete()

void IMACalibBlock::complete ( )
private

complete the triangolar chi2 matrix to a sym one

Definition at line 56 of file IMACalibBlock.cc.

56  {
57  int bef;
58  int aft;
59  for (unsigned int i = 0; i < m_numberOfElements; ++i) {
60  for (unsigned int j = i + 1; j < m_numberOfElements; ++j) {
61  bef = (i * m_numberOfElements + j);
62  aft = (j * m_numberOfElements + i);
63  m_kaliMatrix.at(aft) = m_kaliMatrix.at(bef);
64  } //LP second loop over xtals
65  } //LP first loop over xtals
66 
67  return;
68 }

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

Referenced by solve().

◆ evalX2Size()

int IMACalibBlock::evalX2Size ( )
inlineprivate

give the size of a chi2 matrix

Definition at line 108 of file IMACalibBlock.cc.

References VEcalCalibBlock::m_numberOfElements.

◆ Fill()

void IMACalibBlock::Fill ( std::map< int, double >::const_iterator  MapBegin,
std::map< int, double >::const_iterator  MapEnd,
double  pTk,
double  pSubtract,
double  sigma = 1. 
)
overridevirtual

insert an entry

Implements VEcalCalibBlock.

Definition at line 25 of file IMACalibBlock.cc.

29  {
30  // std::cerr<<"\n\nfaccio il fill!\n";
31  double inverror = 1. / sigma;
32  //LP fist loop over energies
33  for (std::map<int, double>::const_iterator itMap1 = MapBegin; itMap1 != MapEnd; ++itMap1) {
34  // std::cerr<<"numero "<<itMap1->first<<" vale "<<itMap1->second<<"\t";
35  for (std::map<int, double>::const_iterator itMap2 = itMap1; itMap2 != MapEnd; ++itMap2) {
36  //LP calculate the chi square value
37  double dummy = itMap1->second * itMap2->second;
38  dummy *= inverror;
39  //LP fill the calib matrix
40  m_kaliMatrix.at(itMap1->first * m_numberOfElements + itMap2->first) += dummy;
41  } //LP second loop over xtals
42 
43  //LP calculate the vector value
44  double dummy = pTk;
45  dummy -= pSubtract; //LP borders
46  dummy *= itMap1->second;
47  dummy *= inverror;
48  //LP fill the calib vector
49  m_kaliVector.at(itMap1->first) += dummy;
50  } //LP first loop over energies
51  return;
52 }

References m_kaliMatrix, m_kaliVector, and VEcalCalibBlock::m_numberOfElements.

◆ fillMap()

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

fill the coefficients map from the CLHEP vector solution

Definition at line 157 of file IMACalibBlock.cc.

157  {
158  for (unsigned int i = 0; i < m_numberOfElements; ++i) {
159  m_coefficients[i] = result[i];
160  }
161 
162  return;
163 }

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

Referenced by solve().

◆ reset()

void IMACalibBlock::reset ( void  )
overridevirtual

reset the chi2 matrices

Implements VEcalCalibBlock.

Definition at line 144 of file IMACalibBlock.cc.

144  {
145  for (std::vector<double>::iterator vecIt = m_kaliVector.begin(); vecIt != m_kaliVector.end(); ++vecIt) {
146  *vecIt = 0.;
147  }
148 
149  for (std::vector<double>::iterator vecIt = m_kaliMatrix.begin(); vecIt != m_kaliMatrix.end(); ++vecIt) {
150  *vecIt = 0.;
151  }
152 }

References m_kaliMatrix, and m_kaliVector.

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

◆ riempiMtr()

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

copy a vector into a CLHEP object

Definition at line 112 of file IMACalibBlock.cc.

112  {
113  unsigned int max = m_numberOfElements;
114 
115  assert(piena.size() == max * max);
116  assert(vuota.num_row() == int(max));
117  assert(vuota.num_col() == int(max));
118  for (unsigned int i = 0; i < max; ++i)
119  for (unsigned int j = 0; j < max; ++j)
120  if (edm::isNotFinite(piena[i * max + j]))
121  vuota[i][j] = 0.;
122  else
123  vuota[i][j] = piena[i * max + j];
124 
125  return;
126 }

References cms::cuda::assert(), mps_fire::i, createfilelist::int, edm::isNotFinite(), dqmiolumiharvest::j, VEcalCalibBlock::m_numberOfElements, and SiStripPI::max.

Referenced by solve().

◆ riempiVtr()

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

copy a vector into a CLHEP object

Definition at line 130 of file IMACalibBlock.cc.

130  {
131  int max = m_numberOfElements;
132  assert(vuoto.num_row() == max);
133  for (int i = 0; i < max; ++i)
134  if (edm::isNotFinite(pieno[i]))
135  vuoto[i] = 0.;
136  else
137  vuoto[i] = pieno[i];
138 
139  return;
140 }

References cms::cuda::assert(), mps_fire::i, edm::isNotFinite(), VEcalCalibBlock::m_numberOfElements, and SiStripPI::max.

Referenced by solve().

◆ solve()

int IMACalibBlock::solve ( int  usingBlockSolver,
double  min,
double  max 
)
overridevirtual

solve the chi2 linear system

Implements VEcalCalibBlock.

Definition at line 72 of file IMACalibBlock.cc.

72  {
73  complete();
74  // TH1F vettore ("vettore","vettore",10,-0.1,9.9);
75  // TH1F matrice ("matrice","matrice",100,-0.1,99.9);
76  CLHEP::HepMatrix kaliMatrix(m_numberOfElements, m_numberOfElements);
77  // for (std::vector<double>::iterator it = m_kaliVector.begin();
78  // it!= m_kaliVector.end();++it)
79  // vettore.Fill(it-m_kaliVector.begin(),*it);
80  riempiMtr(m_kaliMatrix, kaliMatrix);
81  // for (std::vector<double>::iterator it = m_kaliMatrix.begin();
82  // it!= m_kaliMatrix.end();++it)
83  // matrice.Fill(it-m_kaliMatrix.begin(),*it);
84  // TFile f ("fileInteressante.root","RECREATE");
85  // vettore.Write();
86  // matrice.Write();
87  CLHEP::HepVector kaliVector(m_numberOfElements);
88  riempiVtr(m_kaliVector, kaliVector);
89  //PG linear system solution
90  CLHEP::HepVector result = CLHEP::solve(kaliMatrix, kaliVector);
91  for (int i = 0; i < kaliVector.num_row(); ++i)
92  if (result.normsq() < min * kaliVector.num_row() || result.normsq() > max * kaliVector.num_row()) {
93  if (usingBlockSolver) {
94  edm::LogWarning("IML") << "using blocSlover " << std::endl;
95  BlockSolver()(kaliMatrix, kaliVector, result);
96  } else {
97  edm::LogWarning("IML") << "coeff out of range " << std::endl;
98  for (int i = 0; i < kaliVector.num_row(); ++i)
99  result[i] = 1.;
100  }
101  }
102  fillMap(result);
103  return 0;
104 }

References complete(), fillMap(), mps_fire::i, m_kaliMatrix, m_kaliVector, VEcalCalibBlock::m_numberOfElements, SiStripPI::max, min(), mps_fire::result, riempiMtr(), and riempiVtr().

Member Data Documentation

◆ m_kaliMatrix

std::vector<double> IMACalibBlock::m_kaliMatrix
private

matrix for the chi2 inversion

Definition at line 57 of file IMACalibBlock.h.

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

◆ m_kaliVector

std::vector<double> IMACalibBlock::m_kaliVector
private

vector for the chi2 inversion

Definition at line 55 of file IMACalibBlock.h.

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

IMACalibBlock::m_kaliMatrix
std::vector< double > m_kaliMatrix
matrix for the chi2 inversion
Definition: IMACalibBlock.h:57
mps_fire.i
i
Definition: mps_fire.py:355
IMACalibBlock::riempiVtr
void riempiVtr(const std::vector< double > &pieno, CLHEP::HepVector &vuoto)
copy a vector into a CLHEP object
Definition: IMACalibBlock.cc:130
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
IMACalibBlock::complete
void complete()
complete the triangolar chi2 matrix to a sym one
Definition: IMACalibBlock.cc:56
IMACalibBlock::riempiMtr
void riempiMtr(const std::vector< double > &piena, CLHEP::HepMatrix &vuota)
copy a vector into a CLHEP object
Definition: IMACalibBlock.cc:112
min
T min(T a, T b)
Definition: MathUtil.h:58
cms::cuda::assert
assert(be >=bs)
VEcalCalibBlock::VEcalCalibBlock
VEcalCalibBlock(int numberOfElements)
ctor
Definition: VEcalCalibBlock.h:16
BlockSolver
solves at best the matrix invertion for calibration
Definition: BlockSolver.h:21
IMACalibBlock::fillMap
void fillMap(const CLHEP::HepVector &result)
fill the coefficients map from the CLHEP vector solution
Definition: IMACalibBlock.cc:157
edm::LogWarning
Definition: MessageLogger.h:141
IMACalibBlock::reset
void reset() override
reset the chi2 matrices
Definition: IMACalibBlock.cc:144
IMACalibBlock::evalX2Size
int evalX2Size()
give the size of a chi2 matrix
Definition: IMACalibBlock.cc:108
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
IMACalibBlock::m_kaliVector
std::vector< double > m_kaliVector
vector for the chi2 inversion
Definition: IMACalibBlock.h:55
createfilelist.int
int
Definition: createfilelist.py:10
VEcalCalibBlock::m_coefficients
std::map< unsigned int, float > m_coefficients
map of coefficients
Definition: VEcalCalibBlock.h:38
VEcalCalibBlock::m_numberOfElements
unsigned int m_numberOfElements
The only parameter!
Definition: VEcalCalibBlock.h:36
mps_fire.result
result
Definition: mps_fire.py:303
dummy
Definition: DummySelector.h:38
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66