![]() |
![]() |
#include <RecoVertex/VertexTools/interface/SMS.h>
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 |
Definition at line 18 of file SMS.h.
enum SMS::SMSType |
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 }
float SMS::theRatio [private] |
SMSType SMS::theType [private] |