From 0a38d7c334d57646799aa82a2cd142b83da1e214 Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Tue, 22 Sep 2015 14:07:12 +0200
Subject: [PATCH] More unit tests for histograms

---
 Core/PythonAPI/src/Histogram1D.pypp.cpp    | 234 -------------------
 Core/PythonAPI/src/Histogram2D.pypp.cpp    | 260 +--------------------
 Core/PythonAPI/src/IHistogram.pypp.cpp     | 220 +++++------------
 Core/Tools/inc/CumulativeValue.h           |   2 +-
 Core/Tools/inc/Histogram2D.h               |  26 +--
 Core/Tools/inc/IHistogram.h                |  23 +-
 Core/Tools/src/Histogram1D.cpp             |   9 +-
 Core/Tools/src/Histogram2D.cpp             |  29 +--
 Core/Tools/src/IHistogram.cpp              |  68 +++++-
 Tests/UnitTests/TestCore/Histogram1DTest.h |  10 +-
 Tests/UnitTests/TestCore/Histogram2DTest.h | 214 +++++++++++++++++
 11 files changed, 395 insertions(+), 700 deletions(-)

diff --git a/Core/PythonAPI/src/Histogram1D.pypp.cpp b/Core/PythonAPI/src/Histogram1D.pypp.cpp
index 0f0275bf015..249e6a71146 100644
--- a/Core/PythonAPI/src/Histogram1D.pypp.cpp
+++ b/Core/PythonAPI/src/Histogram1D.pypp.cpp
@@ -68,126 +68,6 @@ struct Histogram1D_wrapper : Histogram1D, bp::wrapper< Histogram1D > {
         return Histogram1D::getRank( );
     }
 
-    virtual ::std::size_t getTotalNumberOfBins(  ) const  {
-        if( bp::override func_getTotalNumberOfBins = this->get_override( "getTotalNumberOfBins" ) )
-            return func_getTotalNumberOfBins(  );
-        else{
-            return this->IHistogram::getTotalNumberOfBins(  );
-        }
-    }
-    
-    ::std::size_t default_getTotalNumberOfBins(  ) const  {
-        return IHistogram::getTotalNumberOfBins( );
-    }
-
-    virtual ::IAxis const * getXaxis(  ) const  {
-        if( bp::override func_getXaxis = this->get_override( "getXaxis" ) )
-            return func_getXaxis(  );
-        else{
-            return this->IHistogram::getXaxis(  );
-        }
-    }
-    
-    ::IAxis const * default_getXaxis(  ) const  {
-        return IHistogram::getXaxis( );
-    }
-
-    virtual double getXaxisValue( ::std::size_t globalbin ) {
-        if( bp::override func_getXaxisValue = this->get_override( "getXaxisValue" ) )
-            return func_getXaxisValue( globalbin );
-        else{
-            return this->IHistogram::getXaxisValue( globalbin );
-        }
-    }
-    
-    double default_getXaxisValue( ::std::size_t globalbin ) {
-        return IHistogram::getXaxisValue( globalbin );
-    }
-
-    virtual double getXmax(  ) const  {
-        if( bp::override func_getXmax = this->get_override( "getXmax" ) )
-            return func_getXmax(  );
-        else{
-            return this->IHistogram::getXmax(  );
-        }
-    }
-    
-    double default_getXmax(  ) const  {
-        return IHistogram::getXmax( );
-    }
-
-    virtual double getXmin(  ) const  {
-        if( bp::override func_getXmin = this->get_override( "getXmin" ) )
-            return func_getXmin(  );
-        else{
-            return this->IHistogram::getXmin(  );
-        }
-    }
-    
-    double default_getXmin(  ) const  {
-        return IHistogram::getXmin( );
-    }
-
-    virtual ::IAxis const * getYaxis(  ) const  {
-        if( bp::override func_getYaxis = this->get_override( "getYaxis" ) )
-            return func_getYaxis(  );
-        else{
-            return this->IHistogram::getYaxis(  );
-        }
-    }
-    
-    ::IAxis const * default_getYaxis(  ) const  {
-        return IHistogram::getYaxis( );
-    }
-
-    virtual double getYaxisValue( ::std::size_t globalbin ) {
-        if( bp::override func_getYaxisValue = this->get_override( "getYaxisValue" ) )
-            return func_getYaxisValue( globalbin );
-        else{
-            return this->IHistogram::getYaxisValue( globalbin );
-        }
-    }
-    
-    double default_getYaxisValue( ::std::size_t globalbin ) {
-        return IHistogram::getYaxisValue( globalbin );
-    }
-
-    virtual double getYmax(  ) const  {
-        if( bp::override func_getYmax = this->get_override( "getYmax" ) )
-            return func_getYmax(  );
-        else{
-            return this->IHistogram::getYmax(  );
-        }
-    }
-    
-    double default_getYmax(  ) const  {
-        return IHistogram::getYmax( );
-    }
-
-    virtual double getYmin(  ) const  {
-        if( bp::override func_getYmin = this->get_override( "getYmin" ) )
-            return func_getYmin(  );
-        else{
-            return this->IHistogram::getYmin(  );
-        }
-    }
-    
-    double default_getYmin(  ) const  {
-        return IHistogram::getYmin( );
-    }
-
-    virtual void reset(  ) {
-        if( bp::override func_reset = this->get_override( "reset" ) )
-            func_reset(  );
-        else{
-            this->IHistogram::reset(  );
-        }
-    }
-    
-    void default_reset(  ) {
-        IHistogram::reset( );
-    }
-
 };
 
 void register_Histogram1D_class(){
@@ -249,120 +129,6 @@ void register_Histogram1D_class(){
                 , default_getRank_function_type(&Histogram1D_wrapper::default_getRank) );
         
         }
-        { //::IHistogram::getTotalNumberOfBins
-        
-            typedef ::std::size_t ( ::IHistogram::*getTotalNumberOfBins_function_type)(  ) const;
-            typedef ::std::size_t ( Histogram1D_wrapper::*default_getTotalNumberOfBins_function_type)(  ) const;
-            
-            Histogram1D_exposer.def( 
-                "getTotalNumberOfBins"
-                , getTotalNumberOfBins_function_type(&::IHistogram::getTotalNumberOfBins)
-                , default_getTotalNumberOfBins_function_type(&Histogram1D_wrapper::default_getTotalNumberOfBins) );
-        
-        }
-        { //::IHistogram::getXaxis
-        
-            typedef ::IAxis const * ( ::IHistogram::*getXaxis_function_type)(  ) const;
-            typedef ::IAxis const * ( Histogram1D_wrapper::*default_getXaxis_function_type)(  ) const;
-            
-            Histogram1D_exposer.def( 
-                "getXaxis"
-                , getXaxis_function_type(&::IHistogram::getXaxis)
-                , default_getXaxis_function_type(&Histogram1D_wrapper::default_getXaxis)
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
-        }
-        { //::IHistogram::getXaxisValue
-        
-            typedef double ( ::IHistogram::*getXaxisValue_function_type)( ::std::size_t ) ;
-            typedef double ( Histogram1D_wrapper::*default_getXaxisValue_function_type)( ::std::size_t ) ;
-            
-            Histogram1D_exposer.def( 
-                "getXaxisValue"
-                , getXaxisValue_function_type(&::IHistogram::getXaxisValue)
-                , default_getXaxisValue_function_type(&Histogram1D_wrapper::default_getXaxisValue)
-                , ( bp::arg("globalbin") ) );
-        
-        }
-        { //::IHistogram::getXmax
-        
-            typedef double ( ::IHistogram::*getXmax_function_type)(  ) const;
-            typedef double ( Histogram1D_wrapper::*default_getXmax_function_type)(  ) const;
-            
-            Histogram1D_exposer.def( 
-                "getXmax"
-                , getXmax_function_type(&::IHistogram::getXmax)
-                , default_getXmax_function_type(&Histogram1D_wrapper::default_getXmax) );
-        
-        }
-        { //::IHistogram::getXmin
-        
-            typedef double ( ::IHistogram::*getXmin_function_type)(  ) const;
-            typedef double ( Histogram1D_wrapper::*default_getXmin_function_type)(  ) const;
-            
-            Histogram1D_exposer.def( 
-                "getXmin"
-                , getXmin_function_type(&::IHistogram::getXmin)
-                , default_getXmin_function_type(&Histogram1D_wrapper::default_getXmin) );
-        
-        }
-        { //::IHistogram::getYaxis
-        
-            typedef ::IAxis const * ( ::IHistogram::*getYaxis_function_type)(  ) const;
-            typedef ::IAxis const * ( Histogram1D_wrapper::*default_getYaxis_function_type)(  ) const;
-            
-            Histogram1D_exposer.def( 
-                "getYaxis"
-                , getYaxis_function_type(&::IHistogram::getYaxis)
-                , default_getYaxis_function_type(&Histogram1D_wrapper::default_getYaxis)
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
-        }
-        { //::IHistogram::getYaxisValue
-        
-            typedef double ( ::IHistogram::*getYaxisValue_function_type)( ::std::size_t ) ;
-            typedef double ( Histogram1D_wrapper::*default_getYaxisValue_function_type)( ::std::size_t ) ;
-            
-            Histogram1D_exposer.def( 
-                "getYaxisValue"
-                , getYaxisValue_function_type(&::IHistogram::getYaxisValue)
-                , default_getYaxisValue_function_type(&Histogram1D_wrapper::default_getYaxisValue)
-                , ( bp::arg("globalbin") ) );
-        
-        }
-        { //::IHistogram::getYmax
-        
-            typedef double ( ::IHistogram::*getYmax_function_type)(  ) const;
-            typedef double ( Histogram1D_wrapper::*default_getYmax_function_type)(  ) const;
-            
-            Histogram1D_exposer.def( 
-                "getYmax"
-                , getYmax_function_type(&::IHistogram::getYmax)
-                , default_getYmax_function_type(&Histogram1D_wrapper::default_getYmax) );
-        
-        }
-        { //::IHistogram::getYmin
-        
-            typedef double ( ::IHistogram::*getYmin_function_type)(  ) const;
-            typedef double ( Histogram1D_wrapper::*default_getYmin_function_type)(  ) const;
-            
-            Histogram1D_exposer.def( 
-                "getYmin"
-                , getYmin_function_type(&::IHistogram::getYmin)
-                , default_getYmin_function_type(&Histogram1D_wrapper::default_getYmin) );
-        
-        }
-        { //::IHistogram::reset
-        
-            typedef void ( ::IHistogram::*reset_function_type)(  ) ;
-            typedef void ( Histogram1D_wrapper::*default_reset_function_type)(  ) ;
-            
-            Histogram1D_exposer.def( 
-                "reset"
-                , reset_function_type(&::IHistogram::reset)
-                , default_reset_function_type(&Histogram1D_wrapper::default_reset) );
-        
-        }
     }
 
 }
