CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/RecoVertex/VertexTools/src/FsmwModeFinder3d.cc

Go to the documentation of this file.
00001 #include "CommonTools/Clustering1D/interface/FsmwClusterizer1D.h"
00002 #include "RecoVertex/VertexTools/interface/FsmwModeFinder3d.h"
00003 
00004 #include <cmath>
00005 #include <cassert>
00006 
00010 FsmwModeFinder3d::FsmwModeFinder3d( float fraction, float weightExp,
00011                                     float cutoff, int no_w_a ) : theFraction ( fraction ),
00012         theWeightExponent ( weightExp ), theCutoff(cutoff),
00013         theNoWeightsAbove ( no_w_a )
00014 {
00015     assert ( theFraction > 0. && theFraction < 1. );
00016 }
00017 
00018 GlobalPoint FsmwModeFinder3d::operator() (
00019     const std::vector< PointAndDistance> & values ) const
00020 {
00021     typedef Cluster1D<void> SimpleCluster;
00022     std::vector< SimpleCluster > vx, vy, vz;
00023     vx.reserve ( values.size() - 1 );
00024     vy.reserve ( values.size() - 1 );
00025     vz.reserve ( values.size() - 1 );
00026     std::vector < const void * > emptyvec;
00027 
00028     for ( std::vector< PointAndDistance >::const_iterator i = values.begin();
00029           i != values.end(); ++i )
00030     {
00031         float weight = 1.;
00032         if ( static_cast<int>( values.size() ) < theNoWeightsAbove )
00033         {
00034             // compute weights if we have fewer than theNoWeightsAbove
00035             // data points
00036             weight = pow ( theCutoff + 10000 * i->second, theWeightExponent );
00037         };
00038 
00039         SimpleCluster tmp_x ( Measurement1D ( i->first.x(), 1.0 ),
00040                               emptyvec, weight );
00041         SimpleCluster tmp_y ( Measurement1D ( i->first.y(), 1.0 ),
00042                               emptyvec, weight );
00043         SimpleCluster tmp_z ( Measurement1D ( i->first.z(), 1.0 ),
00044                               emptyvec, weight );
00045         vx.push_back ( tmp_x );
00046         vy.push_back ( tmp_y );
00047         vz.push_back ( tmp_z );
00048     };
00049 
00050     FsmwClusterizer1D<void> algo( theFraction );
00051     std::vector < SimpleCluster > cresx = algo(vx).first;
00052     std::vector < SimpleCluster > cresy = algo(vy).first;
00053     std::vector < SimpleCluster > cresz = algo(vz).first;
00054     assert ( cresx.size() && cresy.size() && cresz.size() );
00055 
00056     GlobalPoint ret ( cresx.begin()->position().value(),
00057                       cresy.begin()->position().value(),
00058                       cresz.begin()->position().value() );
00059     return ret;
00060 }
00061 
00062 FsmwModeFinder3d * FsmwModeFinder3d::clone() const
00063 {
00064     return new FsmwModeFinder3d( *this );
00065 }
00066 
00067