Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ConversionUtils.cxx
Go to the documentation of this file.
1/// \file
2/// \warning This is part of the %ROOT 7 prototype! It will change without notice. It might trigger earthquakes.
3/// Feedback is welcome!
4
10
11#include <TAxis.h>
12
13namespace ROOT {
14namespace Experimental {
15namespace Hist {
16namespace Internal {
17
18void ConvertAxis(TAxis &dst, const RAxisVariant &src)
19{
20 if (auto *regular = src.GetRegularAxis()) {
21 dst.Set(regular->GetNNormalBins(), regular->GetLow(), regular->GetHigh());
22 } else if (auto *variable = src.GetVariableBinAxis()) {
23 dst.Set(variable->GetNNormalBins(), variable->GetBinEdges().data());
24 } else if (auto *categorical = src.GetCategoricalAxis()) {
25 const auto &categories = categorical->GetCategories();
26 dst.Set(categories.size(), 0, categories.size());
27
28 for (std::size_t i = 0; i < categories.size(); i++) {
29 dst.SetBinLabel(i + 1, categories[i].c_str());
30 }
31 } else {
32 throw std::logic_error("unimplemented axis type in ConvertAxis"); // GCOVR_EXCL_LINE
33 }
34}
35
36} // namespace Internal
37} // namespace Hist
38} // namespace Experimental
39} // namespace ROOT
A variant of all supported axis types.
const RRegularAxis * GetRegularAxis() const
const RVariableBinAxis * GetVariableBinAxis() const
const RCategoricalAxis * GetCategoricalAxis() const
Class to manage histogram axis.
Definition TAxis.h:32
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition TAxis.cxx:891
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Definition TAxis.cxx:790
void ConvertAxis(TAxis &dst, const RAxisVariant &src)
Convert a single axis object to TAxis.
Namespace for ROOT features in testing.
Definition TROOT.h:100