diff --git a/Core/PythonAPI/src/Histogram2D.pypp.cpp b/Core/PythonAPI/src/Histogram2D.pypp.cpp
index 6474db301cb..387a2b2e92f 100644
--- a/Core/PythonAPI/src/Histogram2D.pypp.cpp
+++ b/Core/PythonAPI/src/Histogram2D.pypp.cpp
@@ -68,126 +68,6 @@ struct Histogram2D_wrapper : Histogram2D, bp::wrapper< Histogram2D > {
         return Histogram2D::getRank( );
     }
 
-    virtual ::std::size_t getTotalNumberOfBins(  ) const  {
-        if( bp::override func_getTotalNumberOfBins = this->get_override( "getTotalNumberOfBins" ) )
-            return func_getTotalNumberOfBins(  );
-        else{
-            return this->IHistogram::getTotalNumberOfBins(  );
-        }
-    }
-    
-    ::std::size_t default_getTotalNumberOfBins(  ) const  {
-        return IHistogram::getTotalNumberOfBins( );
-    }
-
-    virtual ::IAxis const * getXaxis(  ) const  {
-        if( bp::override func_getXaxis = this->get_override( "getXaxis" ) )
-            return func_getXaxis(  );
-        else{
-            return this->IHistogram::getXaxis(  );
-        }
-    }
-    
-    ::IAxis const * default_getXaxis(  ) const  {
-        return IHistogram::getXaxis( );
-    }
-
-    virtual double getXaxisValue( ::std::size_t globalbin ) {
-        if( bp::override func_getXaxisValue = this->get_override( "getXaxisValue" ) )
-            return func_getXaxisValue( globalbin );
-        else{
-            return this->IHistogram::getXaxisValue( globalbin );
-        }
-    }
-    
-    double default_getXaxisValue( ::std::size_t globalbin ) {
-        return IHistogram::getXaxisValue( globalbin );
-    }
-
-    virtual double getXmax(  ) const  {
-        if( bp::override func_getXmax = this->get_override( "getXmax" ) )
-            return func_getXmax(  );
-        else{
-            return this->IHistogram::getXmax(  );
-        }
-    }
-    
-    double default_getXmax(  ) const  {
-        return IHistogram::getXmax( );
-    }
-
-    virtual double getXmin(  ) const  {
-        if( bp::override func_getXmin = this->get_override( "getXmin" ) )
-            return func_getXmin(  );
-        else{
-            return this->IHistogram::getXmin(  );
-        }
-    }
-    
-    double default_getXmin(  ) const  {
-        return IHistogram::getXmin( );
-    }
-
-    virtual ::IAxis const * getYaxis(  ) const  {
-        if( bp::override func_getYaxis = this->get_override( "getYaxis" ) )
-            return func_getYaxis(  );
-        else{
-            return this->IHistogram::getYaxis(  );
-        }
-    }
-    
-    ::IAxis const * default_getYaxis(  ) const  {
-        return IHistogram::getYaxis( );
-    }
-
-    virtual double getYaxisValue( ::std::size_t globalbin ) {
-        if( bp::override func_getYaxisValue = this->get_override( "getYaxisValue" ) )
-            return func_getYaxisValue( globalbin );
-        else{
-            return this->IHistogram::getYaxisValue( globalbin );
-        }
-    }
-    
-    double default_getYaxisValue( ::std::size_t globalbin ) {
-        return IHistogram::getYaxisValue( globalbin );
-    }
-
-    virtual double getYmax(  ) const  {
-        if( bp::override func_getYmax = this->get_override( "getYmax" ) )
-            return func_getYmax(  );
-        else{
-            return this->IHistogram::getYmax(  );
-        }
-    }
-    
-    double default_getYmax(  ) const  {
-        return IHistogram::getYmax( );
-    }
-
-    virtual double getYmin(  ) const  {
-        if( bp::override func_getYmin = this->get_override( "getYmin" ) )
-            return func_getYmin(  );
-        else{
-            return this->IHistogram::getYmin(  );
-        }
-    }
-    
-    double default_getYmin(  ) const  {
-        return IHistogram::getYmin( );
-    }
-
-    virtual void reset(  ) {
-        if( bp::override func_reset = this->get_override( "reset" ) )
-            func_reset(  );
-        else{
-            this->IHistogram::reset(  );
-        }
-    }
-    
-    void default_reset(  ) {
-        IHistogram::reset( );
-    }
-
 };
 
 void register_Histogram2D_class(){
@@ -235,14 +115,13 @@ void register_Histogram2D_class(){
         }
         { //::Histogram2D::projectionX
         
-            typedef ::Histogram1D * ( ::Histogram2D::*projectionX_function_type)( ::IHistogram::ProjectionType ) ;
+            typedef ::Histogram1D * ( ::Histogram2D::*projectionX_function_type)(  ) ;
             
             Histogram2D_exposer.def( 
                 "projectionX"
                 , projectionX_function_type( &::Histogram2D::projectionX )
-                , ( bp::arg("projectionType")=::IHistogram::INTEGRAL )
                 , bp::return_value_policy< bp::manage_new_object >()
-                , "Project a 2D histogram into 1D histogram along X. The projection is made from all bins along y-axis. The content is either integrated or averaged. @param projectionType defines type of projection (INTEGRAL or AVERAGE) \n\n:Parameters:\n  - 'projectionType' - defines type of projection (INTEGRAL or AVERAGE)\n" );
+                , "Project a 2D histogram into 1D histogram along X. The projection is made from all bins along y-axis. " );
         
         }
         { //::Histogram2D::projectionX
@@ -254,31 +133,30 @@ void register_Histogram2D_class(){
                 , projectionX_function_type( &::Histogram2D::projectionX )
                 , ( bp::arg("yvalue") )
                 , bp::return_value_policy< bp::manage_new_object >()
-                , "Project a 2D histogram into 1D histogram along X. The projection is made from the y-bin corresponding to ordinate yvalue. @param yvalue the value on y-axis at which projection is taken \n\n:Parameters:\n  - 'yvalue' - the value on y-axis at which projection is taken\n" );
+                , "Project a 2D histogram into 1D histogram along X. The projection is made from the y-bin closest to given ordinate yvalue. @param yvalue the value on y-axis at which projection is taken \n\n:Parameters:\n  - 'yvalue' - the value on y-axis at which projection is taken\n" );
         
         }
         { //::Histogram2D::projectionX
         
-            typedef ::Histogram1D * ( ::Histogram2D::*projectionX_function_type)( double,double,::IHistogram::ProjectionType ) ;
+            typedef ::Histogram1D * ( ::Histogram2D::*projectionX_function_type)( double,double ) ;
             
             Histogram2D_exposer.def( 
                 "projectionX"
                 , projectionX_function_type( &::Histogram2D::projectionX )
-                , ( bp::arg("ylow"), bp::arg("yup"), bp::arg("projectionType")=::IHistogram::INTEGRAL )
+                , ( bp::arg("ylow"), bp::arg("yup") )
                 , bp::return_value_policy< bp::manage_new_object >()
-                , "Project a 2D histogram into 1D histogram along X. The projection is made from all y-bins corresponding to ordinate between ylow and yup. The content is either integrated or averaged. @param ylow lower edje on y-axis @param yup upper edje on y-axis @param projectionType defines type of projection (INTEGRAL or AVERAGE) \n\n:Parameters:\n  - 'ylow' - lower edje on y-axis\n  - 'yup' - upper edje on y-axis\n  - 'projectionType' - defines type of projection (INTEGRAL or AVERAGE)\n" );
+                , "Project a 2D histogram into 1D histogram along X. The projection is made from all y-bins corresponding to ordinate between ylow and yup. @param ylow lower edje on y-axis @param yup upper edje on y-axis \n\n:Parameters:\n  - 'ylow' - lower edje on y-axis\n  - 'yup' - upper edje on y-axis\n" );
         
         }
         { //::Histogram2D::projectionY
         
-            typedef ::Histogram1D * ( ::Histogram2D::*projectionY_function_type)( ::IHistogram::ProjectionType ) ;
+            typedef ::Histogram1D * ( ::Histogram2D::*projectionY_function_type)(  ) ;
             
             Histogram2D_exposer.def( 
                 "projectionY"
                 , projectionY_function_type( &::Histogram2D::projectionY )
-                , ( bp::arg("projectionType")=::IHistogram::INTEGRAL )
                 , bp::return_value_policy< bp::manage_new_object >()
-                , "Project a 2D histogram into 1D histogram along Y. The projection is made from all bins along x-axis. The content is either integrated or averaged. @param projectionType defines type of projection (INTEGRAL or AVERAGE) \n\n:Parameters:\n  - 'projectionType' - defines type of projection (INTEGRAL or AVERAGE)\n" );
+                , "Project a 2D histogram into 1D histogram along Y. The projection is made from all bins along x-axis. " );
         
         }
         { //::Histogram2D::projectionY
@@ -290,133 +168,19 @@ void register_Histogram2D_class(){
                 , projectionY_function_type( &::Histogram2D::projectionY )
                 , ( bp::arg("xvalue") )
                 , bp::return_value_policy< bp::manage_new_object >()
-                , "Project a 2D histogram into 1D histogram along Y. The projection is made from the x-bin corresponding to abscissa xvalue. @param xvalue the value on x-axis at which projection is taken \n\n:Parameters:\n  - 'xvalue' - the value on x-axis at which projection is taken\n" );
+                , "Project a 2D histogram into 1D histogram along Y. The projection is made from the x-bin closest to given abscissa xvalue. @param xvalue the value on x-axis at which projection is taken \n\n:Parameters:\n  - 'xvalue' - the value on x-axis at which projection is taken\n" );
         
         }
         { //::Histogram2D::projectionY
         
-            typedef ::Histogram1D * ( ::Histogram2D::*projectionY_function_type)( double,double,::IHistogram::ProjectionType ) ;
+            typedef ::Histogram1D * ( ::Histogram2D::*projectionY_function_type)( double,double ) ;
             
             Histogram2D_exposer.def( 
                 "projectionY"
                 , projectionY_function_type( &::Histogram2D::projectionY )
-                , ( bp::arg("xlow"), bp::arg("xup"), bp::arg("projectionType")=::IHistogram::INTEGRAL )
+                , ( bp::arg("xlow"), bp::arg("xup") )
                 , bp::return_value_policy< bp::manage_new_object >()
-                , "Project a 2D histogram into 1D histogram along Y. The projection is made from all x-bins corresponding to abscissa between xlow and xup. The content is either integrated or averaged. @param xlow lower edje on x-axis @param xup upper edje on x-axis @param projectionType defines type of projection (INTEGRAL or AVERAGE) \n\n:Parameters:\n  - 'xlow' - lower edje on x-axis\n  - 'xup' - upper edje on x-axis\n  - 'projectionType' - defines type of projection (INTEGRAL or AVERAGE)\n" );
-        
-        }
-        { //::IHistogram::getTotalNumberOfBins
-        
-            typedef ::std::size_t ( ::IHistogram::*getTotalNumberOfBins_function_type)(  ) const;
-            typedef ::std::size_t ( Histogram2D_wrapper::*default_getTotalNumberOfBins_function_type)(  ) const;
-            
-            Histogram2D_exposer.def( 
-                "getTotalNumberOfBins"
-                , getTotalNumberOfBins_function_type(&::IHistogram::getTotalNumberOfBins)
-                , default_getTotalNumberOfBins_function_type(&Histogram2D_wrapper::default_getTotalNumberOfBins) );
-        
-        }
-        { //::IHistogram::getXaxis
-        
-            typedef ::IAxis const * ( ::IHistogram::*getXaxis_function_type)(  ) const;
-            typedef ::IAxis const * ( Histogram2D_wrapper::*default_getXaxis_function_type)(  ) const;
-            
-            Histogram2D_exposer.def( 
-                "getXaxis"
-                , getXaxis_function_type(&::IHistogram::getXaxis)
-                , default_getXaxis_function_type(&Histogram2D_wrapper::default_getXaxis)
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
-        }
-        { //::IHistogram::getXaxisValue
-        
-            typedef double ( ::IHistogram::*getXaxisValue_function_type)( ::std::size_t ) ;
-            typedef double ( Histogram2D_wrapper::*default_getXaxisValue_function_type)( ::std::size_t ) ;
-            
-            Histogram2D_exposer.def( 
-                "getXaxisValue"
-                , getXaxisValue_function_type(&::IHistogram::getXaxisValue)
-                , default_getXaxisValue_function_type(&Histogram2D_wrapper::default_getXaxisValue)
-                , ( bp::arg("globalbin") ) );
-        
-        }
-        { //::IHistogram::getXmax
-        
-            typedef double ( ::IHistogram::*getXmax_function_type)(  ) const;
-            typedef double ( Histogram2D_wrapper::*default_getXmax_function_type)(  ) const;
-            
-            Histogram2D_exposer.def( 
-                "getXmax"
-                , getXmax_function_type(&::IHistogram::getXmax)
-                , default_getXmax_function_type(&Histogram2D_wrapper::default_getXmax) );
-        
-        }
-        { //::IHistogram::getXmin
-        
-            typedef double ( ::IHistogram::*getXmin_function_type)(  ) const;
-            typedef double ( Histogram2D_wrapper::*default_getXmin_function_type)(  ) const;
-            
-            Histogram2D_exposer.def( 
-                "getXmin"
-                , getXmin_function_type(&::IHistogram::getXmin)
-                , default_getXmin_function_type(&Histogram2D_wrapper::default_getXmin) );
-        
-        }
-        { //::IHistogram::getYaxis
-        
-            typedef ::IAxis const * ( ::IHistogram::*getYaxis_function_type)(  ) const;
-            typedef ::IAxis const * ( Histogram2D_wrapper::*default_getYaxis_function_type)(  ) const;
-            
-            Histogram2D_exposer.def( 
-                "getYaxis"
-                , getYaxis_function_type(&::IHistogram::getYaxis)
-                , default_getYaxis_function_type(&Histogram2D_wrapper::default_getYaxis)
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
-        }
-        { //::IHistogram::getYaxisValue
-        
-            typedef double ( ::IHistogram::*getYaxisValue_function_type)( ::std::size_t ) ;
-            typedef double ( Histogram2D_wrapper::*default_getYaxisValue_function_type)( ::std::size_t ) ;
-            
-            Histogram2D_exposer.def( 
-                "getYaxisValue"
-                , getYaxisValue_function_type(&::IHistogram::getYaxisValue)
-                , default_getYaxisValue_function_type(&Histogram2D_wrapper::default_getYaxisValue)
-                , ( bp::arg("globalbin") ) );
-        
-        }
-        { //::IHistogram::getYmax
-        
-            typedef double ( ::IHistogram::*getYmax_function_type)(  ) const;
-            typedef double ( Histogram2D_wrapper::*default_getYmax_function_type)(  ) const;
-            
-            Histogram2D_exposer.def( 
-                "getYmax"
-                , getYmax_function_type(&::IHistogram::getYmax)
-                , default_getYmax_function_type(&Histogram2D_wrapper::default_getYmax) );
-        
-        }
-        { //::IHistogram::getYmin
-        
-            typedef double ( ::IHistogram::*getYmin_function_type)(  ) const;
-            typedef double ( Histogram2D_wrapper::*default_getYmin_function_type)(  ) const;
-            
-            Histogram2D_exposer.def( 
-                "getYmin"
-                , getYmin_function_type(&::IHistogram::getYmin)
-                , default_getYmin_function_type(&Histogram2D_wrapper::default_getYmin) );
-        
-        }
-        { //::IHistogram::reset
-        
-            typedef void ( ::IHistogram::*reset_function_type)(  ) ;
-            typedef void ( Histogram2D_wrapper::*default_reset_function_type)(  ) ;
-            
-            Histogram2D_exposer.def( 
-                "reset"
-                , reset_function_type(&::IHistogram::reset)
-                , default_reset_function_type(&Histogram2D_wrapper::default_reset) );
+                , "Project a 2D histogram into 1D histogram along Y. The projection is made from all x-bins corresponding to abscissa between xlow and xup. @param xlow lower edje on x-axis @param xup upper edje on x-axis \n\n:Parameters:\n  - 'xlow' - lower edje on x-axis\n  - 'xup' - upper edje on x-axis\n" );
         
         }
     }
