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

◆ SMSType

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::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.

Member Function Documentation

◆ location() [1/2]

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, data, mps_fire::i, createfilelist::int, Interpolate, Iterate, dqmiolumiharvest::j, mag2(), jetUpdater_cfi::sort, 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
GlobalPoint location(const std::vector< GlobalPoint > &) const
Definition: SMS.cc:57
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
float theRatio
Definition: SMS.h:32
tmp
align.sh
Definition: createJobs.py:716

◆ location() [2/2]

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

Member Data Documentation

◆ theRatio

float SMS::theRatio
private

Definition at line 32 of file SMS.h.

Referenced by location().

◆ theType

SMSType SMS::theType
private

Definition at line 31 of file SMS.h.

Referenced by location().