CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
KalmanAlignmentMetricsCalculator Class Reference

#include <KalmanAlignmentMetricsCalculator.h>

Public Types

typedef std::map< Alignable
*, SingleDistancesList * > 
FullDistancesList
 
typedef std::map< Alignable
*, short int > 
SingleDistancesList
 

Public Member Functions

const std::vector< Alignable * > alignables (void) const
 Return all known alignables. More...
 
void clear (void)
 Clear stored distances. More...
 
const SingleDistancesListgetDistances (Alignable *i) const
 
 KalmanAlignmentMetricsCalculator (void)
 
unsigned int nDistances (void) const
 Number of stored distances. More...
 
short int operator() (Alignable *i, Alignable *j) const
 
void readDistances (std::string filename)
 
void setMaxDistance (short int maxDistance)
 Set maximum distance to be stored. More...
 
void updateDistances (const std::vector< Alignable * > &alignables)
 Update list of distances with a set Alignables. More...
 
void writeDistances (std::string filename)
 
 ~KalmanAlignmentMetricsCalculator (void)
 

Private Member Functions

void clearDistances (FullDistancesList &dist)
 
void connect (FullDistancesList &changes, SingleDistancesList *connection, Alignable *alignable, short int value)
 
void createBranches (TTree *tree)
 
void extractPropagatedDistances (FullDistancesList &changes, Alignable *alignable, SingleDistancesList *oldList, SingleDistancesList *newList)
 Extract entries from the updated lists that need to be further propagated. More...
 
void insertDistance (FullDistancesList &dist, Alignable *i, Alignable *j, short int value)
 
void insertDistance (SingleDistancesList *distList, Alignable *j, short int value)
 
void insertPropagatedDistances (FullDistancesList &propagated)
 Insert the 'propagated distances' into the lists of the remaining alignables. More...
 
void insertUpdatedDistances (FullDistancesList &updated)
 Insert changes due to the update of the lists of the current alignables. More...
 
void setBranchAddresses (TTree *tree)
 
void updateList (SingleDistancesList *thisList, SingleDistancesList *otherList)
 

Private Attributes

SingleDistancesList theDefaultReturnList
 
FullDistancesList theDistances
 
short int theMaxDistance
 

Detailed Description

Calculates the metrical distances (stored as short int) for a set of Alignables. See E.Widl, R.Fr"uhwirth, W.Adam, A Kalman Filter for Track-based Alignment, CMS NOTE-2006/022 for more details.

Definition at line 17 of file KalmanAlignmentMetricsCalculator.h.

Member Typedef Documentation

Definition at line 23 of file KalmanAlignmentMetricsCalculator.h.

Definition at line 22 of file KalmanAlignmentMetricsCalculator.h.

Constructor & Destructor Documentation

KalmanAlignmentMetricsCalculator::KalmanAlignmentMetricsCalculator ( void  )
KalmanAlignmentMetricsCalculator::~KalmanAlignmentMetricsCalculator ( void  )

Definition at line 7 of file KalmanAlignmentMetricsCalculator.cc.

References clear().

7 { clear(); }
void clear(void)
Clear stored distances.

Member Function Documentation

const std::vector< Alignable * > KalmanAlignmentMetricsCalculator::alignables ( void  ) const

Return all known alignables.

Definition at line 114 of file KalmanAlignmentMetricsCalculator.cc.

References theDistances.

Referenced by SimpleMetricsUpdator::alignables().

115 {
116  std::vector< Alignable* > alignables;
117  alignables.reserve( theDistances.size() );
118 
119  for ( FullDistancesList::const_iterator itL = theDistances.begin(); itL != theDistances.end(); ++itL )
120  alignables.push_back( itL->first );
121 
122  return alignables;
123 }
const std::vector< Alignable * > alignables(void) const
Return all known alignables.
void KalmanAlignmentMetricsCalculator::clear ( void  )
void KalmanAlignmentMetricsCalculator::clearDistances ( FullDistancesList dist)
private

Definition at line 126 of file KalmanAlignmentMetricsCalculator.cc.

Referenced by clear(), and updateDistances().

127 {
128  FullDistancesList::iterator itD;
129  for ( itD = dist.begin(); itD != dist.end(); ++itD ) delete itD->second;
130  dist.clear();
131 }
void KalmanAlignmentMetricsCalculator::connect ( FullDistancesList changes,
SingleDistancesList connection,
Alignable alignable,
short int  value 
)
private

If the current update of the metric has connected previously unrelated parts (in a metrical sense), add this information to the table of propagated distances.

Definition at line 223 of file KalmanAlignmentMetricsCalculator.cc.

