00001
00002 #ifdef __ICC
00003
00004
00005 #pragma warning(disable:2259)
00006
00007
00008 #pragma warning(disable:1572)
00009 #endif
00010 #ifdef WIN32
00011
00012
00013
00014 #pragma warning(disable:4996)
00015 #endif
00016
00017
00018
00019
00020
00021 #include <cmath>
00022 #include <vector>
00023 #include <iostream>
00024 #include <utility>
00025 #include <sstream>
00026
00027
00028
00029 #include "AIDA/IHistogram1D.h"
00030 #include "AIDA/IProfile1D.h"
00031 #include "AIDA/IAxis.h"
00032 #include "AIDA/IAnnotation.h"
00033
00034
00035
00036 #include "GaudiKernel/StatusCode.h"
00037
00038
00039
00040 #include "TH1.h"
00041 #include "TProfile.h"
00042 #include "TAxis.h"
00043
00044
00045
00046 #include "boost/format.hpp"
00047
00048
00049
00050 #include "GaudiUtils/HistoDump.h"
00051 #include "GaudiUtils/HistoTableFormat.h"
00052 #include "GaudiUtils/HistoStats.h"
00053
00054 namespace
00055 {
00056
00062 struct Histo
00063 {
00064
00065 Histo() : bins() , under() , over() {}
00066
00072 struct Bin
00073 {
00074
00075 Bin ( const double h = 0 ,
00076 const double e = 0 ,
00077 const double l = -1 )
00078 : height ( h )
00079 , error ( e )
00080 , lower ( l ) {}
00081
00083 double height ;
00085 double error ;
00087 double lower ;
00088
00089 Bin& operator+= ( const Bin& right )
00090 {
00091 height += right.height ;
00092 const double e2 = error * error + right.error * right.error ;
00093 error = std::sqrt ( e2 ) ;
00094 return *this ;
00095 }
00096
00097 } ;
00098
00100 double maxY ( const bool withErr ) const
00101 {
00102 double _m = std::max ( under.height , over.height ) ;
00103 for ( Bins::const_iterator ib = bins.begin() ; bins.end() != ib ; ++ib )
00104 { _m = std::max ( _m , withErr ? ib->height + ib->error : ib->height ) ; }
00105 return _m ;
00106 }
00108 double minY ( const bool withErr ) const
00109 {
00110 double _m = std::min ( under.height , over.height ) ;
00111 for ( Bins::const_iterator ib = bins.begin() ; bins.end() != ib ; ++ib )
00112 { _m = std::min ( _m , withErr ? ib->height - ib->error : ib->height ) ; }
00113 return _m ;
00114 }
00116 Histo rebin ( const unsigned int bin ) const
00117 {
00118
00119 Histo nh ;
00120
00121 nh.under = under ;
00122 nh.over = over ;
00123
00124 for ( unsigned int ibin = 0 ; ibin < bins.size() ; ++ibin )
00125 {
00126 const Bin& current = bins[ibin] ;
00127 if ( nh.bins.empty() ) { nh.bins.push_back ( current ) ; }
00128 else if ( 0 == ibin % bin ) { nh.bins.push_back ( current ) ; }
00129 else { nh.bins.back() += current ; }
00130 }
00131 return nh ;
00132 }
00133
00134 int nullBin () const
00135 {
00136 for ( Bins::const_iterator ib = bins.begin() ; bins.end() != ib + 1 ; ++ib )
00137 { if ( ib->lower <= 0 && 0 < (ib+1)->lower ) { return ib - bins.begin() ; } }
00138 return -1 ;
00139 }
00140
00141 typedef std::vector<Bin> Bins ;
00142
00144 Bins bins ;
00146 Bin under ;
00148 Bin over ;
00149
00150 } ;
00151
00159 StatusCode _getHisto ( const TH1* root , Histo& hist )
00160 {
00161
00162 hist.bins.clear() ;
00163
00164 if ( 0 == root ) { return StatusCode::FAILURE ; }
00165 const TAxis* axis = root->GetXaxis() ;
00166 if ( 0 == axis ) { return StatusCode::FAILURE ; }
00167 const int nbins = axis->GetNbins () ;
00168 if ( 0 == nbins ) { return StatusCode::FAILURE ; }
00169
00170
00171 hist.under = Histo::Bin ( root -> GetBinContent ( 0 ) ,
00172 root -> GetBinError ( 0 ) ,
00173 axis -> GetXmin () ) ;
00174
00175 hist.over = Histo::Bin ( root -> GetBinContent ( nbins + 1 ) ,
00176 root -> GetBinError ( nbins + 1 ) ,
00177 axis -> GetXmax () ) ;
00178
00179
00180 for ( int ibin = 1 ; ibin <= nbins ; ++ibin )
00181 {
00182
00183 Histo::Bin bin ( root -> GetBinContent ( ibin ) ,
00184 root -> GetBinError ( ibin ) ,
00185 axis -> GetBinLowEdge ( ibin ) ) ;
00186 hist.bins.push_back ( bin ) ;
00187 }
00188 return StatusCode::SUCCESS ;
00189 }
00190
00198 StatusCode _getHisto ( const TProfile* root ,
00199 Histo& hist ,
00200 const bool )
00201 {
00202 const TH1* histo = root ;
00203 return _getHisto ( histo , hist ) ;
00204 }
00205
00213 StatusCode _getHisto
00214 ( const AIDA::IHistogram1D* aida , Histo& hist )
00215 {
00216
00217 hist.bins.clear() ;
00218
00219 if ( 0 == aida ) { return StatusCode::FAILURE ; }
00220
00221 const AIDA::IAxis& axis = aida -> axis () ;
00222 const int nbins = axis . bins () ;
00223
00224
00225 hist.under = Histo::Bin ( aida -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ,
00226 aida -> binError ( AIDA::IAxis::UNDERFLOW_BIN ) ,
00227 axis . lowerEdge () ) ;
00228
00229 hist.over = Histo::Bin ( aida -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ,
00230 aida -> binError ( AIDA::IAxis::OVERFLOW_BIN ) ,
00231 axis . upperEdge () ) ;
00232
00233 for ( int ibin = 0 ; ibin < nbins ; ++ibin )
00234 {
00235
00236 Histo::Bin bin ( aida -> binHeight ( ibin ) ,
00237 aida -> binError ( ibin ) ,
00238 axis . binLowerEdge ( ibin ) ) ;
00239 hist.bins.push_back ( bin ) ;
00240 }
00241 return StatusCode::SUCCESS ;
00242 }
00243
00251 StatusCode _getHisto
00252 ( const AIDA::IProfile1D* aida ,
00253 Histo& hist ,
00254 const bool spread )
00255 {
00256
00257 hist.bins.clear() ;
00258
00259 if ( 0 == aida ) { return StatusCode::FAILURE ; }
00260
00261 const AIDA::IAxis& axis = aida -> axis () ;
00262 const int nbins = axis . bins () ;
00263
00264
00265 hist.under = Histo::Bin ( aida -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ,
00266 spread ?
00267 aida -> binRms ( AIDA::IAxis::UNDERFLOW_BIN ) :
00268 aida -> binError ( AIDA::IAxis::UNDERFLOW_BIN ) ,
00269 axis . lowerEdge () ) ;
00270
00271 hist.over = Histo::Bin ( aida -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ,
00272 spread ?
00273 aida -> binRms ( AIDA::IAxis::OVERFLOW_BIN ) :
00274 aida -> binError ( AIDA::IAxis::OVERFLOW_BIN ) ,
00275 axis . upperEdge () ) ;
00276
00277 for ( int ibin = 0 ; ibin < nbins ; ++ibin )
00278 {
00279
00280 Histo::Bin bin ( aida -> binHeight ( ibin ) ,
00281 spread ?
00282 aida -> binRms ( ibin ) :
00283 aida -> binError ( ibin ) ,
00284 axis . binLowerEdge ( ibin ) ) ;
00285 hist.bins.push_back ( bin ) ;
00286 }
00287 return StatusCode::SUCCESS ;
00288 }
00289
00295 inline unsigned int rebin
00296 ( const unsigned int bins ,
00297 const unsigned int imax )
00298 {
00299 if ( 0 == imax ) { return 1 ; }
00300 unsigned int ibin = 1 ;
00301 while ( bins > imax * ibin ) { ++ibin ; }
00302 return ibin ;
00303 }
00304
00310 std::pair<double,int> decompose ( double v )
00311 {
00312 if ( 0 == v ) { return std::make_pair ( 0.0 , 0 ) ; }
00313 else if ( 1 == v ) { return std::make_pair ( 1.0 , 0 ) ; }
00314 else if ( 0 > v )
00315 {
00316 std::pair<double,int> r = decompose ( -v ) ;
00317 return std::pair<double,int>( -r.first , r.second ) ;
00318 }
00319 else if ( 0.1 > v )
00320 {
00321 int i = 0 ;
00322 while ( 0.1 > v ) { ++i ; v *= 10 ; }
00323 return std::make_pair ( v , -i ) ;
00324 }
00325 else if ( 1 < v )
00326 {
00327 int i = 0 ;
00328 while ( 1 <= v ) { ++i ; v /= 10 ; }
00329 return std::make_pair ( v , i ) ;
00330 }
00331 return std::make_pair ( v , 1 ) ;
00332 }
00333
00338 inline double _pow ( double __x , unsigned long __n )
00339 {
00340 double __y = __n % 2 ? __x : 1;
00341 while ( __n >>= 1 )
00342 {
00343 __x = __x * __x;
00344 if ( __n % 2) { __y = __y * __x; }
00345 }
00346 return __y ;
00347 }
00348
00353 inline double rValMax ( const double v ) ;
00354
00359 inline double rValMin ( const double v ) ;
00360
00365 inline double rValMax ( const double v )
00366 {
00367 if ( 0 == v ) { return 0 ; }
00368 else if ( 0 > v ) { return -1 * rValMin ( -v ) ; }
00369
00370 std::pair<double,int> r = decompose ( v ) ;
00371
00372 const double f = std::ceil ( 20 * r.first ) / 2 ;
00373 const int l = r.second - 1 ;
00374 return 0 < l ? f * _pow ( 10 , l ) : f / _pow ( 10 , -l ) ;
00375 }
00376
00381 inline double rValMin ( const double v )
00382 {
00383 if ( 0 == v ) { return 0 ; }
00384 else if ( 0 > v ) { return -1 * rValMax ( -v ) ; }
00385
00386 std::pair<double,int> r = decompose ( v ) ;
00387 const double f = std::floor ( 20 * r.first ) / 2 ;
00388 const int l = r.second - 1 ;
00389 return 0 < l ? f * _pow ( 10 , l ) : f / _pow ( 10 , -l ) ;
00390 }
00391
00396 inline std::string yLabel ( const double value )
00397 {
00398 boost::format fmt ( "%10.3g" ) ;
00399 fmt % value ;
00400 return fmt.str () ;
00401 }
00402
00407 inline std::string xLabel ( const double value )
00408 {
00409 boost::format fmt ( "%9.3g" ) ;
00410 fmt % value ;
00411 return fmt.str () ;
00412 }
00413
00415 char symbBin ( const Histo::Bin& bin ,
00416 const double yLow ,
00417 const double yHigh ,
00418 const bool yNull ,
00419 const bool errors )
00420 {
00421 if ( errors && yLow <= bin.height && bin.height < yHigh ) { return '*' ; }
00422 else if ( errors && yHigh < bin.height - bin.error ) { return ' ' ; }
00423 else if ( errors && yLow >= bin.height + bin.error ) { return ' ' ; }
00424 else if ( errors ) { return 'I' ; }
00425 else if ( yLow <= bin.height && bin.height < yHigh ) { return '*' ; }
00426 else if ( 0 <= bin.height && yLow <= bin.height && 0 < yHigh && !yNull ) { return '*' ; }
00427 else if ( 0 > bin.height && yHigh > bin.height && 0 >= yLow && !yNull ) { return '*' ; }
00428
00429 return ' ' ;
00430 }
00431
00436 std::ostream& dumpText
00437 ( const Histo& histo ,
00438 const std::size_t width ,
00439 const std::size_t height ,
00440 const bool errors ,
00441 std::ostream& stream )
00442 {
00443 if ( 40 > width ) { return dumpText ( histo , 40 , height , errors , stream ) ; }
00444 if ( 200 < width ) { return dumpText ( histo , 200 , height , errors , stream ) ; }
00445 if ( 150 < height ) { return dumpText ( histo , width , 150 , errors , stream ) ; }
00446 if ( 20 > height ) { return dumpText ( histo , width , 20 , errors , stream ) ; }
00447 if ( height > width ) { return dumpText ( histo , width , width , errors , stream ) ; }
00448
00449 const unsigned int nBins = histo.bins.size() ;
00450 if ( nBins > width )
00451 {
00452
00453 Histo r = histo.rebin ( rebin ( nBins , width ) ) ;
00454 return dumpText ( r , width , height , errors , stream ) ;
00455 }
00456
00457
00458 double yMax = std::max ( rValMax ( histo.maxY ( errors ) ) , 0.0 ) ;
00459 double yMin = std::min ( rValMin ( histo.minY ( errors ) ) , 0.0 ) ;
00460
00461 if ( yMin == yMax ) { yMax = yMin + 1 ; }
00463 std::pair<double,int> r = decompose ( yMax - yMin ) ;
00464 double _ny = std::ceil ( 10 * r.first ) ;
00465 if ( 1 >= _ny ) { _ny = 10 ; }
00466 int yBins = (int) std::max ( 1. , std::ceil ( height / _ny ) ) ;
00467
00468 yBins *= (int) _ny ;
00469 if ( 20 > yBins ) { yBins = 20 ; }
00470 const double yScale = ( yMax - yMin ) / yBins ;
00471
00472
00473 const int ySkip =
00474 0 == yBins % 13 ? 13 :
00475 0 == yBins % 11 ? 11 :
00476 0 == yBins % 9 ? 9 :
00477 0 == yBins % 8 ? 8 :
00478 0 == yBins % 7 ? 7 :
00479 0 == yBins % 6 ? 6 :
00480 0 == yBins % 5 ? 5 :
00481 0 == yBins % 4 ? 4 : 10 ;
00482
00483 const int xSkip =
00484
00485 0 == nBins % 7 ? 7 :
00486 0 == nBins % 6 ? 6 :
00487 0 == nBins % 5 ? 5 :
00488 0 == nBins % 4 ? 4 : 10 ;
00489
00490 int iNull = histo.nullBin() ;
00491
00492 if ( 0 <= iNull ) { iNull %= xSkip ; }
00493 else { iNull = 0 ; }
00494
00495 stream << std::endl ;
00496
00497 for ( int yLine = -1 ; yLine < yBins ; ++yLine )
00498 {
00499 const double yHigh = yMax - yScale * yLine ;
00500
00501 const double yLow = yMax - yScale * ( yLine + 1 ) ;
00502
00503 std::string line1 = " " ;
00504
00505 const bool ynull = ( yLow <= 0 && 0 < yHigh ) ;
00506 const bool yfirst = -1 == yLine || yBins -1 == yLine ;
00507 const bool ylab =
00508 ( 0 == ( yLine + 1 ) % ySkip ) || yfirst || ynull ;
00509
00510 if ( ylab ) { line1 += yLabel ( ( yLow <= 0 && 0 < yHigh ) ? 0.0 : yLow ) ; }
00511 else { line1 += std::string( 10 , ' ' ) ; }
00512
00513 line1 += " " ;
00514
00516 line1 += symbBin ( histo.under , yLow , yHigh , ynull , errors ) ;
00517
00518 line1 +=
00519 ynull ? "-+" :
00520 ylab ? " +" : " |" ;
00521
00522 std::string line2 ;
00523
00524 for ( Histo::Bins::const_iterator ibin = histo.bins.begin() ;
00525 histo.bins.end() != ibin ; ++ibin )
00526 {
00527
00528 const int i = ibin - histo.bins.begin () ;
00529
00530 const bool xnull =
00531 ibin->lower <= 0 && ( ibin + 1 ) != histo.bins.end() && 0 < (ibin+1)->lower ;
00532 const bool xlab = iNull == i % xSkip ;
00533
00534 char symb = symbBin ( *ibin, yLow , yHigh , ynull , errors ) ;
00535
00536 if ( ' ' == symb )
00537 {
00538 if ( ( ynull || yfirst ) && xlab ) { symb = '+' ; }
00539 else if ( ynull || yfirst ) { symb = '-' ; }
00540
00541 else if ( ylab && xnull ) { symb = '+' ; }
00542 else if ( xnull ) { symb = '|' ; }
00543
00544 else if ( ylab || xlab ) { symb = '.' ; }
00545
00546 }
00547 line2 += symb ;
00548
00549 }
00550
00551 std::string line3 =
00552 ynull ? "->" :
00553 ylab ? "+ " : "| " ;
00554
00556 line3 += symbBin ( histo.over , yLow , yHigh , ynull , errors ) ;
00557
00558 stream << line1 << line2 << line3 << std::endl ;
00559
00560 }
00561
00562
00563 std::vector<std::string> xlabels ;
00564 for ( Histo::Bins::const_iterator ib = histo.bins.begin() ; histo.bins.end() != ib ; ++ib )
00565 { xlabels.push_back ( xLabel ( ib->lower ) ) ; }
00566
00567 const std::string oLabel = xLabel ( histo.over.lower ) ;
00568 const std::string uLabel = xLabel ( histo.under.lower ) ;
00569
00570 static const std::string s_UNDERFLOW ( "UNDERFLOW" ) ;
00571 static const std::string s_OVERFLOW ( " OVERFLOW" ) ;
00572
00573
00574 for ( unsigned int yLine = 0 ; yLine < 12 ; ++yLine )
00575 {
00576 std::string line = std::string ( 12 , ' ' ) ;
00577
00578 if ( yLine < s_UNDERFLOW.size() ) { line += s_UNDERFLOW[yLine] ; }
00579 else { line += ' ' ; }
00580
00581 line += ' ' ;
00582
00583 if ( uLabel.size() > yLine ) { line += uLabel[yLine] ; }
00584 else { line += ' ' ; }
00585
00586 for ( Histo::Bins::const_iterator ibin = histo.bins.begin() ; histo.bins.end() != ibin ; ++ibin )
00587 {
00588 int ib = ibin - histo.bins.begin() ;
00589 const bool xlab = ( iNull == ib % xSkip ) ;
00590 if ( xlab && yLine < xlabels[ib].size() ) { line += xlabels[ib][yLine] ; }
00591 else { line += ' ' ; }
00592 }
00593
00594 if ( oLabel.size() > yLine ) { line += oLabel[yLine] ; }
00595 else { line += ' ' ; }
00596
00597 line += ' ' ;
00598
00599 if ( yLine < s_OVERFLOW.size() ) { line += s_OVERFLOW[yLine] ; }
00600 else { line += ' ' ; }
00601
00602 stream << line << std::endl ;
00603 }
00604
00605 return stream ;
00606 }
00607 }
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 std::ostream& Gaudi::Utils::Histos::histoDump_
00621 ( const AIDA::IHistogram1D* histo ,
00622 std::ostream& stream ,
00623 const std::size_t width ,
00624 const std::size_t height ,
00625 const bool errors )
00626 {
00627 stream << std::endl ;
00628 if ( 0 == histo ) { return stream ; }
00629 Histo hist ;
00630 StatusCode sc = _getHisto ( histo , hist ) ;
00631 if ( sc.isFailure() ) { return stream ; }
00632
00633 stream
00634 << boost::format ( " Histo TES : \"%s\"") % path ( histo )
00635 << std::endl
00636 << boost::format ( " Histo Title : \"%s\"") % histo->title()
00637 << std::endl
00638 << std::endl ;
00639
00640 stream
00641 << boost::format ( " Mean : %11.5g +- %-10.4g ")
00642 % Gaudi::Utils::HistoStats::mean ( histo )
00643 % Gaudi::Utils::HistoStats::meanErr ( histo )
00644 << std::endl
00645 << boost::format ( " Rms : %11.5g +- %-10.4g ")
00646 % Gaudi::Utils::HistoStats::rms ( histo )
00647 % Gaudi::Utils::HistoStats::rmsErr ( histo )
00648 << std::endl
00649 << boost::format ( " Skewness : %11.5g +- %-10.4g ")
00650 % Gaudi::Utils::HistoStats::skewness ( histo )
00651 % Gaudi::Utils::HistoStats::skewnessErr ( histo )
00652 << std::endl
00653 << boost::format ( " Kurtosis : %11.5g +- %-10.4g ")
00654 % Gaudi::Utils::HistoStats::kurtosis ( histo )
00655 % Gaudi::Utils::HistoStats::kurtosisErr ( histo )
00656 << std::endl
00657 << std::endl ;
00658
00659 stream
00660 << boost::format ( " Entries :\n | %=9s | %=9s | %=9s | %9s | %=11s | %=11s | %=11s |")
00661 % "All"
00662 % "In Range"
00663 % "Underflow"
00664 % "Overflow"
00665 % "#Equivalent"
00666 % "Integral"
00667 % "Total"
00668 << std::endl
00669 << boost::format ( " | %=9d | %=9d | %=9d | %=9d | %=11.5g | %=11.5g | %=11.5g |")
00670 % histo -> allEntries ()
00671 % histo -> entries ()
00672 % histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN )
00673 % histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN )
00674 % histo -> equivalentBinEntries ()
00675 % histo -> sumBinHeights ()
00676 % histo -> sumAllBinHeights ()
00677 << std::endl
00678 << std::endl ;
00679
00680 const AIDA::IAnnotation& a = histo->annotation () ;
00681 if ( 0 != a.size() )
00682 {
00683 stream << " Annotation" << std::endl ;
00684 for ( int i = 0 ; i < a.size() ; ++i )
00685 {
00686 stream
00687 << boost::format ( " | %-25.25s : %-45.45s | ")
00688 % a.key ( i )
00689 % a.value ( i )
00690 << std::endl ;
00691 }
00692 stream << std::endl ;
00693 }
00694
00695 return dumpText ( hist , width , height , errors , stream ) ;
00696 }
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709 std::string Gaudi::Utils::Histos::histoDump
00710 ( const AIDA::IHistogram1D* histo ,
00711 const std::size_t width ,
00712 const std::size_t height ,
00713 const bool errors )
00714 {
00715 std::ostringstream stream ;
00716 histoDump_ ( histo , stream , width , height , errors );
00717 return stream.str() ;
00718 }
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731 std::ostream& Gaudi::Utils::Histos::histoDump_
00732 ( const AIDA::IProfile1D* histo ,
00733 std::ostream& stream ,
00734 const std::size_t width ,
00735 const std::size_t height ,
00736 const bool spread )
00737 {
00738 stream << std::endl ;
00739 if ( 0 == histo ) { return stream ; }
00740 Histo hist ;
00741 StatusCode sc = _getHisto ( histo , hist , spread ) ;
00742 if ( sc.isFailure() ) { return stream ; }
00743
00744 stream
00745 << boost::format ( " Histo TES : \"%s\"") % path ( histo )
00746 << std::endl
00747 << boost::format ( " Histo Title : \"%s\"") % histo->title()
00748 << std::endl
00749 << std::endl ;
00750
00751 stream
00752 << boost::format ( " Mean : %11.5g ") % histo->mean()
00753 << std::endl
00754 << boost::format ( " Rms : %11.5g ") % histo->rms ()
00755 << std::endl
00756 << std::endl ;
00757
00758 stream
00759 << boost::format ( " Entries :\n | %=9s | %=9s | %=9s | %9s | %=11s | %=11s |")
00760 % "All"
00761 % "In Range"
00762 % "Underflow"
00763 % "Overflow"
00764
00765 % "Integral"
00766 % "Total"
00767 << std::endl
00768 << boost::format ( " | %=9d | %=9d | %=9d | %=9d | %=11.5g | %=11.5g |")
00769 % histo -> allEntries ()
00770 % histo -> entries ()
00771 % histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN )
00772 % histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN )
00773
00774 % histo -> sumBinHeights ()
00775 % histo -> sumAllBinHeights ()
00776 << std::endl
00777 << std::endl ;
00778
00779 const AIDA::IAnnotation& a = histo->annotation () ;
00780 if ( 0 != a.size() )
00781 {
00782 stream << " Annotation" << std::endl ;
00783 for ( int i = 0 ; i < a.size() ; ++i )
00784 {
00785 stream
00786 << boost::format ( " | %-25.25s : %-45.45s | ")
00787 % a.key ( i )
00788 % a.value ( i )
00789 << std::endl ;
00790 }
00791 stream << std::endl ;
00792 }
00793
00794 return dumpText ( hist , width , height , true , stream ) ;
00795 }
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806 std::string Gaudi::Utils::Histos::histoDump
00807 ( const AIDA::IProfile1D* histo ,
00808 const std::size_t width ,
00809 const std::size_t height ,
00810 const bool spread )
00811 {
00812 std::ostringstream stream ;
00813 histoDump_ ( histo , stream , width , height , spread );
00814 return stream.str() ;
00815 }
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827 std::ostream& Gaudi::Utils::Histos::histoDump_
00828 ( const TH1* histo ,
00829 std::ostream& stream ,
00830 const std::size_t width ,
00831 const std::size_t height ,
00832 const bool errors )
00833 {
00834 const TProfile* profile = dynamic_cast<const TProfile*> ( histo ) ;
00835 if ( 0 != profile )
00836 { return histoDump_ ( profile , stream , width , height ) ; }
00837
00838 stream << std::endl ;
00839 if ( 0 == histo ) { return stream ; }
00840 Histo hist ;
00841 StatusCode sc = _getHisto ( histo , hist ) ;
00842 if ( sc.isFailure() ) { return stream ; }
00843
00844 stream
00845 << boost::format ( " Histo Name : \"%s\"")
00846 % histo -> GetName ()
00847 << std::endl
00848 << boost::format ( " Histo Title : \"%s\"")
00849 % histo -> GetTitle ()
00850 << std::endl
00851 << std::endl ;
00852
00853 stream
00854 << boost::format ( " Mean : %11.5g +- %-10.4g ")
00855 % histo -> GetMean ()
00856 % histo -> GetMeanError ()
00857 << std::endl
00858 << boost::format ( " Rms : %11.5g +- %-10.4g ")
00859 % histo -> GetRMS ()
00860 % histo -> GetRMSError ()
00861 << std::endl
00862 << boost::format ( " Skewness : %11.5g ")
00863 % histo -> GetSkewness ()
00864 << std::endl
00865 << boost::format ( " Kurtosis : %11.5g ")
00866 % histo -> GetKurtosis ()
00867 << std::endl
00868 << std::endl ;
00869
00870 stream
00871 << boost::format ( " Entries :\n | %=11s | %=11s | %=11s | %=11s | %=11s |")
00872 % "All"
00873 % "Underflow"
00874 % "Overflow"
00875 % "#Equivalent"
00876 % "Integral"
00877 << std::endl
00878 << boost::format ( " | %=11.5g | %=11.5g | %=11.5g | %=11.5g | %=11.5g |")
00879 % histo -> GetEntries ()
00880 % histo -> GetBinContent ( 0 )
00881 % histo -> GetBinContent ( histo->GetNbinsX() + 1 )
00882 % histo -> GetEffectiveEntries ()
00883 % histo -> Integral ()
00884 << std::endl
00885 << std::endl ;
00886
00887 return dumpText ( hist , width , height , errors , stream ) ;
00888 }
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900 std::ostream& Gaudi::Utils::Histos::histoDump_
00901 ( const TProfile* histo ,
00902 std::ostream& stream ,
00903 const std::size_t width ,
00904 const std::size_t height )
00905 {
00906 stream << std::endl ;
00907 if ( 0 == histo ) { return stream ; }
00908 Histo hist ;
00909 StatusCode sc = _getHisto ( histo , hist , true ) ;
00910 if ( sc.isFailure() ) { return stream ; }
00911
00912 stream
00913 << boost::format ( " Profile Name : \"%s\"")
00914 % histo -> GetName ()
00915 << std::endl
00916 << boost::format ( " Profile Title : \"%s\"")
00917 % histo -> GetTitle ()
00918 << std::endl
00919 << std::endl ;
00920
00921 stream
00922 << boost::format ( " Mean : %11.5g ") % histo -> GetMean ()
00923 << std::endl
00924 << boost::format ( " Rms : %11.5g ") % histo -> GetRMS ()
00925 << std::endl
00926 << std::endl ;
00927
00928 stream
00929 << boost::format ( " Entries :\n | %=11s | %=11s | %=11s | %=11s |")
00930 % "All"
00931 % "Underflow"
00932 % "Overflow"
00933 % "Integral"
00934 << std::endl
00935 << boost::format ( " | %=11.5g | %=11.5g | %=11.5g | %=11.5g |")
00936 % histo -> GetEntries ()
00937 % histo -> GetBinContent ( 0 )
00938 % histo -> GetBinContent ( histo->GetNbinsX() + 1 )
00939 % histo -> Integral ()
00940 << std::endl
00941 << std::endl ;
00942
00943 return dumpText ( hist , width , height , true , stream ) ;
00944 }
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955 std::string Gaudi::Utils::Histos::histoDump
00956 ( const TH1* histo ,
00957 const std::size_t width ,
00958 const std::size_t height ,
00959 const bool errors )
00960 {
00961 std::ostringstream stream ;
00962 histoDump_ ( histo , stream , width , height , errors );
00963 return stream.str() ;
00964 }
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975 std::string Gaudi::Utils::Histos::histoDump
00976 ( const TProfile* histo ,
00977 const std::size_t width ,
00978 const std::size_t height )
00979 {
00980 std::ostringstream stream ;
00981 histoDump_ ( histo , stream , width , height );
00982 return stream.str() ;
00983 }
00984
00985
00986
00987
00988
00989
00990
00991