24 declareProperty(
"Fraction", m_fraction);
25 declareProperty(
"FirstFraction", m_firstfraction);
26 declareInterface<IMode1dFinder>(
this);
32 #ifdef FSMWMODE1DFINDER_DEBUG
34 int debug_counter=200;
40 if(DoubleAndWeights.empty())
return 0.;
41 if(DoubleAndWeights.size() == 1)
return DoubleAndWeights.begin()->first;
43 #ifdef FSMWMODE1DFINDER_DEBUG
51 std::vector<DoubleAndWeight>::const_iterator
begin=DoubleAndWeights.begin();
52 std::vector<DoubleAndWeight>::const_iterator
end=DoubleAndWeights.end();
54 double overallweight(0.);
55 std::vector<DoubleAndWeight>::const_iterator best_begin=
begin;
56 std::vector<DoubleAndWeight>::const_iterator best_end=
end;
58 #ifdef FSMWMODE1DFINDER_DEBUG
63 double last_value(1e100);
76 #ifdef FSMWMODE1DFINDER_DEBUG
82 std::vector<DoubleAndWeight>::const_iterator
i=
begin;
84 std::vector<DoubleAndWeight>::const_iterator j_end=
i+
step-1;
85 for (std::vector<DoubleAndWeight>::const_iterator j=
i;j!=j_end;++j) {
86 #ifdef FSMWMODE1DFINDER_DEBUG
90 overallweight+=j->second;
95 std::vector<DoubleAndWeight>::const_iterator i_last =
begin+
step-1;
97 #ifdef FSMWMODE1DFINDER_DEBUG
100 for (std::vector<DoubleAndWeight>::const_iterator
i=
begin;
i!=(
end-
step+1);++
i, ++i_last) {
101 #ifdef FSMWMODE1DFINDER_DEBUG
106 overallweight+= i_last->second;
108 #ifdef FSMWMODE1DFINDER_DEBUG
112 double alt_overallweight=0.;
113 for (std::vector<DoubleAndWeight>::const_iterator j=
i;j!=
i+
step;j++) {
114 #ifdef FSMWMODE1DFINDER_DEBUG
118 alt_overallweight+=j->second;
120 if (std::abs(alt_overallweight - overallweight) > alt_overallweight * std::numeric_limits<double>::epsilon() * 16 ) {
121 ATH_MSG_ERROR(
"Weights differ: " << alt_overallweight <<
" != " << overallweight);
127 double new_value = ((
i+
step-1)->
first-
i->first)/overallweight;
128 if (new_value<last_value) {
129 #ifdef FSMWMODE1DFINDER_DEBUG
134 last_value=((
i+
step-1)->
first-
i->first)/overallweight;
138 overallweight-=
i->second;
142 #ifdef FSMWMODE1DFINDER_DEBUG
144 if (
begin==best_begin &&
end ==best_end) {
154 if (best_end-best_begin<=2) isthelast=
true;
162 if (best_end-best_begin==2)
164 std::vector<DoubleAndWeight>::const_iterator medium=
begin;
166 return (
begin->first*
begin->second+medium->first*medium->second+
end->first*
end->second)/(
begin->second+medium->second+
end->second);
179 #ifdef FSMWMODE1DFINDER_DEBUG
187 std::vector<double>::const_iterator
begin=Doubles.begin();
188 std::vector<double>::const_iterator
end=Doubles.end();
191 std::vector<double>::const_iterator best_begin=
begin;
192 std::vector<double>::const_iterator best_end=
end;
194 #ifdef FSMWMODE1DFINDER_DEBUG
199 double last_value(1e100);
201 bool isthelast=
false;
203 #ifdef FSMWMODE1DFINDER_DEBUG
207 #ifdef FSMWMODE1DFINDER_DEBUG
210 for (std::vector<double>::const_iterator
i=
begin;
i!=(
end-
step+1);++
i) {
211 #ifdef FSMWMODE1DFINDER_DEBUG
223 if ((*(
i+
step-1)-*
i)<last_value) {
224 #ifdef FSMWMODE1DFINDER_DEBUG
229 last_value=*(
i+
step-1)-*
i;
235 #ifdef FSMWMODE1DFINDER_DEBUG
245 if (best_end-best_begin<=2) isthelast=
true;
248 if (best_end-best_begin==2)
250 std::vector<double>::const_iterator medium=
begin;