00001 #include "HTL/H_Bin_Helper.h"
00002
00003
00004 #define CLASS___ H_Bin_Helper
00005
00006
00007
00008 double CLASS___::in_range_error( const I_Histo &a_histo
00009 , const H_F1d & an_operation )
00010
00011
00012
00013
00014
00015
00016
00017
00018 {
00019 H_F1d &operation = (H_F1d &) an_operation;
00020 I_Histo &h = (I_Histo &) a_histo;
00021 double result = operation( h.i_bin(0).error() );
00022 for( Index i=1; i<h.bin_count(); i++ ) {
00023 result += operation( h.i_bin(i).error() );
00024 }
00025 return result;
00026 }
00027
00028 double CLASS___::in_range_value( const I_Histo &a_histo
00029 , const H_F1d & an_operation )
00030
00031
00032
00033
00034
00035
00036
00037
00038 {
00039 H_F1d &operation = (H_F1d &) an_operation;
00040 I_Histo &h = (I_Histo &) a_histo;
00041 double result = operation( h.i_bin(0).value() );
00042 for( Index i=1; i<h.bin_count(); i++ ) {
00043 result += operation( h.i_bin(i).value() );
00044 }
00045 return result;
00046 }
00047
00048 double CLASS___::in_range_min_value( const I_Histo &a_histo )
00049
00050 {
00051 I_Histo &h = (I_Histo &) a_histo;
00052 double result = h.i_bin(0).value();
00053 double v = 0.0;
00054 for( Index i=1; i<h.bin_count(); i++ ) {
00055 v = h.i_bin(i).value();
00056 if( v<result ) result = v;
00057 }
00058 return result;
00059 }
00060
00061 double CLASS___::in_range_max_value( const I_Histo &a_histo )
00062
00063 {
00064 I_Histo &h = (I_Histo &) a_histo;
00065 double result = h.i_bin(0).value();
00066 double v = 0.0;
00067 for( Index i=1; i<h.bin_count(); i++ ) {
00068 v = h.i_bin(i).value();
00069 if( v>result ) result = v;
00070 }
00071 return result;
00072 }
00073
00074 double CLASS___::bin_center( const I_Histo &a_histo, Index p,
00075 I_Histo::I_Bin_Location &l )
00076
00077
00078 {
00079 I_Histo &h = (I_Histo &) a_histo;
00080 if (h.dim() >= p && l.size() >= (unsigned long)p) {
00081 if( (h.i_bin(l).count() != 0) && (h.i_bin(l).offset(p) == 0 )) {
00082
00083 return h.i_bin(l).center(p);
00084 } else {
00085
00086 return h.i_partition(p).i_lower_point( l[p] ) +
00087 h.i_partition(p).i_bin_width( l[p] ) * 0.5;
00088 }
00089 } else {
00090 HTL_ERR("Incompatible index or dimension in bin_center(). Center is zero");
00091 return 0;
00092 }
00093 }
00094
00095
00096 #undef CLASS___
00097