10 #pragma warning(disable:4996) 23 #include "TProfile2D.h" 30 template <
typename R,
typename A>
31 bool setAxisLabels_( A* aida,
35 if (!aida)
return false;
37 if (!root)
return false;
38 root->SetXTitle(xAxis.
c_str());
39 root->SetYTitle(yAxis.
c_str());
45 bool setBinLabels_( TAxis* axis,
48 if (!axis)
return false;
49 const unsigned nbins = axis->GetNbins();
50 for (
const auto& i : labels )
52 if ( 1+i.first <= 0 || 1+i.first > nbins )
return false;
54 axis -> SetBinLabel( 1 + i.first, i.second.c_str() );
61 template <
typename R,
typename A>
62 bool setBinLabels_( A* aida,
65 if (!aida)
return false;
67 if (!root)
return false;
68 return setBinLabels_( root->GetXaxis(), labels );
71 template <
typename Histogram>
72 bool setBinLabels_( Histogram* hist,
76 l.reserve(labels.size());
77 for (
unsigned i = 0; i<labels.size(); ++i ) l.emplace_back( i,labels[i] );
97 return setBinLabels_<TH1D>(hist,labels);
103 return setBinLabels_<TProfile>(hist,labels);
109 return setBinLabels_(hist,labels);
115 return setBinLabels_(hist,labels);
122 if (!hist)
return false;
124 if (!h2d)
return false;
127 for (
unsigned int i = 0; i < xlabels.
size(); ++i )
133 for (
unsigned int i = 0; i < ylabels.
size(); ++i )
137 return ( setBinLabels_( h2d->GetXaxis(), lx ) &&
138 setBinLabels_( h2d->GetYaxis(), ly ) );
147 setBinLabels_( h2d->GetXaxis(), xlabels ) &&
148 setBinLabels_( h2d->GetYaxis(), ylabels ) );
155 if (!hist)
return false;
157 if (!h2d)
return false;
160 for (
unsigned int i = 0; i < xlabels.
size(); ++i )
166 for (
unsigned int i = 0; i < ylabels.
size(); ++i )
170 return ( setBinLabels_( h2d->GetXaxis(), lx ) &&
171 setBinLabels_( h2d->GetYaxis(), ly ) );
180 setBinLabels_( h2d->GetXaxis(), xlabels ) &&
181 setBinLabels_( h2d->GetYaxis(), ylabels ) );
190 return setAxisLabels_<TH1D>( hist, xAxis, yAxis );
197 return setAxisLabels_<TProfile>( hist, xAxis, yAxis );
204 return setAxisLabels_<TH2D>( hist, xAxis, yAxis );
211 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.