diff --git a/Core/PythonAPI/src/IHistogram.pypp.cpp b/Core/PythonAPI/src/IHistogram.pypp.cpp
index 779870c105a..7fbbe377577 100644
--- a/Core/PythonAPI/src/IHistogram.pypp.cpp
+++ b/Core/PythonAPI/src/IHistogram.pypp.cpp
@@ -49,13 +49,6 @@ struct IHistogram_wrapper : IHistogram, bp::wrapper< IHistogram > {
     
     }
 
-    IHistogram_wrapper(::OutputData< double > const & source )
-    : IHistogram( boost::ref(source) )
-      , bp::wrapper< IHistogram >(){
-        // constructor
-    
-    }
-
     virtual ::std::size_t getRank(  ) const  {
         if( bp::override func_getRank = this->get_override( "getRank" ) )
             return func_getRank(  );
@@ -68,126 +61,6 @@ struct IHistogram_wrapper : IHistogram, bp::wrapper< IHistogram > {
         return IHistogram::getRank( );
     }
 
-    virtual ::std::size_t getTotalNumberOfBins(  ) const  {
-        if( bp::override func_getTotalNumberOfBins = this->get_override( "getTotalNumberOfBins" ) )
-            return func_getTotalNumberOfBins(  );
-        else{
-            return this->IHistogram::getTotalNumberOfBins(  );
-        }
-    }
-    
-    ::std::size_t default_getTotalNumberOfBins(  ) const  {
-        return IHistogram::getTotalNumberOfBins( );
-    }
-
-    virtual ::IAxis const * getXaxis(  ) const  {
-        if( bp::override func_getXaxis = this->get_override( "getXaxis" ) )
-            return func_getXaxis(  );
-        else{
-            return this->IHistogram::getXaxis(  );
-        }
-    }
-    
-    ::IAxis const * default_getXaxis(  ) const  {
-        return IHistogram::getXaxis( );
-    }
-
-    virtual double getXaxisValue( ::std::size_t globalbin ) {
-        if( bp::override func_getXaxisValue = this->get_override( "getXaxisValue" ) )
-            return func_getXaxisValue( globalbin );
-        else{
-            return this->IHistogram::getXaxisValue( globalbin );
-        }
-    }
-    
-    double default_getXaxisValue( ::std::size_t globalbin ) {
-        return IHistogram::getXaxisValue( globalbin );
-    }
-
-    virtual double getXmax(  ) const  {
-        if( bp::override func_getXmax = this->get_override( "getXmax" ) )
-            return func_getXmax(  );
-        else{
-            return this->IHistogram::getXmax(  );
-        }
-    }
-    
-    double default_getXmax(  ) const  {
-        return IHistogram::getXmax( );
-    }
-
-    virtual double getXmin(  ) const  {
-        if( bp::override func_getXmin = this->get_override( "getXmin" ) )
-            return func_getXmin(  );
-        else{
-            return this->IHistogram::getXmin(  );
-        }
-    }
-    
-    double default_getXmin(  ) const  {
-        return IHistogram::getXmin( );
-    }
-
-    virtual ::IAxis const * getYaxis(  ) const  {
-        if( bp::override func_getYaxis = this->get_override( "getYaxis" ) )
-            return func_getYaxis(  );
-        else{
-            return this->IHistogram::getYaxis(  );
-        }
-    }
-    
-    ::IAxis const * default_getYaxis(  ) const  {
-        return IHistogram::getYaxis( );
-    }
-
-    virtual double getYaxisValue( ::std::size_t globalbin ) {
-        if( bp::override func_getYaxisValue = this->get_override( "getYaxisValue" ) )
-            return func_getYaxisValue( globalbin );
-        else{
-            return this->IHistogram::getYaxisValue( globalbin );
-        }
-    }
-    
-    double default_getYaxisValue( ::std::size_t globalbin ) {
-        return IHistogram::getYaxisValue( globalbin );
-    }
-
-    virtual double getYmax(  ) const  {
-        if( bp::override func_getYmax = this->get_override( "getYmax" ) )
-            return func_getYmax(  );
-        else{
-            return this->IHistogram::getYmax(  );
-        }
-    }
-    
-    double default_getYmax(  ) const  {
-        return IHistogram::getYmax( );
-    }
-
-    virtual double getYmin(  ) const  {
-        if( bp::override func_getYmin = this->get_override( "getYmin" ) )
-            return func_getYmin(  );
-        else{
-            return this->IHistogram::getYmin(  );
-        }
-    }
-    
-    double default_getYmin(  ) const  {
-        return IHistogram::getYmin( );
-    }
-
-    virtual void reset(  ) {
-        if( bp::override func_reset = this->get_override( "reset" ) )
-            func_reset(  );
-        else{
-            this->IHistogram::reset(  );
-        }
-    }
-    
-    void default_reset(  ) {
-        IHistogram::reset( );
-    }
-
 };
 
 void register_IHistogram_class(){
@@ -196,14 +69,15 @@ void register_IHistogram_class(){
         typedef bp::class_< IHistogram_wrapper, boost::noncopyable > IHistogram_exposer_t;
         IHistogram_exposer_t IHistogram_exposer = IHistogram_exposer_t( "IHistogram", "Base class for 1D and 2D histograms holding values of double typ.", bp::init< >() );
         bp::scope IHistogram_scope( IHistogram_exposer );
-        bp::enum_< IHistogram::ProjectionType>("ProjectionType")
+        bp::enum_< IHistogram::DataType>("DataType")
             .value("INTEGRAL", IHistogram::INTEGRAL)
             .value("AVERAGE", IHistogram::AVERAGE)
+            .value("ERROR", IHistogram::ERROR)
+            .value("NENTRIES", IHistogram::NENTRIES)
             .export_values()
             ;
         IHistogram_exposer.def( bp::init< IAxis const & >(( bp::arg("axis_x") )) );
         IHistogram_exposer.def( bp::init< IAxis const &, IAxis const & >(( bp::arg("axis_x"), bp::arg("axis_y") )) );
-        IHistogram_exposer.def( bp::init< OutputData< double > const & >(( bp::arg("source") )) );
         { //::IHistogram::getArray
         
             typedef ::PyObject * ( ::IHistogram::*getArray_function_type)(  ) const;
@@ -289,6 +163,26 @@ void register_IHistogram_class(){
                 , ( bp::arg("binx"), bp::arg("biny")=(int)(0) )
                 , "Returns global bin index for given axes indices. For 1D histogram the global bin index coinside with axis index. @param binx X-axis bin index @param biny Y-axis bin index @return The global bin index \n\n:Parameters:\n  - 'binx' - X-axis bin index\n  - 'biny' - Y-axis bin index\n" );
         
+        }
+        { //::IHistogram::getNbinsX
+        
+            typedef ::std::size_t ( ::IHistogram::*getNbinsX_function_type)(  ) const;
+            
+            IHistogram_exposer.def( 
+                "getNbinsX"
+                , getNbinsX_function_type( &::IHistogram::getNbinsX )
+                , "Returns number of bins on x-axis." );
+        
+        }
+        { //::IHistogram::getNbinsY
+        
+            typedef ::std::size_t ( ::IHistogram::*getNbinsY_function_type)(  ) const;
+            
+            IHistogram_exposer.def( 
+                "getNbinsY"
+                , getNbinsY_function_type( &::IHistogram::getNbinsY )
+                , "Returns number of bins on y-axis." );
+        
         }
         { //::IHistogram::getRank
         
@@ -304,24 +198,22 @@ void register_IHistogram_class(){
         { //::IHistogram::getTotalNumberOfBins
         
             typedef ::std::size_t ( ::IHistogram::*getTotalNumberOfBins_function_type)(  ) const;
-            typedef ::std::size_t ( IHistogram_wrapper::*default_getTotalNumberOfBins_function_type)(  ) const;
             
             IHistogram_exposer.def( 
                 "getTotalNumberOfBins"
-                , getTotalNumberOfBins_function_type(&::IHistogram::getTotalNumberOfBins)
-                , default_getTotalNumberOfBins_function_type(&IHistogram_wrapper::default_getTotalNumberOfBins) );
+                , getTotalNumberOfBins_function_type( &::IHistogram::getTotalNumberOfBins )
+                , "Returns total number of histogram bins. For 2D histograms the result will be the product of bin numbers along X and Y axes. " );
         
         }
         { //::IHistogram::getXaxis
         
             typedef ::IAxis const * ( ::IHistogram::*getXaxis_function_type)(  ) const;
-            typedef ::IAxis const * ( IHistogram_wrapper::*default_getXaxis_function_type)(  ) const;
             
             IHistogram_exposer.def( 
                 "getXaxis"
-                , getXaxis_function_type(&::IHistogram::getXaxis)
-                , default_getXaxis_function_type(&IHistogram_wrapper::default_getXaxis)
-                , bp::return_value_policy< bp::reference_existing_object >() );
+                , getXaxis_function_type( &::IHistogram::getXaxis )
+                , bp::return_value_policy< bp::reference_existing_object >()
+                , "returns x-axis." );
         
         }
         { //::IHistogram::getXaxisIndex
@@ -338,47 +230,43 @@ void register_IHistogram_class(){
         { //::IHistogram::getXaxisValue
         
             typedef double ( ::IHistogram::*getXaxisValue_function_type)( ::std::size_t ) ;
-            typedef double ( IHistogram_wrapper::*default_getXaxisValue_function_type)( ::std::size_t ) ;
             
             IHistogram_exposer.def( 
                 "getXaxisValue"
-                , getXaxisValue_function_type(&::IHistogram::getXaxisValue)
-                , default_getXaxisValue_function_type(&IHistogram_wrapper::default_getXaxisValue)
-                , ( bp::arg("globalbin") ) );
+                , getXaxisValue_function_type( &::IHistogram::getXaxisValue )
+                , ( bp::arg("globalbin") )
+                , "Returns the value on x-axis corresponding to the global bin index. @param binGlobalIndex The global bin index @return The center of axis's corresponding bin \n\n:Parameters:\n  - 'binGlobalIndex' - The global bin index\n" );
         
         }
         { //::IHistogram::getXmax
         
             typedef double ( ::IHistogram::*getXmax_function_type)(  ) const;
-            typedef double ( IHistogram_wrapper::*default_getXmax_function_type)(  ) const;
             
             IHistogram_exposer.def( 
                 "getXmax"
-                , getXmax_function_type(&::IHistogram::getXmax)
-                , default_getXmax_function_type(&IHistogram_wrapper::default_getXmax) );
+                , getXmax_function_type( &::IHistogram::getXmax )
+                , "Returns x-axis max (upper edge of last bin)." );
         
         }
         { //::IHistogram::getXmin
         
             typedef double ( ::IHistogram::*getXmin_function_type)(  ) const;
-            typedef double ( IHistogram_wrapper::*default_getXmin_function_type)(  ) const;
             
             IHistogram_exposer.def( 
                 "getXmin"
-                , getXmin_function_type(&::IHistogram::getXmin)
-                , default_getXmin_function_type(&IHistogram_wrapper::default_getXmin) );
+                , getXmin_function_type( &::IHistogram::getXmin )
+                , "Returns x-axis min (lower edge of first bin)." );
         
         }
         { //::IHistogram::getYaxis
         
             typedef ::IAxis const * ( ::IHistogram::*getYaxis_function_type)(  ) const;
-            typedef ::IAxis const * ( IHistogram_wrapper::*default_getYaxis_function_type)(  ) const;
             
             IHistogram_exposer.def( 
                 "getYaxis"
-                , getYaxis_function_type(&::IHistogram::getYaxis)
-                , default_getYaxis_function_type(&IHistogram_wrapper::default_getYaxis)
-                , bp::return_value_policy< bp::reference_existing_object >() );
+                , getYaxis_function_type( &::IHistogram::getYaxis )
+                , bp::return_value_policy< bp::reference_existing_object >()
+                , "returns y-axis for 2D histograms." );
         
         }
         { //::IHistogram::getYaxisIndex
@@ -395,46 +283,52 @@ void register_IHistogram_class(){
         { //::IHistogram::getYaxisValue
         
             typedef double ( ::IHistogram::*getYaxisValue_function_type)( ::std::size_t ) ;
-            typedef double ( IHistogram_wrapper::*default_getYaxisValue_function_type)( ::std::size_t ) ;
             
             IHistogram_exposer.def( 
                 "getYaxisValue"
-                , getYaxisValue_function_type(&::IHistogram::getYaxisValue)
-                , default_getYaxisValue_function_type(&IHistogram_wrapper::default_getYaxisValue)
-                , ( bp::arg("globalbin") ) );
+                , getYaxisValue_function_type( &::IHistogram::getYaxisValue )
+                , ( bp::arg("globalbin") )
+                , "Returns the value on y-axis corresponding to the global bin index (for 2D histograms). @param globalbin The global bin index @return The center of axis's corresponding bin \n\n:Parameters:\n  - 'globalbin' - The global bin index\n" );
         
         }
         { //::IHistogram::getYmax
         
             typedef double ( ::IHistogram::*getYmax_function_type)(  ) const;
-            typedef double ( IHistogram_wrapper::*default_getYmax_function_type)(  ) const;
             
             IHistogram_exposer.def( 
                 "getYmax"
-                , getYmax_function_type(&::IHistogram::getYmax)
-                , default_getYmax_function_type(&IHistogram_wrapper::default_getYmax) );
+                , getYmax_function_type( &::IHistogram::getYmax )
+                , "Returns y-axis max (upper edge of last bin) for 2D histograms." );
         
         }
         { //::IHistogram::getYmin
         
             typedef double ( ::IHistogram::*getYmin_function_type)(  ) const;
-            typedef double ( IHistogram_wrapper::*default_getYmin_function_type)(  ) const;
             
             IHistogram_exposer.def( 
                 "getYmin"
-                , getYmin_function_type(&::IHistogram::getYmin)
-                , default_getYmin_function_type(&IHistogram_wrapper::default_getYmin) );
+                , getYmin_function_type( &::IHistogram::getYmin )
+                , "Returns y-axis min (lower edge of first bin) for 2D histograms." );
         
         }
         { //::IHistogram::reset
         
             typedef void ( ::IHistogram::*reset_function_type)(  ) ;
-            typedef void ( IHistogram_wrapper::*default_reset_function_type)(  ) ;
             
             IHistogram_exposer.def( 
                 "reset"
-                , reset_function_type(&::IHistogram::reset)
-                , default_reset_function_type(&IHistogram_wrapper::default_reset) );
+                , reset_function_type( &::IHistogram::reset )
+                , "Reset histogram content (axes remains)." );
+        
+        }
+        { //::IHistogram::setDataType
+        
+            typedef void ( ::IHistogram::*setDataType_function_type)( ::IHistogram::DataType ) ;
+            
+            IHistogram_exposer.def( 
+                "setDataType"
+                , setDataType_function_type( &::IHistogram::setDataType )
+                , ( bp::arg("data_type") ) );
         
         }
     }
