Skip to content

Display does not respect parameters if another operation is booked before printing #11390

@vepadulano

Description

@vepadulano

Describe the bug

Apparently calling Display with some extra parameter like nRows is not respected if before calling Print one adds any other operation to the graph.

To Reproduce

#include <ROOT/RDataFrame.hxx>
#include <TString.h>
#include <string>
#include <vector>
#include <memory>
void write_tree()
{
    int x{};
    TString s{};

    TFile file{"dataset.root", "recreate"};
    TTree tree{"events", "events"};
    tree.Branch("nJets", &x, "nJets/I");
    tree.Branch("systName", &s);

    std::vector<std::string> values{"nominal", "up", "down"};

    for (int i = 0; i < 3; i++)
    {
        x = i + 1;
        s.Replace(0, s.Length(), values[i]);
        tree.Fill();
    }

    tree.Write();
}

void read_tree()
{
    TFile file{"dataset.root", "read"};
    std::unique_ptr<TTree> tree{file.Get<TTree>("events")};
    tree->Scan("*");
}

void analyze()
{
    ROOT::RDataFrame df{"events", "dataset.root"};

    // Book display
    auto disp = df.Display("systName", 1);

    // Do anything else
    df.Count().GetValue();

    // The display doesn't respect the original parameters
    // Prints all 3 rows whereas it should print only one
    disp->Print();
}

int main()
{
    write_tree();
    read_tree();
    analyze();
}

Setup

Additional context

Fedora 36
ROOT 6.26/06 from conda

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions