00001 #ifndef _H_T__HISTOGRAMS_3D_H_
00002
00003 #if 0
00004 #define _H_P__HISTOGRAMS_3D_H_ 1
00005
00006
00007 #define T_HISTOS_INSTANTIATED
00008
00009 #include "HTL/P_Histograms.h"
00010 #include "HTL/P_Histograms3.h"
00011 #else
00012 #define _H_T__HISTOGRAMS_3D_H_ 1
00013
00014
00015 #define T_HISTOS_INSTANTIATED
00016
00017 #include "HTL/T_Histograms.h"
00018 #include "HTL/T_Histograms3.h"
00019 #endif
00020
00021
00022
00023 #include "HTL/H_Statistics.h"
00024 #include "HTL/HTLlimits.h"
00025
00026 #ifndef T__POINTS_VECTOR_H_
00027 #define T__POINTS_VECTOR_H_
00028
00029 typedef T_Uneven_Partition::Points_Set T_Points_Vector;
00030
00031 #endif //_POINTS_VECTOR_H_
00032
00037 class T_Histo3D: public T_Histo_3D_WED
00038 {
00039 public:
00041 H_IID_IMPLEMENT( T_Histo3D );
00043 typedef T_Histo3D Like_Current;
00045 typedef H_T_REF( Like_Current ) Ref_Like_Current;
00046 public:
00059 T_Histo3D( const char *a_title ,
00060 Size n1, double x1 , double x2
00061 ,Size n2, double y1 , double y2
00062 ,Size n3, double z1 , double z2
00063 , End_Point_Convention epc1 = RIGHT_OPEN
00064 , End_Point_Convention epc2 = RIGHT_OPEN
00065 , End_Point_Convention epc3 = RIGHT_OPEN )
00066 :H_H3D_E_EP(T_Histo_3D_WED,a_title,n1,x1,x2,epc1,n2,y1,y2,epc2,n3,z1,z2,epc3)
00067 {}
00068
00072 T_Histo3D( I_Histo &a_histo, int copy_data = 1 )
00073 : T_Histo_3D_WED( a_histo, copy_data )
00074 {}
00078 T_Histo3D(const I_Histo &a_histo, int copy_data = 1 )
00079 : T_Histo_3D_WED( a_histo, copy_data )
00080 {}
00082 virtual ~T_Histo3D() {}
00083 public:
00086 void fill( double x, double y, double z, double w = 1.0 ) {
00087
00088 if ((w == 1.0) && (HTLlimits::isFinite(x))&&
00089 (HTLlimits::isFinite(y)&&(HTLlimits::isFinite(z))))
00090 mapped_bin(x,y,z).put(w);
00091 else {
00092
00093 if (HTLlimits::isFinite(w)&&HTLlimits::isFinite(x)&&
00094 HTLlimits::isFinite(y)&&HTLlimits::isFinite(z))
00095 mapped_bin(x,y,z).put(w);
00096 else
00097 {HTLlimits::classify(x);HTLlimits::classify(y);
00098 HTLlimits::classify(z);HTLlimits::classify(w);}
00099 }
00100 }
00101
00104 double bin_center( Index i, Index j, Index k, Index p = 0 )
00105 { I_Histo::I_Bin_Location l(3);
00106 l[0]=i; l[1]=j; l[2] = k;
00107 return H_Bin_Helper::bin_center( *this, p, l ); }
00109 double mean( Index p=0 ) { return H_Statistics::mean( *this, p ); }
00111 double rms(Index p=0) {
00112 return H_Statistics::rms(*this, mean(p), p); }
00113 public:
00117 Ref_Like_Current clone( int copy_data = 1 ) {
00118 Ref_Like_Current h =
00119 H_T_NEW_CLUSTER0 Like_Current( *this, copy_data );
00120 return h;
00121 }
00126 Ref_Like_Current clone( H_T_CLUSTER1(a_place), int copy_data = 1 )
00127 { return H_T_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00128
00129 protected:
00130 virtual T_REF_I_Histo clone_( int copy_data = 1 )
00131 { return (T_REF_I_Histo) clone( copy_data ); }
00132 virtual T_REF_I_Histo clone_( H_T_CLUSTER1(a_place),
00133 int copy_data = 1 )
00134 { return (T_REF_I_Histo) clone( a_place, copy_data ); }
00135 public:
00137 Ref_Like_Current add( const Ref_Like_Current &other )
00138 {
00139 Ref_Like_Current h = (Ref_Like_Current &) other;
00140 if( partition_X().is_compatible_with( h->partition_X() )
00141 && partition_Y().is_compatible_with( h->partition_Y())
00142 && partition_Z().is_compatible_with( h->partition_Z())) {
00143 H_BIN_UPDATE
00144 for( Index i = 0; i<bin_count()+extra_bin_count(); i++ )
00145 bins_[i].add( h->_bin(i) );
00146 } else {
00147 HTL_ERR("Incompatible partitions in add(..)" );
00148 }
00149 return H_T_THIS;
00150 }
00152 void add( const I_Histo &other ) { add_( other ); }
00154 Ref_Like_Current sub( const Ref_Like_Current &other )
00155 {
00156 Ref_Like_Current h = (Ref_Like_Current &) other;
00157 if( partition_X().is_compatible_with( h->partition_X() )
00158 && partition_Y().is_compatible_with( h->partition_Y())
00159 && partition_Z().is_compatible_with( h->partition_Z())) {
00160 H_BIN_UPDATE
00161 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00162 bins_[i].sub( h->_bin(i) );
00163 } else {
00164 HTL_ERR("Incompatible partitions in sub(..)" );
00165 }
00166 return H_T_THIS;
00167 }
00170 void sub( const I_Histo &other ) { sub_( other ); }
00172 Ref_Like_Current mul( const Ref_Like_Current &other )
00173 {
00174 Ref_Like_Current h = (Ref_Like_Current &) other;
00175 if( partition_X().is_compatible_with( h->partition_X() )
00176 && partition_Y().is_compatible_with( h->partition_Y())
00177 && partition_Z().is_compatible_with( h->partition_Z())) {
00178 H_BIN_UPDATE
00179 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00180 bins_[i].mul( h->_bin(i) );
00181 } else {
00182 HTL_ERR("Incompatible partitions in mul(..)" );
00183 }
00184 return H_T_THIS;
00185 }
00188 void mul( const I_Histo &other ) { mul_( other ); }
00190 Ref_Like_Current div( const Ref_Like_Current &other )
00191 {
00192 Ref_Like_Current h = (Ref_Like_Current &) other;
00193 if( partition_X().is_compatible_with( h->partition_X() )
00194 && partition_Y().is_compatible_with( h->partition_Y())
00195 && partition_Z().is_compatible_with( h->partition_Z())) {
00196 H_BIN_UPDATE
00197 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00198 bins_[i].div( h->_bin(i) );
00199 } else {
00200 HTL_ERR("Incompatible partitions in div(..)" );
00201 }
00202 return H_T_THIS;
00203 }
00206 void div( const I_Histo &other ) { div_( other ); }
00208 void add( double x ) { add_( x ); }
00210 void sub( double x ) { sub_( x ); }
00212 void mul( double x ) { mul_( x ); }
00214 void div( double x ) { div_( x ); }
00215 };
00216
00217
00223 class T_Histo3DVar: public T_Histo_3D_WUD
00224 {
00225 public:
00227 H_IID_IMPLEMENT( T_Histo3DVar );
00229 typedef T_Histo3DVar Like_Current;
00231 typedef H_T_REF( Like_Current ) Ref_Like_Current;
00232 public:
00250 T_Histo3DVar( const char *a_title
00251 , HTL_STD::vector<float> &some_points1
00252 , HTL_STD::vector<float> &some_points2
00253 , HTL_STD::vector<float> &some_points3
00254 , End_Point_Convention epc1 = RIGHT_OPEN
00255 , End_Point_Convention epc2 = RIGHT_OPEN
00256 , End_Point_Convention epc3 = RIGHT_OPEN
00257 )
00258 : H_H3D_U_EP( T_Histo_3D_WUD, a_title, some_points1,
00259 epc1, some_points2, epc2, some_points3, epc3)
00260 {}
00261
00279 T_Histo3DVar( const char *a_title
00280 , HTL_STD::vector<double> &some_points1
00281 , HTL_STD::vector<double> &some_points2
00282 , HTL_STD::vector<double> &some_points3
00283 , End_Point_Convention epc1 = RIGHT_OPEN
00284 , End_Point_Convention epc2 = RIGHT_OPEN
00285 , End_Point_Convention epc3 = RIGHT_OPEN
00286 )
00287 : H_H3D_U_EP( T_Histo_3D_WUD, a_title, some_points1,
00288 epc1, some_points2, epc2, some_points3, epc3 )
00289 {}
00290
00294 T_Histo3DVar( I_Histo &a_histo, int copy_data=1 )
00295 : T_Histo_3D_WUD( a_histo, copy_data )
00296 {}
00300 T_Histo3DVar(const I_Histo &a_histo, int copy_data=1 )
00301 : T_Histo_3D_WUD( a_histo, copy_data )
00302 {}
00304 virtual ~T_Histo3DVar() {}
00305
00306 public:
00309 void fill( double x, double y, double z, double w = 1.0 ) {
00310
00311 if ((w == 1.0) && (HTLlimits::isFinite(x))&&
00312 (HTLlimits::isFinite(y)&&(HTLlimits::isFinite(z))))
00313 mapped_bin(x,y,z).put(w);
00314 else {
00315
00316 if (HTLlimits::isFinite(w)&&HTLlimits::isFinite(x)&&
00317 HTLlimits::isFinite(y)&&HTLlimits::isFinite(z))
00318 mapped_bin(x,y,z).put(w);
00319 else
00320 {HTLlimits::classify(x);HTLlimits::classify(y);
00321 HTLlimits::classify(z);HTLlimits::classify(w);}
00322 }
00323 }
00324
00327 double bin_center( Index i, Index j, Index k, Index p = 0 )
00328 { I_Histo::I_Bin_Location l(3);
00329 l[0]=i; l[1]=j; l[2] = k;
00330 return H_Bin_Helper::bin_center( *this, p, l ); }
00332 double mean( Index p=0 ) { return H_Statistics::mean( *this, p ); }
00334 double rms(Index p=0) { return H_Statistics::rms(*this, mean(p), p); }
00335 public:
00339 Ref_Like_Current clone( int copy_data = 1 ) {
00340 Ref_Like_Current h =
00341 H_T_NEW_CLUSTER0 Like_Current( *this, copy_data );
00342 return h;
00343 }
00348 Ref_Like_Current clone( H_T_CLUSTER1(a_place), int copy_data = 1 )
00349 { return H_T_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00350 protected:
00351 virtual T_REF_I_Histo clone_( int copy_data = 1 )
00352 { return (T_REF_I_Histo) clone( copy_data ); }
00353 virtual T_REF_I_Histo clone_( H_T_CLUSTER1(a_place),
00354 int copy_data = 1 )
00355 { return (T_REF_I_Histo) clone( a_place, copy_data ); }
00356 public:
00358 Ref_Like_Current add( const Ref_Like_Current &other )
00359 {
00360 Ref_Like_Current h = (Ref_Like_Current &) other;
00361 if( partition_X().is_compatible_with( h->partition_X() )
00362 && partition_Y().is_compatible_with( h->partition_Y())
00363 && partition_Z().is_compatible_with( h->partition_Z())) {
00364 H_BIN_UPDATE
00365 for( Index i = 0; i<bin_count()+extra_bin_count(); i++ )
00366 bins_[i].add( h->_bin(i) );
00367 } else {
00368 HTL_ERR("Incompatible partitions in add(..)" );
00369 }
00370 return H_T_THIS;
00371 }
00373 void add( const I_Histo &other ) { add_( other ); }
00375 Ref_Like_Current sub( const Ref_Like_Current &other )
00376 {
00377 Ref_Like_Current h = (Ref_Like_Current &) other;
00378 if( partition_X().is_compatible_with( h->partition_X() )
00379 && partition_Y().is_compatible_with( h->partition_Y())
00380 && partition_Z().is_compatible_with( h->partition_Z())) {
00381 H_BIN_UPDATE
00382 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00383 bins_[i].sub( h->_bin(i) );
00384 } else {
00385 HTL_ERR("Incompatible partitions in sub(..)" );
00386 }
00387 return H_T_THIS;
00388 }
00391 void sub( const I_Histo &other ) { sub_( other ); }
00393 Ref_Like_Current mul( const Ref_Like_Current &other )
00394 {
00395 Ref_Like_Current h = (Ref_Like_Current &) other;
00396 if( partition_X().is_compatible_with( h->partition_X() )
00397 && partition_Y().is_compatible_with( h->partition_Y())
00398 && partition_Z().is_compatible_with( h->partition_Z())) {
00399 H_BIN_UPDATE
00400 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00401 bins_[i].mul( h->_bin(i) );
00402 } else {
00403 HTL_ERR("Incompatible partitions in mul(..)" );
00404 }
00405 return H_T_THIS;
00406 }
00409 void mul( const I_Histo &other ) { mul_( other ); }
00411 Ref_Like_Current div( const Ref_Like_Current &other )
00412 {
00413 Ref_Like_Current h = (Ref_Like_Current &) other;
00414 if( partition_X().is_compatible_with( h->partition_X() )
00415 && partition_Y().is_compatible_with( h->partition_Y())
00416 && partition_Z().is_compatible_with( h->partition_Z())) {
00417 H_BIN_UPDATE
00418 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00419 bins_[i].div( h->_bin(i) );
00420 } else {
00421 HTL_ERR("Incompatible partitions in div(..)" );
00422 }
00423 return H_T_THIS;
00424 }
00427 void div( const I_Histo &other ) { div_( other ); }
00429 void add( double x ) { add_( x ); }
00431 void sub( double x ) { sub_( x ); }
00433 void mul( double x ) { mul_( x ); }
00435 void div( double x ) { div_( x ); }
00436 };
00437
00438
00439
00440 #endif
00441