11 #pragma warning(disable:4996)
24 #include "TProfile2D.h"
31 template <
typename R,
typename A>
32 bool setAxisLabels_( A* aida,
33 const std::string& xAxis,
34 const std::string& yAxis )
36 if (!aida)
return false;
38 if (!root)
return false;
39 root->SetXTitle(xAxis.c_str());
40 root->SetYTitle(yAxis.c_str());
46 bool setBinLabels_( TAxis* axis,
49 if (!axis)
return false;
50 const unsigned nbins = axis->GetNbins();
51 for ( Gaudi::Utils::Histos::BinLabels::const_iterator
i = labels.begin();
52 i != labels.end(); ++
i )
54 if ( 1+
i->first <= 0 || 1+
i->first > nbins )
return false;
56 axis -> SetBinLabel( 1 +
i->first,
i->second.c_str() );
63 template <
typename R,
typename A>
64 bool setBinLabels_( A* aida,
67 if (!aida)
return false;
69 if (!root)
return false;
70 return setBinLabels_( root->GetXaxis(), labels );
73 template <
typename Histogram>
74 bool setBinLabels_( Histogram* hist,
78 l.reserve(labels.size());
79 for (
unsigned i = 0;
i<labels.size(); ++
i )
102 return setBinLabels_<TH1D>(hist,labels);
108 return setBinLabels_<TProfile>(hist,labels);
114 return setBinLabels_(hist,labels);
120 return setBinLabels_(hist,labels);
127 if (!hist)
return false;
129 if (!h2d)
return false;
131 lx.reserve(xlabels.size());
132 for (
unsigned int i = 0;
i < xlabels.size(); ++
i )
137 ly.reserve(ylabels.size());
138 for (
unsigned int i = 0;
i < ylabels.size(); ++
i )
142 return ( setBinLabels_( h2d->GetXaxis(), lx ) &&
143 setBinLabels_( h2d->GetYaxis(), ly ) );
152 setBinLabels_( h2d->GetXaxis(), xlabels ) &&
153 setBinLabels_( h2d->GetYaxis(), ylabels ) );
160 if (!hist)
return false;
162 if (!h2d)
return false;
164 lx.reserve(xlabels.size());
165 for (
unsigned int i = 0;
i < xlabels.size(); ++
i )
170 ly.reserve(ylabels.size());
171 for (
unsigned int i = 0;
i < ylabels.size(); ++
i )
175 return ( setBinLabels_( h2d->GetXaxis(), lx ) &&
176 setBinLabels_( h2d->GetYaxis(), ly ) );
185 setBinLabels_( h2d->GetXaxis(), xlabels ) &&
186 setBinLabels_( h2d->GetYaxis(), ylabels ) );
192 const std::string & xAxis,
193 const std::string & yAxis )
195 return setAxisLabels_<TH1D>( hist, xAxis, yAxis );
199 const std::string & xAxis,
200 const std::string & yAxis )
202 return setAxisLabels_<TProfile>( hist, xAxis, yAxis );
206 const std::string & xAxis,
207 const std::string & yAxis )
209 return setAxisLabels_<TH2D>( hist, xAxis, yAxis );
213 const std::string & xAxis,
214 const std::string & yAxis )
216 return setAxisLabels_<TProfile2D>( hist, xAxis, yAxis );
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.
std::pair< unsigned, std::string > BinLabel
Typedef for a bin number and its associated label.
This is a number of static methods for bootstrapping the Gaudi framework.