00001 #ifndef _H_P__HISTOGRAMS_1D_H_
00002
00003 #if 1
00004 #define _H_P__HISTOGRAMS_1D_H_ 1
00005
00006
00007 #define P_HISTOS_INSTANTIATED
00008
00009 #include "HTL/P_Histograms.h"
00010 #else
00011 #define _H_T__HISTOGRAMS_1D_H_ 1
00012
00013
00014 #define P_HISTOS_INSTANTIATED
00015
00016 #include "HTL/T_Histograms.h"
00017 #endif
00018
00019 #include "HTL/HTLlimits.h"
00020 #include "HTL/H_Statistics.h"
00021
00022 #ifndef P__POINTS_VECTOR_H_
00023 #define P__POINTS_VECTOR_H_
00024
00025 typedef P_Uneven_Partition::Points_Set P_Points_Vector;
00026
00027 #endif //_POINTS_VECTOR_H_
00028
00029
00034 class P_Histo1D: public P_Histo_1D_GED
00035 {
00036 public:
00038 H_IID_IMPLEMENT( P_Histo1D );
00040 typedef P_Histo1D Like_Current;
00042 typedef H_P_REF( Like_Current ) Ref_Like_Current;
00043 public:
00051 P_Histo1D( const char *a_title, Size n, double x1
00052 , double x2, End_Point_Convention epc = RIGHT_OPEN )
00053 : H_H1D_E_EP( P_Histo_1D_GED, a_title
00054 , n, x1, x2, epc )
00055 {}
00056
00060 P_Histo1D( I_Histo &a_histo, int copy_data = 1 )
00061 : P_Histo_1D_GED( a_histo, copy_data )
00062 {}
00063
00067 P_Histo1D( const I_Histo &a_histo, int copy_data = 1 )
00068 : P_Histo_1D_GED( a_histo, copy_data )
00069 {}
00070
00072 virtual ~P_Histo1D() {}
00073
00074 public:
00076 void fill( double x, double w = 1.0 ) {
00077
00078 if ((w == 1.0) && (HTLlimits::isFinite(x)))
00079 mapped_bin(x).put(w,x);
00080 else {
00081
00082 if (HTLlimits::isFinite(w) && HTLlimits::isFinite(x))
00083 mapped_bin(x).put(w,x);
00084 else
00085 {HTLlimits::classify(x);HTLlimits::classify(w);}
00086 }
00087 }
00089 double bin_center( Index i ) {
00090 I_Histo::I_Bin_Location l(1); l[0]=i;
00091 return H_Bin_Helper::bin_center( *this, 0, l );
00092 }
00094 double mean() { return H_Statistics::mean( *this, 0 ); }
00096 double rms() { return H_Statistics::rms( *this, mean(), 0 ); }
00097 public:
00101 Ref_Like_Current clone( int copy_data = 1 )
00102 {
00103 Ref_Like_Current h =
00104 H_P_NEW_CLUSTER0 Like_Current( *this, copy_data );
00105 return h;
00106 }
00111 Ref_Like_Current clone( H_P_CLUSTER1(a_place), int copy_data = 1 )
00112 { return H_P_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00113 protected:
00114 virtual P_REF_I_Histo clone_( int copy_data = 1 )
00115 { return (P_REF_I_Histo) clone( copy_data ); }
00116
00117 virtual P_REF_I_Histo clone_( H_P_CLUSTER1(a_place),
00118 int copy_data = 1 )
00119 { return (P_REF_I_Histo) clone( a_place, copy_data ); }
00120 public:
00122 Ref_Like_Current add( const Ref_Like_Current &other )
00123 {
00124 Ref_Like_Current h = (Ref_Like_Current &) other;
00125 if( partition().is_compatible_with( h->partition())){
00126 H_BIN_UPDATE
00127 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00128 bins_[i].add( h->_bin(i) );
00129 } else {
00130 HTL_ERR("Incompatible partitions in add(..)" );
00131 }
00132 return H_P_THIS;
00133 }
00135 void add( const I_Histo &other ) { add_( other ); }
00137 Ref_Like_Current sub( const Ref_Like_Current &other )
00138 {
00139 Ref_Like_Current h = (Ref_Like_Current &) other;
00140 if( partition().is_compatible_with( h->partition())){
00141 H_BIN_UPDATE
00142 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00143 bins_[i].sub( h->_bin(i) );
00144 } else {
00145 HTL_ERR("Incompatible partitions in sub(..)" );
00146 }
00147 return H_P_THIS;
00148 }
00151 void sub( const I_Histo &other ) { sub_( other ); }
00153 Ref_Like_Current mul( const Ref_Like_Current &other )
00154 {
00155 Ref_Like_Current h = (Ref_Like_Current &) other;
00156 if( partition().is_compatible_with( h->partition())) {
00157 H_BIN_UPDATE
00158 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00159 bins_[i].mul( h->_bin(i) );
00160 } else {
00161 HTL_ERR("Incompatible partitions in mul(..)" );
00162 }
00163 return H_P_THIS;
00164 }
00167 void mul( const I_Histo &other ) { mul_( other ); }
00169 Ref_Like_Current div( const Ref_Like_Current &other )
00170 {
00171 Ref_Like_Current h = (Ref_Like_Current &) other;
00172 if( partition().is_compatible_with( h->partition())) {
00173 H_BIN_UPDATE
00174 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00175 bins_[i].div( h->_bin(i) );
00176 } else {
00177 HTL_ERR("Incompatible partitions in div(..)" );
00178 }
00179 return H_P_THIS;
00180 }
00183 void div( const I_Histo &other ) { div_( other ); }
00185 void add( double x ) { add_( x ); }
00187 void sub( double x ) { sub_( x ); }
00189 void mul( double x ) { mul_( x ); }
00191 void div( double x ) { div_( x ); }
00192 };
00193
00194
00198 class P_Histo1DVar: public P_Histo_1D_GUD
00199 {
00200 public:
00202 H_IID_IMPLEMENT( P_Histo1DVar );
00204 typedef P_Histo1DVar Like_Current;
00206 typedef H_P_REF( Like_Current ) Ref_Like_Current;
00207 public:
00216 P_Histo1DVar( const char *a_title, HTL_STD::vector<float>&
00217 some_points, End_Point_Convention epc = RIGHT_OPEN)
00218 : H_H1D_U_EP( P_Histo_1D_GUD, a_title , some_points, epc )
00219 {}
00220
00225 P_Histo1DVar( const char *a_title, HTL_STD::vector<double>&
00226 some_points, End_Point_Convention epc = RIGHT_OPEN)
00227 : H_H1D_U_EP( P_Histo_1D_GUD, a_title , some_points, epc )
00228 {}
00229
00233 P_Histo1DVar( I_Histo &a_histo, int copy_data=1 )
00234 : P_Histo_1D_GUD( a_histo, copy_data )
00235 {}
00236
00240 P_Histo1DVar( const I_Histo &a_histo, int copy_data=1 )
00241 : P_Histo_1D_GUD( a_histo, copy_data )
00242 {}
00243
00245 virtual ~P_Histo1DVar() {}
00246
00247 public:
00249 void fill( double x, double w = 1.0 ) {
00250
00251 if ((w == 1.0) && (HTLlimits::isFinite(x)))
00252 mapped_bin(x).put(w,x);
00253 else {
00254
00255 if (HTLlimits::isFinite(w) && HTLlimits::isFinite(x))
00256 mapped_bin(x).put(w,x);
00257 else
00258 {HTLlimits::classify(x);HTLlimits::classify(w);}
00259 }
00260 }
00261
00263 double bin_center( Index i ) { I_Histo::I_Bin_Location l(1); l[0]=i;
00264 return H_Bin_Helper::bin_center( *this, 0, l ); }
00266 double mean() { return H_Statistics::mean( *this, 0 ); }
00268 double rms() { return H_Statistics::rms( *this, mean(), 0 ); }
00269 public:
00273 Ref_Like_Current clone( int copy_data = 1 ) {
00274 Ref_Like_Current h =
00275 H_P_NEW_CLUSTER0 Like_Current( *this, copy_data );
00276 return h;
00277 }
00282 Ref_Like_Current clone( H_P_CLUSTER1(a_place), int copy_data = 1 )
00283 { return H_P_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00284
00285 protected:
00286 virtual P_REF_I_Histo clone_( int copy_data = 1 )
00287 { return (P_REF_I_Histo) clone( copy_data ); }
00288 virtual P_REF_I_Histo clone_( H_P_CLUSTER1(a_place),
00289 int copy_data = 1 )
00290 { return (P_REF_I_Histo) clone( a_place, copy_data ); }
00291 public:
00293 Ref_Like_Current add( const Ref_Like_Current &other )
00294 {
00295 Ref_Like_Current h = (Ref_Like_Current &) other;
00296 if( partition().is_compatible_with( h->partition())){
00297 H_BIN_UPDATE
00298 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00299 bins_[i].add( h->_bin(i) );
00300 } else {
00301 HTL_ERR("Incompatible partitions in add(..)" );
00302 }
00303 return H_P_THIS;
00304 }
00306 void add( const I_Histo &other ) { add_( other ); }
00308 Ref_Like_Current sub( const Ref_Like_Current &other )
00309 {
00310 Ref_Like_Current h = (Ref_Like_Current &) other;
00311 if( partition().is_compatible_with( h->partition())){
00312 H_BIN_UPDATE
00313 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00314 bins_[i].sub( h->_bin(i) );
00315 } else {
00316 HTL_ERR("Incompatible partitions in sub(..)" );
00317 }
00318 return H_P_THIS;
00319 }
00322 void sub( const I_Histo &other ) { sub_( other ); }
00324 Ref_Like_Current mul( const Ref_Like_Current &other )
00325 {
00326 Ref_Like_Current h = (Ref_Like_Current &) other;
00327 if( partition().is_compatible_with( h->partition())) {
00328 H_BIN_UPDATE
00329 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00330 bins_[i].mul( h->_bin(i) );
00331 } else {
00332 HTL_ERR("Incompatible partitions in mul(..)" );
00333 }
00334 return H_P_THIS;
00335 }
00338 void mul( const I_Histo &other ) { mul_( other ); }
00340 Ref_Like_Current div( const Ref_Like_Current &other )
00341 {
00342 Ref_Like_Current h = (Ref_Like_Current &) other;
00343 if( partition().is_compatible_with( h->partition())) {
00344 H_BIN_UPDATE
00345 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00346 bins_[i].div( h->_bin(i) );
00347 } else {
00348 HTL_ERR("Incompatible partitions in div(..)" );
00349 }
00350 return H_P_THIS;
00351 }
00354 void div( const I_Histo &other ) { div_( other ); }
00356 void add( double x ) { add_( x ); }
00358 void sub( double x ) { sub_( x ); }
00360 void mul( double x ) { mul_( x ); }
00362 void div( double x ) { div_( x ); }
00363 };
00364
00368 class P_ProfileHisto1D: public P_Histo_1D_PED
00369 {
00370 public:
00372 H_IID_IMPLEMENT( P_ProfileHisto1D );
00374 typedef P_ProfileHisto1D Like_Current;
00376 typedef H_P_REF( Like_Current ) Ref_Like_Current;
00377 public:
00383 P_ProfileHisto1D(const char *a_title,Size n,double x1,double x2,
00384 End_Point_Convention epc = RIGHT_OPEN )
00385 : H_H1D_E_EP( P_Histo_1D_PED, a_title , n, x1, x2, epc )
00386 {}
00387
00391 P_ProfileHisto1D( I_Histo &a_histo, int copy_data = 1 )
00392 : P_Histo_1D_PED( a_histo, copy_data )
00393 {}
00397 P_ProfileHisto1D( const I_Histo &a_histo, int copy_data = 1 )
00398 : P_Histo_1D_PED( a_histo, copy_data )
00399 {}
00401 virtual ~P_ProfileHisto1D() {}
00402 public:
00404 void fill( double x, double k ,double w = 1.0) {
00405
00406 if ((w == 1.0) && (HTLlimits::isFinite(x))&&(HTLlimits::isFinite(k)))
00407 mapped_bin(x).put(w,k);
00408 else {
00409
00410 if (HTLlimits::isFinite(w)&&HTLlimits::isFinite(x)
00411 &&HTLlimits::isFinite(k))
00412 mapped_bin(x).put(w,k);
00413 else
00414 {HTLlimits::classify(x);HTLlimits::classify(w);HTLlimits::classify(k);}
00415 }
00416 }
00417
00419 double bin_center( Index i ) { I_Histo::I_Bin_Location l(1); l[0]=i;
00420 return H_Bin_Helper::bin_center( *this, 0, l ); }
00422 double mean() { return H_Statistics::mean( *this, 0 ); }
00424 double rms() { return H_Statistics::rms( *this, mean(), 0 ); }
00425 public:
00429 Ref_Like_Current clone( int copy_data = 1 ) {
00430 Ref_Like_Current h =
00431 H_P_NEW_CLUSTER0 Like_Current( *this, copy_data );
00432 return h;
00433 }
00438 Ref_Like_Current clone( H_P_CLUSTER1(a_place), int copy_data = 1 )
00439 { return H_P_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00440 protected:
00441 virtual P_REF_I_Histo clone_( int copy_data = 1 )
00442 { return (P_REF_I_Histo) clone( copy_data ); }
00443
00444 virtual P_REF_I_Histo clone_( H_P_CLUSTER1(a_place),
00445 int copy_data = 1 )
00446 { return (P_REF_I_Histo) clone( a_place, copy_data ); }
00447 public:
00449 Ref_Like_Current add( const Ref_Like_Current &other )
00450 {
00451 Ref_Like_Current h = (Ref_Like_Current &) other;
00452 if( partition().is_compatible_with( h->partition())){
00453 H_BIN_UPDATE
00454 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00455 bins_[i].add( h->_bin(i) );
00456 } else {
00457 HTL_ERR("Incompatible partitions in add(..)" );
00458 }
00459 return H_P_THIS;
00460 }
00462 void add( const I_Histo &other ) { add_( other ); }
00464 Ref_Like_Current sub( const Ref_Like_Current &other )
00465 {
00466 Ref_Like_Current h = (Ref_Like_Current &) other;
00467 if( partition().is_compatible_with( h->partition())){
00468 H_BIN_UPDATE
00469 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00470 bins_[i].sub( h->_bin(i) );
00471 } else {
00472 HTL_ERR("Incompatible partitions in sub(..)" );
00473 }
00474 return H_P_THIS;
00475 }
00478 void sub( const I_Histo &other ) { sub_( other ); }
00480 Ref_Like_Current mul( const Ref_Like_Current &other )
00481 {
00482 Ref_Like_Current h = (Ref_Like_Current &) other;
00483 if( partition().is_compatible_with( h->partition())) {
00484 H_BIN_UPDATE
00485 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00486 bins_[i].mul( h->_bin(i) );
00487 } else {
00488 HTL_ERR("Incompatible partitions in mul(..)" );
00489 }
00490 return H_P_THIS;
00491 }
00494 void mul( const I_Histo &other ) { mul_( other ); }
00496 Ref_Like_Current div( const Ref_Like_Current &other )
00497 {
00498 Ref_Like_Current h = (Ref_Like_Current &) other;
00499 if( partition().is_compatible_with( h->partition())) {
00500 H_BIN_UPDATE
00501 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00502 bins_[i].div( h->_bin(i) );
00503 } else {
00504 HTL_ERR("Incompatible partitions in div(..)" );
00505 }
00506 return H_P_THIS;
00507 }
00510 void div( const I_Histo &other ) { div_( other ); }
00512 void add( double x ) { add_( x ); }
00514 void sub( double x ) { sub_( x ); }
00516 void mul( double x ) { mul_( x ); }
00518 void div( double x ) { div_( x ); }
00519 };
00520
00524 class P_ProfileHisto1DVar: public P_Histo_1D_PUD
00525 {
00526 public:
00528 H_IID_IMPLEMENT( P_ProfileHisto1DVar );
00530 typedef P_ProfileHisto1DVar Like_Current;
00532 typedef H_P_REF( Like_Current ) Ref_Like_Current;
00533 public:
00541 P_ProfileHisto1DVar( const char *a_title,
00542 HTL_STD::vector<float>& some_points,
00543 End_Point_Convention epc = RIGHT_OPEN )
00544 : H_H1D_U_EP( P_Histo_1D_PUD, a_title , some_points, epc )
00545 {}
00546
00550 P_ProfileHisto1DVar( const char *a_title,
00551 HTL_STD::vector<double>& some_points,
00552 End_Point_Convention epc = RIGHT_OPEN )
00553 : H_H1D_U_EP( P_Histo_1D_PUD, a_title , some_points, epc )
00554 {}
00555
00559 P_ProfileHisto1DVar( I_Histo &a_histo, int copy_data = 1 )
00560 : P_Histo_1D_PUD( a_histo, copy_data )
00561 {}
00562
00566 P_ProfileHisto1DVar( const I_Histo &a_histo, int copy_data = 1 )
00567 : P_Histo_1D_PUD( a_histo, copy_data )
00568 {}
00570 virtual ~P_ProfileHisto1DVar() {}
00571
00572 public:
00574 void fill( double x, double k ,double w = 1.0) {
00575
00576 if ((w == 1.0) && (HTLlimits::isFinite(x))&&(HTLlimits::isFinite(k)))
00577 mapped_bin(x).put(w,k);
00578 else {
00579
00580 if (HTLlimits::isFinite(w)&&HTLlimits::isFinite(x)&&
00581 HTLlimits::isFinite(k))
00582 mapped_bin(x).put(w,k);
00583 else {
00584 HTLlimits::classify(x);HTLlimits::classify(w);
00585 HTLlimits::classify(k);}
00586 }
00587 }
00589 double bin_center( Index i ) { I_Histo::I_Bin_Location l(1); l[0]=i;
00590 return H_Bin_Helper::bin_center( *this, 0, l ); }
00592 double mean() { return H_Statistics::mean( *this, 0 ); }
00594 double rms() { return H_Statistics::rms( *this, mean(), 0 ); }
00595 public:
00599 Ref_Like_Current clone( int copy_data = 1 ) {
00600 Ref_Like_Current h =
00601 H_P_NEW_CLUSTER0 Like_Current( *this, copy_data );
00602 return h;
00603 }
00608 Ref_Like_Current clone( H_P_CLUSTER1(a_place), int copy_data = 1 )
00609 { return H_P_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00610 protected:
00611 virtual P_REF_I_Histo clone_( int copy_data = 1 )
00612 { return (P_REF_I_Histo) clone( copy_data ); }
00613 virtual P_REF_I_Histo clone_( H_P_CLUSTER1(a_place),
00614 int copy_data = 1 )
00615 { return (P_REF_I_Histo) clone( a_place, copy_data ); }
00616 public:
00618 Ref_Like_Current add( const Ref_Like_Current &other )
00619 {
00620 Ref_Like_Current h = (Ref_Like_Current &) other;
00621 if( partition().is_compatible_with( h->partition())){
00622 H_BIN_UPDATE
00623 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00624 bins_[i].add( h->_bin(i) );
00625 } else {
00626 HTL_ERR("Incompatible partitions in add(..)" );
00627 }
00628 return H_P_THIS;
00629 }
00631 void add( const I_Histo &other ) { add_( other ); }
00633 Ref_Like_Current sub( const Ref_Like_Current &other )
00634 {
00635 Ref_Like_Current h = (Ref_Like_Current &) other;
00636 if( partition().is_compatible_with( h->partition())){
00637 H_BIN_UPDATE
00638 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00639 bins_[i].sub( h->_bin(i) );
00640 } else {
00641 HTL_ERR("Incompatible partitions in sub(..)" );
00642 }
00643 return H_P_THIS;
00644 }
00647 void sub( const I_Histo &other ) { sub_( other ); }
00649 Ref_Like_Current mul( const Ref_Like_Current &other )
00650 {
00651 Ref_Like_Current h = (Ref_Like_Current &) other;
00652 if( partition().is_compatible_with( h->partition())) {
00653 H_BIN_UPDATE
00654 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00655 bins_[i].mul( h->_bin(i) );
00656 } else {
00657 HTL_ERR("Incompatible partitions in mul(..)" );
00658 }
00659 return H_P_THIS;
00660 }
00663 void mul( const I_Histo &other ) { mul_( other ); }
00665 Ref_Like_Current div( const Ref_Like_Current &other )
00666 {
00667 Ref_Like_Current h = (Ref_Like_Current &) other;
00668 if( partition().is_compatible_with( h->partition())) {
00669 H_BIN_UPDATE
00670 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00671 bins_[i].div( h->_bin(i) );
00672 } else {
00673 HTL_ERR("Incompatible partitions in div(..)" );
00674 }
00675 return H_P_THIS;
00676 }
00679 void div( const I_Histo &other ) { div_( other ); }
00681 void add( double x ) { add_( x ); }
00683 void sub( double x ) { sub_( x ); }
00685 void mul( double x ) { mul_( x ); }
00687 void div( double x ) { div_( x ); }
00688 };
00689
00690
00697 class P_Histo1D_FTS: public P_Histo_1D_WED
00698 {
00699 public:
00700 H_IID_IMPLEMENT( P_Histo1D_FTS );
00702 typedef P_Histo1D_FTS Like_Current;
00704 typedef H_P_REF( Like_Current ) Ref_Like_Current;
00705 public:
00713 P_Histo1D_FTS( const char *a_title, Size n, double x1
00714 ,double x2, End_Point_Convention epc = RIGHT_OPEN)
00715 : H_H1D_E_EP( P_Histo_1D_WED, a_title , n, x1, x2, epc )
00716 , sum_wx_(0.), sum_wxx_(0.), entries_count_(0)
00717 {}
00721 P_Histo1D_FTS( I_Histo &a_histo, int copy_data = 1 )
00722 : P_Histo_1D_WED( a_histo, copy_data )
00723 , sum_wx_(0.), sum_wxx_(0.), entries_count_(0)
00724 {}
00728 P_Histo1D_FTS( const I_Histo &a_histo, int copy_data = 1 )
00729 : P_Histo_1D_WED( a_histo, copy_data )
00730 , sum_wx_(0.), sum_wxx_(0.), entries_count_(0)
00731 {}
00733 virtual ~P_Histo1D_FTS() {}
00734 public:
00736 void fill( double x, double w = 1.0 ) {
00737 if (HTLlimits::isFinite(w) && HTLlimits::isFinite(x))
00738 mapped_bin(x).put(w);
00739 if( is_in_range( extra_index_ ) ) {
00740 sum_wx_ += w*x;
00741 sum_wxx_ += w*x*x;
00742 }
00743 }
00744
00746 double bin_center( Index i ) { I_Histo::I_Bin_Location l(1); l[0]=i;
00747 return H_Bin_Helper::bin_center( *this, 0, l ); }
00749 double mean() { return sum_wx_ / H_Bin_Helper::in_range_value(*this); }
00751 double rms() {
00752 double m = mean(); m *= m;
00753 double r = sum_wxx_ / H_Bin_Helper::in_range_value(*this) - m;
00754 if( r <= 0. ) return 0.;
00755 return sqrt(r);
00756 }
00757
00758 void set_wx( double v ) { sum_wx_ = v; }
00759 void set_wxx( double v ) { sum_wxx_ = v; }
00760 double wx() { return sum_wx_; }
00761 double wxx() { return sum_wxx_; }
00762 void set_entries_count( Size a_count ) { entries_count_ = a_count; }
00763 Size entries_count() { return entries_count_; }
00764 virtual void reset() {
00765 P_Histo_1D_WED::reset();
00766 sum_wx_ = 0.; sum_wxx_ = 0.; entries_count_ = 0;
00767 }
00768 protected:
00769
00770 double sum_wx_;
00771
00772 double sum_wxx_;
00773
00774 Size entries_count_;
00775 public:
00779 Ref_Like_Current clone( int copy_data = 1 ) {
00780 Ref_Like_Current h =
00781 H_P_NEW_CLUSTER0 Like_Current( *this, copy_data );
00782 return h;
00783 }
00788 Ref_Like_Current clone( H_P_CLUSTER1(a_place), int copy_data = 1 )
00789 { return H_P_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00790 protected:
00791 virtual P_REF_I_Histo clone_( int copy_data = 1 )
00792 { return (P_REF_I_Histo) clone( copy_data ); }
00793 virtual P_REF_I_Histo clone_( H_P_CLUSTER1(a_place),
00794 int copy_data = 1 )
00795 { return (P_REF_I_Histo) clone( a_place, copy_data ); }
00796 public:
00798 Ref_Like_Current add( const Ref_Like_Current &other )
00799 {
00800 Ref_Like_Current h = (Ref_Like_Current &) other;
00801 if( partition().is_compatible_with( h->partition())){
00802 H_BIN_UPDATE
00803 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00804 bins_[i].add( h->_bin(i) );
00805 } else {
00806 HTL_ERR("Incompatible partitions in add(..)" );
00807 }
00808 return H_P_THIS;
00809 }
00811 void add( const I_Histo &other ) { add_( other ); }
00813 Ref_Like_Current sub( const Ref_Like_Current &other )
00814 {
00815 Ref_Like_Current h = (Ref_Like_Current &) other;
00816 if( partition().is_compatible_with( h->partition())){
00817 H_BIN_UPDATE
00818 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00819 bins_[i].sub( h->_bin(i) );
00820 } else {
00821 HTL_ERR("Incompatible partitions in sub(..)" );
00822 }
00823 return H_P_THIS;
00824 }
00827 void sub( const I_Histo &other ) { sub_( other ); }
00829 Ref_Like_Current mul( const Ref_Like_Current &other )
00830 {
00831 Ref_Like_Current h = (Ref_Like_Current &) other;
00832 if( partition().is_compatible_with( h->partition())) {
00833 H_BIN_UPDATE
00834 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00835 bins_[i].mul( h->_bin(i) );
00836 } else {
00837 HTL_ERR("Incompatible partitions in mul(..)" );
00838 }
00839 return H_P_THIS;
00840 }
00843 void mul( const I_Histo &other ) { mul_( other ); }
00845 Ref_Like_Current div( const Ref_Like_Current &other )
00846 {
00847 Ref_Like_Current h = (Ref_Like_Current &) other;
00848 if( partition().is_compatible_with( h->partition())) {
00849 H_BIN_UPDATE
00850 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00851 bins_[i].div( h->_bin(i) );
00852 } else {
00853 HTL_ERR("Incompatible partitions in div(..)" );
00854 }
00855 return H_P_THIS;
00856 }
00859 void div( const I_Histo &other ) { div_( other ); }
00861 void add( double x ) { add_( x ); }
00863 void sub( double x ) { sub_( x ); }
00865 void mul( double x ) { mul_( x ); }
00867 void div( double x ) { div_( x ); }
00868 };
00869
00876 class P_Histo1DVar_FTS: public P_Histo_1D_WUD
00877 {
00878 public:
00880 H_IID_IMPLEMENT( P_Histo1DVar_FTS );
00882 typedef P_Histo1DVar_FTS Like_Current;
00884 typedef H_P_REF( Like_Current ) Ref_Like_Current;
00885 public:
00893 P_Histo1DVar_FTS( const char *a_title,
00894 HTL_STD::vector<float>& some_points,
00895 End_Point_Convention epc = RIGHT_OPEN )
00896 : H_H1D_U_EP( P_Histo_1D_WUD, a_title
00897 , some_points, epc )
00898 , sum_wx_(0.), sum_wxx_(0.), entries_count_(0)
00899 {}
00900
00904 P_Histo1DVar_FTS( const char *a_title,
00905 HTL_STD::vector<double>& some_points,
00906 End_Point_Convention epc = RIGHT_OPEN )
00907 : H_H1D_U_EP( P_Histo_1D_WUD, a_title , some_points, epc )
00908 , sum_wx_(0.), sum_wxx_(0.), entries_count_(0)
00909 {}
00910
00914 P_Histo1DVar_FTS( I_Histo &a_histo, int copy_data=1 )
00915 : P_Histo_1D_WUD( a_histo, copy_data )
00916 , sum_wx_(0.), sum_wxx_(0.), entries_count_(0)
00917 {}
00921 P_Histo1DVar_FTS(const I_Histo &a_histo, int copy_data=1 )
00922 : P_Histo_1D_WUD( a_histo, copy_data )
00923 , sum_wx_(0.), sum_wxx_(0.), entries_count_(0)
00924 {}
00926 virtual ~P_Histo1DVar_FTS() {}
00927 public:
00929 void fill( double x, double w = 1.0 )
00930 {
00931 if (HTLlimits::isFinite(w) && HTLlimits::isFinite(x))
00932 mapped_bin(x).put(w);
00933 if( is_in_range( extra_index_ ) ) {
00934 sum_wx_ += w*x;
00935 sum_wxx_ += w*x*x;
00936 }
00937 }
00938
00940 double bin_center( Index i ) { I_Histo::I_Bin_Location l(1); l[0]=i;
00941 return H_Bin_Helper::bin_center( *this, 0, l ); }
00943 double mean() { return sum_wx_ / H_Bin_Helper::in_range_value(*this); }
00945 double rms() {
00946 double m = mean(); m *= m;
00947 double r = sum_wxx_ / H_Bin_Helper::in_range_value(*this) - m;
00948 if( r <= 0. ) return 0.;
00949 return sqrt(r);
00950 }
00951 void set_wx( double v ) { sum_wx_ = v; }
00952 void set_wxx( double v ) { sum_wxx_ = v; }
00953 double wx() { return sum_wx_; }
00954 double wxx() { return sum_wxx_; }
00955 void set_entries_count( Size a_count ) { entries_count_ = a_count; }
00956 Size entries_count() { return entries_count_; }
00957 virtual void reset() {
00958 P_Histo_1D_WUD::reset();
00959 sum_wx_ = 0.; sum_wxx_ = 0.; entries_count_ = 0;
00960 }
00961 protected:
00962
00963 double sum_wx_;
00964
00965 double sum_wxx_;
00966
00967 Size entries_count_;
00968 public:
00972 Ref_Like_Current clone( int copy_data = 1 ) {
00973 Ref_Like_Current h =
00974 H_P_NEW_CLUSTER0 Like_Current( *this, copy_data );
00975 return h;
00976 }
00981 Ref_Like_Current clone( H_P_CLUSTER1(a_place), int copy_data = 1 )
00982 { return H_P_NEW_CLUSTER1(a_place) Like_Current(*this, copy_data); }
00983 protected:
00984 virtual P_REF_I_Histo clone_( int copy_data = 1 )
00985 { return (P_REF_I_Histo) clone( copy_data ); }
00986 virtual P_REF_I_Histo clone_( H_P_CLUSTER1(a_place),
00987 int copy_data = 1 )
00988 { return (P_REF_I_Histo) clone( a_place, copy_data ); }
00989 public:
00991 Ref_Like_Current add( const Ref_Like_Current &other )
00992 {
00993 Ref_Like_Current h = (Ref_Like_Current &) other;
00994 if( partition().is_compatible_with( h->partition())){
00995 H_BIN_UPDATE
00996 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
00997 bins_[i].add( h->_bin(i) );
00998 } else {
00999 HTL_ERR("Incompatible partitions in add(..)" );
01000 }
01001 return H_P_THIS;
01002 }
01004 void add( const I_Histo &other ) { add_( other ); }
01006 Ref_Like_Current sub( const Ref_Like_Current &other )
01007 {
01008 Ref_Like_Current h = (Ref_Like_Current &) other;
01009 if( partition().is_compatible_with( h->partition())){
01010 H_BIN_UPDATE
01011 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
01012 bins_[i].sub( h->_bin(i) );
01013 } else {
01014 HTL_ERR("Incompatible partitions in sub(..)" );
01015 }
01016 return H_P_THIS;
01017 }
01020 void sub( const I_Histo &other ) { sub_( other ); }
01022 Ref_Like_Current mul( const Ref_Like_Current &other )
01023 {
01024 Ref_Like_Current h = (Ref_Like_Current &) other;
01025 if( partition().is_compatible_with( h->partition())) {
01026 H_BIN_UPDATE
01027 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
01028 bins_[i].mul( h->_bin(i) );
01029 } else {
01030 HTL_ERR("Incompatible partitions in mul(..)" );
01031 }
01032 return H_P_THIS;
01033 }
01036 void mul( const I_Histo &other ) { mul_( other ); }
01038 Ref_Like_Current div( const Ref_Like_Current &other )
01039 {
01040 Ref_Like_Current h = (Ref_Like_Current &) other;
01041 if( partition().is_compatible_with( h->partition())) {
01042 H_BIN_UPDATE
01043 for( Index i=0; i<bin_count()+extra_bin_count(); i++ )
01044 bins_[i].div( h->_bin(i) );
01045 } else {
01046 HTL_ERR("Incompatible partitions in div(..)" );
01047 }
01048 return H_P_THIS;
01049 }
01052 void div( const I_Histo &other ) { div_( other ); }
01054 void add( double x ) { add_( x ); }
01056 void sub( double x ) { sub_( x ); }
01058 void mul( double x ) { mul_( x ); }
01060 void div( double x ) { div_( x ); }
01061 };
01062
01063
01064 #endif
01065