CMS 3D CMS Logo

Functions
FsmwClusterizer1DNameSpace Namespace Reference

Functions

template<class T >
std::pair< typename std::vector< Cluster1D< T > >::const_iterator, typename std::vector< Cluster1D< T > >::const_iterator > fsmw (const std::vector< Cluster1D< T > > &values, double fraction)
 

Function Documentation

template<class T >
std::pair< typename std::vector< Cluster1D<T> >::const_iterator,typename std::vector< Cluster1D<T> >::const_iterator > FsmwClusterizer1DNameSpace::fsmw ( const std::vector< Cluster1D< T > > &  values,
double  fraction 
)

Definition at line 53 of file FsmwClusterizer1D.h.

References begin, gather_cfg::cout, end, dedxEstimators_cff::fraction, FsmwClusterizer1D< T >::FsmwClusterizer1D(), mps_fire::i, createfilelist::int, connectstrParser::o, position, findQualityFiles::size, createBeamHaloJobs::stepsize, FsmwClusterizer1D< T >::theEstimator, FsmwClusterizer1D< T >::theFraction, FsmwClusterizer1D< T >::theNSigmaIn, MuonErrorMatrixValues_cff::values, and w.

Referenced by FsmwClusterizer1D< T >::operator()().

54 {
55  typedef Cluster1D<T> Cluster1D;
56  typename std::vector< Cluster1D >::const_iterator begin = values.begin();
57  typename std::vector< Cluster1D >::const_iterator end = values.end()-1;
58 
59  while (1)
60  {
61 #ifdef FsmwClusterizer1DDebug
62  cout << "Begin at " << begin->position().value() << endl;
63 #endif
64 
65  const int size = (int) (end-begin);
66 #ifdef FsmwClusterizer1DDebug
67 
68  cout << "Size " << size << endl;
69 #endif
70 
71  int stepsize = (int) floor ( ( 1+ size ) * fraction );
72  if ( stepsize == 0 )
73  stepsize=1;
74 #ifdef FsmwClusterizer1DDebug
75 
76  cout << "Old end at " << end->position().value() << endl;
77 #endif
78 
79  end=begin+stepsize;
80  typename std::vector< Cluster1D >::const_iterator new_begin = begin;
81  typename std::vector< Cluster1D >::const_iterator new_end = end;
82 
83 #ifdef FsmwClusterizer1DDebug
84 
85  cout << "New end at " << end->position().value() << endl;
86  cout << "stepsize " << stepsize << endl;
87 #endif
88 
89  // Old version: used the weights of just the end points
90  // double totalweight = begin->weight() + end->weight();
91 
92  // new version: sums up the weights of all points involved
93  // _including_ the "end" point
94  double totalweight = end->weight();
95  for ( typename std::vector< Cluster1D >::const_iterator w=begin; w!=end ; ++w )
96  {
97  totalweight+=w->weight();
98  };
99 
100  double div=fabs ( end->position().value() - begin->position().value() ) /
101  totalweight;
102 #ifdef FsmwClusterizer1DDebug
103 
104  cout << "Div at " << begin->position().value() << ":" << (end)->position().value()
105  << " = " << div << endl;
106 #endif
107 
108  for ( typename std::vector< Cluster1D >::const_iterator i = (begin + 1);
109  i!=(begin + size - stepsize + 1); ++i )
110  {
111  // FIXME wrong
112  // double tmpweight = i->weight() + (i+stepsize)->weight();
113  //
114  // new version: sums up the weights of all points in the interval
115  // _including_ the end point (i+stepsize)
116  double tmpweight = 0.;
117  for ( typename std::vector< Cluster1D >::const_iterator wt=i; wt!=(i+stepsize+1); ++wt )
118  {
119  tmpweight+=wt->weight();
120  };
121 
122  double tmpdiv = fabs( i->position().value() - (i+stepsize)->position().value() )
123  / tmpweight;
124 #ifdef FsmwClusterizer1DDebug
125 
126  cout << "Div at " << i->position().value() << ":" << (i+stepsize)->position().value()
127  << " = " << tmpdiv << endl;
128 #endif
129 
130  if ( tmpdiv < div)
131  {
132  new_begin= i;
133  new_end = i+stepsize;
134  div= tmpdiv;
135  };
136  };
137 #ifdef FsmwClusterizer1DDebug
138 
139  cout << "---- new interval: " << new_begin->position().value()
140  << ":" << new_end->position().value() << endl;
141 #endif
142 
143  begin = new_begin;
144  end = new_end;
145  if ( size < 4 )
146  break;
147  };
148 
149  std::pair < typename std::vector< Cluster1D >::const_iterator,
150  typename std::vector< Cluster1D >::const_iterator > ret ( begin, end );
151  return ret;
152 }
size
Write out results.
const double w
Definition: UKUtility.cc:23
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
static int position[264][3]
Definition: ReadPGInfo.cc:509