13 #include "AIDA/IHistogram1D.h" 14 #include "AIDA/IHistogram2D.h" 35 template <
class HISTO>
44 stream <<
"'name' : ";
46 stream <<
"'title' : ";
49 const TAxis* axis = histo.GetXaxis();
50 const unsigned int nBins = axis->GetNbins();
53 if ( axis->IsVariableBinSize() ) {
54 const TArrayD* xbins = axis->GetXbins();
55 const unsigned int xsize = xbins->GetSize();
57 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) {
60 stream <<
"'edges' : ";
63 stream <<
"'nbins' : ";
67 stream <<
"'high' : ";
72 for (
unsigned int iBin = 0; iBin <= nBins + 1; ++iBin ) {
73 bins.
emplace_back( histo.GetBinContent( iBin ), histo.GetBinError( iBin ) );
75 stream <<
"'bins' : ";
83 template <
class HISTO>
92 stream <<
"'name' : ";
94 stream <<
"'title' : ";
97 const TAxis* xaxis = histo.GetXaxis();
98 const int xBins = xaxis->GetNbins();
100 stream << std::endl <<
"'X' : { ";
101 if ( xaxis->IsVariableBinSize() ) {
102 const TArrayD* xbins = xaxis->GetXbins();
103 const unsigned int xsize = xbins->GetSize();
105 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) {
109 stream <<
"'edges' : ";
112 stream <<
"'nbins' : ";
114 stream <<
"'low' : ";
116 stream <<
"'high' : ";
120 const TAxis* yaxis = histo.GetYaxis();
121 const int yBins = yaxis->GetNbins();
123 stream << std::endl <<
"'Y' : { ";
124 if ( yaxis->IsVariableBinSize() ) {
125 const TArrayD* ybins = yaxis->GetXbins();
126 const unsigned int ysize = ybins->GetSize();
128 for (
unsigned int iBin = 0; iBin < ysize; ++iBin ) {
132 stream <<
" 'edges' : ";
135 stream <<
"'nbins' : ";
137 stream <<
"'low' : ";
139 stream <<
"'high' : ";
144 stream <<
"'bins' : " << std::endl <<
" [ ";
145 for (
int jBin = yBins + 1; jBin >= 0; --jBin ) {
146 if ( yBins + 1 != jBin ) {
149 for (
int iBin = 0; iBin <= xBins + 1; ++iBin ) {
154 if ( xBins + 1 != iBin || 0 != jBin ) {
176 return _toStream_1D_( histo, stream, asXML );
187 return _toStream_1D_( histo, stream, asXML );
198 return _toStream_2D_( histo, stream, asXML );
209 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 &)