13 #include "AIDA/IHistogram1D.h"
14 #include "AIDA/IHistogram2D.h"
35 template <
class HISTO>
37 (
const HISTO& histo ,
45 stream <<
"'name' : " ;
47 stream <<
"'title' : " ;
50 const TAxis* axis = histo.GetXaxis() ;
51 const unsigned int nBins = axis->GetNbins() ;
54 if ( axis->IsVariableBinSize() )
56 const TArrayD* xbins = axis->GetXbins() ;
57 const unsigned int xsize = xbins->GetSize() ;
59 for (
unsigned int iBin = 0 ; iBin < xsize ; ++iBin )
60 { edges.
push_back ( xbins->At( iBin ) ) ; }
61 stream <<
"'edges' : " ;
66 stream <<
"'nbins' : " ;
68 stream <<
"'low' : " ;
70 stream <<
"'high' : " ;
75 for (
unsigned int iBin = 0 ; iBin <= nBins + 1 ; ++iBin )
78 histo.GetBinError ( iBin ) ) ) ;
80 stream <<
"'bins' : " ;
88 template <
class HISTO>
90 (
const HISTO& histo ,
98 stream <<
"'name' : " ;
100 stream <<
"'title' : " ;
103 const TAxis* xaxis = histo.GetXaxis() ;
104 const int xBins = xaxis->GetNbins() ;
106 stream << std::endl <<
"'X' : { " ;
107 if ( xaxis->IsVariableBinSize() )
109 const TArrayD* xbins = xaxis->GetXbins() ;
110 const unsigned int xsize = xbins->GetSize() ;
112 for (
unsigned int iBin = 0 ; iBin < xsize ; ++iBin )
113 { edges.
push_back ( xbins->At( iBin ) ) ; }
115 stream <<
"'edges' : " ;
120 stream <<
"'nbins' : " ;
122 stream <<
"'low' : " ;
124 stream <<
"'high' : " ;
128 const TAxis* yaxis = histo.GetYaxis() ;
129 const int yBins = yaxis->GetNbins() ;
131 stream << std::endl <<
"'Y' : { " ;
132 if ( yaxis->IsVariableBinSize() )
134 const TArrayD* ybins = yaxis->GetXbins() ;
135 const unsigned int ysize = ybins->GetSize() ;
137 for (
unsigned int iBin = 0 ; iBin < ysize ; ++iBin )
138 { edges.
push_back ( ybins->At( iBin ) ) ; }
140 stream <<
" 'edges' : " ;
145 stream <<
"'nbins' : " ;
147 stream <<
"'low' : " ;
149 stream <<
"'high' : " ;
154 stream <<
"'bins' : " << std::endl <<
" [ " ;
155 for (
int jBin = yBins + 1 ; jBin >= 0 ; --jBin )
157 if ( yBins + 1 != jBin ) { stream <<
std::endl ; }
158 for (
int iBin = 0 ; iBin <= xBins + 1 ; ++iBin )
162 ( histo.GetBinContent( iBin , jBin ) ,
163 histo.GetBinError ( iBin , jBin ) ) , stream ) ;
165 if ( xBins + 1 != iBin || 0 != jBin ) { stream <<
" , " ; }
184 (
const TH1D& histo ,
186 const bool asXML ) {
return _toStream_1D_ ( histo , stream , asXML ) ; }
195 (
const TH1F& histo ,
197 const bool asXML ) {
return _toStream_1D_ ( histo , stream , asXML ) ; }
206 (
const TH2D& histo ,
208 const bool asXML ) {
return _toStream_2D_ ( histo , stream , asXML ) ; }
217 (
const TH2F& histo ,
219 const bool asXML ) {
return _toStream_2D_ ( histo , stream , asXML ) ; }
228 (
const AIDA::IHistogram1D& histo ,
233 AIDA::IHistogram1D* aida =
const_cast<AIDA::IHistogram1D*
> ( &histo ) ;
236 if ( 0 == root ) {
return stream ; }
238 return toStream ( *root , stream , asXML ) ;
248 (
const AIDA::IHistogram2D& histo ,
253 AIDA::IHistogram2D* aida =
const_cast<AIDA::IHistogram2D*
> ( &histo ) ;
256 if ( 0 == root ) {
return stream ; }
258 return toStream ( *root , stream , asXML ) ;
270 (
const TH1D& histo ,
287 (
const TH1F& histo ,
304 (
const TH2D& histo ,
321 (
const TH2F& histo ,
338 (
const AIDA::IHistogram1D& histo ,
355 (
const AIDA::IHistogram2D& histo ,