CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoVertex/VertexTools/src/hsm_3d.cc

Go to the documentation of this file.
00001 #include "RecoVertex/VertexTools/interface/hsm_3d.h"
00002 #include "CommonTools/Statistics/interface/hsm_1d.icc"
00003 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00004 
00005 #include <iostream>
00006 
00008 GlobalPoint hsm_3d ( const std::vector<GlobalPoint> & values )
00009 {
00010   const int sze = values.size();
00011   if ( sze == 0 ) {
00012       throw VertexException("hsm_3d: no values given.");
00013   };
00014   std::vector <float> x_vals, y_vals, z_vals;
00015   x_vals.reserve(sze-1);
00016   y_vals.reserve(sze-1);
00017   z_vals.reserve(sze-1);
00018   for ( std::vector<GlobalPoint>::const_iterator i=values.begin();
00019       i!=values.end() ; i++ )
00020   {
00021     x_vals.push_back( i->x() );
00022     y_vals.push_back( i->y() );
00023     z_vals.push_back( i->z() );
00024   };
00025 
00026   // FIXME isnt necessary, is it?
00027   /*
00028   sort ( x_vals.begin(), x_vals.end() );
00029   sort ( y_vals.begin(), y_vals.end() );
00030   sort ( z_vals.begin(), z_vals.end() );*/
00031 
00032   GlobalPoint ret ( hsm_1d(x_vals), hsm_1d(y_vals), hsm_1d(z_vals) );
00033   return ret;
00034 }