23 #include "AIDA/IHistogram1D.h" 24 #include "AIDA/IHistogram2D.h" 44 template <
class HISTO>
50 stream <<
"'name' : ";
52 stream <<
"'title' : ";
55 const TAxis* axis = histo.GetXaxis();
56 const unsigned int nBins = axis->GetNbins();
59 if ( axis->IsVariableBinSize() ) {
60 const TArrayD* xbins = axis->GetXbins();
61 const unsigned int xsize = xbins->GetSize();
63 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) { edges.
push_back( xbins->At( iBin ) ); }
64 stream <<
"'edges' : ";
67 stream <<
"'nbins' : ";
71 stream <<
"'high' : ";
76 for (
unsigned int iBin = 0; iBin <= nBins + 1; ++iBin ) {
77 bins.
emplace_back( histo.GetBinContent( iBin ), histo.GetBinError( iBin ) );
79 stream <<
"'bins' : ";
87 template <
class HISTO>
93 stream <<
"'name' : ";
95 stream <<
"'title' : ";
98 const TAxis* xaxis = histo.GetXaxis();
99 const int xBins = xaxis->GetNbins();
102 if ( xaxis->IsVariableBinSize() ) {
103 const TArrayD* xbins = xaxis->GetXbins();
104 const unsigned int xsize = xbins->GetSize();
106 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) { edges.
push_back( xbins->At( iBin ) ); }
108 stream <<
"'edges' : ";
111 stream <<
"'nbins' : ";
113 stream <<
"'low' : ";
115 stream <<
"'high' : ";
119 const TAxis* yaxis = histo.GetYaxis();
120 const int yBins = yaxis->GetNbins();
123 if ( yaxis->IsVariableBinSize() ) {
124 const TArrayD* ybins = yaxis->GetXbins();
125 const unsigned int ysize = ybins->GetSize();
127 for (
unsigned int iBin = 0; iBin < ysize; ++iBin ) { edges.
push_back( ybins->At( iBin ) ); }
129 stream <<
" 'edges' : ";
132 stream <<
"'nbins' : ";
134 stream <<
"'low' : ";
136 stream <<
"'high' : ";
141 stream <<
"'bins' : " <<
std::endl <<
" [ ";
142 for (
int jBin = yBins + 1; jBin >= 0; --jBin ) {
143 if ( yBins + 1 != jBin ) { stream <<
std::endl; }
144 for (
int iBin = 0; iBin <= xBins + 1; ++iBin ) {
149 if ( xBins + 1 != iBin || 0 != jBin ) { stream <<
" , "; }
168 return _toStream_1D_( histo, stream, asXML );
178 return _toStream_1D_( histo, stream, asXML );
188 return _toStream_2D_( histo, stream, asXML );
198 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.
T emplace_back(T... args)