10 #pragma warning( disable : 4996 ) 23 #include "TProfile2D.h" 30 template <
typename R,
typename A>
33 if ( !aida )
return false;
35 if ( !root )
return false;
36 root->SetXTitle( xAxis.
c_str() );
37 root->SetYTitle( yAxis.
c_str() );
45 if ( !axis )
return false;
46 const unsigned nbins = axis->GetNbins();
47 for (
const auto& i : labels ) {
48 if ( 1 + i.first <= 0 || 1 + i.first > nbins )
return false;
50 axis->SetBinLabel( 1 + i.first, i.second.c_str() );
57 template <
typename R,
typename A>
60 if ( !aida )
return false;
62 if ( !root )
return false;
63 return setBinLabels_( root->GetXaxis(), labels );
66 template <
typename Histogram>
70 l.reserve( labels.size() );
71 for (
unsigned i = 0; i < labels.size(); ++i ) l.emplace_back( i, labels[i] );
89 return setBinLabels_<TH1D>( hist, labels );
94 return setBinLabels_<TProfile>( hist, labels );
97 bool setBinLabels( AIDA::IHistogram1D* hist,
const Labels& labels ) {
return setBinLabels_( hist, labels ); }
99 bool setBinLabels( AIDA::IProfile1D* hist,
const Labels& labels ) {
return setBinLabels_( hist, labels ); }
103 if ( !hist )
return false;
105 if ( !h2d )
return false;
108 for (
unsigned int i = 0; i < xlabels.
size(); ++i ) {
113 for (
unsigned int i = 0; i < ylabels.
size(); ++i ) {
116 return ( setBinLabels_( h2d->GetXaxis(), lx ) && setBinLabels_( h2d->GetYaxis(), ly ) );
122 return ( h2d && setBinLabels_( h2d->GetXaxis(), xlabels ) && setBinLabels_( h2d->GetYaxis(), ylabels ) );
127 if ( !hist )
return false;
129 if ( !h2d )
return false;
132 for (
unsigned int i = 0; i < xlabels.
size(); ++i ) {
137 for (
unsigned int i = 0; i < ylabels.
size(); ++i ) {
140 return ( setBinLabels_( h2d->GetXaxis(), lx ) && setBinLabels_( h2d->GetYaxis(), ly ) );
146 return ( h2d && setBinLabels_( h2d->GetXaxis(), xlabels ) && setBinLabels_( h2d->GetYaxis(), ylabels ) );
153 return setAxisLabels_<TH1D>( hist, xAxis, yAxis );
158 return setAxisLabels_<TProfile>( hist, xAxis, yAxis );
163 return setAxisLabels_<TH2D>( hist, xAxis, yAxis );
168 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.