References insertDistance().

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), extractPropagatedDistances(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

225 {
226  SingleDistancesList::iterator itL;
227  for ( itL = connection->begin(); itL != connection->end(); ++itL )
228  {
229  if ( itL->first != alignable ) insertDistance( changes, alignable, itL->first, value + itL->second );
230  }
231 
232 }
void insertDistance(FullDistancesList &dist, Alignable *i, Alignable *j, short int value)
void KalmanAlignmentMetricsCalculator::createBranches ( TTree *  tree)
private

Definition at line 274 of file KalmanAlignmentMetricsCalculator.cc.

275 {
276 
277 }
void KalmanAlignmentMetricsCalculator::extractPropagatedDistances ( FullDistancesList changes,
Alignable alignable,
SingleDistancesList oldList,
SingleDistancesList newList 
)
private

Extract entries from the updated lists that need to be further propagated.

Definition at line 190 of file KalmanAlignmentMetricsCalculator.cc.

References connect(), and insertDistance().

Referenced by updateDistances().

194 {
195  SingleDistancesList::iterator itOld;
196  SingleDistancesList::iterator itNew;
197 
198  SingleDistancesList newConnections;
199 
200  // Distances-list newList has at least entries for the same indices as distances-list
201  // oldList. For this reason 'newList->begin()->first <= oldList->begin()->first' and
202  // hence 'itNew->first <= itOld->first' is always true in the loop below.
203  for ( itOld = oldList->begin(), itNew = newList->begin(); itNew != newList->end(); ++itNew )
204  {
205  // No entry associated to index itNew->first present in oldList. --> This is indeed a change.
206  if ( itOld == oldList->end() || itNew->first < itOld->first )
207  {
208  insertDistance( changes, itNew->first, alignable, itNew->second );
209  newConnections[itNew->first] = itNew->second;
210  // Entry associated to index itNew->first present in oldList. --> Check if it has changed.
211  } else if ( itNew->first == itOld->first ) {
212  if ( itNew->second != itOld->second ) insertDistance( changes, itNew->first, alignable, itNew->second );
213  ++itOld;
214  }
215  }
216 
217  SingleDistancesList::iterator it;
218  for ( it = newConnections.begin(); it != newConnections.end(); ++it )
219  connect( changes, newList, it->first, it->second );
220 }
void connect(FullDistancesList &changes, SingleDistancesList *connection, Alignable *alignable, short int value)
void insertDistance(FullDistancesList &dist, Alignable *i, Alignable *j, short int value)
std::map< Alignable *, short int > SingleDistancesList
const KalmanAlignmentMetricsCalculator::SingleDistancesList & KalmanAlignmentMetricsCalculator::getDistances ( Alignable i) const

Return map of related Alignables (identified via Alignable*) and their distances for a distinct Alignable.

Definition at line 75 of file KalmanAlignmentMetricsCalculator.cc.

References theDefaultReturnList, and theDistances.

Referenced by SimpleMetricsUpdator::additionalAlignables(), and SimpleMetricsUpdator::additionalAlignablesWithDistances().

76 {
77  FullDistancesList::const_iterator itD = theDistances.find( i );
78  if ( itD == theDistances.end() ) return theDefaultReturnList;
79  return *itD->second;
80 }
void KalmanAlignmentMetricsCalculator::insertDistance ( FullDistancesList dist,
Alignable i,
Alignable j,
short int  value 
)
private

Definition at line 235 of file KalmanAlignmentMetricsCalculator.cc.

References i, j, and relativeConstraints::value.

Referenced by connect(), extractPropagatedDistances(), and insertPropagatedDistances().

236 {
237  FullDistancesList::iterator itD = dist.find( i );
238  if ( itD != dist.end() ) // Found distances-list for index i.
239  {
240  insertDistance( itD->second, j, value );
241  }
242  else // No distances-list found for value i.
243  {
245  (*newList)[j] = value;
246  dist[i] = newList;
247  }
248 }
int i
Definition: DBlmapReader.cc:9
void insertDistance(FullDistancesList &dist, Alignable *i, Alignable *j, short int value)
int j
Definition: DBlmapReader.cc:9
std::map< Alignable *, short int > SingleDistancesList
void KalmanAlignmentMetricsCalculator::insertDistance ( SingleDistancesList distList,
Alignable j,
short int  value 
)
private

Definition at line 251 of file KalmanAlignmentMetricsCalculator.cc.

References j, and relativeConstraints::value.

252 {
253  SingleDistancesList::iterator itL = distList->find( j );
254  if ( itL != distList->end() ) { // Entry associated to index j found.
255  if ( itL->second > value ) itL->second = value;
256  } else { // No entry associated to index j found. -> Insert new entry.
257  (*distList)[j] = value;
258  }
259 }
int j
Definition: DBlmapReader.cc:9
void KalmanAlignmentMetricsCalculator::insertPropagatedDistances ( FullDistancesList propagated)
private

Insert the 'propagated distances' into the lists of the remaining alignables.

Definition at line 175 of file KalmanAlignmentMetricsCalculator.cc.

References insertDistance(), and theDistances.

Referenced by updateDistances().

176 {
177  FullDistancesList::iterator itOld;
178  FullDistancesList::iterator itNew;
179 
180  for ( itNew = propagated.begin(); itNew != propagated.end(); ++itNew )
181  {
182  itOld = theDistances.find( itNew->first );
183  SingleDistancesList::iterator itL;
184  for ( itL = itNew->second->begin(); itL != itNew->second->end(); ++itL )
185  insertDistance( itOld->second, itL->first, itL->second );
186  }
187 }
void insertDistance(FullDistancesList &dist, Alignable *i, Alignable *j, short int value)
void KalmanAlignmentMetricsCalculator::insertUpdatedDistances ( FullDistancesList updated)
private

Insert changes due to the update of the lists of the current alignables.

Definition at line 161 of file KalmanAlignmentMetricsCalculator.cc.

References theDistances.

Referenced by updateDistances().

162 {
163  FullDistancesList::iterator itOld;
164  FullDistancesList::iterator itNew;
165 
166  for ( itNew = updated.begin(); itNew != updated.end(); ++itNew )
167  {
168  itOld = theDistances.find( itNew->first );
169  delete itOld->second;
170  itOld->second = itNew->second;
171  }
172 }
unsigned int KalmanAlignmentMetricsCalculator::nDistances ( void  ) const

Number of stored distances.

Definition at line 97 of file KalmanAlignmentMetricsCalculator.cc.

References theDistances.

98 {
99  unsigned int nod = 0;
100 
101  FullDistancesList::const_iterator itD;
102  for ( itD = theDistances.begin(); itD != theDistances.end(); ++itD ) nod += itD->second->size();
103 
104  return nod;
105 }
short int KalmanAlignmentMetricsCalculator::operator() ( Alignable i,
Alignable j 
) const

Return distance between two Alignables. If there is no metrical relation between the two Alignables -1 is returned.

Definition at line 83 of file KalmanAlignmentMetricsCalculator.cc.

References theDistances.

84 {
85  if ( i == j ) return 0;
86 
87  FullDistancesList::const_iterator itD = theDistances.find( i );
88  if ( itD == theDistances.end() ) return -1;
89 
90  SingleDistancesList::const_iterator itL = itD->second->find( j );
91  if ( itL == itD->second->end() ) return -1;
92 
93  return itL->second;
94 }
void KalmanAlignmentMetricsCalculator::readDistances ( std::string  filename)

Definition at line 268 of file KalmanAlignmentMetricsCalculator.cc.

269 {
270 
271 }
void KalmanAlignmentMetricsCalculator::setBranchAddresses ( TTree *  tree)
private

Definition at line 280 of file KalmanAlignmentMetricsCalculator.cc.

281 {
282 
283 }
void KalmanAlignmentMetricsCalculator::setMaxDistance ( short int  maxDistance)
inline

Set maximum distance to be stored.

Definition at line 40 of file KalmanAlignmentMetricsCalculator.h.

References theMaxDistance.

Referenced by SimpleMetricsUpdator::SimpleMetricsUpdator().

void KalmanAlignmentMetricsCalculator::updateDistances ( const std::vector< Alignable * > &  alignables)

Update list of distances with a set Alignables.

Definition at line 10 of file KalmanAlignmentMetricsCalculator.cc.

References clearDistances(), extractPropagatedDistances(), insertPropagatedDistances(), insertUpdatedDistances(), theDistances, and updateList().

Referenced by SimpleMetricsUpdator::update().

11 {
12  // List of the distances of the current alignables.
13  FullDistancesList currentDistances;
14 
15  // Updated list of the distances of the current alignables.
16  FullDistancesList updatedDistances;
17 
18  // List of distances between the current and all other alignables that changed due to the update of the list
19  // of the current alignables. This information has to be propagated to the lists of all other alignables.
20  FullDistancesList propagatedDistances;
21 
22  // Iterate over current alignables and set the distances between them to 1 - save pointers to
23  // their distances-lists for further manipulation.
24  std::vector< Alignable* >::const_iterator itA;
25  for ( itA = alignables.begin(); itA != alignables.end(); ++itA )
26  {
27  FullDistancesList::iterator itD = theDistances.find( *itA );
28 
29  if ( itD != theDistances.end() )
30  {
31  currentDistances[*itA] = itD->second;
32 
33  std::vector< Alignable* >::const_iterator itA2;
34  for ( itA2 = alignables.begin(); itA2 != alignables.end(); ++itA2 ) (*itD->second)[*itA2] = ( *itA == *itA2 ) ? 0 : 1;
35  }
36  else
37  {
39  theDistances[*itA] = newEntry;
40  currentDistances[*itA] = newEntry;
41 
42  std::vector< Alignable* >::const_iterator itA2;
43  for ( itA2 = alignables.begin(); itA2 != alignables.end(); ++itA2 ) (*newEntry)[*itA2] = ( *itA == *itA2 ) ? 0 : 1;
44  }
45  }
46 
47  // Iterate over the current alignables' distances-lists and compute updates.
48  FullDistancesList::iterator itC1;
49  FullDistancesList::iterator itC2;
50  for ( itC1 = currentDistances.begin(); itC1 != currentDistances.end(); ++itC1 )
51  {
52  SingleDistancesList* updatedList = new SingleDistancesList( *itC1->second );
53 
54  for ( itC2 = currentDistances.begin(); itC2 != currentDistances.end(); ++itC2 )
55  {
56  if ( itC1->first != itC2->first ) updateList( updatedList, itC2->second );
57  }
58 
59  extractPropagatedDistances( propagatedDistances, itC1->first, itC1->second, updatedList );
60  updatedDistances[itC1->first] = updatedList;
61  }
62 
63  // Insert the updated distances-lists.
64  insertUpdatedDistances( updatedDistances );
65 
66  // Insert the propagated distances-lists.
67  insertPropagatedDistances( propagatedDistances );
68 
69  // Used only temporary - clear it to deallocate its memory.
70  clearDistances( propagatedDistances );
71 }
const std::vector< Alignable * > alignables(void) const
Return all known alignables.
void insertPropagatedDistances(FullDistancesList &propagated)
Insert the &#39;propagated distances&#39; into the lists of the remaining alignables.
void updateList(SingleDistancesList *thisList, SingleDistancesList *otherList)
void insertUpdatedDistances(FullDistancesList &updated)
Insert changes due to the update of the lists of the current alignables.
void extractPropagatedDistances(FullDistancesList &changes, Alignable *alignable, SingleDistancesList *oldList, SingleDistancesList *newList)
Extract entries from the updated lists that need to be further propagated.
std::map< Alignable *, SingleDistancesList * > FullDistancesList
std::map< Alignable *, short int > SingleDistancesList
void KalmanAlignmentMetricsCalculator::updateList ( SingleDistancesList thisList,
SingleDistancesList otherList 
)
private

Update thisList with information from otherList - thisList and otherList are assumed to belong to different alignables.

Definition at line 134 of file KalmanAlignmentMetricsCalculator.cc.

References theMaxDistance.

Referenced by updateDistances().

136 {
137  SingleDistancesList::iterator itThis;
138  SingleDistancesList::iterator itOther;
139 
140  // Iterate through the ordered entries (via "<") of thisList and otherList.
141  for ( itThis = thisList->begin(), itOther = otherList->begin(); itOther != otherList->end(); ++itOther )
142  {
143  // Irrelevant information.
144  if ( itOther->second >= theMaxDistance ) continue;
145 
146  // Skip these elements of thisList - no new information available for them in otherList.
147  while ( itThis != thisList->end() && itThis->first < itOther->first ) ++itThis;
148 
149  // Insert new element ...
150  if ( itThis == thisList->end() || itThis->first > itOther->first ) {
151  (*thisList)[itOther->first] = itOther->second + 1;
152  // ... or write smaller distance for existing element.
153  } else if ( itThis->second > itOther->second ) {
154  itThis->second = itOther->second + 1;
155  }
156 
157  }
158 }
void KalmanAlignmentMetricsCalculator::writeDistances ( std::string  filename)

Definition at line 262 of file KalmanAlignmentMetricsCalculator.cc.

263 {
264 
265 }

Member Data Documentation

SingleDistancesList KalmanAlignmentMetricsCalculator::theDefaultReturnList
private

Definition at line 83 of file KalmanAlignmentMetricsCalculator.h.

Referenced by getDistances().

FullDistancesList KalmanAlignmentMetricsCalculator::theDistances
private
short int KalmanAlignmentMetricsCalculator::theMaxDistance
private

Definition at line 81 of file KalmanAlignmentMetricsCalculator.h.

Referenced by setMaxDistance(), and updateList().