CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
SMS Class Reference

#include <SMS.h>

Public Types

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

Public Member Functions

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

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 16 of file SMS.h.

Member Enumeration Documentation

Enumerator
None 
Interpolate 
Iterate 
Weighted 

Definition at line 19 of file SMS.h.

19  { None = 0,
20  Interpolate = 1,
21  Iterate = 2,
22  Weighted = 4 };
Definition: SMS.h:19

Constructor & Destructor Documentation

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

Constructor.

Parameters
tpWhat specific kind of SMS algorithm do you want?
qWhat fraction of data points are considered for the "next step"?

Definition at line 73 of file SMS.cc.

73 : theType(tp) , theRatio(q) {}
SMSType theType
Definition: SMS.h:35
float theRatio
Definition: SMS.h:36

Member Function Documentation

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

Definition at line 76 of file SMS.cc.

References gather_cfg::cout, debug, mps_fire::i, createfilelist::int, Interpolate, Iterate, gen::k, mag2(), PixelPairStep_cff::points, theRatio, theType, tmp, and Weighted.

Referenced by SmsModeFinder3d::operator()().

77 {
78  if ( theType & Weighted )
79  {
80  std::cout << "[SMS] warning: Weighted SMS was asked for, but data are "
81  << "weightless!" << std::endl;
82  };
83  int nobs=data.size();
84  int nq=(int) ceil( theRatio*nobs);
85  // cout << "nobs= " << nobs << " nq= " << nq << endl;
86 
87  // Compute distances
88  std::vector<MyPair> pairs;
89 
90  for ( std::vector< GlobalPoint >::const_iterator i=data.begin(); i!=data.end() ; ++i )
91  {
92  std::vector < float > D;
93  // Compute squared distances to all points
94  for ( std::vector< GlobalPoint >::const_iterator j=data.begin(); j!=data.end() ; ++j )
95  { D.push_back ( (*j - *i).mag2() ); }
96  // Find q-quantile in each row of the distance matrix
97  sort( D.begin(), D.end() );
98  MyPair tmp ( D[nq-1], &(*i) );
99  pairs.push_back ( tmp );
100  };
101 
102  // Sort pairs by first element
103  sort( pairs.begin(), pairs.end(), Sorter() );
104  if ( !(theType & SMS::Interpolate) &&
105  !(theType & SMS::Iterate) )
106  {
107  // we dont interpolate, we dont iterate, so we can stop right here.
108  // cout << "No interpolation, no iteration" << endl;
109  return *(pairs.begin()->second);
110  };
111 
112  // we dont iterate, or we dont have anything to iterate (anymore?)
113  // so we stop here
114 
115  // cout << "nobs= " << nobs << " nq= " << nq << endl;
116  if (!(theType & SMS::Iterate) || nq<=2)
117  return average ( pairs, nq );
118 
119  // we iterate (recursively)
120 
121  std::vector < GlobalPoint > data1;
122  std::vector<MyPair>::iterator j;
123 
124  for ( j=pairs.begin(); j-pairs.begin()<nq; ++j)
125  data1.push_back(*(j->second));
126 
127  return this->location( data1 );
128 
129 }
SMSType theType
Definition: SMS.h:35
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
float theRatio
Definition: SMS.h:36
GlobalPoint location(const std::vector< GlobalPoint > &) const
Definition: SMS.cc:76
GlobalPoint SMS::location ( const std::vector< std::pair< GlobalPoint, float > > &  ) const

Member Data Documentation

float SMS::theRatio
private

Definition at line 36 of file SMS.h.

Referenced by location().

SMSType SMS::theType
private

Definition at line 35 of file SMS.h.

Referenced by location().