13 #include "AIDA/IHistogram1D.h" 14 #include "AIDA/IHistogram2D.h" 34 template <
class HISTO>
40 stream <<
"'name' : ";
42 stream <<
"'title' : ";
45 const TAxis* axis = histo.GetXaxis();
46 const unsigned int nBins = axis->GetNbins();
49 if ( axis->IsVariableBinSize() ) {
50 const TArrayD* xbins = axis->GetXbins();
51 const unsigned int xsize = xbins->GetSize();
53 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) { edges.
push_back( xbins->At( iBin ) ); }
54 stream <<
"'edges' : ";
57 stream <<
"'nbins' : ";
61 stream <<
"'high' : ";
66 for (
unsigned int iBin = 0; iBin <= nBins + 1; ++iBin ) {
67 bins.
emplace_back( histo.GetBinContent( iBin ), histo.GetBinError( iBin ) );
69 stream <<
"'bins' : ";
77 template <
class HISTO>
83 stream <<
"'name' : ";
85 stream <<
"'title' : ";
88 const TAxis* xaxis = histo.GetXaxis();
89 const int xBins = xaxis->GetNbins();
91 stream << std::endl <<
"'X' : { ";
92 if ( xaxis->IsVariableBinSize() ) {
93 const TArrayD* xbins = xaxis->GetXbins();
94 const unsigned int xsize = xbins->GetSize();
96 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) { edges.
push_back( xbins->At( iBin ) ); }
98 stream <<
"'edges' : ";
101 stream <<
"'nbins' : ";
103 stream <<
"'low' : ";
105 stream <<
"'high' : ";
109 const TAxis* yaxis = histo.GetYaxis();
110 const int yBins = yaxis->GetNbins();
112 stream << std::endl <<
"'Y' : { ";
113 if ( yaxis->IsVariableBinSize() ) {
114 const TArrayD* ybins = yaxis->GetXbins();
115 const unsigned int ysize = ybins->GetSize();
117 for (
unsigned int iBin = 0; iBin < ysize; ++iBin ) { edges.
push_back( ybins->At( iBin ) ); }
119 stream <<
" 'edges' : ";
122 stream <<
"'nbins' : ";
124 stream <<
"'low' : ";
126 stream <<
"'high' : ";
131 stream <<
"'bins' : " << std::endl <<
" [ ";
132 for (
int jBin = yBins + 1; jBin >= 0; --jBin ) {
133 if ( yBins + 1 != jBin ) { stream <<
std::endl; }
134 for (
int iBin = 0; iBin <= xBins + 1; ++iBin ) {
139 if ( xBins + 1 != iBin || 0 != jBin ) { stream <<
" , "; }
158 return _toStream_1D_( histo, stream, asXML );
168 return _toStream_1D_( histo, stream, asXML );
178 return _toStream_2D_( histo, stream, asXML );
188 return _toStream_2D_( histo, stream, asXML );
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
std::ostream & toStream(const DataObjID &d, std::ostream &os)
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.
std::string toString(const Type &)