#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. | |
void | clear (void) |
Clear stored distances. | |
const SingleDistancesList & | getDistances (Alignable *i) const |
KalmanAlignmentMetricsCalculator (void) | |
unsigned int | nDistances (void) const |
Number of stored distances. | |
short int | operator() (Alignable *i, Alignable *j) const |
void | readDistances (std::string filename) |
void | setMaxDistance (short int maxDistance) |
Set maximum distance to be stored. | |
void | updateDistances (const std::vector< Alignable * > &alignables) |
Update list of distances with a set Alignables. | |
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. | |
void | insertDistance (SingleDistancesList *distList, Alignable *j, short int value) |
void | insertDistance (FullDistancesList &dist, Alignable *i, Alignable *j, short int value) |
void | insertPropagatedDistances (FullDistancesList &propagated) |
Insert the 'propagated distances' into the lists of the remaining alignables. | |
void | insertUpdatedDistances (FullDistancesList &updated) |
Insert changes due to the update of the lists of the current alignables. | |
void | setBranchAddresses (TTree *tree) |
void | updateList (SingleDistancesList *thisList, SingleDistancesList *otherList) |
Private Attributes | |
SingleDistancesList | theDefaultReturnList |
FullDistancesList | theDistances |
short int | theMaxDistance |
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.
typedef std::map< Alignable*, SingleDistancesList* > KalmanAlignmentMetricsCalculator::FullDistancesList |
Definition at line 23 of file KalmanAlignmentMetricsCalculator.h.
typedef std::map< Alignable*, short int > KalmanAlignmentMetricsCalculator::SingleDistancesList |
Definition at line 22 of file KalmanAlignmentMetricsCalculator.h.
KalmanAlignmentMetricsCalculator::KalmanAlignmentMetricsCalculator | ( | void | ) |
Definition at line 4 of file KalmanAlignmentMetricsCalculator.cc.
: theMaxDistance( SHRT_MAX ) {}
KalmanAlignmentMetricsCalculator::~KalmanAlignmentMetricsCalculator | ( | void | ) |
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().
{ std::vector< Alignable* > alignables; alignables.reserve( theDistances.size() ); for ( FullDistancesList::const_iterator itL = theDistances.begin(); itL != theDistances.end(); ++itL ) alignables.push_back( itL->first ); return alignables; }
void KalmanAlignmentMetricsCalculator::clear | ( | void | ) |
Clear stored distances.
Definition at line 108 of file KalmanAlignmentMetricsCalculator.cc.
References clearDistances(), and theDistances.
Referenced by ~KalmanAlignmentMetricsCalculator().
{ clearDistances( theDistances ); }
void KalmanAlignmentMetricsCalculator::clearDistances | ( | FullDistancesList & | dist | ) | [private] |
Definition at line 126 of file KalmanAlignmentMetricsCalculator.cc.
Referenced by clear(), and updateDistances().
{ FullDistancesList::iterator itD; for ( itD = dist.begin(); itD != dist.end(); ++itD ) delete itD->second; dist.clear(); }
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 extractPropagatedDistances().
{ SingleDistancesList::iterator itL; for ( itL = connection->begin(); itL != connection->end(); ++itL ) { if ( itL->first != alignable ) insertDistance( changes, alignable, itL->first, value + itL->second ); } }
void KalmanAlignmentMetricsCalculator::createBranches | ( | TTree * | tree | ) | [private] |
Definition at line 274 of file KalmanAlignmentMetricsCalculator.cc.
{ }
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().
{ SingleDistancesList::iterator itOld; SingleDistancesList::iterator itNew; SingleDistancesList newConnections; // Distances-list newList has at least entries for the same indices as distances-list // oldList. For this reason 'newList->begin()->first <= oldList->begin()->first' and // hence 'itNew->first <= itOld->first' is always true in the loop below. for ( itOld = oldList->begin(), itNew = newList->begin(); itNew != newList->end(); ++itNew ) { // No entry associated to index itNew->first present in oldList. --> This is indeed a change. if ( itOld == oldList->end() || itNew->first < itOld->first ) { insertDistance( changes, itNew->first, alignable, itNew->second ); newConnections[itNew->first] = itNew->second; // Entry associated to index itNew->first present in oldList. --> Check if it has changed. } else if ( itNew->first == itOld->first ) { if ( itNew->second != itOld->second ) insertDistance( changes, itNew->first, alignable, itNew->second ); ++itOld; } } SingleDistancesList::iterator it; for ( it = newConnections.begin(); it != newConnections.end(); ++it ) connect( changes, newList, it->first, it->second ); }
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().
{ FullDistancesList::const_iterator itD = theDistances.find( i ); if ( itD == theDistances.end() ) return theDefaultReturnList; return *itD->second; }
void KalmanAlignmentMetricsCalculator::insertDistance | ( | SingleDistancesList * | distList, |
Alignable * | j, | ||
short int | value | ||
) | [private] |
Definition at line 251 of file KalmanAlignmentMetricsCalculator.cc.
References j, and relativeConstraints::value.
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().
{ FullDistancesList::iterator itD = dist.find( i ); if ( itD != dist.end() ) // Found distances-list for index i. { insertDistance( itD->second, j, value ); } else // No distances-list found for value i. { SingleDistancesList* newList = new SingleDistancesList; (*newList)[j] = value; dist[i] = newList; } }
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().
{ FullDistancesList::iterator itOld; FullDistancesList::iterator itNew; for ( itNew = propagated.begin(); itNew != propagated.end(); ++itNew ) { itOld = theDistances.find( itNew->first ); SingleDistancesList::iterator itL; for ( itL = itNew->second->begin(); itL != itNew->second->end(); ++itL ) insertDistance( itOld->second, itL->first, itL->second ); } }
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().
{ FullDistancesList::iterator itOld; FullDistancesList::iterator itNew; for ( itNew = updated.begin(); itNew != updated.end(); ++itNew ) { itOld = theDistances.find( itNew->first ); delete itOld->second; itOld->second = itNew->second; } }
unsigned int KalmanAlignmentMetricsCalculator::nDistances | ( | void | ) | const |
Number of stored distances.
Definition at line 97 of file KalmanAlignmentMetricsCalculator.cc.
References theDistances.
{ unsigned int nod = 0; FullDistancesList::const_iterator itD; for ( itD = theDistances.begin(); itD != theDistances.end(); ++itD ) nod += itD->second->size(); return nod; }
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.
{ if ( i == j ) return 0; FullDistancesList::const_iterator itD = theDistances.find( i ); if ( itD == theDistances.end() ) return -1; SingleDistancesList::const_iterator itL = itD->second->find( j ); if ( itL == itD->second->end() ) return -1; return itL->second; }
void KalmanAlignmentMetricsCalculator::readDistances | ( | std::string | filename | ) |
Definition at line 268 of file KalmanAlignmentMetricsCalculator.cc.
{ }
void KalmanAlignmentMetricsCalculator::setBranchAddresses | ( | TTree * | tree | ) | [private] |
Definition at line 280 of file KalmanAlignmentMetricsCalculator.cc.
{ }
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().
{ theMaxDistance = maxDistance; }
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().
{ // List of the distances of the current alignables. FullDistancesList currentDistances; // Updated list of the distances of the current alignables. FullDistancesList updatedDistances; // List of distances between the current and all other alignables that changed due to the update of the list // of the current alignables. This information has to be propagated to the lists of all other alignables. FullDistancesList propagatedDistances; // Iterate over current alignables and set the distances between them to 1 - save pointers to // their distances-lists for further manipulation. std::vector< Alignable* >::const_iterator itA; for ( itA = alignables.begin(); itA != alignables.end(); ++itA ) { FullDistancesList::iterator itD = theDistances.find( *itA ); if ( itD != theDistances.end() ) { currentDistances[*itA] = itD->second; std::vector< Alignable* >::const_iterator itA2; for ( itA2 = alignables.begin(); itA2 != alignables.end(); ++itA2 ) (*itD->second)[*itA2] = ( *itA == *itA2 ) ? 0 : 1; } else { SingleDistancesList* newEntry = new SingleDistancesList; theDistances[*itA] = newEntry; currentDistances[*itA] = newEntry; std::vector< Alignable* >::const_iterator itA2; for ( itA2 = alignables.begin(); itA2 != alignables.end(); ++itA2 ) (*newEntry)[*itA2] = ( *itA == *itA2 ) ? 0 : 1; } } // Iterate over the current alignables' distances-lists and compute updates. FullDistancesList::iterator itC1; FullDistancesList::iterator itC2; for ( itC1 = currentDistances.begin(); itC1 != currentDistances.end(); ++itC1 ) { SingleDistancesList* updatedList = new SingleDistancesList( *itC1->second ); for ( itC2 = currentDistances.begin(); itC2 != currentDistances.end(); ++itC2 ) { if ( itC1->first != itC2->first ) updateList( updatedList, itC2->second ); } extractPropagatedDistances( propagatedDistances, itC1->first, itC1->second, updatedList ); updatedDistances[itC1->first] = updatedList; } // Insert the updated distances-lists. insertUpdatedDistances( updatedDistances ); // Insert the propagated distances-lists. insertPropagatedDistances( propagatedDistances ); // Used only temporary - clear it to deallocate its memory. clearDistances( propagatedDistances ); }
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().
{ SingleDistancesList::iterator itThis; SingleDistancesList::iterator itOther; // Iterate through the ordered entries (via "<") of thisList and otherList. for ( itThis = thisList->begin(), itOther = otherList->begin(); itOther != otherList->end(); ++itOther ) { // Irrelevant information. if ( itOther->second >= theMaxDistance ) continue; // Skip these elements of thisList - no new information available for them in otherList. while ( itThis != thisList->end() && itThis->first < itOther->first ) ++itThis; // Insert new element ... if ( itThis == thisList->end() || itThis->first > itOther->first ) { (*thisList)[itOther->first] = itOther->second + 1; // ... or write smaller distance for existing element. } else if ( itThis->second > itOther->second ) { itThis->second = itOther->second + 1; } } }
void KalmanAlignmentMetricsCalculator::writeDistances | ( | std::string | filename | ) |
Definition at line 262 of file KalmanAlignmentMetricsCalculator.cc.
{ }
Definition at line 83 of file KalmanAlignmentMetricsCalculator.h.
Referenced by getDistances().
Definition at line 80 of file KalmanAlignmentMetricsCalculator.h.
Referenced by alignables(), clear(), getDistances(), insertPropagatedDistances(), insertUpdatedDistances(), nDistances(), operator()(), and updateDistances().
short int KalmanAlignmentMetricsCalculator::theMaxDistance [private] |
Definition at line 81 of file KalmanAlignmentMetricsCalculator.h.
Referenced by setMaxDistance(), and updateList().