CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
AlignmentCorrelationsStore Class Reference

#include <AlignmentCorrelationsStore.h>

Inheritance diagram for AlignmentCorrelationsStore:
AlignmentExtendedCorrelationsStore

Public Types

typedef std::map< Alignable *, CorrelationsTable * > Correlations
 
typedef std::map< Alignable *, AlgebraicMatrixCorrelationsTable
 

Public Member Functions

 AlignmentCorrelationsStore (void)
 
virtual void correlations (Alignable *ap1, Alignable *ap2, AlgebraicSymMatrix &cov, int row, int col) const
 
virtual bool correlationsAvailable (Alignable *ap1, Alignable *ap2) const
 Check whether correlations are stored for a given pair of alignables. More...
 
virtual void resetCorrelations (void)
 Reset correlations. More...
 
virtual void setCorrelations (Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
 
virtual void setCorrelations (Alignable *ap1, Alignable *ap2, AlgebraicMatrix &mat)
 Set correlations. More...
 
virtual unsigned int size (void) const
 Get number of stored correlations. More...
 
virtual ~AlignmentCorrelationsStore (void)
 

Private Member Functions

void fillCorrelationsTable (Alignable *ap1, Alignable *ap2, CorrelationsTable *table, const AlgebraicSymMatrix &cov, int row, int col, bool transpose)
 
void fillCovariance (Alignable *ap1, Alignable *ap2, const AlgebraicMatrix &entry, AlgebraicSymMatrix &cov, int row, int col) const
 
void fillCovarianceT (Alignable *ap1, Alignable *ap2, const AlgebraicMatrix &entry, AlgebraicSymMatrix &cov, int row, int col) const
 
void readFromCovariance (Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)
 
void readFromCovarianceT (Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)
 

Private Attributes

Correlations theCorrelations
 

Detailed Description

Definition at line 16 of file AlignmentCorrelationsStore.h.

Member Typedef Documentation

◆ Correlations

Definition at line 19 of file AlignmentCorrelationsStore.h.

◆ CorrelationsTable

Definition at line 18 of file AlignmentCorrelationsStore.h.

Constructor & Destructor Documentation

◆ AlignmentCorrelationsStore()

AlignmentCorrelationsStore::AlignmentCorrelationsStore ( void  )

Definition at line 7 of file AlignmentCorrelationsStore.cc.

7  {
8  edm::LogInfo("Alignment") << "@SUB=AlignmentCorrelationsStore::AlignmentCorrelationsStore "
9  << "\nCreated.";
10 }
Log< level::Info, false > LogInfo

◆ ~AlignmentCorrelationsStore()

virtual AlignmentCorrelationsStore::~AlignmentCorrelationsStore ( void  )
inlinevirtual

Definition at line 23 of file AlignmentCorrelationsStore.h.

23 {}

Member Function Documentation

◆ correlations()

void AlignmentCorrelationsStore::correlations ( Alignable ap1,
Alignable ap2,
AlgebraicSymMatrix cov,
int  row,
int  col 
) const
virtual

Write correlations directly to the covariance matrix starting at the given position. Indices are assumed to start from 0.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 12 of file AlignmentCorrelationsStore.cc.

References cuy::col, fillCovariance(), fillCovarianceT(), edm::swap(), theCorrelations, and geometryDiff::transpose().

Referenced by resetCorrelations(), and AlignmentParameterStore::selectParameters().

13  {
14  static Alignable* previousAlignable = nullptr;
15  static CorrelationsTable* previousCorrelations;
16 
17  // Needed by 'resetCorrelations()' to reset the static pointer:
18  if (ap1 == nullptr) {
19  previousAlignable = nullptr;
20  return;
21  }
22 
23  bool transpose = (ap2 > ap1);
24  if (transpose)
25  std::swap(ap1, ap2);
26 
27  if (ap1 == previousAlignable) {
28  CorrelationsTable::const_iterator itC2 = previousCorrelations->find(ap2);
29  if (itC2 != previousCorrelations->end()) {
30  transpose ? fillCovarianceT(ap1, ap2, (*itC2).second, cov, row, col)
31  : fillCovariance(ap1, ap2, (*itC2).second, cov, row, col);
32  }
33  } else {
34  Correlations::const_iterator itC1 = theCorrelations.find(ap1);
35  if (itC1 != theCorrelations.end()) {
36  previousAlignable = ap1;
37  previousCorrelations = (*itC1).second;
38 
39  CorrelationsTable::const_iterator itC2 = (*itC1).second->find(ap2);
40  if (itC2 != (*itC1).second->end()) {
41  transpose ? fillCovarianceT(ap1, ap2, (*itC2).second, cov, row, col)
42  : fillCovariance(ap1, ap2, (*itC2).second, cov, row, col);
43  }
44  }
45  }
46 
47  // don't fill anything into the covariance if there's no entry
48  return;
49 }
def transpose(a)
Definition: geometryDiff.py:39
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
U second(std::pair< T, U > const &p)
std::map< Alignable *, AlgebraicMatrix > CorrelationsTable
void fillCovariance(Alignable *ap1, Alignable *ap2, const AlgebraicMatrix &entry, AlgebraicSymMatrix &cov, int row, int col) const
void fillCovarianceT(Alignable *ap1, Alignable *ap2, const AlgebraicMatrix &entry, AlgebraicSymMatrix &cov, int row, int col) const
col
Definition: cuy.py:1009

◆ correlationsAvailable()

bool AlignmentCorrelationsStore::correlationsAvailable ( Alignable ap1,
Alignable ap2 
) const
virtual

Check whether correlations are stored for a given pair of alignables.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 100 of file AlignmentCorrelationsStore.cc.

References edm::swap(), theCorrelations, and geometryDiff::transpose().

Referenced by AlignmentParameterStore::attachCorrelations().

100  {
101  bool transpose = (ap2 > ap1);
102  if (transpose)
103  std::swap(ap1, ap2);
104 
105  Correlations::const_iterator itC1 = theCorrelations.find(ap1);
106  if (itC1 != theCorrelations.end()) {
107  CorrelationsTable::const_iterator itC2 = itC1->second->find(ap2);
108  if (itC2 != itC1->second->end())
109  return true;
110  }
111  return false;
112 }
def transpose(a)
Definition: geometryDiff.py:39
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112

◆ fillCorrelationsTable()

void AlignmentCorrelationsStore::fillCorrelationsTable ( Alignable ap1,
Alignable ap2,
CorrelationsTable table,
const AlgebraicSymMatrix cov,
int  row,
int  col,
bool  transpose 
)
private

Definition at line 135 of file AlignmentCorrelationsStore.cc.

References Alignable::alignmentParameters(), cuy::col, AlignmentParameters::numSelected(), readFromCovariance(), readFromCovarianceT(), TableParser::table, and geometryDiff::transpose().

Referenced by setCorrelations().

141  {
142  CorrelationsTable::iterator itC = table->find(ap2);
143 
144  if (itC != table->end()) {
145  transpose ? readFromCovarianceT(ap1, ap2, itC->second, cov, row, col)
146  : readFromCovariance(ap1, ap2, itC->second, cov, row, col);
147  } else {
148  int nRow = ap1->alignmentParameters()->numSelected();
149  int nCol = ap2->alignmentParameters()->numSelected();
150  AlgebraicMatrix newEntry(nRow, nCol);
151 
152  transpose ? readFromCovarianceT(ap1, ap2, newEntry, cov, row, col)
153  : readFromCovariance(ap1, ap2, newEntry, cov, row, col);
154 
155  (*table)[ap2] = newEntry;
156  }
157 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
def transpose(a)
Definition: geometryDiff.py:39
void readFromCovarianceT(Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)
int numSelected(void) const
Get number of selected parameters.
U second(std::pair< T, U > const &p)
CLHEP::HepMatrix AlgebraicMatrix
col
Definition: cuy.py:1009
void readFromCovariance(Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)

◆ fillCovariance()

void AlignmentCorrelationsStore::fillCovariance ( Alignable ap1,
Alignable ap2,
const AlgebraicMatrix entry,
AlgebraicSymMatrix cov,
int  row,
int  col 
) const
private

Definition at line 159 of file AlignmentCorrelationsStore.cc.

References cuy::col, and mps_splice::entry.

Referenced by correlations().

160  {
161  int nRow = entry.num_row();
162  int nCol = entry.num_col();
163 
164  for (int iRow = 0; iRow < nRow; ++iRow)
165  for (int jCol = 0; jCol < nCol; ++jCol)
166  cov[row + iRow][col + jCol] = entry[iRow][jCol];
167 }
col
Definition: cuy.py:1009

◆ fillCovarianceT()

void AlignmentCorrelationsStore::fillCovarianceT ( Alignable ap1,
Alignable ap2,
const AlgebraicMatrix entry,
AlgebraicSymMatrix cov,
int  row,
int  col 
) const
private

Definition at line 169 of file AlignmentCorrelationsStore.cc.

References cuy::col, and mps_splice::entry.

Referenced by correlations().

170  {
171  int nRow = entry.num_row();
172  int nCol = entry.num_col();
173 
174  for (int iRow = 0; iRow < nRow; ++iRow)
175  for (int jCol = 0; jCol < nCol; ++jCol)
176  cov[row + jCol][col + iRow] = entry[iRow][jCol];
177 }
col
Definition: cuy.py:1009

◆ readFromCovariance()

void AlignmentCorrelationsStore::readFromCovariance ( Alignable ap1,
Alignable ap2,
AlgebraicMatrix entry,
const AlgebraicSymMatrix cov,
int  row,
int  col 
)
private

Definition at line 179 of file AlignmentCorrelationsStore.cc.

References cuy::col, and mps_splice::entry.

Referenced by fillCorrelationsTable().

180  {
181  int nRow = entry.num_row();
182  int nCol = entry.num_col();
183 
184  for (int iRow = 0; iRow < nRow; ++iRow)
185  for (int jCol = 0; jCol < nCol; ++jCol)
186  entry[iRow][jCol] = cov[row + iRow][col + jCol];
187 }
col
Definition: cuy.py:1009

◆ readFromCovarianceT()

void AlignmentCorrelationsStore::readFromCovarianceT ( Alignable ap1,
Alignable ap2,
AlgebraicMatrix entry,
const AlgebraicSymMatrix cov,
int  row,
int  col 
)
private

Definition at line 189 of file AlignmentCorrelationsStore.cc.

References cuy::col, and mps_splice::entry.

Referenced by fillCorrelationsTable().

190  {
191  int nRow = entry.num_row();
192  int nCol = entry.num_col();
193 
194  for (int iRow = 0; iRow < nRow; ++iRow)
195  for (int jCol = 0; jCol < nCol; ++jCol)
196  entry[iRow][jCol] = cov[row + jCol][col + iRow];
197 }
col
Definition: cuy.py:1009

◆ resetCorrelations()

void AlignmentCorrelationsStore::resetCorrelations ( void  )
virtual

Reset correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 114 of file AlignmentCorrelationsStore.cc.

References correlations(), setCorrelations(), and theCorrelations.

Referenced by AlignmentParameterStore::resetParameters().

114  {
115  Correlations::iterator itC;
116  for (itC = theCorrelations.begin(); itC != theCorrelations.end(); ++itC)
117  delete (*itC).second;
118  theCorrelations.erase(theCorrelations.begin(), theCorrelations.end());
119 
120  // Reset the static pointers to the 'previous alignables'
122  correlations(nullptr, nullptr, dummy, 0, 0);
123  setCorrelations(nullptr, nullptr, dummy, 0, 0);
124 }
virtual void correlations(Alignable *ap1, Alignable *ap2, AlgebraicSymMatrix &cov, int row, int col) const
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
CLHEP::HepSymMatrix AlgebraicSymMatrix

◆ setCorrelations() [1/2]

void AlignmentCorrelationsStore::setCorrelations ( Alignable ap1,
Alignable ap2,
const AlgebraicSymMatrix cov,
int  row,
int  col 
)
virtual

Get correlations directly from the given position of the covariance matrix and store them. Indices are assumed to start from 0.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 51 of file AlignmentCorrelationsStore.cc.

References cuy::col, fillCorrelationsTable(), edm::swap(), theCorrelations, and geometryDiff::transpose().

Referenced by AlignmentParameterStore::attachCorrelations(), resetCorrelations(), and AlignmentParameterStore::updateParameters().

52  {
53  static Alignable* previousAlignable = nullptr;
54  static CorrelationsTable* previousCorrelations;
55 
56  // Needed by 'resetCorrelations()' to reset the static pointer:
57  if (ap1 == nullptr) {
58  previousAlignable = nullptr;
59  return;
60  }
61 
62  bool transpose = (ap2 > ap1);
63  if (transpose)
64  std::swap(ap1, ap2);
65 
66  if (ap1 == previousAlignable) {
67  fillCorrelationsTable(ap1, ap2, previousCorrelations, cov, row, col, transpose);
68  } else {
69  Correlations::iterator itC = theCorrelations.find(ap1);
70  if (itC != theCorrelations.end()) {
71  fillCorrelationsTable(ap1, ap2, itC->second, cov, row, col, transpose);
72  previousAlignable = ap1;
73  previousCorrelations = itC->second;
74  } else {
75  CorrelationsTable* newTable = new CorrelationsTable;
76  fillCorrelationsTable(ap1, ap2, newTable, cov, row, col, transpose);
77 
78  theCorrelations[ap1] = newTable;
79  previousAlignable = ap1;
80  previousCorrelations = newTable;
81  }
82  }
83 }
def transpose(a)
Definition: geometryDiff.py:39
void fillCorrelationsTable(Alignable *ap1, Alignable *ap2, CorrelationsTable *table, const AlgebraicSymMatrix &cov, int row, int col, bool transpose)
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
std::map< Alignable *, AlgebraicMatrix > CorrelationsTable
col
Definition: cuy.py:1009

◆ setCorrelations() [2/2]

void AlignmentCorrelationsStore::setCorrelations ( Alignable ap1,
Alignable ap2,
AlgebraicMatrix mat 
)
virtual

Set correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 85 of file AlignmentCorrelationsStore.cc.

References edm::swap(), theCorrelations, and geometryDiff::transpose().

85  {
86  bool transpose = (ap2 > ap1);
87  if (transpose)
88  std::swap(ap1, ap2);
89 
90  Correlations::iterator itC1 = theCorrelations.find(ap1);
91  if (itC1 != theCorrelations.end()) {
92  (*itC1->second)[ap2] = transpose ? mat.T() : mat;
93  } else {
94  CorrelationsTable* newTable = new CorrelationsTable;
95  (*newTable)[ap2] = transpose ? mat.T() : mat;
96  theCorrelations[ap1] = newTable;
97  }
98 }
def transpose(a)
Definition: geometryDiff.py:39
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
std::map< Alignable *, AlgebraicMatrix > CorrelationsTable

◆ size()

unsigned int AlignmentCorrelationsStore::size ( void  ) const
virtual

Get number of stored correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 126 of file AlignmentCorrelationsStore.cc.

References theCorrelations.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and AlignmentParameterStore::numCorrelations().

126  {
127  unsigned int size = 0;
128  Correlations::const_iterator itC;
129  for (itC = theCorrelations.begin(); itC != theCorrelations.end(); ++itC)
130  size += itC->second->size();
131 
132  return size;
133 }
virtual unsigned int size(void) const
Get number of stored correlations.

Member Data Documentation

◆ theCorrelations

Correlations AlignmentCorrelationsStore::theCorrelations
private