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, AlgebraicMatrix &mat)
 Set correlations. More...
 
virtual void setCorrelations (Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
 
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 }

◆ ~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.

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 }

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

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

◆ 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.

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 }

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

Referenced by AlignmentParameterStore::attachCorrelations().

◆ 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.

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 }

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

Referenced by setCorrelations().

◆ 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.

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 }

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

Referenced by correlations().

◆ 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.

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 }

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

Referenced by correlations().

◆ 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.

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 }

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

Referenced by fillCorrelationsTable().

◆ 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.

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 }

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

Referenced by fillCorrelationsTable().

◆ resetCorrelations()

void AlignmentCorrelationsStore::resetCorrelations ( void  )
virtual

Reset correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 114 of file AlignmentCorrelationsStore.cc.

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 }

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

Referenced by AlignmentParameterStore::resetParameters().

◆ setCorrelations() [1/2]

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

Set correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 85 of file AlignmentCorrelationsStore.cc.

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 }

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

◆ setCorrelations() [2/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.

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 }

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

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

◆ size()

unsigned int AlignmentCorrelationsStore::size ( void  ) const
virtual

Get number of stored correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 126 of file AlignmentCorrelationsStore.cc.

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 }

References theCorrelations.

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

Member Data Documentation

◆ theCorrelations

Correlations AlignmentCorrelationsStore::theCorrelations
private
geometryDiff.transpose
def transpose(a)
Definition: geometryDiff.py:39
AlignmentCorrelationsStore::CorrelationsTable
std::map< Alignable *, AlgebraicMatrix > CorrelationsTable
Definition: AlignmentCorrelationsStore.h:18
AlignmentCorrelationsStore::fillCovariance
void fillCovariance(Alignable *ap1, Alignable *ap2, const AlgebraicMatrix &entry, AlgebraicSymMatrix &cov, int row, int col) const
Definition: AlignmentCorrelationsStore.cc:159
mps_splice.entry
entry
Definition: mps_splice.py:68
Alignable
Definition: Alignable.h:27
cuy.col
col
Definition: cuy.py:1010
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
AlignmentCorrelationsStore::size
virtual unsigned int size(void) const
Get number of stored correlations.
Definition: AlignmentCorrelationsStore.cc:126
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
AlignmentCorrelationsStore::setCorrelations
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
Definition: AlignmentCorrelationsStore.cc:51
AlignmentCorrelationsStore::theCorrelations
Correlations theCorrelations
Definition: AlignmentCorrelationsStore.h:66
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
AlignmentCorrelationsStore::correlations
virtual void correlations(Alignable *ap1, Alignable *ap2, AlgebraicSymMatrix &cov, int row, int col) const
Definition: AlignmentCorrelationsStore.cc:12
AlignmentCorrelationsStore::fillCorrelationsTable
void fillCorrelationsTable(Alignable *ap1, Alignable *ap2, CorrelationsTable *table, const AlgebraicSymMatrix &cov, int row, int col, bool transpose)
Definition: AlignmentCorrelationsStore.cc:135
AlignmentCorrelationsStore::readFromCovariance
void readFromCovariance(Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)
Definition: AlignmentCorrelationsStore.cc:179
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
AlignmentCorrelationsStore::readFromCovarianceT
void readFromCovarianceT(Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)
Definition: AlignmentCorrelationsStore.cc:189
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
AlignmentParameters::numSelected
int numSelected(void) const
Get number of selected parameters.
Definition: AlignmentParameters.cc:51
AlignmentCorrelationsStore::fillCovarianceT
void fillCovarianceT(Alignable *ap1, Alignable *ap2, const AlgebraicMatrix &entry, AlgebraicSymMatrix &cov, int row, int col) const
Definition: AlignmentCorrelationsStore.cc:169
dummy
Definition: DummySelector.h:38
TableParser.table
table
Definition: TableParser.py:111
Alignable::alignmentParameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58