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

Definition at line 22 of file AlignmentCorrelationsStore.h.

Definition at line 21 of file AlignmentCorrelationsStore.h.

Constructor & Destructor Documentation

AlignmentCorrelationsStore::AlignmentCorrelationsStore ( void  )

Definition at line 8 of file AlignmentCorrelationsStore.cc.

9 {
10  edm::LogInfo("Alignment") << "@SUB=AlignmentCorrelationsStore::AlignmentCorrelationsStore "
11  << "\nCreated.";
12 }
virtual AlignmentCorrelationsStore::~AlignmentCorrelationsStore ( void  )
inlinevirtual

Member Function Documentation

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 15 of file AlignmentCorrelationsStore.cc.

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

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

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

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

Referenced by AlignmentParameterStore::attachCorrelations(), and ~AlignmentCorrelationsStore().

118 {
119  bool transpose = ( ap2 > ap1 );
120  if ( transpose ) std::swap( ap1, ap2 );
121 
122  Correlations::const_iterator itC1 = theCorrelations.find( ap1 );
123  if ( itC1 != theCorrelations.end() )
124  {
125  CorrelationsTable::const_iterator itC2 = itC1->second->find( ap2 );
126  if ( itC2 != itC1->second->end() ) return true;
127  }
128  return false;
129 }
def transpose(a)
Definition: geometryDiff.py:37
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void AlignmentCorrelationsStore::fillCorrelationsTable ( Alignable ap1,
Alignable ap2,
CorrelationsTable table,
const AlgebraicSymMatrix cov,
int  row,
int  col,
bool  transpose 
)
private

Definition at line 157 of file AlignmentCorrelationsStore.cc.

References Alignable::alignmentParameters(), AlignmentParameters::numSelected(), readFromCovariance(), and readFromCovarianceT().

Referenced by setCorrelations(), and ~AlignmentCorrelationsStore().

