1 #ifndef _FsmwClusterizer1D_H_
2 #define _FsmwClusterizer1D_H_
22 double n_sigma_in = 3.,
27 std::pair<std::vector<Cluster1D<T> >, std::vector<const T*> >
operator()(
50 std::pair<typename std::vector<Cluster1D<T> >::const_iterator,
typename std::vector<Cluster1D<T> >::const_iterator>
53 typename std::vector<Cluster1D>::const_iterator
begin =
values.begin();
54 typename std::vector<Cluster1D>::const_iterator
end =
values.end() - 1;
57 #ifdef FsmwClusterizer1DDebug
58 cout <<
"Begin at " <<
begin->position().value() << endl;
62 #ifdef FsmwClusterizer1DDebug
70 #ifdef FsmwClusterizer1DDebug
72 cout <<
"Old end at " <<
end->position().value() << endl;
76 typename std::vector<Cluster1D>::const_iterator new_begin =
begin;
77 typename std::vector<Cluster1D>::const_iterator new_end =
end;
79 #ifdef FsmwClusterizer1DDebug
81 cout <<
"New end at " <<
end->position().value() << endl;
90 double totalweight =
end->weight();
91 for (
typename std::vector<Cluster1D>::const_iterator
w =
begin;
w !=
end; ++
w) {
92 totalweight +=
w->weight();
95 double div = fabs(
end->position().value() -
begin->position().value()) / totalweight;
96 #ifdef FsmwClusterizer1DDebug
98 cout <<
"Div at " <<
begin->position().value() <<
":" << (
end)->
position().value() <<
" = " << div << endl;
107 double tmpweight = 0.;
108 for (
typename std::vector<Cluster1D>::const_iterator wt =
i; wt != (
i +
stepsize + 1); ++wt) {
109 tmpweight += wt->weight();
112 double tmpdiv = fabs(
i->position().value() - (
i +
stepsize)->
position().value()) / tmpweight;
113 #ifdef FsmwClusterizer1DDebug
115 cout <<
"Div at " <<
i->position().value() <<
":" << (
i +
stepsize)->
position().value() <<
" = " << tmpdiv
125 #ifdef FsmwClusterizer1DDebug
127 cout <<
"---- new interval: " << new_begin->position().value() <<
":" << new_end->position().value() << endl;
136 std::pair<typename std::vector<Cluster1D>::const_iterator,
typename std::vector<Cluster1D>::const_iterator>
ret(
144 : theEstimator(
o.theEstimator->
clone()), theFraction(
o.theFraction), theNSigmaIn(
o.theNSigmaIn) {}
148 : theEstimator(est.
clone()), theFraction(
fraction), theNSigmaIn(nsig) {}
166 std::vector<const T*> unusedtracks;
172 std::pair<std::vector<Cluster1D>, std::vector<const T*> >
ret(ov, unusedtracks);
176 std::vector<Cluster1D>
v = ov;
178 std::vector<Cluster1D> sols;
180 std::pair<typename std::vector<Cluster1D>::const_iterator,
typename std::vector<Cluster1D>::const_iterator> estors =
181 fsmw(
v, theFraction);
183 double weight = estors.first->weight() + estors.second->weight();
184 double est = (estors.first->weight() * estors.first->position().value() +
185 estors.second->weight() * estors.second->position().value()) /
188 double sigma =
sqrt(
square(estors.first->position().value() - est) +
square(estors.second->position().value() - est));
197 std::vector<const T*> trks;
200 for (
typename std::vector<Cluster1D>::iterator
i =
v.begin();
i !=
v.end(); ++
i) {
206 if (fabs(
i->position().value() - est) < theNSigmaIn * sigma) {
208 add(
i->tracks(), trks);
212 add(
i->tracks(), unusedtracks);
215 err /= (inliers - 1);
221 std::pair<std::vector<Cluster1D>, std::vector<const T*> >
ret(sols, unusedtracks);