34 RobustEstimateZapper ();
38 void set_error_bar (
bool flag) { error = flag; }
41 bool get_log ()
const {
return logarithmic; }
42 void set_log (
bool flag) { logarithmic = flag; }
46 void set_scale (
bool flag) { scale = flag; }
50 void set_cutoff_threshold (
float val) { threshold_max = threshold_min = val; }
54 void set_cutoff_threshold_min (
float val) { threshold_min = val; }
58 void set_cutoff_threshold_max (
float val) { threshold_max = val; }
65 float get_value (
const Estimate<float>& datum)
70 val = sqrt(datum.
var);
80 template<
class Container,
class Size,
class Get,
class Val
id>
81 void excise (
unsigned iparam, Container* container, Size size, Get get, Valid valid)
83 unsigned npt = (container->*size)();
84 DEBUG(
"RobustEstimateZapper::excise iparam=" << iparam <<
" npt=" << npt);
86 std::vector<float> work (npt);
89 for (
unsigned ipt=0; ipt<npt; ipt++)
91 Estimate<float> val = (container->*get)(iparam, ipt);
95 work[iwork] = get_value (val);
100 std::nth_element (work.begin(), work.begin()+iwork/2, work.begin()+iwork);
101 float median = work[ iwork/2 ];
103 DEBUG(
"RobustEstimateZapper::excise work size=" << work.size() <<
" median=" << median);
110 for (
unsigned ipt=0; ipt < iwork; ipt++)
111 work[ipt] = fabs(work[ipt] - median);
114 std::nth_element (work.begin(), work.begin()+iwork/2, work.begin()+iwork);
115 madm = work[ iwork/2 ];
117 DEBUG(
"RobustEstimateZapper::excise scale by madm=" << madm);
120 DEBUG(
"RobustEstimateZapper::excise iwork=" << iwork
121 <<
" iparam=" << iparam <<
" median=" << median
122 <<
" madm=" << madm);
124 unsigned excised = 0;
126 double max_extreme = median + threshold_max * madm;
127 double min_extreme = median - threshold_min * madm;
129 for (
unsigned ipt=0; ipt<npt; ipt++)
131 Estimate<float> val = (container->*get)(iparam, ipt);
135 double test = get_value(val);
137 if (threshold_max && test > max_extreme)
139 DEBUG(
"RobustEstimateZapper::excise zapping >max iparam=" << iparam <<
" ipt=" << ipt);
142 (container->*valid)(ipt,
false);
145 if (threshold_min && test < min_extreme)
147 DEBUG(
"RobustEstimateZapper::excise zapping <min iparam=" << iparam <<
" ipt=" << ipt);
150 (container->*valid)(ipt,
false);
155 DEBUG(
"RobustEstimateZapper::excise excised=" << excised);