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 ,
243 (
const AIDA::IHistogram2D& histo ,
261 (
const TH1D& histo ,
278 (
const TH1F& histo ,
295 (
const TH2D& histo ,
312 (
const TH2F& histo ,
329 (
const AIDA::IHistogram1D& histo ,
346 (
const AIDA::IHistogram2D& histo ,
364 return histo ?
toString ( *histo ) :
"{}";
377 return histo ?
toString ( *histo ) :
"{}";
390 return histo ?
toString ( *histo ) :
"{}";
403 return histo ?
toString ( *histo ) :
"{}";
416 return histo ?
toString ( *histo ) :
"{}";
429 return histo ?
toString ( *histo ) :
"{}";
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
GAUDI_API std::ostream & toXml(const TH1D &histo, std::ostream &stream)
stream the ROOT histogram into output stream as XML
implementation of various functions for streaming.