CMS 3D CMS Logo

SMS Class Reference

Class to compute the SMS location estimator The SMS estimator is the mean value of a set of observations with Small Median of Squared distances. More...

#include <RecoVertex/VertexTools/interface/SMS.h>

List of all members.

Public Types

enum  SMSType { None = 0, Interpolate = 1, Iterate = 2, Weighted = 4 }

Public Member Functions

GlobalPoint location (const vector< pair< GlobalPoint, float > > &) const
GlobalPoint location (const vector< GlobalPoint > &) const
 SMS (SMSType tp=(SMSType)(Interpolate|Iterate|Weighted), float q=0.5)
 Constructor.

Private Attributes

float theRatio
SMSType theType


Detailed Description

Class to compute the SMS location estimator The SMS estimator is the mean value of a set of observations with Small Median of Squared distances.

Definition at line 18 of file SMS.h.


Member Enumeration Documentation

enum SMS::SMSType

Enumerator:
None 
Interpolate 
Iterate 
Weighted 

Definition at line 21 of file SMS.h.

00021                { None        = 0,
00022                  Interpolate = 1,
00023                  Iterate     = 2,
00024                  Weighted    = 4 };


Constructor & Destructor Documentation

SMS::SMS ( SMSType  tp = (SMSType) (Interpolate | Iterate | Weighted),
float  q = 0.5 
)

Constructor.

Parameters:
tp What specific kind of SMS algorithm do you want?
q What fraction of data points are considered for the "next step"?

Definition at line 73 of file SMS.cc.

00073 : theType(tp) , theRatio(q) {}


Member Function Documentation

GlobalPoint SMS::location ( const vector< pair< GlobalPoint, float > > &   )  const

GlobalPoint SMS::location ( const vector< GlobalPoint > &  data  )  const

Definition at line 76 of file SMS.cc.

References average(), GenMuonPlsPt100GeV_cfg::cout, funct::D, lat::endl(), i, int, Interpolate, Iterate, j, mergeAndRegister_online::pairs, python::multivaluedict::sort(), theRatio, theType, tmp, and Weighted.

Referenced by SmsModeFinder3d::operator()().

00077 {
00078   if ( theType & Weighted )
00079   {
00080     cout << "[SMS] warning: Weighted SMS was asked for, but data are "
00081          << "weightless!" << endl;
00082   };
00083   int nobs=data.size();
00084   int nq=(int) ceil( theRatio*nobs);
00085   // cout << "nobs= " << nobs << "  nq= " << nq << endl;
00086 
00087   // Compute distances
00088   vector<MyPair> pairs;
00089 
00090   for ( vector< GlobalPoint >::const_iterator i=data.begin(); i!=data.end() ; ++i )
00091   {
00092     vector < float > D;
00093     // Compute squared distances to all points
00094     for ( vector< GlobalPoint >::const_iterator j=data.begin(); j!=data.end() ; ++j )
00095     { D.push_back ( (*j - *i).mag2() ); }
00096     // Find q-quantile in each row of the distance matrix
00097     sort( D.begin(), D.end() );
00098     MyPair tmp (  D[nq-1], &(*i) );
00099     pairs.push_back ( tmp );
00100   };
00101 
00102   // Sort pairs by first element
00103   sort( pairs.begin(), pairs.end(), Sorter() );
00104   if ( !(theType & SMS::Interpolate) &&
00105        !(theType & SMS::Iterate) )
00106   {
00107     // we dont interpolate, we dont iterate, so we can stop right here.
00108     // cout << "No interpolation, no iteration" << endl;
00109     return *(pairs.begin()->second);
00110   };
00111 
00112   // we dont iterate, or we dont have anything to iterate (anymore?)
00113   // so we stop here
00114 
00115   // cout << "nobs= " << nobs << "  nq= " << nq << endl;
00116   if (!(theType & SMS::Iterate) || nq<=2)
00117     return average ( pairs, nq );
00118 
00119   // we iterate (recursively)
00120 
00121   vector < GlobalPoint > data1;
00122   vector<MyPair>::iterator j;
00123 
00124   for ( j=pairs.begin(); j-pairs.begin()<nq; ++j)
00125      data1.push_back(*(j->second));
00126 
00127   return this->location( data1 );
00128 
00129 }


Member Data Documentation

float SMS::theRatio [private]

Definition at line 38 of file SMS.h.

Referenced by location().

SMSType SMS::theType [private]

Definition at line 37 of file SMS.h.

Referenced by location().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:39 2009 for CMSSW by  doxygen 1.5.4