1 #ifndef _FsmwClusterizer1D_H_
2 #define _FsmwClusterizer1D_H_
27 std::pair < std::vector < Cluster1D<T> >, std::vector < const T * > >
43 namespace FsmwClusterizer1DNameSpace
51 std::pair < typename std::vector< Cluster1D<T> >::const_iterator,
52 typename std::vector< Cluster1D<T> >::const_iterator >
56 typename std::vector< Cluster1D >::const_iterator
begin =
values.begin();
57 typename std::vector< Cluster1D >::const_iterator
end =
values.end()-1;
61 #ifdef FsmwClusterizer1DDebug
62 cout <<
"Begin at " << begin->position().value() << endl;
65 const int size = (int) (end-begin);
66 #ifdef FsmwClusterizer1DDebug
68 cout <<
"Size " << size << endl;
74 #ifdef FsmwClusterizer1DDebug
76 cout <<
"Old end at " << end->position().value() << endl;
80 typename std::vector< Cluster1D >::const_iterator new_begin =
begin;
81 typename std::vector< Cluster1D >::const_iterator new_end =
end;
83 #ifdef FsmwClusterizer1DDebug
85 cout <<
"New end at " << end->position().value() << endl;
86 cout <<
"stepsize " << stepsize << endl;
94 double totalweight = end->weight();
95 for (
typename std::vector< Cluster1D >::const_iterator
w=begin;
w!=
end ; ++
w )
97 totalweight+=
w->weight();
100 double div=fabs ( end->position().value() - begin->position().value() ) /
102 #ifdef FsmwClusterizer1DDebug
104 cout <<
"Div at " << begin->position().value() <<
":" << (
end)->
position().value()
105 <<
" = " << div << endl;
108 for (
typename std::vector< Cluster1D >::const_iterator
i = (begin + 1);
109 i!=(begin + size - stepsize + 1); ++
i )
116 double tmpweight = 0.;
117 for (
typename std::vector< Cluster1D >::const_iterator wt=
i; wt!=(
i+stepsize+1); ++wt )
119 tmpweight+=wt->weight();
124 #ifdef FsmwClusterizer1DDebug
127 <<
" = " << tmpdiv << endl;
137 #ifdef FsmwClusterizer1DDebug
139 cout <<
"---- new interval: " << new_begin->position().value()
140 <<
":" << new_end->position().value() << endl;
149 std::pair < typename std::vector< Cluster1D >::const_iterator,
150 typename std::vector< Cluster1D >::const_iterator >
ret ( begin, end );
157 : theEstimator( o.theEstimator->
clone() ), theFraction ( o.theFraction ),
158 theNSigmaIn ( o.theNSigmaIn )
164 : theEstimator ( est.
clone() ), theFraction ( fraction ), theNSigmaIn ( nsig )
181 std::pair < std::vector< Cluster1D<T> >, std::vector< const T * > >
184 using namespace Clusterizer1DCommons;
185 using namespace FsmwClusterizer1DNameSpace;
187 std::vector < const T * > unusedtracks;
194 std::pair < std::vector < Cluster1D >, std::vector < const T * > >
ret ( ov, unusedtracks );
198 std::vector < Cluster1D >
v = ov;
200 std::vector < Cluster1D > sols;
202 std::pair < typename std::vector< Cluster1D >::const_iterator,
203 typename std::vector< Cluster1D >::const_iterator > estors
204 =
fsmw (
v, theFraction );
206 double weight = estors.first->weight() + estors.second->weight();
207 double est = ( estors.first->weight() * estors.first->position().value() +
208 estors.second->weight() * estors.second->position().value() ) /
211 double sigma =
sqrt (
square ( estors.first->position().value() - est ) +
212 square ( estors.second->position().value() - est ));
221 std::vector < const T * > trks;
224 for (
typename std::vector< Cluster1D >::iterator
i=
v.begin();
232 if ( fabs (
i->position().value() - est ) < theNSigmaIn * sigma )
235 add (
i->tracks(), trks );
236 err+=
square (
i->position().value() - est );
239 add (
i->tracks(), unusedtracks );
242 err /= ( inliers - 1 );
249 std::pair < std::vector < Cluster1D >, std::vector < const T * > >
ret ( sols, unusedtracks );
WeightEstimator< T > * theEstimator
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > operator()(const std::vector< Cluster1D< T > > &) const
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)
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
FsmwClusterizer1D(double fraction=.05, double n_sigma_in=3., const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
virtual FsmwClusterizer1D * clone() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
static int position[264][3]
double square(const double a)
tuple size
Write out results.