159 {
160  CorrelationsTable::iterator itC = table->find( ap2 );
161 
162  if ( itC != table->end() )
163  {
164  transpose ?
165  readFromCovarianceT( ap1, ap2, itC->second, cov, row, col ) :
166  readFromCovariance( ap1, ap2, itC->second, cov, row, col );
167  }
168  else
169  {
170  int nRow = ap1->alignmentParameters()->numSelected();
171  int nCol = ap2->alignmentParameters()->numSelected();
172  AlgebraicMatrix newEntry( nRow, nCol );
173 
174  transpose ?
175  readFromCovarianceT( ap1, ap2, newEntry, cov, row, col ) :
176  readFromCovariance( ap1, ap2, newEntry, cov, row, col );
177 
178  (*table)[ap2] = newEntry;
179  }
180 }
def transpose(a)
Definition: geometryDiff.py:37
void readFromCovarianceT(Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
U second(std::pair< T, U > const &p)
CLHEP::HepMatrix AlgebraicMatrix
int numSelected(void) const
Get number of selected parameters.
col
Definition: cuy.py:1009
void readFromCovariance(Alignable *ap1, Alignable *ap2, AlgebraicMatrix &entry, const AlgebraicSymMatrix &cov, int row, int col)
void AlignmentCorrelationsStore::fillCovariance ( Alignable ap1,
Alignable ap2,
const AlgebraicMatrix entry,
AlgebraicSymMatrix cov,
int  row,
int  col 
) const
private

Definition at line 184 of file AlignmentCorrelationsStore.cc.

Referenced by correlations(), and ~AlignmentCorrelationsStore().

186 {
187  int nRow = entry.num_row();
188  int nCol = entry.num_col();
189 
190  for ( int iRow = 0; iRow < nRow; ++iRow )
191  for ( int jCol = 0; jCol < nCol; ++jCol )
192  cov[row+iRow][col+jCol] = entry[iRow][jCol];
193 }
col
Definition: cuy.py:1009
void AlignmentCorrelationsStore::fillCovarianceT ( Alignable ap1,
Alignable ap2,
const AlgebraicMatrix entry,
AlgebraicSymMatrix cov,
int  row,
int  col 
) const
private

Definition at line 197 of file AlignmentCorrelationsStore.cc.

Referenced by correlations(), and ~AlignmentCorrelationsStore().

199 {
200  int nRow = entry.num_row();
201  int nCol = entry.num_col();
202 
203  for ( int iRow = 0; iRow < nRow; ++iRow )
204  for ( int jCol = 0; jCol < nCol; ++jCol )
205  cov[row+jCol][col+iRow] = entry[iRow][jCol];
206 }
col
Definition: cuy.py:1009
void AlignmentCorrelationsStore::readFromCovariance ( Alignable ap1,
Alignable ap2,
AlgebraicMatrix entry,
const AlgebraicSymMatrix cov,
int  row,
int  col 
)
private

Definition at line 210 of file AlignmentCorrelationsStore.cc.

Referenced by fillCorrelationsTable(), and ~AlignmentCorrelationsStore().

212 {
213  int nRow = entry.num_row();
214  int nCol = entry.num_col();
215 
216  for ( int iRow = 0; iRow < nRow; ++iRow )
217  for ( int jCol = 0; jCol < nCol; ++jCol )
218  entry[iRow][jCol] = cov[row+iRow][col+jCol];
219 }
col
Definition: cuy.py:1009
void AlignmentCorrelationsStore::readFromCovarianceT ( Alignable ap1,
Alignable ap2,
AlgebraicMatrix entry,
const AlgebraicSymMatrix cov,
int  row,
int  col 
)
private

Definition at line 223 of file AlignmentCorrelationsStore.cc.

Referenced by fillCorrelationsTable(), and ~AlignmentCorrelationsStore().

225 {
226  int nRow = entry.num_row();
227  int nCol = entry.num_col();
228 
229  for ( int iRow = 0; iRow < nRow; ++iRow )
230  for ( int jCol = 0; jCol < nCol; ++jCol )
231  entry[iRow][jCol] = cov[row+jCol][col+iRow];
232 }
col
Definition: cuy.py:1009
void AlignmentCorrelationsStore::resetCorrelations ( void  )
virtual

Reset correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 132 of file AlignmentCorrelationsStore.cc.

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

Referenced by AlignmentParameterStore::resetParameters(), and ~AlignmentCorrelationsStore().

133 {
134  Correlations::iterator itC;
135  for ( itC = theCorrelations.begin(); itC != theCorrelations.end(); ++itC ) delete (*itC).second;
136  theCorrelations.erase( theCorrelations.begin(), theCorrelations.end() );
137 
138  // Reset the static pointers to the 'previous alignables'
140  correlations( nullptr, nullptr, dummy, 0, 0 );
141  setCorrelations( nullptr, nullptr, dummy, 0, 0 );
142 }
virtual void setCorrelations(Alignable *ap1, Alignable *ap2, const AlgebraicSymMatrix &cov, int row, int col)
virtual void correlations(Alignable *ap1, Alignable *ap2, AlgebraicSymMatrix &cov, int row, int col) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
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 60 of file AlignmentCorrelationsStore.cc.

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

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

62 {
63  static Alignable* previousAlignable = nullptr;
64  static CorrelationsTable* previousCorrelations;
65 
66  // Needed by 'resetCorrelations()' to reset the static pointer:
67  if ( ap1 == nullptr ) { previousAlignable = nullptr; return; }
68 
69  bool transpose = ( ap2 > ap1 );
70  if ( transpose ) std::swap( ap1, ap2 );
71 
72  if ( ap1 == previousAlignable )
73  {
74  fillCorrelationsTable( ap1, ap2, previousCorrelations, cov, row, col, transpose );
75  }
76  else
77  {
78  Correlations::iterator itC = theCorrelations.find( ap1 );
79  if ( itC != theCorrelations.end() )
80  {
81  fillCorrelationsTable( ap1, ap2, itC->second, cov, row, col, transpose );
82  previousAlignable = ap1;
83  previousCorrelations = itC->second;
84  }
85  else
86  {
87  CorrelationsTable* newTable = new CorrelationsTable;
88  fillCorrelationsTable( ap1, ap2, newTable, cov, row, col, transpose );
89 
90  theCorrelations[ap1] = newTable;
91  previousAlignable = ap1;
92  previousCorrelations = newTable;
93  }
94  }
95 }
std::map< Alignable *, AlgebraicMatrix > CorrelationsTable
def transpose(a)
Definition: geometryDiff.py:37
void fillCorrelationsTable(Alignable *ap1, Alignable *ap2, CorrelationsTable *table, const AlgebraicSymMatrix &cov, int row, int col, bool transpose)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
col
Definition: cuy.py:1009
void AlignmentCorrelationsStore::setCorrelations ( Alignable ap1,
Alignable ap2,
AlgebraicMatrix mat 
)
virtual

Set correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 98 of file AlignmentCorrelationsStore.cc.

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

99 {
100  bool transpose = ( ap2 > ap1 );
101  if ( transpose ) std::swap( ap1, ap2 );
102 
103  Correlations::iterator itC1 = theCorrelations.find( ap1 );
104  if ( itC1 != theCorrelations.end() )
105  {
106  (*itC1->second)[ap2] = transpose ? mat.T() : mat;
107  }
108  else
109  {
110  CorrelationsTable* newTable = new CorrelationsTable;
111  (*newTable)[ap2] = transpose ? mat.T() : mat;
112  theCorrelations[ap1] = newTable;
113  }
114 }
std::map< Alignable *, AlgebraicMatrix > CorrelationsTable
def transpose(a)
Definition: geometryDiff.py:37
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
unsigned int AlignmentCorrelationsStore::size ( void  ) const
virtual

Get number of stored correlations.

Reimplemented in AlignmentExtendedCorrelationsStore.

Definition at line 145 of file AlignmentCorrelationsStore.cc.

References theCorrelations.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and ~AlignmentCorrelationsStore().

146 {
147  unsigned int size = 0;
148  Correlations::const_iterator itC;
149  for ( itC = theCorrelations.begin(); itC != theCorrelations.end(); ++itC )
150  size += itC->second->size();
151 
152  return size;
153 }
virtual unsigned int size(void) const
Get number of stored correlations.

Member Data Documentation

Correlations AlignmentCorrelationsStore::theCorrelations
private