10 # pragma warning( disable : 4996 ) 23 #include "TProfile2D.h" 29 template <
typename R,
typename A>
31 if ( !aida )
return false;
33 if ( !root )
return false;
34 root->SetXTitle( xAxis.
c_str() );
35 root->SetYTitle( yAxis.
c_str() );
42 if ( !axis )
return false;
43 const unsigned nbins = axis->GetNbins();
44 for (
const auto& i : labels ) {
45 if ( 1 + i.first <= 0 || 1 + i.first > nbins )
return false;
47 axis->SetBinLabel( 1 + i.first, i.second.c_str() );
54 template <
typename R,
typename A>
56 if ( !aida )
return false;
58 if ( !root )
return false;
59 return setBinLabels_( root->GetXaxis(), labels );
62 template <
typename Histogram>
65 l.reserve( labels.size() );
66 for (
unsigned i = 0; i < labels.size(); ++i ) l.emplace_back( i, labels[i] );
80 return setBinLabels_<TH1D>( hist, labels );
84 return setBinLabels_<TProfile>( hist, labels );
87 bool setBinLabels( AIDA::IHistogram1D* hist,
const Labels& labels ) {
return setBinLabels_( hist, labels ); }
89 bool setBinLabels( AIDA::IProfile1D* hist,
const Labels& labels ) {
return setBinLabels_( hist, labels ); }
92 if ( !hist )
return false;
94 if ( !h2d )
return false;
97 for (
unsigned int i = 0; i < xlabels.
size(); ++i ) { lx.
emplace_back( i, xlabels[i] ); }
100 for (
unsigned int i = 0; i < ylabels.
size(); ++i ) { ly.
emplace_back( i, ylabels[i] ); }
101 return ( setBinLabels_( h2d->GetXaxis(), lx ) && setBinLabels_( h2d->GetYaxis(), ly ) );
106 return ( h2d && setBinLabels_( h2d->GetXaxis(), xlabels ) && setBinLabels_( h2d->GetYaxis(), ylabels ) );
110 if ( !hist )
return false;
112 if ( !h2d )
return false;
115 for (
unsigned int i = 0; i < xlabels.
size(); ++i ) { lx.
emplace_back( i, xlabels[i] ); }
118 for (
unsigned int i = 0; i < ylabels.
size(); ++i ) { ly.
emplace_back( i, ylabels[i] ); }
119 return ( setBinLabels_( h2d->GetXaxis(), lx ) && setBinLabels_( h2d->GetYaxis(), ly ) );
124 return ( h2d && setBinLabels_( h2d->GetXaxis(), xlabels ) && setBinLabels_( h2d->GetYaxis(), ylabels ) );
130 return setAxisLabels_<TH1D>( hist, xAxis, yAxis );
134 return setAxisLabels_<TProfile>( hist, xAxis, yAxis );
138 return setAxisLabels_<TH2D>( hist, xAxis, yAxis );
142 return setAxisLabels_<TProfile2D>( hist, xAxis, yAxis );
helper namespace to collect useful definitions, types, constants and functions, related to manipulati...
std::vector< BinLabel > BinLabels
Typedef for a list of bin numbers and their associated label.
GAUDI_API bool setAxisLabels(AIDA::IHistogram1D *hist, const std::string &xAxis, const std::string &yAxis)
Set the axis labels for the given 1D histogram.
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
std::vector< std::string > Labels
Typedef for a list of labels.
GAUDI_API bool setBinLabels(AIDA::IHistogram1D *hist, const Labels &labels)
Set the Bin labels for a given 1D histogram.
Helper functions to set/get the application return code.