diff --git a/Core/Tools/inc/CumulativeValue.h b/Core/Tools/inc/CumulativeValue.h
index a03e4b282d5..8006edf3b97 100644
--- a/Core/Tools/inc/CumulativeValue.h
+++ b/Core/Tools/inc/CumulativeValue.h
@@ -43,7 +43,7 @@ private:
     int m_n_entries;
     double m_sum;
     double m_average;
-    double m_rms2;
+    double m_rms2; //sum[ (x-x_aver)^2]/nentries
     double m_sum_of_weights;
 };
 
diff --git a/Core/Tools/inc/Histogram2D.h b/Core/Tools/inc/Histogram2D.h
index 724c3c4ecd7..b939e63bc84 100644
--- a/Core/Tools/inc/Histogram2D.h
+++ b/Core/Tools/inc/Histogram2D.h
@@ -65,41 +65,35 @@ public:
 
 
     //! Project a 2D histogram into 1D histogram along X. The projection is made
-    //! from all bins along y-axis. The content is either integrated or averaged.
-    //! @param projectionType defines type of projection (INTEGRAL or AVERAGE)
-    Histogram1D *projectionX(ProjectionType projectionType = INTEGRAL);
+    //! from all bins along y-axis.
+    Histogram1D *projectionX();
 
     //! Project a 2D histogram into 1D histogram along X. The projection is made
