CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/Alignment/CommonAlignment/src/AlignmentParametersData.cc

Go to the documentation of this file.
00001 #include "Alignment/CommonAlignment/interface/AlignmentParametersData.h"
00002 
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 
00005 #include <algorithm>
00006 #include <functional>
00007 
00008 
00009 AlignmentParametersData::AlignmentParametersData( void ) :
00010   theParameters( new AlgebraicVector() ),
00011   theCovariance( new AlgebraicSymMatrix() ),
00012   theSelector( new std::vector<bool>() ),
00013   theNumSelected( 0 )
00014 {}
00015 
00016 
00017 AlignmentParametersData::AlignmentParametersData( AlgebraicVector* param,
00018                                                   AlgebraicSymMatrix* cov,
00019                                                   std::vector<bool>* sel ) :
00020   theParameters( param ),
00021   theCovariance( cov ),
00022   theSelector( sel )
00023 {
00024   theNumSelected = std::count_if( theSelector->begin(),
00025                                   theSelector->end(),
00026                                   std::bind2nd( std::equal_to<bool>(), true ) );
00027 }
00028 
00029 
00030 AlignmentParametersData::AlignmentParametersData( const AlgebraicVector& param,
00031                                                   const AlgebraicSymMatrix& cov,
00032                                                   const std::vector<bool>& sel ) :
00033   theParameters( new AlgebraicVector( param ) ),
00034   theCovariance( new AlgebraicSymMatrix( cov ) ),
00035   theSelector( new std::vector<bool>( sel ) )
00036 {
00037   theNumSelected = std::count_if( theSelector->begin(),
00038                                   theSelector->end(),
00039                                   std::bind2nd( std::equal_to<bool>(), true ) );
00040 }
00041 
00042 
00043 AlignmentParametersData::AlignmentParametersData( AlgebraicVector* param,
00044                                                   AlgebraicSymMatrix* cov ) :
00045   theParameters( param ),
00046   theCovariance( cov ),
00047   theSelector( new std::vector<bool>( param->num_row(), true ) ),
00048   theNumSelected( param->num_row() )
00049 {}
00050 
00051 
00052 AlignmentParametersData::AlignmentParametersData( const AlgebraicVector& param,
00053                                                   const AlgebraicSymMatrix& cov ) :
00054   theParameters( new AlgebraicVector( param ) ),
00055   theCovariance( new AlgebraicSymMatrix( cov ) ),
00056   theSelector( new std::vector<bool>( param.num_row(), true ) ),
00057   theNumSelected( param.num_row() )
00058 {}
00059 
00060 
00061 AlignmentParametersData::~AlignmentParametersData( void )
00062 {
00063   delete theParameters;
00064   delete theCovariance;
00065   delete theSelector;
00066 }
00067 
00068 
00069 void AlignmentParametersData::checkConsistency( void ) const
00070 {
00071   int selectorSize = static_cast<int>( theSelector->size() );
00072   int paramSize = theParameters->num_row();
00073   int covSize = theCovariance->num_row();
00074 
00075   if ( ( paramSize != covSize ) || ( paramSize != selectorSize ) )
00076       throw cms::Exception("LogicError") << "@SUB=AlignmentParametersData::checkConsistency "
00077                                          << "\nSize mismatch: parameter size = " << paramSize
00078                                          << ", covariance size = " << covSize
00079                                          << ", selector size = " << selectorSize << ".";
00080 }