00001 #ifndef _H_BIN_HELPER_H_
00002 #define _H_BIN_HELPER_H_ 1
00003
00004
00005 #include "HTL/I_Histo.h"
00006 #include "HTL/HTL_std.h"
00007
00009 class H_F1d {
00010 public: virtual double operator()( double x ) = 0;
00011 };
00012
00014 class H_Identity: public H_F1d {
00015 public: virtual double operator()( double x ) { return x; }
00016 };
00017
00019 class H_Sqr: public H_F1d {
00020 public: virtual double operator()( double x ) { return x*x; }
00021 };
00022
00026 class H_Bin_Helper {
00027 protected:
00028 H_Bin_Helper() {}
00029 virtual ~H_Bin_Helper() {}
00030 public:
00040 static double in_range_error( const I_Histo &a_histo
00041 , const H_F1d & operation = H_Identity() );
00042
00052 static double in_range_value( const I_Histo &a_histo
00053 , const H_F1d & operation = H_Identity() );
00054
00056 static double in_range_min_value( const I_Histo &a_histo );
00057
00059 static double in_range_max_value( const I_Histo &a_histo );
00060
00063 static double bin_center( const I_Histo &a_histo, Index p,
00064 I_Histo::I_Bin_Location &l );
00065
00067 static double bin_center( const I_Histo &a_histo, Index i )
00068 {
00069 if (a_histo.dim() == 1) {
00070 I_Histo::I_Bin_Location l(1); l[0] = i;
00071 return bin_center( a_histo, 0, l );
00072 } else {
00073 HTL_ERR("Not a 1D histo in bin_center(). Center is zero.");
00074 return 0;
00075 }
00076 }
00077
00080 static double bin_center( const I_Histo &a_histo, Index p, Index i, Index j )
00081 {
00082 if (a_histo.dim() == 2) {
00083 I_Histo::I_Bin_Location l(2); l[0] = i; l[1]= j;
00084 return bin_center( a_histo, p, l );
00085 } else {
00086 HTL_ERR("Not a 2D histo in bin_center(). Center is zero.");
00087 return 0;
00088 }
00089 }
00090 };
00091
00092
00093 #endif // _H_BIN_HELPER_H_
00094