Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9295

[TDF] Variable sized bins are not respected by Histo actions

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • master, 6.12/08
    • 6.12/08, 6.13/02
    • Other
    • None
    • any

    Description

      Reproducer:

      #include <ROOT/TDataFrame.hxx>
      #include <TApplication.h>
      #include <TH1D.h>
      #include <random>
      #include <TCanvas.h>
      using namespace ROOT::Experimental;
       
      int main() {
        TApplication app("app", nullptr, nullptr);
        std::default_random_engine eng;
        auto rnd = [&eng]() { return eng() / double(eng.max()) * 10.; };
        double bins[] = {0., 1., 2., 10.};
        int nbins = 3;
       
        // with a TH1DModel, no datapoints are shown
        TDF::TH1DModel histmodel("histomodel", "histomodel", nbins, bins);
        TDataFrame(1000).Define("x", rnd).Histo1D<double>(histmodel, "x")->DrawClone();
       
        // with a TH1D, the binning is not the one specified
        TCanvas c;
        TH1D hist("histo", "histo", nbins, bins);
        TDataFrame(1000).Define("x", rnd).Histo1D<double>(hist, "x")->DrawClone();
       
        app.Run();
       
        return 0;
      }
      

      Attachments

        1. h1.png
          h1.png
          27 kB
        2. h2.png
          h2.png
          27 kB

        Activity

          People

            dpiparo Danilo Piparo
            eguiraud Enrico Guiraud
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Actual Start:
              Actual End: