Skip to content
Snippets Groups Projects
Commit c815a34d authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Attempt to make HistoDump close to readable. No code change in principle

parent cfba0cea
No related branches found
No related tags found
1 merge request!1490Fixed unsafe floating point comparisons
...@@ -8,49 +8,24 @@ ...@@ -8,49 +8,24 @@
* granted to it by virtue of its status as an Intergovernmental Organization * * granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. * * or submit itself to any jurisdiction. *
\***********************************************************************************/ \***********************************************************************************/
#ifndef GAUDIUTILS_HISTODUMP_H #pragma once
#define GAUDIUTILS_HISTODUMP_H 1
// ============================================================================
// Include files
// ============================================================================
// STD & STL
// ============================================================================
#include <string>
// ============================================================================
// GaudiKernel
// ============================================================================
#include "GaudiKernel/Kernel.h" #include "GaudiKernel/Kernel.h"
// ============================================================================
/// forward declarations: #include <string>
// ============================================================================
namespace AIDA { namespace AIDA {
class IHistogram1D; // AIDA class IHistogram1D; // AIDA
class IProfile1D; // AIDA class IProfile1D; // AIDA
} // namespace AIDA } // namespace AIDA
// ============================================================================
class TH1; // ROOT class TH1; // ROOT
class TProfile; // ROOT class TProfile; // ROOT
// ============================================================================
namespace Gaudi { namespace Gaudi {
// ==========================================================================
namespace Utils { namespace Utils {
// ========================================================================
namespace Histos { namespace Histos {
// ======================================================================
/** dump the text representation of the histogram
* @param histo (INPUT) the histogram
* @param stream (OUTUT) the stream
* @param width (INPUT) the maximal column width
* @param height (INPUT) the proposed column height
* @param errors (INPUT) print/plot errors
* @return the stream
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19
*/
GAUDI_API
std::ostream& histoDump_( const AIDA::IHistogram1D* histo, std::ostream& stream, const std::size_t width = 80,
const std::size_t height = 50, const bool errors = false );
// ======================================================================
/** dump the text representation of the histogram /** dump the text representation of the histogram
* @param histo (INPUT) the histogram * @param histo (INPUT) the histogram
* @param width (INPUT) the maximal column width * @param width (INPUT) the maximal column width
...@@ -63,21 +38,7 @@ namespace Gaudi { ...@@ -63,21 +38,7 @@ namespace Gaudi {
GAUDI_API GAUDI_API
std::string histoDump( const AIDA::IHistogram1D* histo, const std::size_t width = 80, std::string histoDump( const AIDA::IHistogram1D* histo, const std::size_t width = 80,
const std::size_t height = 50, const bool errors = false ); const std::size_t height = 50, const bool errors = false );
// ======================================================================
/** dump the text representation of 1D-profile
* @param histo (INPUT) the 1D-profile
* @param stream (OUTUT) the stream
* @param width (INPUT) the maximal column width
* @param height (INPUT) the proposed column height
* @param spread (INPUT) print/plot spread/rms ?
* @return the stream
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19
*/
GAUDI_API
std::ostream& histoDump_( const AIDA::IProfile1D* histo, std::ostream& stream, const std::size_t width = 80,
const std::size_t height = 50, const bool spread = true );
// ====================================================================
/** dump the text representation of the 1D-profile /** dump the text representation of the 1D-profile
* @param histo (INPUT) the histogram * @param histo (INPUT) the histogram
* @param width (INPUT) the maximal column width * @param width (INPUT) the maximal column width
...@@ -90,21 +51,7 @@ namespace Gaudi { ...@@ -90,21 +51,7 @@ namespace Gaudi {
GAUDI_API GAUDI_API
std::string histoDump( const AIDA::IProfile1D* histo, const std::size_t width = 80, const std::size_t height = 50, std::string histoDump( const AIDA::IProfile1D* histo, const std::size_t width = 80, const std::size_t height = 50,
const bool spread = true ); const bool spread = true );
// ======================================================================
/** dump the text representation of the Profile
* @param histo (INPUT) the histogram
* @param stream (OUTUT) the stream
* @param width (INPUT) the maximal column width
* @param height (INPUT) the proposed coulmn height
* @param spread (INPUT) print/plot rms versus erorr
* @return the stream
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19
*/
GAUDI_API
std::ostream& histoDump_( const TProfile* histo, std::ostream& stream, const std::size_t width = 80,
const std::size_t height = 50 );
// ====================================================================
/** dump the text representation of the histogram /** dump the text representation of the histogram
* @param histo (INPUT) the histogram * @param histo (INPUT) the histogram
* @param width (INPUT) the maximal column width * @param width (INPUT) the maximal column width
...@@ -116,21 +63,7 @@ namespace Gaudi { ...@@ -116,21 +63,7 @@ namespace Gaudi {
*/ */
GAUDI_API GAUDI_API
std::string histoDump( const TProfile* histo, const std::size_t width = 80, const std::size_t height = 50 ); std::string histoDump( const TProfile* histo, const std::size_t width = 80, const std::size_t height = 50 );
// ====================================================================
/** dump the text representation of the histogram
* @param histo (INPUT) the histogram
* @param stream (OUTUT) the stream
* @param width (INPUT) the maximal column width
* @param height (INPUT) the proposed coulmn height
* @param errors (INPUT) print/plot errors
* @return the stream
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19
*/
GAUDI_API
std::ostream& histoDump_( const TH1* histo, std::ostream& stream, const std::size_t width = 80,
const std::size_t height = 50, const bool errors = false );
// ====================================================================
/** dump the text representation of the histogram /** dump the text representation of the histogram
* @param histo (INPUT) the histogram * @param histo (INPUT) the histogram
* @param width (INPUT) the maximal column width * @param width (INPUT) the maximal column width
...@@ -143,13 +76,8 @@ namespace Gaudi { ...@@ -143,13 +76,8 @@ namespace Gaudi {
GAUDI_API GAUDI_API
std::string histoDump( const TH1* histo, const std::size_t width = 80, const std::size_t height = 50, std::string histoDump( const TH1* histo, const std::size_t width = 80, const std::size_t height = 50,
const bool errors = false ); const bool errors = false );
// ======================================================================
} // namespace Histos } // namespace Histos
// ========================================================================
} // namespace Utils } // namespace Utils
// ==========================================================================
} // end of namespace Gaudi } // end of namespace Gaudi
// ============================================================================
// The END
// ============================================================================
#endif // GAUDIUTILS_HISTODUMP_H
...@@ -373,8 +373,8 @@ namespace { ...@@ -373,8 +373,8 @@ namespace {
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl * @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19 * @date 2009-09-19
*/ */
std::ostream& dumpText( const Histo& histo, const std::size_t width, const std::size_t height, const bool errors, std::ostringstream& dumpText( const Histo& histo, const std::size_t width, const std::size_t height,
std::ostream& stream ) { const bool errors, std::ostringstream& stream ) {
if ( 40 > width ) { return dumpText( histo, 40, height, errors, stream ); } if ( 40 > width ) { return dumpText( histo, 40, height, errors, stream ); }
if ( 200 < width ) { return dumpText( histo, 200, height, errors, stream ); } if ( 200 < width ) { return dumpText( histo, 200, height, errors, stream ); }
if ( 150 < height ) { return dumpText( histo, width, 150, errors, stream ); } if ( 150 < height ) { return dumpText( histo, width, 150, errors, stream ); }
...@@ -556,25 +556,27 @@ namespace { ...@@ -556,25 +556,27 @@ namespace {
return stream; // RETURN return stream; // RETURN
} }
} // namespace } // namespace
// ============================================================================ // ============================================================================
/* dump the text representation of the histogram /* dump the text representation of the histogram
* @param histo (INPUT) the histogram * @param histo the histogram
* @param stream (OUTUT) the stream * @param stream the stream
* @param width (INPUT) the maximal column width * @param width the maximal column width
* @param height (INPUT) the proposed coulmn height * @param height (INPUT) the proposed coulmn height
* @param errors (INPUT) print/plot errors * @param errors (INPUT) print/plot errors
* @return the stream * @param erorrs print/plot errors
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl * @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19 * @date 2009-09-19
*/ */
// ============================================================================ // ============================================================================
std::ostream& Gaudi::Utils::Histos::histoDump_( const AIDA::IHistogram1D* histo, std::ostream& stream, std::string Gaudi::Utils::Histos::histoDump( const AIDA::IHistogram1D* histo, const std::size_t width,
const std::size_t width, const std::size_t height, const bool errors ) { const std::size_t height, const bool errors ) {
std::ostringstream stream;
stream << std::endl; stream << std::endl;
if ( !histo ) { return stream; } // RETURN if ( !histo ) { return stream.str(); } // RETURN
Histo hist; Histo hist;
StatusCode sc = _getHisto( histo, hist ); StatusCode sc = _getHisto( histo, hist );
if ( sc.isFailure() ) { return stream; } // RETURN if ( sc.isFailure() ) { return stream.str(); } // RETURN
stream << fmt::format( R"( Histo TES : "{}" stream << fmt::format( R"( Histo TES : "{}"
Histo Title : "{}" Histo Title : "{}"
...@@ -607,45 +609,25 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const AIDA::IHistogram1D* histo, ...@@ -607,45 +609,25 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const AIDA::IHistogram1D* histo,
stream << '\n'; stream << '\n';
} }
return dumpText( hist, width, height, errors, stream ); return dumpText( hist, width, height, errors, stream ).str();
} }
// ============================================================================
/* dump the text representation of the histogram /* dump the text representation of the 1D-profile
* @param histo the histogram * @param histo the histogram
* @param stream the stream * @param stream the stream
* @param width the maximal column width * @param width the maximal column width
* @param height (INPUT) the proposed coulmn height * @param height (INPUT) the proposed coulmn height
* @param errors (INPUT) print/plot errors
* @param erorrs print/plot errors
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl * @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19 * @date 2009-09-19
*/ */
// ============================================================================ std::string Gaudi::Utils::Histos::histoDump( const AIDA::IProfile1D* histo, const std::size_t width,
std::string Gaudi::Utils::Histos::histoDump( const AIDA::IHistogram1D* histo, const std::size_t width, const std::size_t height, const bool spread ) {
const std::size_t height, const bool errors ) {
std::ostringstream stream; std::ostringstream stream;
histoDump_( histo, stream, width, height, errors );
return stream.str();
}
// ============================================================================
/* dump the text representation of the 1D-profile
* @param histo (INPUT) the profile
* @param stream (OUTUT) the stream
* @param width (INPUT) the maximal column width
* @param height (INPUT) the proposed coulmn height
* @param spread (INPUT) plot spread/error?
* @return the stream
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19
*/
// ============================================================================
std::ostream& Gaudi::Utils::Histos::histoDump_( const AIDA::IProfile1D* histo, std::ostream& stream,
const std::size_t width, const std::size_t height, const bool spread ) {
stream << std::endl; stream << std::endl;
if ( !histo ) { return stream; } // RETURN if ( !histo ) { return stream.str(); } // RETURN
Histo hist; Histo hist;
StatusCode sc = _getHisto( histo, hist, spread ); StatusCode sc = _getHisto( histo, hist, spread );
if ( sc.isFailure() ) { return stream; } // RETURN if ( sc.isFailure() ) { return stream.str(); } // RETURN
stream << fmt::format( R"( Histo TES : "{}" stream << fmt::format( R"( Histo TES : "{}"
Histo Title : "{}" Histo Title : "{}"
...@@ -673,45 +655,28 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const AIDA::IProfile1D* histo, s ...@@ -673,45 +655,28 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const AIDA::IProfile1D* histo, s
stream << std::endl; stream << std::endl;
} }
return dumpText( hist, width, height, true, stream ); return dumpText( hist, width, height, true, stream ).str();
}
// ============================================================================
/* dump the text representation of the 1D-profile
* @param histo the histogram
* @param stream the stream
* @param width the maximal column width
* @param height (INPUT) the proposed coulmn height
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2009-09-19
*/
// ============================================================================
std::string Gaudi::Utils::Histos::histoDump( const AIDA::IProfile1D* histo, const std::size_t width,
const std::size_t height, const bool spread ) {
std::ostringstream stream;
histoDump_( histo, stream, width, height, spread );
return stream.str();
} }
// ============================================================================
/* dump the text representation of the histogram /* dump the text representation of the histogram
* @param histo (INPUT) the histogram * @param histo (INPUT) the histogram
* @param stream (OUTUT) the stream
* @param width (INPUT) the maximal column width * @param width (INPUT) the maximal column width
* @param errors (INPUT) print/plot errors * @param errors (INPUT) print/plot errors
* @return the stream * @return string representation of the histogram
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
* @date 2009-09-19 * @date 2009-09-19
*/ */
// ============================================================================ std::string Gaudi::Utils::Histos::histoDump( const TH1* histo, const std::size_t width, const std::size_t height,
std::ostream& Gaudi::Utils::Histos::histoDump_( const TH1* histo, std::ostream& stream, const std::size_t width, const bool errors ) {
const std::size_t height, const bool errors ) {
const TProfile* profile = dynamic_cast<const TProfile*>( histo ); const TProfile* profile = dynamic_cast<const TProfile*>( histo );
if ( profile ) { return histoDump_( profile, stream, width, height ); } if ( profile ) { return histoDump( profile, width, height ); }
// //
std::ostringstream stream;
stream << std::endl; stream << std::endl;
if ( !histo ) { return stream; } // RETURN if ( !histo ) { return stream.str(); } // RETURN
Histo hist; Histo hist;
StatusCode sc = _getHisto( histo, hist ); StatusCode sc = _getHisto( histo, hist );
if ( sc.isFailure() ) { return stream; } // RETURN if ( sc.isFailure() ) { return stream.str(); } // RETURN
stream << fmt::format( R"( Histo Name : "{}" stream << fmt::format( R"( Histo Name : "{}"
Histo Title : "{}" Histo Title : "{}"
...@@ -732,26 +697,25 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const TH1* histo, std::ostream& ...@@ -732,26 +697,25 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const TH1* histo, std::ostream&
histo->GetBinContent( histo->GetNbinsX() + 1 ), histo->GetEffectiveEntries(), histo->GetBinContent( histo->GetNbinsX() + 1 ), histo->GetEffectiveEntries(),
histo->Integral() ); histo->Integral() );
return dumpText( hist, width, height, errors, stream ); return dumpText( hist, width, height, errors, stream ).str();
} }
// ============================================================================
/* dump the text representation of the histogram /* dump the text representation of the histogram
* @param histo (INPUT) the histogram * @param histo (INPUT) the histogram
* @param stream (OUTUT) the stream
* @param width (INPUT) the maximal column width * @param width (INPUT) the maximal column width
* @param errors (INPUT) print/plot errors * @param errors (INPUT) print/plot errors
* @return the stream * @return string representation of the histogram
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
* @date 2009-09-19 * @date 2009-09-19
*/ */
// ============================================================================ std::string Gaudi::Utils::Histos::histoDump( const TProfile* histo, const std::size_t width,
std::ostream& Gaudi::Utils::Histos::histoDump_( const TProfile* histo, std::ostream& stream, const std::size_t width, const std::size_t height ) {
const std::size_t height ) { std::ostringstream stream;
stream << std::endl; stream << std::endl;
if ( !histo ) { return stream; } // RETURN if ( !histo ) { return stream.str(); } // RETURN
Histo hist; Histo hist;
StatusCode sc = _getHisto( histo, hist, true ); StatusCode sc = _getHisto( histo, hist, true );
if ( sc.isFailure() ) { return stream; } // RETURN if ( sc.isFailure() ) { return stream.str(); } // RETURN
stream << fmt::format( R"( Profile Name : "{}" stream << fmt::format( R"( Profile Name : "{}"
Profile Title : "{}" Profile Title : "{}"
...@@ -769,42 +733,5 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const TProfile* histo, std::ostr ...@@ -769,42 +733,5 @@ std::ostream& Gaudi::Utils::Histos::histoDump_( const TProfile* histo, std::ostr
histo->GetEntries(), histo->GetBinContent( 0 ), histo->GetBinContent( histo->GetNbinsX() + 1 ), histo->GetEntries(), histo->GetBinContent( 0 ), histo->GetBinContent( histo->GetNbinsX() + 1 ),
histo->Integral() ); histo->Integral() );
return dumpText( hist, width, height, true, stream ); return dumpText( hist, width, height, true, stream ).str();
} }
// ============================================================================
/* dump the text representation of the histogram
* @param histo (INPUT) the histogram
* @param width (INPUT) the maximal column width
* @param errors (INPUT) print/plot errors
* @return string representation of the histogram
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
* @date 2009-09-19
*/
// ============================================================================
std::string Gaudi::Utils::Histos::histoDump( const TH1* histo, const std::size_t width, const std::size_t height,
const bool errors ) {
std::ostringstream stream;
histoDump_( histo, stream, width, height, errors );
return stream.str();
}
// ============================================================================
/* dump the text representation of the histogram
* @param histo (INPUT) the histogram
* @param width (INPUT) the maximal column width
* @param errors (INPUT) print/plot errors
* @return string representation of the histogram
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
* @date 2009-09-19
*/
// ============================================================================
std::string Gaudi::Utils::Histos::histoDump( const TProfile* histo, const std::size_t width,
const std::size_t height ) {
std::ostringstream stream;
histoDump_( histo, stream, width, height );
return stream.str();
}
// ============================================================================
// ============================================================================
// The END
// ============================================================================
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment