11 #pragma warning(disable:4996)
24 #include "TProfile2D.h"
31 template <
typename R,
typename A>
32 bool setAxisLabels_( A* aida,
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;
132 for (
unsigned int i = 0;
i < xlabels.
size(); ++
i )
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;
165 for (
unsigned int i = 0;
i < xlabels.
size(); ++
i )
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 ) );
195 return setAxisLabels_<TH1D>( hist, xAxis, yAxis );
202 return setAxisLabels_<TProfile>( hist, xAxis, yAxis );
209 return setAxisLabels_<TH2D>( hist, xAxis, yAxis );
216 return setAxisLabels_<TProfile2D>( hist, xAxis, yAxis );