CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 18 of file SMS.h.

18 { None = 0, Interpolate = 1, Iterate = 2, Weighted = 4 };
Definition: SMS.h:18

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 55 of file SMS.cc.

55 : theType(tp), theRatio(q) {}
SMSType theType
Definition: SMS.h:31
float theRatio
Definition: SMS.h:32

Member Function Documentation

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

Definition at line 57 of file SMS.cc.

References PDRates::average, reco::ceil(), gather_cfg::cout, mps_fire::i, Interpolate, Iterate, dqmiolumiharvest::j, mag2(), theRatio, theType, createJobs::tmp, and Weighted.

Referenced by SmsModeFinder3d::operator()().

57  {
58  if (theType & Weighted) {
59  std::cout << "[SMS] warning: Weighted SMS was asked for, but data are "
60  << "weightless!" << std::endl;
61  };
62  int nobs = data.size();
63  int nq = (int)ceil(theRatio * nobs);
64  // cout << "nobs= " << nobs << " nq= " << nq << endl;
65 
66  // Compute distances
67  std::vector<MyPair> pairs;
68 
69  for (std::vector<GlobalPoint>::const_iterator i = data.begin(); i != data.end(); ++i) {
70  std::vector<float> D;
71  // Compute squared distances to all points
72  for (std::vector<GlobalPoint>::const_iterator j = data.begin(); j != data.end(); ++j) {
73  D.push_back((*j - *i).mag2());
74  }
75  // Find q-quantile in each row of the distance matrix
76  sort(D.begin(), D.end());
77  MyPair tmp(D[nq - 1], &(*i));
78  pairs.push_back(tmp);
79  };
80 
81  // Sort pairs by first element
82  sort(pairs.begin(), pairs.end(), Sorter());
83  if (!(theType & SMS::Interpolate) && !(theType & SMS::Iterate)) {
84  // we dont interpolate, we dont iterate, so we can stop right here.
85  // cout << "No interpolation, no iteration" << endl;
86  return *(pairs.begin()->second);
87  };
88 
89  // we dont iterate, or we dont have anything to iterate (anymore?)
90  // so we stop here
91 
92  // cout << "nobs= " << nobs << " nq= " << nq << endl;
93  if (!(theType & SMS::Iterate) || nq <= 2)
94  return average(pairs, nq);
95 
96  // we iterate (recursively)
97 
98  std::vector<GlobalPoint> data1;
99  std::vector<MyPair>::iterator j;
100 
101  for (j = pairs.begin(); j - pairs.begin() < nq; ++j)
102  data1.push_back(*(j->second));
103 
104  return this->location(data1);
105 }
constexpr int32_t ceil(float num)
SMSType theType
Definition: SMS.h:31
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
int average
Definition: PDRates.py:138
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
tuple cout
Definition: gather_cfg.py:144
float theRatio
Definition: SMS.h:32
tmp
align.sh
Definition: createJobs.py:716
GlobalPoint location(const std::vector< GlobalPoint > &) const
Definition: SMS.cc:57
GlobalPoint SMS::location ( const std::vector< std::pair< GlobalPoint, float > > &  ) const

Member Data Documentation

float SMS::theRatio
private

Definition at line 32 of file SMS.h.

Referenced by location().

SMSType SMS::theType
private

Definition at line 31 of file SMS.h.

Referenced by location().