25 #include <AIDA/IHistogram1D.h>
26 #include <AIDA/IHistogram2D.h>
27 #include <AIDA/IHistogram3D.h>
47 template <
class HISTO>
48 std::ostream& _toStream_1D_(
const HISTO& histo, std::ostream&
stream,
const bool asXML ) {
58 const TAxis* axis = histo.GetXaxis();
59 const unsigned int nBins = axis->GetNbins();
61 stream << std::endl <<
"'X' : { ";
62 if ( axis->IsVariableBinSize() ) {
63 const TArrayD* xbins = axis->GetXbins();
64 const unsigned int xsize = xbins->GetSize();
65 std::vector<double> edges;
66 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) { edges.push_back( xbins->At( iBin ) ); }
78 std::vector<std::pair<double, double>> bins;
79 for (
unsigned int iBin = 0; iBin <= nBins + 1; ++iBin ) {
80 bins.emplace_back( histo.GetBinContent( iBin ), histo.GetBinError( iBin ) );
90 template <
class HISTO>
91 std::ostream& _toStream_2D_(
const HISTO& histo, std::ostream&
stream,
const bool asXML ) {
101 const TAxis* xaxis = histo.GetXaxis();
102 const int xBins = xaxis->GetNbins();
104 stream << std::endl <<
"'X' : { ";
105 if ( xaxis->IsVariableBinSize() ) {
106 const TArrayD* xbins = xaxis->GetXbins();
107 const unsigned int xsize = xbins->GetSize();
108 std::vector<double> edges;
109 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) { edges.push_back( xbins->At( iBin ) ); }
122 const TAxis* yaxis = histo.GetYaxis();
123 const int yBins = yaxis->GetNbins();
125 stream << std::endl <<
"'Y' : { ";
126 if ( yaxis->IsVariableBinSize() ) {
127 const TArrayD* ybins = yaxis->GetXbins();
128 const unsigned int ysize = ybins->GetSize();
129 std::vector<double> edges;
130 for (
unsigned int iBin = 0; iBin < ysize; ++iBin ) { edges.push_back( ybins->At( iBin ) ); }
144 stream <<
"'bins' : " << std::endl <<
" [ ";
145 for (
int jBin = yBins + 1; jBin >= 0; --jBin ) {
146 if ( yBins + 1 != jBin ) {
stream << std::endl; }
147 for (
int iBin = 0; iBin <= xBins + 1; ++iBin ) {
149 Gaudi::Utils::toStream( std::make_pair( histo.GetBinContent( iBin, jBin ), histo.GetBinError( iBin, jBin ) ),
152 if ( xBins + 1 != iBin || 0 != jBin ) {
stream <<
" , "; }
162 template <
class HISTO>
163 std::ostream& _toStream_3D_(
const HISTO& histo, std::ostream&
stream,
const bool asXML ) {
173 const TAxis* xaxis = histo.GetXaxis();
174 const int xBins = xaxis->GetNbins();
176 stream << std::endl <<
"'X' : { ";
177 if ( xaxis->IsVariableBinSize() ) {
178 const TArrayD* xbins = xaxis->GetXbins();
179 const unsigned int xsize = xbins->GetSize();
180 std::vector<double> edges;
181 for (
unsigned int iBin = 0; iBin < xsize; ++iBin ) { edges.push_back( xbins->At( iBin ) ); }
194 const TAxis* yaxis = histo.GetYaxis();
195 const int yBins = yaxis->GetNbins();
197 stream << std::endl <<
"'Y' : { ";
198 if ( yaxis->IsVariableBinSize() ) {
199 const TArrayD* ybins = yaxis->GetXbins();
200 const unsigned int ysize = ybins->GetSize();
201 std::vector<double> edges;
202 for (
unsigned int iBin = 0; iBin < ysize; ++iBin ) { edges.push_back( ybins->At( iBin ) ); }
215 const TAxis* zaxis = histo.GetZaxis();
216 const int zBins = zaxis->GetNbins();
218 stream << std::endl <<
"'Z' : { ";
219 if ( zaxis->IsVariableBinSize() ) {
220 const TArrayD* zbins = zaxis->GetXbins();
221 const unsigned int zsize = zbins->GetSize();
222 std::vector<double> edges;
223 for (
unsigned int iBin = 0; iBin < zsize; ++iBin ) { edges.push_back( zbins->At( iBin ) ); }
237 stream <<
"'bins' : " << std::endl <<
" [ ";
238 for (
int kBin = 0; kBin <= zBins + 1; ++kBin ) {
239 for (
int jBin = yBins + 1; jBin >= 0; --jBin ) {
240 if ( yBins + 1 != jBin ) {
stream << std::endl; }
241 for (
int iBin = 0; iBin <= xBins + 1; ++iBin ) {
244 std::make_pair( histo.GetBinContent( iBin, jBin, kBin ), histo.GetBinError( iBin, jBin, kBin ) ),
247 if ( !( ( ( xBins + 1 ) == iBin ) && ( 0 == jBin ) && ( ( zBins + 1 ) == kBin ) ) ) {
stream <<
" , "; }
267 return _toStream_1D_( histo,
stream, asXML );
277 return _toStream_1D_( histo,
stream, asXML );
287 return _toStream_2D_( histo,
stream, asXML );
297 return _toStream_2D_( histo,
stream, asXML );
307 return _toStream_3D_( histo,
stream, asXML );
317 return _toStream_3D_( histo,
stream, asXML );
365 std::ostringstream o;
379 std::ostringstream o;
393 std::ostringstream o;
407 std::ostringstream o;
421 std::ostringstream o;
435 std::ostringstream o;
449 std::ostringstream o;
463 std::ostringstream o;
477 std::ostringstream o;