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