-    //! from the y-bin corresponding to ordinate yvalue.
+    //! from the y-bin closest to given ordinate yvalue.
     //! @param yvalue the value on y-axis at which projection is taken
     Histogram1D *projectionX(double yvalue);
 
     //! Project a 2D histogram into 1D histogram along X. The projection is made from
     //! all y-bins corresponding to ordinate between ylow and yup.
-    //! The content is either integrated or averaged.
     //! @param ylow lower edje on y-axis
     //! @param yup upper edje on y-axis
-    //! @param projectionType defines type of projection (INTEGRAL or AVERAGE)
-    Histogram1D *projectionX(double ylow, double yup, ProjectionType projectionType = INTEGRAL);
+    Histogram1D *projectionX(double ylow, double yup);
 
 
     //! Project a 2D histogram into 1D histogram along Y. The projection is made
-    //! from all bins along x-axis. The content is either integrated or averaged.
-    //! @param projectionType defines type of projection (INTEGRAL or AVERAGE)
-    Histogram1D *projectionY(ProjectionType projectionType = INTEGRAL);
+    //! from all bins along x-axis.
+    Histogram1D *projectionY();
 
     //! Project a 2D histogram into 1D histogram along Y. The projection is made
-    //! from the x-bin corresponding to abscissa xvalue.
+    //! from the x-bin closest to given abscissa xvalue.
     //! @param xvalue the value on x-axis at which projection is taken
     Histogram1D *projectionY(double xvalue);
 
     //! Project a 2D histogram into 1D histogram along Y. The projection is made from
     //! all x-bins corresponding to abscissa between xlow and xup.
-    //! The content is either integrated or averaged.
     //! @param xlow lower edje on x-axis
     //! @param xup upper edje on x-axis
-    //! @param projectionType defines type of projection (INTEGRAL or AVERAGE)
-    Histogram1D *projectionY(double xlow, double xup, ProjectionType projectionType = INTEGRAL);
+    Histogram1D *projectionY(double xlow, double xup);
 
 
     //! Create new histogram by applying rectangular clip.
@@ -123,11 +117,11 @@ public:
 protected:
     //! Creates projection along X. The projections is made by collecting the data in the range
     //! between [ybinlow, ybinup].
-    Histogram1D *create_projectionX(int ybinlow, int ybinup, ProjectionType projectionType = INTEGRAL);
+    Histogram1D *create_projectionX(int ybinlow, int ybinup);
 
     //! Creates projection along Y. The projections is made by collecting the data in the range
     //! between [xbinlow, xbinup].
-    Histogram1D *create_projectionY(int xbinlow, int xbinup, ProjectionType projectionType = INTEGRAL);
+    Histogram1D *create_projectionY(int xbinlow, int xbinup);
 
 };
 
diff --git a/Core/Tools/inc/IHistogram.h b/Core/Tools/inc/IHistogram.h
index 99383bcdd96..bad7f4d7179 100644
--- a/Core/Tools/inc/IHistogram.h
+++ b/Core/Tools/inc/IHistogram.h
@@ -26,6 +26,9 @@ typedef _object PyObject;
 #endif
 #endif
 
+class Histogram1D;
+class Histogram2D;
+
 //! @class IHistogram
 //! @ingroup tools
 //! @brief Base class for 1D and 2D histograms holding values of double type
@@ -34,14 +37,13 @@ class IHistogram
 {
 public:
 
-    enum ProjectionType {INTEGRAL, AVERAGE};
+    enum DataType {INTEGRAL, AVERAGE, ERROR, NENTRIES};
 
-    IHistogram(){}
+    IHistogram();
     virtual ~IHistogram(){}
 
     IHistogram(const IAxis &axis_x);
     IHistogram(const IAxis &axis_x, const IAxis &axis_y);
-    IHistogram(const OutputData<double> &source);
 
     //! Returns number of histogram dimensions (1 or 2).
     virtual size_t getRank() const;
@@ -62,12 +64,18 @@ public:
     //! Returns x-axis max (upper edge of last bin).
     double getXmax() const;
 
+    //! Returns number of bins on x-axis
+    size_t getNbinsX() const;
+
     //! Returns y-axis min (lower edge of first bin) for 2D histograms.
     double getYmin() const;
 
     //! Returns y-axis max (upper edge of last bin) for 2D histograms.
     double getYmax() const;
 
+    //! Returns number of bins on y-axis
+    size_t getNbinsY() const;
+
     //! Returns global bin index for given axes indices. For 1D histogram the global bin
     //! index coinside with axis index.
     //! @param binx X-axis bin index
@@ -125,9 +133,16 @@ public:
 #endif
 
     //! Reset histogram content (axes remains)
-    virtual void reset();
+    void reset();
+
+//    static Histogram1D *createHistogram1D(const OutputData<double> &source);
+//    static Histogram2D *createHistogram2D(const OutputData<double> &source);
+
+    void setDataType(DataType data_type);
 
 protected:
+    DataType m_data_type;
+
     void check_x_axis() const;
     void check_y_axis() const;
     void init_from_data(const OutputData<double> &source);
diff --git a/Core/Tools/src/Histogram1D.cpp b/Core/Tools/src/Histogram1D.cpp
index 9235923a65f..5a94aa68e44 100644
--- a/Core/Tools/src/Histogram1D.cpp
+++ b/Core/Tools/src/Histogram1D.cpp
@@ -35,15 +35,8 @@ Histogram1D::Histogram1D(const IAxis &axis)
 }
 
 Histogram1D::Histogram1D(const OutputData<double> &data)
-    : IHistogram(data)
 {
-    if(getRank() != m_data.getRank()) {
-        std::ostringstream message;
-        message << "IHistogram::IHistogram(const OutputData<double> &data) -> Error. ";
-        message << "The dimension of this histogram " << getRank() << " ";
-        message << "is differ from the dimension of source " << m_data.getRank() << std::endl;
-        throw LogicErrorException(message.str());
-    }
+    init_from_data(data);
 }
 
 int Histogram1D::fill(double x, double weight)
diff --git a/Core/Tools/src/Histogram2D.cpp b/Core/Tools/src/Histogram2D.cpp
index 8ef5b7321d5..a169a269a77 100644
--- a/Core/Tools/src/Histogram2D.cpp
+++ b/Core/Tools/src/Histogram2D.cpp
@@ -38,15 +38,8 @@ Histogram2D::Histogram2D(const IAxis &axis_x, const IAxis &axis_y)
 }
 
 Histogram2D::Histogram2D(const OutputData<double> &data)
-    : IHistogram(data)
 {
-    if(getRank() != m_data.getRank()) {
-        std::ostringstream message;
-        message << "IHistogram::IHistogram(const OutputData<double> &data) -> Error. ";
-        message << "The dimension of this histogram " << getRank() << " ";
-        message << "is differ from the dimension of source " << m_data.getRank() << std::endl;
-        throw LogicErrorException(message.str());
-    }
+    init_from_data(data);
 }
 
 int Histogram2D::fill(double x, double y, double weight)
@@ -63,9 +56,9 @@ int Histogram2D::fill(double x, double y, double weight)
     return (int)index;
 }
 
-Histogram1D *Histogram2D::projectionX(IHistogram::ProjectionType projectionType)
+Histogram1D *Histogram2D::projectionX()
 {
-    return create_projectionX(0, getXaxis()->getSize()-1, projectionType);
+    return create_projectionX(0, getXaxis()->getSize()-1);
 }
 
 Histogram1D *Histogram2D::projectionX(double yvalue)
@@ -74,16 +67,16 @@ Histogram1D *Histogram2D::projectionX(double yvalue)
     return create_projectionX(ybin_selected, ybin_selected);
 }
 
-Histogram1D *Histogram2D::projectionX(double ylow, double yup, IHistogram::ProjectionType projectionType)
+Histogram1D *Histogram2D::projectionX(double ylow, double yup)
 {
     int ybinlow = getYaxis()->findClosestIndex(ylow);
     int ybinup = getYaxis()->findClosestIndex(yup);
-    return create_projectionX(ybinlow, ybinup, projectionType);
+    return create_projectionX(ybinlow, ybinup);
 }
 
-Histogram1D *Histogram2D::projectionY(IHistogram::ProjectionType projectionType)
+Histogram1D *Histogram2D::projectionY()
 {
-    return create_projectionX(0, getYaxis()->getSize()-1, projectionType);
+    return create_projectionY(0, getXaxis()->getSize()-1);
 }
 
 Histogram1D *Histogram2D::projectionY(double xvalue)
@@ -92,11 +85,11 @@ Histogram1D *Histogram2D::projectionY(double xvalue)
     return create_projectionY(xbin_selected, xbin_selected);
 }
 
-Histogram1D *Histogram2D::projectionY(double xlow, double xup, IHistogram::ProjectionType projectionType)
+Histogram1D *Histogram2D::projectionY(double xlow, double xup)
 {
     int xbinlow = getXaxis()->findClosestIndex(xlow);
     int xbinup = getXaxis()->findClosestIndex(xup);
-    return create_projectionY(xbinlow, xbinup, projectionType);
+    return create_projectionY(xbinlow, xbinup);
 }
 
 Histogram2D *Histogram2D::crop(double xmin, double ymin, double xmax, double ymax)
@@ -145,7 +138,7 @@ Histogram2D *Histogram2D::crop(double xmin, double ymin, double xmax, double yma
 //    return result;
 //}
 
-Histogram1D *Histogram2D::create_projectionX(int ybinlow, int ybinup, IHistogram::ProjectionType projectionType)
+Histogram1D *Histogram2D::create_projectionX(int ybinlow, int ybinup)
 {
     Histogram1D *result = new Histogram1D(*this->getXaxis());
 
@@ -160,7 +153,7 @@ Histogram1D *Histogram2D::create_projectionX(int ybinlow, int ybinup, IHistogram
     return result;
 }
 
-Histogram1D *Histogram2D::create_projectionY(int xbinlow, int xbinup, IHistogram::ProjectionType projectionType)
+Histogram1D *Histogram2D::create_projectionY(int xbinlow, int xbinup)
 {
     Histogram1D *result = new Histogram1D(*this->getYaxis());
 
diff --git a/Core/Tools/src/IHistogram.cpp b/Core/Tools/src/IHistogram.cpp
index cf0f4d0b464..79d7243a573 100644
--- a/Core/Tools/src/IHistogram.cpp
+++ b/Core/Tools/src/IHistogram.cpp
@@ -17,25 +17,30 @@
 #include "FixedBinAxis.h"
 #include "VariableBinAxis.h"
 #include "Exceptions.h"
+#include "Histogram1D.h"
+#include "Histogram2D.h"
 #include <sstream>
 #include <boost/assign/list_of.hpp>
 
+IHistogram::IHistogram()
+    : m_data_type(INTEGRAL)
+{
+
+}
+
 IHistogram::IHistogram(const IAxis &axis_x)
+    : m_data_type(INTEGRAL)
 {
     m_data.addAxis(axis_x);
 }
 
 IHistogram::IHistogram(const IAxis &axis_x, const IAxis &axis_y)
+    : m_data_type(INTEGRAL)
 {
     m_data.addAxis(axis_x);
     m_data.addAxis(axis_y);
 }
 
-IHistogram::IHistogram(const OutputData<double> &source)
-{
-    init_from_data(source);
-}
-
 size_t IHistogram::getRank() const
 {
     throw NotImplementedException("IHistogram::getRank() -> Error. Not implemented.");
@@ -74,6 +79,11 @@ double IHistogram::getXmax() const
     return getXaxis()->getMax();
 }
 
+size_t IHistogram::getNbinsX() const
+{
+    return getXaxis()->getSize();
+}
+
 double IHistogram::getYmin() const
 {
     return getYaxis()->getMin();
@@ -84,6 +94,11 @@ double IHistogram::getYmax() const
     return getYaxis()->getMax();
 }
 
+size_t IHistogram::getNbinsY() const
+{
+    return getYaxis()->getSize();
+}
+
 int IHistogram::getGlobalBin(int binx, int biny) const
 {
     std::vector<int > axes_indices;
@@ -116,7 +131,21 @@ double IHistogram::getYaxisValue(size_t globalbin)
 
 double IHistogram::getBinContent(int bin) const
 {
-    return m_data[bin].getValue();
+    if(m_data_type == INTEGRAL) {
+        return m_data[bin].getValue();
+    }
+    else if(m_data_type == AVERAGE) {
+        return m_data[bin].getAverage();
+    }
+    else if(m_data_type == ERROR) {
+        return m_data[bin].getRMS();
+    }
+    else if(m_data_type == NENTRIES) {
+        return m_data[bin].getNumberOfEntries();
+    }
+    else {
+        throw LogicErrorException("IHistogram::getBinContent() -> Error. Wrong data type.");
+    }
 }
 
 double IHistogram::getBinContent(int binx, int biny) const
@@ -149,7 +178,7 @@ PyObject *IHistogram::getArray() const
     OutputData<double> array;
     array.copyShapeFrom(m_data);
     for(size_t i=0; i<m_data.getAllocatedSize(); ++i) {
-        array[i] = m_data[i].getValue();
+        array[i] = getBinContent(i);
     }
     return array.getArray();
 }
@@ -159,6 +188,23 @@ void IHistogram::reset()
     m_data.setAllTo(CumulativeValue());
 }
 
+void IHistogram::setDataType(IHistogram::DataType data_type)
+{
+    m_data_type = data_type;
+}
+
+//Histogram1D *IHistogram::createHistogram1D(const OutputData<double> &source)
+//{
+//    Histogram1D *result = new Histogram1D(source);
+//    return result;
+//}
+
+//Histogram2D *IHistogram::createHistogram2D(const OutputData<double> &source)
+//{
+//    Histogram2D *result = new Histogram2D(source);
+//    return result;
+//}
+
 
 void IHistogram::check_x_axis() const
 {
@@ -182,6 +228,14 @@ void IHistogram::check_y_axis() const
 
 void IHistogram::init_from_data(const OutputData<double> &source)
 {
+    if(getRank() != source.getRank()) {
+        std::ostringstream message;
+        message << "IHistogram::IHistogram(const OutputData<double> &data) -> Error. ";
+        message << "The dimension of this histogram " << getRank() << " ";
+        message << "is differ from the dimension of source " << m_data.getRank() << std::endl;
+        throw LogicErrorException(message.str());
+    }
+
     m_data.copyShapeFrom(source);
     for(size_t i=0; i<source.getAllocatedSize(); ++i) {
         m_data[i].add(source[i]);
diff --git a/Tests/UnitTests/TestCore/Histogram1DTest.h b/Tests/UnitTests/TestCore/Histogram1DTest.h
index 1191962beba..6e0c46df3d0 100644
--- a/Tests/UnitTests/TestCore/Histogram1DTest.h
+++ b/Tests/UnitTests/TestCore/Histogram1DTest.h
@@ -98,12 +98,20 @@ TEST_F(Histogram1DTest, FixedBinFill)
     const double xvalue(1.5);
     const int xbin = 1;
 
-    hist.fill(xvalue);
+    hist.fill(xvalue, 1.0);
     hist.fill(xvalue, 3.0);
     EXPECT_EQ(2, hist.getBinNumberOfEntries(xbin));
     EXPECT_EQ(4.0, hist.getBinContent(xbin));
     EXPECT_EQ(1.0, hist.getBinError(xbin));
 
+    // another fill
+    hist.reset();
+    hist.fill(xvalue, 1.0);
+    hist.fill(xvalue, 2.0);
+    hist.fill(xvalue, 3.0);
+    EXPECT_EQ(3, hist.getBinNumberOfEntries(xbin));
+    EXPECT_EQ(6.0, hist.getBinContent(xbin));
+    EXPECT_EQ(2.0/3.0, hist.getBinError(xbin)*hist.getBinError(xbin));
 }
 
 
diff --git a/Tests/UnitTests/TestCore/Histogram2DTest.h b/Tests/UnitTests/TestCore/Histogram2DTest.h
index 64bafd30a1d..5c786199caa 100644
--- a/Tests/UnitTests/TestCore/Histogram2DTest.h
+++ b/Tests/UnitTests/TestCore/Histogram2DTest.h
@@ -3,6 +3,7 @@
 
 #include "Histogram2D.h"
 #include <boost/assign/list_of.hpp>
+#include <boost/scoped_ptr.hpp>
 #include "gtest/gtest.h"
 
 class Histogram2DTest : public ::testing::Test
@@ -115,16 +116,19 @@ TEST_F(Histogram2DTest, VariableHistFill)
     std::vector<double> xvalues = boost::assign::list_of(-0.75)(-0.75)(-0.75)(0.0)(0.0)(0.0)(0.75)(0.75)(0.75)(1.5)(1.5)(1.5);
     std::vector<double> yvalues = boost::assign::list_of(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0);
 
+    // put in every histogram bin one double value proportional to globalbin (globalbin*10.0)
     for(size_t i=0; i<xvalues.size(); ++i) {
         hist->fill(xvalues[i], yvalues[i], i*10.0);
     }
 
+    // check bin content using globalbin
     for(size_t globalbin=0; globalbin<hist->getTotalNumberOfBins(); ++globalbin) {
         EXPECT_EQ(globalbin*10.0, hist->getBinContent(globalbin));
         EXPECT_EQ(1.0, hist->getBinNumberOfEntries(globalbin));
 
     }
 
+    // check bin content using axes bins
     for(size_t binx=0; binx<hist->getXaxis()->getSize(); ++binx){
         for(size_t biny=0; biny<hist->getYaxis()->getSize(); ++biny){
             int globalbin = hist->getGlobalBin(binx, biny);
@@ -135,5 +139,215 @@ TEST_F(Histogram2DTest, VariableHistFill)
 
 }
 
+// y
+// 4.0   -----------------------------------
+//       |     |          |     |          |
+//       |  2  |    5     |  8  |    11    |
+// 2.0   -----------------------------------
+//       |  1  |    4     |  7  |    10    |
+// 1.0   -----------------------------------
+//       |  0  |    3     |  6  |    9     |
+// 0.0   -----------------------------------
+//     -1.0  -0.5        0.5   1.0        2.0  X
+
+TEST_F(Histogram2DTest, projectionX)
+{
+    hist->reset();
+
+    // values to fill all histogram
+    std::vector<double> xvalues = boost::assign::list_of(-0.75)(-0.75)(-0.75)(0.0)(0.0)(0.0)(0.75)(0.75)(0.75)(1.5)(1.5)(1.5);
+    std::vector<double> yvalues = boost::assign::list_of(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0);
+    std::vector<double> content = boost::assign::list_of(1.0)(2.0)(3.0)(1.0)(2.0)(3.0)(1.0)(2.0)(3.0)(1.0)(2.0)(3.0);
+
+    // put in every histogram bin the value from 'content' vector
+    for(size_t i=0; i<xvalues.size(); ++i) {
+        hist->fill(xvalues[i], yvalues[i], content[i]);
+    }
+
+    // a) create projection along X axis
+    boost::scoped_ptr<Histogram1D > h1(hist->projectionX());
+    EXPECT_EQ(hist->getXmin(), h1->getXmin());
+    EXPECT_EQ(hist->getXmax(), h1->getXmax());
+    EXPECT_EQ(hist->getNbinsX(), h1->getNbinsX());
+    EXPECT_EQ(hist->getXaxisValue(0), h1->getXaxisValue(0));
+    EXPECT_EQ(hist->getXaxisValue(3), h1->getXaxisValue(1));
+    EXPECT_EQ(hist->getXaxisValue(6), h1->getXaxisValue(2));
+    EXPECT_EQ(hist->getXaxisValue(9), h1->getXaxisValue(3));
+
+    // check content of projections
+    for(size_t binx=0; binx<h1->getNbinsX(); ++binx) {
+        EXPECT_EQ(3, h1->getBinNumberOfEntries(binx));
+        EXPECT_EQ(6.0, h1->getBinContent(binx));
+        EXPECT_DOUBLE_EQ(std::sqrt(2.0/3.0), h1->getBinError(binx));
+    }
+
+    // b) create projection along X axis at given y (slice)
+    h1.reset(hist->projectionX(1.01));
+    EXPECT_EQ(hist->getXmin(), h1->getXmin());
+    EXPECT_EQ(hist->getXmax(), h1->getXmax());
+    EXPECT_EQ(hist->getNbinsX(), h1->getNbinsX());
+    EXPECT_EQ(hist->getXaxisValue(0), h1->getXaxisValue(0));
+    EXPECT_EQ(hist->getXaxisValue(3), h1->getXaxisValue(1));
+    EXPECT_EQ(hist->getXaxisValue(6), h1->getXaxisValue(2));
+    EXPECT_EQ(hist->getXaxisValue(9), h1->getXaxisValue(3));
+
+    // check content of projections
+    for(size_t binx=0; binx<h1->getNbinsX(); ++binx) {
+        EXPECT_EQ(1, h1->getBinNumberOfEntries(binx));
+        EXPECT_EQ(2.0, h1->getBinContent(binx));
+        EXPECT_DOUBLE_EQ(0.0, h1->getBinError(binx));
+    }
+
+    // c) create projection along X for y between [ylow, yup]
+    h1.reset(hist->projectionX(0.99, 1.01));
+    EXPECT_EQ(hist->getXmin(), h1->getXmin());
+    EXPECT_EQ(hist->getXmax(), h1->getXmax());
+    EXPECT_EQ(hist->getNbinsX(), h1->getNbinsX());
+    EXPECT_EQ(hist->getXaxisValue(0), h1->getXaxisValue(0));
+    EXPECT_EQ(hist->getXaxisValue(3), h1->getXaxisValue(1));
+    EXPECT_EQ(hist->getXaxisValue(6), h1->getXaxisValue(2));
+    EXPECT_EQ(hist->getXaxisValue(9), h1->getXaxisValue(3));
+
+    // check content of projections
+    for(size_t binx=0; binx<h1->getNbinsX(); ++binx) {
+        EXPECT_EQ(2, h1->getBinNumberOfEntries(binx));
+        EXPECT_EQ(3.0, h1->getBinContent(binx));
+        EXPECT_DOUBLE_EQ(std::sqrt(0.25), h1->getBinError(binx));
+    }
+
+
+}
+
+// y
+// 4.0   -----------------------------------
+//       |     |          |     |          |
+//       |  2  |    5     |  8  |    11    |
+// 2.0   -----------------------------------
+//       |  1  |    4     |  7  |    10    |
+// 1.0   -----------------------------------
+//       |  0  |    3     |  6  |    9     |
+// 0.0   -----------------------------------
+//     -1.0  -0.5        0.5   1.0        2.0  X
+
+
+TEST_F(Histogram2DTest, projectionY)
+{
+    hist->reset();
+
+    // values to fill all histogram
+    std::vector<double> xvalues = boost::assign::list_of(-0.75)(-0.75)(-0.75)(0.0)(0.0)(0.0)(0.75)(0.75)(0.75)(1.5)(1.5)(1.5);
+    std::vector<double> yvalues = boost::assign::list_of(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0);
+    std::vector<double> content = boost::assign::list_of(1.0)(2.0)(3.0)(1.0)(2.0)(3.0)(1.0)(2.0)(3.0)(1.0)(2.0)(3.0);
+
+    // put in every histogram bin the value from 'content' vector
+    for(size_t i=0; i<xvalues.size(); ++i) {
+        hist->fill(xvalues[i], yvalues[i], content[i]);
+    }
+
+    // a) create projection along Y axis
+    boost::scoped_ptr<Histogram1D > h1(hist->projectionY());
+    EXPECT_EQ(hist->getYmin(), h1->getXmin());
+    EXPECT_EQ(hist->getYmax(), h1->getXmax());
+    EXPECT_EQ(3, h1->getNbinsX());
+    EXPECT_EQ(hist->getNbinsY(), h1->getNbinsX());
+    EXPECT_EQ(hist->getYaxisValue(3), h1->getXaxisValue(0));
+    EXPECT_EQ(hist->getYaxisValue(4), h1->getXaxisValue(1));
+    EXPECT_EQ(hist->getYaxisValue(5), h1->getXaxisValue(2));
+
+    // check content of projections
+
+    for(size_t binx=0; binx<h1->getNbinsX(); ++binx) {
+        EXPECT_EQ(4, h1->getBinNumberOfEntries(binx));
+        EXPECT_DOUBLE_EQ(0.0, h1->getBinError(binx));
+    }
+    EXPECT_EQ(4.0, h1->getBinContent(0));
+    EXPECT_EQ(8.0, h1->getBinContent(1));
+    EXPECT_EQ(12.0, h1->getBinContent(2));
+
+    // b) create projection along Y axis at given x(slice)
+    h1.reset(hist->projectionY(0.0));
+    EXPECT_EQ(hist->getYmin(), h1->getXmin());
+    EXPECT_EQ(hist->getYmax(), h1->getXmax());
+    EXPECT_EQ(3, h1->getNbinsX());
+    EXPECT_EQ(hist->getNbinsY(), h1->getNbinsX());
+    EXPECT_EQ(hist->getYaxisValue(3), h1->getXaxisValue(0));
+    EXPECT_EQ(hist->getYaxisValue(4), h1->getXaxisValue(1));
+    EXPECT_EQ(hist->getYaxisValue(5), h1->getXaxisValue(2));
+
+    // check content of projections
+
+    for(size_t binx=0; binx<h1->getNbinsX(); ++binx) {
+        EXPECT_EQ(1, h1->getBinNumberOfEntries(binx));
+        EXPECT_DOUBLE_EQ(0.0, h1->getBinError(binx));
+    }
+    EXPECT_EQ(1.0, h1->getBinContent(0));
+    EXPECT_EQ(2.0, h1->getBinContent(1));
+    EXPECT_EQ(3.0, h1->getBinContent(2));
+
+    // c) create projection along Y axis for x's between [xlow,xup]
+    h1.reset(hist->projectionY(0.0, 0.51));
+    EXPECT_EQ(hist->getYmin(), h1->getXmin());
+    EXPECT_EQ(hist->getYmax(), h1->getXmax());
+    EXPECT_EQ(3, h1->getNbinsX());
+    EXPECT_EQ(hist->getNbinsY(), h1->getNbinsX());
+    EXPECT_EQ(hist->getYaxisValue(3), h1->getXaxisValue(0));
+    EXPECT_EQ(hist->getYaxisValue(4), h1->getXaxisValue(1));
+    EXPECT_EQ(hist->getYaxisValue(5), h1->getXaxisValue(2));
+
+    // check content of projections
+
+    for(size_t binx=0; binx<h1->getNbinsX(); ++binx) {
+        EXPECT_EQ(2, h1->getBinNumberOfEntries(binx));
+        EXPECT_DOUBLE_EQ(0.0, h1->getBinError(binx));
+    }
+    EXPECT_EQ(2.0, h1->getBinContent(0));
+    EXPECT_EQ(4.0, h1->getBinContent(1));
+    EXPECT_EQ(6.0, h1->getBinContent(2));
+}
+
+// y
+// 4.0   -----------------------------------
+//       |     |          |     |          |
+//       |  2  |    5     |  8  |    11    |
+// 2.0   -----------------------------------
+//       |  1  |    4     |  7  |    10    |
+// 1.0   -----------------------------------
+//       |  0  |    3     |  6  |    9     |
+// 0.0   -----------------------------------
+//     -1.0  -0.5        0.5   1.0        2.0  X
+
+
+TEST_F(Histogram2DTest, crop)
+{
+    hist->reset();
+
+    // values to fill all histogram
+    std::vector<double> xvalues = boost::assign::list_of(-0.75)(-0.75)(-0.75)(0.0)(0.0)(0.0)(0.75)(0.75)(0.75)(1.5)(1.5)(1.5);
+    std::vector<double> yvalues = boost::assign::list_of(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0)(0.5)(1.5)(3.0);
+    std::vector<double> content = boost::assign::list_of(1.0)(2.0)(3.0)(1.0)(2.0)(3.0)(1.0)(2.0)(3.0)(1.0)(2.0)(3.0);
+
+    // put in every histogram bin the value from 'content' vector
+    for(size_t i=0; i<xvalues.size(); ++i) {
+        hist->fill(xvalues[i], yvalues[i], content[i]);
+    }
+
+    boost::scoped_ptr<Histogram2D > crop(hist->crop(-0.49, 0.0, 1.99,1.9));
+    EXPECT_EQ(-0.5, crop->getXmin());
+    EXPECT_EQ(2.0, crop->getXmax());
+    EXPECT_EQ(3, crop->getNbinsX());
+    EXPECT_EQ(0.0, crop->getYmin());
+    EXPECT_EQ(2.0, crop->getYmax());
+    EXPECT_EQ(2, crop->getNbinsY());
+
+    EXPECT_EQ(1.0, crop->getBinContent(0,0));
+    EXPECT_EQ(2.0, crop->getBinContent(0,1));
+    EXPECT_EQ(1.0, crop->getBinContent(1,0));
+    EXPECT_EQ(2.0, crop->getBinContent(1,1));
+    EXPECT_EQ(1.0, crop->getBinContent(2,0));
+    EXPECT_EQ(2.0, crop->getBinContent(2,1));
+
+
+}
+
 
 #endif
-- 
GitLab