#include <AlignmentExtendedCorrelationsStore.h>
Definition at line 18 of file AlignmentExtendedCorrelationsStore.h.
typedef std::map< Alignable*, ExtendedCorrelationsTable* > AlignmentExtendedCorrelationsStore::ExtendedCorrelations |
Definition at line 25 of file AlignmentExtendedCorrelationsStore.h.
typedef AlignmentExtendedCorrelationsEntry AlignmentExtendedCorrelationsStore::ExtendedCorrelationsEntry |
Definition at line 23 of file AlignmentExtendedCorrelationsStore.h.
typedef std::map< Alignable*, ExtendedCorrelationsEntry > AlignmentExtendedCorrelationsStore::ExtendedCorrelationsTable |
Definition at line 24 of file AlignmentExtendedCorrelationsStore.h.
AlignmentExtendedCorrelationsStore::AlignmentExtendedCorrelationsStore | ( | const edm::ParameterSet & | config | ) |
Definition at line 12 of file AlignmentExtendedCorrelationsStore.cc.
References edm::ParameterSet::getParameter(), theCut, theMaxUpdates, and theWeight.
{ theMaxUpdates = config.getParameter<int>( "MaxUpdates" ); theCut = config.getParameter<double>( "CutValue" ); theWeight = config.getParameter<double>( "Weight" ); edm::LogInfo("Alignment") << "@SUB=AlignmentExtendedCorrelationsStore::AlignmentExtendedCorrelationsStore" << "Created."; }
virtual AlignmentExtendedCorrelationsStore::~AlignmentExtendedCorrelationsStore | ( | void | ) | [inline, virtual] |
Definition at line 29 of file AlignmentExtendedCorrelationsStore.h.
{}
void AlignmentExtendedCorrelationsStore::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 from AlignmentCorrelationsStore.
Definition at line 23 of file AlignmentExtendedCorrelationsStore.cc.
References fillCovariance(), fillCovarianceT(), swap(), theCorrelations, and geometryDiff::transpose().
Referenced by resetCorrelations().
{ static Alignable* previousAlignable = 0; static ExtendedCorrelationsTable* previousCorrelations; // Needed by 'resetCorrelations()' to reset the static pointer: if ( ap1 == 0 ) { previousAlignable = 0; return; } bool transpose = ( ap2 > ap1 ); if ( transpose ) std::swap( ap1, ap2 ); if ( ap1 == previousAlignable ) { ExtendedCorrelationsTable::const_iterator itC2 = previousCorrelations->find( ap2 ); if ( itC2 != previousCorrelations->end() ) { transpose ? fillCovarianceT( ap1, ap2, (*itC2).second, cov, row, col ) : fillCovariance( ap1, ap2, (*itC2).second, cov, row, col ); } } else { ExtendedCorrelations::const_iterator itC1 = theCorrelations.find( ap1 ); if ( itC1 != theCorrelations.end() ) { previousAlignable = ap1; previousCorrelations = (*itC1).second; ExtendedCorrelationsTable::const_iterator itC2 = (*itC1).second->find( ap2 ); if ( itC2 != (*itC1).second->end() ) { transpose ? fillCovarianceT( ap1, ap2, (*itC2).second, cov, row, col ) : fillCovariance( ap1, ap2, (*itC2).second, cov, row, col ); } } } // don't fill anything into the covariance if there's no entry return; }
bool AlignmentExtendedCorrelationsStore::correlationsAvailable | ( | Alignable * | ap1, |
Alignable * | ap2 | ||
) | const [virtual] |
Check whether correlations are stored for a given pair of alignables.
Reimplemented from AlignmentCorrelationsStore.
Definition at line 155 of file AlignmentExtendedCorrelationsStore.cc.
References swap(), theCorrelations, and geometryDiff::transpose().
{ bool transpose = ( ap2 > ap1 ); if ( transpose ) std::swap( ap1, ap2 ); ExtendedCorrelations::const_iterator itC1 = theCorrelations.find( ap1 ); if ( itC1 != theCorrelations.end() ) { ExtendedCorrelationsTable::const_iterator itC2 = itC1->second->find( ap2 ); if ( itC2 != itC1->second->end() ) return true; } return false; }
void AlignmentExtendedCorrelationsStore::fillCorrelationsTable | ( | Alignable * | ap1, |
Alignable * | ap2, | ||
ExtendedCorrelationsTable * | table, | ||
const AlgebraicSymMatrix & | cov, | ||
int | row, | ||
int | col, | ||
bool | transpose | ||
) | [protected, virtual] |
Definition at line 195 of file AlignmentExtendedCorrelationsStore.cc.
References Alignable::alignmentParameters(), AlignmentParameters::numSelected(), readFromCovariance(), and readFromCovarianceT().
Referenced by setCorrelations().
{ ExtendedCorrelationsTable::iterator itC = table->find( ap2 ); if ( itC != table->end() ) { //if ( itC->second.counter() > theMaxUpdates ) return; transpose ? readFromCovarianceT( ap1, ap2, itC->second, cov, row, col ) : readFromCovariance( ap1, ap2, itC->second, cov, row, col ); //itC->second.incrementCounter(); } else { int nRow = ap1->alignmentParameters()->numSelected(); int nCol = ap2->alignmentParameters()->numSelected(); ExtendedCorrelationsEntry newEntry( nRow, nCol ); transpose ? readFromCovarianceT( ap1, ap2, newEntry, cov, row, col ) : readFromCovariance( ap1, ap2, newEntry, cov, row, col ); (*table)[ap2] = newEntry; } }
void AlignmentExtendedCorrelationsStore::fillCovariance | ( | Alignable * | ap1, |
Alignable * | ap2, | ||
const ExtendedCorrelationsEntry & | entry, | ||
AlgebraicSymMatrix & | cov, | ||
int | row, | ||
int | col | ||
) | const [protected, virtual] |
Definition at line 228 of file AlignmentExtendedCorrelationsStore.cc.
References Exception, edm::isNotFinite(), AlignmentExtendedCorrelationsEntry::numCol(), AlignmentExtendedCorrelationsEntry::numRow(), and mathSSE::sqrt().
Referenced by correlations().
{ int nRow = entry.numRow(); int nCol = entry.numCol(); for ( int iRow = 0; iRow < nRow; ++iRow ) { double factor = sqrt(cov[row+iRow][row+iRow]); if ( edm::isNotFinite(factor) ) throw cms::Exception("LogicError") << "[AlignmentExtendedCorrelationsStore::fillCovariance] " << "NaN-factor: sqrt(" << cov[row+iRow][row+iRow] << ")"; for ( int jCol = 0; jCol < nCol; ++jCol ) cov[row+iRow][col+jCol] = entry( iRow, jCol )*factor; } for ( int jCol = 0; jCol < nCol; ++jCol ) { double factor = sqrt(cov[col+jCol][col+jCol]); if ( edm::isNotFinite(factor) ) throw cms::Exception("LogicError") << "[AlignmentExtendedCorrelationsStore::fillCovariance] " << "NaN-factor: sqrt(" << cov[col+jCol][col+jCol] << ")"; for ( int iRow = 0; iRow < nRow; ++iRow ) cov[row+iRow][col+jCol] *= factor; } }
void AlignmentExtendedCorrelationsStore::fillCovarianceT | ( | Alignable * | ap1, |
Alignable * | ap2, | ||
const ExtendedCorrelationsEntry & | entry, | ||
AlgebraicSymMatrix & | cov, | ||
int | row, | ||
int | col | ||
) | const [protected, virtual] |
Definition at line 257 of file AlignmentExtendedCorrelationsStore.cc.
References Exception, edm::isNotFinite(), AlignmentExtendedCorrelationsEntry::numCol(), AlignmentExtendedCorrelationsEntry::numRow(), and mathSSE::sqrt().
Referenced by correlations().
{ int nRow = entry.numRow(); int nCol = entry.numCol(); for ( int iRow = 0; iRow < nRow; ++iRow ) { double factor = sqrt(cov[col+iRow][col+iRow]); if ( edm::isNotFinite(factor) ) throw cms::Exception("LogicError") << "[AlignmentExtendedCorrelationsStore::fillCovarianceT] " << "NaN-factor: sqrt(" << cov[col+iRow][col+iRow] << ")"; for ( int jCol = 0; jCol < nCol; ++jCol ) cov[row+jCol][col+iRow] = entry( iRow, jCol )*factor; } for ( int jCol = 0; jCol < nCol; ++jCol ) { double factor = sqrt(cov[row+jCol][row+jCol]); if ( edm::isNotFinite(factor) ) throw cms::Exception("LogicError") << "[AlignmentExtendedCorrelationsStore::fillCovarianceT] " << "NaN-factor: sqrt(" << cov[row+jCol][row+jCol] << ")"; for ( int iRow = 0; iRow < nRow; ++iRow ) cov[row+jCol][col+iRow] *= factor; } }
void AlignmentExtendedCorrelationsStore::getCorrelations | ( | Alignable * | ap1, |
Alignable * | ap2, | ||
AlgebraicMatrix & | mat | ||
) | const [virtual] |
Get correlations.
Definition at line 135 of file AlignmentExtendedCorrelationsStore.cc.
References swap(), theCorrelations, and geometryDiff::transpose().
{ bool transpose = ( ap2 > ap1 ); if ( transpose ) std::swap( ap1, ap2 ); ExtendedCorrelations::const_iterator itC1 = theCorrelations.find( ap1 ); if ( itC1 != theCorrelations.end() ) { ExtendedCorrelationsTable::const_iterator itC2 = itC1->second->find( ap2 ); if ( itC2 != itC1->second->end() ) { mat = transpose ? itC2->second.matrix().T() : itC2->second.matrix(); return; } } mat = AlgebraicMatrix(); }
void AlignmentExtendedCorrelationsStore::readFromCovariance | ( | Alignable * | ap1, |
Alignable * | ap2, | ||
ExtendedCorrelationsEntry & | entry, | ||
const AlgebraicSymMatrix & | cov, | ||
int | row, | ||
int | col | ||
) | [protected, virtual] |
Definition at line 285 of file AlignmentExtendedCorrelationsStore.cc.
References AlignmentExtendedCorrelationsEntry::numCol(), AlignmentExtendedCorrelationsEntry::numRow(), resizeCorruptCorrelations(), and mathSSE::sqrt().
Referenced by fillCorrelationsTable().
{ int nRow = entry.numRow(); int nCol = entry.numCol(); for ( int iRow = 0; iRow < nRow; ++iRow ) { double factor = sqrt(cov[row+iRow][row+iRow]); for ( int jCol = 0; jCol < nCol; ++jCol ) entry( iRow, jCol ) = cov[row+iRow][col+jCol]/factor; } double maxCorr = 0; for ( int jCol = 0; jCol < nCol; ++jCol ) { double factor = sqrt(cov[col+jCol][col+jCol]); for ( int iRow = 0; iRow < nRow; ++iRow ) { entry( iRow, jCol ) /= factor; if ( fabs( entry( iRow, jCol ) ) > maxCorr ) maxCorr = fabs( entry( iRow, jCol ) ); } } resizeCorruptCorrelations( entry, maxCorr ); }
void AlignmentExtendedCorrelationsStore::readFromCovarianceT | ( | Alignable * | ap1, |
Alignable * | ap2, | ||
ExtendedCorrelationsEntry & | entry, | ||
const AlgebraicSymMatrix & | cov, | ||
int | row, | ||
int | col | ||
) | [protected, virtual] |
Definition at line 315 of file AlignmentExtendedCorrelationsStore.cc.
References AlignmentExtendedCorrelationsEntry::numCol(), AlignmentExtendedCorrelationsEntry::numRow(), resizeCorruptCorrelations(), and mathSSE::sqrt().
Referenced by fillCorrelationsTable().
{ int nRow = entry.numRow(); int nCol = entry.numCol(); for ( int iRow = 0; iRow < nRow; ++iRow ) { double factor = sqrt(cov[col+iRow][col+iRow]); for ( int jCol = 0; jCol < nCol; ++jCol ) entry( iRow, jCol ) = cov[row+jCol][col+iRow]/factor; } double maxCorr = 0; for ( int jCol = 0; jCol < nCol; ++jCol ) { double factor = sqrt(cov[row+jCol][row+jCol]); for ( int iRow = 0; iRow < nRow; ++iRow ) { entry( iRow, jCol ) /= factor; if ( fabs( entry( iRow, jCol ) ) > maxCorr ) maxCorr = fabs( entry( iRow, jCol ) ); } } resizeCorruptCorrelations( entry, maxCorr ); }
void AlignmentExtendedCorrelationsStore::resetCorrelations | ( | void | ) | [virtual] |
Reset correlations.
Reimplemented from AlignmentCorrelationsStore.
Definition at line 170 of file AlignmentExtendedCorrelationsStore.cc.
References correlations(), setCorrelations(), and theCorrelations.
{ ExtendedCorrelations::iterator itC; for ( itC = theCorrelations.begin(); itC != theCorrelations.end(); ++itC ) delete (*itC).second; theCorrelations.erase( theCorrelations.begin(), theCorrelations.end() ); // Reset the static pointers to the 'previous alignables' AlgebraicSymMatrix dummy; correlations( 0, 0, dummy, 0, 0 ); setCorrelations( 0, 0, dummy, 0, 0 ); }
void AlignmentExtendedCorrelationsStore::resizeCorruptCorrelations | ( | ExtendedCorrelationsEntry & | entry, |
double | maxCorr | ||
) | [protected] |
Definition at line 345 of file AlignmentExtendedCorrelationsStore.cc.
References theCut, and theWeight.
Referenced by readFromCovariance(), and readFromCovarianceT().
void AlignmentExtendedCorrelationsStore::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 from AlignmentCorrelationsStore.
Definition at line 68 of file AlignmentExtendedCorrelationsStore.cc.
References fillCorrelationsTable(), swap(), theCorrelations, and geometryDiff::transpose().
Referenced by resetCorrelations().
{ static Alignable* previousAlignable = 0; static ExtendedCorrelationsTable* previousCorrelations; // Needed by 'resetCorrelations()' to reset the static pointer: if ( ap1 == 0 ) { previousAlignable = 0; return; } bool transpose = ( ap2 > ap1 ); if ( transpose ) std::swap( ap1, ap2 ); if ( ap1 == previousAlignable ) { fillCorrelationsTable( ap1, ap2, previousCorrelations, cov, row, col, transpose ); } else { ExtendedCorrelations::iterator itC = theCorrelations.find( ap1 ); if ( itC != theCorrelations.end() ) { fillCorrelationsTable( ap1, ap2, itC->second, cov, row, col, transpose ); previousAlignable = ap1; previousCorrelations = itC->second; } else { // make new entry ExtendedCorrelationsTable* newTable = new ExtendedCorrelationsTable; fillCorrelationsTable( ap1, ap2, newTable, cov, row, col, transpose ); theCorrelations[ap1] = newTable; previousAlignable = ap1; previousCorrelations = newTable; } } }
void AlignmentExtendedCorrelationsStore::setCorrelations | ( | Alignable * | ap1, |
Alignable * | ap2, | ||
AlgebraicMatrix & | mat | ||
) | [virtual] |
Set correlations without checking whether the maximum number of updates has already been reached.
Reimplemented from AlignmentCorrelationsStore.
Definition at line 108 of file AlignmentExtendedCorrelationsStore.cc.
References swap(), theCorrelations, and geometryDiff::transpose().
{ bool transpose = ( ap2 > ap1 ); if ( transpose ) std::swap( ap1, ap2 ); ExtendedCorrelations::iterator itC1 = theCorrelations.find( ap1 ); if ( itC1 != theCorrelations.end() ) { ExtendedCorrelationsTable::iterator itC2 = itC1->second->find( ap1 ); if ( itC2 != itC1->second->end() ) { itC2->second = transpose ? ExtendedCorrelationsEntry( mat.T() ) : ExtendedCorrelationsEntry( mat ); } else { (*itC1->second)[ap2] = transpose ? ExtendedCorrelationsEntry( mat.T() ) : ExtendedCorrelationsEntry( mat ); } } else { ExtendedCorrelationsTable* newTable = new ExtendedCorrelationsTable; (*newTable)[ap2] = transpose ? ExtendedCorrelationsEntry( mat.T() ) : ExtendedCorrelationsEntry( mat ); theCorrelations[ap1] = newTable; } }
unsigned int AlignmentExtendedCorrelationsStore::size | ( | void | ) | const [virtual] |
Get number of stored correlations.
Reimplemented from AlignmentCorrelationsStore.
Definition at line 183 of file AlignmentExtendedCorrelationsStore.cc.
References theCorrelations.
{ unsigned int size = 0; ExtendedCorrelations::const_iterator itC; for ( itC = theCorrelations.begin(); itC != theCorrelations.end(); ++itC ) size += itC->second->size(); return size; }
Reimplemented from AlignmentCorrelationsStore.
Definition at line 78 of file AlignmentExtendedCorrelationsStore.h.
Referenced by correlations(), correlationsAvailable(), getCorrelations(), resetCorrelations(), setCorrelations(), and size().
double AlignmentExtendedCorrelationsStore::theCut [protected] |
Definition at line 81 of file AlignmentExtendedCorrelationsStore.h.
Referenced by AlignmentExtendedCorrelationsStore(), and resizeCorruptCorrelations().
int AlignmentExtendedCorrelationsStore::theMaxUpdates [protected] |
Definition at line 80 of file AlignmentExtendedCorrelationsStore.h.
Referenced by AlignmentExtendedCorrelationsStore().
double AlignmentExtendedCorrelationsStore::theWeight [protected] |
Definition at line 82 of file AlignmentExtendedCorrelationsStore.h.
Referenced by AlignmentExtendedCorrelationsStore(), and resizeCorruptCorrelations().