RDF progress bar used together with formatted output streams

ROOT Version: 6.30.04
Platform: Various
Compiler: Various

Dear ROOT community,

I have been enjoying a lot the new feature from the latest ROOT version, ROOT::RDF::Experimental::AddProgressBar. Thanks a lot for adding it! As it is also still experimental, I understand there may be some unexpected behaviour, so I wanted to ask here whether I was missing a configuration or this was indeed unexpected.

For some output, I format the stream to be left- or right-aligned, usually filling the “empty” area with whitespaces (default). However, when I use the progress bar, it seems the default format is changed and not reset after the event loop has been fully processed, leading to the previously empty area being filled with zeros. This is what the output would more or less look like:

Without progress bar:

Col1 | Col2 | Col3
   0 |    1 |    3
   3 |   10 |   15

If I activate the progress bar:

Col1 | Col2 | Col3
0000 |00001 |00003
0003 |00010 |00015

For now, I simply fix the issue resetting the formatting myself (following the solution provided on Stack Overflow here), but I was wondering, is there a ROOT-native way to control this? Thanks a lot in advance.

Hi @eska,
I’m sure @mczurylo can help you with this!



Hi @eska!

Nice to hear you’ve been using the ProgressBar. As you said - the feature is still experimental and we are very happy to hear our users feedback, thanks! This functionality hasn’t been considered yet but I will take a look into making a fix upstream.


Perfect, thanks a lot!

Hi @eska,

I opened a bug report on github: [DF] ProgressBar destroys formatted output streams · Issue #14611 · root-project/root · GitHub.


1 Like

Dear @eska ,

Thanks for reporting! Could I ask you to also to give us a small code reproducer of what you are trying to do, so we can kickstart the debugging faster?

Thanks a lot!

Hi @vpadulan , @mczurylo ,

Sure! Please find below an example:

void print_info(){
    ROOT::RDataFrame df(100);  
    //populate dataframe
    auto df_1 = df
            .Define("x", [](){return gRandom->Gaus(0,4);})
            .Define("y", [](){return gRandom->Gaus(10,2);});
    auto f1 = df_1.Filter("x>0");
    auto f2 =   f1.Filter("y>10");
    std::vector<ROOT::RDF::RResultPtr<ULong64_t>> n_pass;
    std::vector<ROOT::RDF::RResultPtr<double>> mean_pass;

    int Ntot = *n_pass[0]; // trigger event loop

    std::cout << std::right << std::setw(2) << " # |     N |    mean x\n";
    for(int i = 0; i<n_pass.size(); i++){
        std::cout << std::right << std::setw(2) << i << " | " << std::right << std::setw(5) << *n_pass[i] << " | " << std::right << std::setw(9) << *mean_pass[i] << std::endl;

Without AddProgressBar, the output is e.g.:

 # |     N |    mean x
 0 |   100 |  0.246279
 1 |    51 |   3.12609
 2 |    19 |   3.04681

With AddProgressBar, it is e.g.:

[Total elapsed time: 0:00m  processed files: 0 / 0  processed evts: 874 / 874]                                                                                                                            
 # |     N |    mean x
00 | 00100 | 04.85e-01
01 | 00054 | 03.13e+00
02 | 00027 | 03.29e+00

We see here how both the leading character and floating point value representation change.

Please let me know if this works for you!

1 Like

Hi @eska,

It should now be fixed in the ROOT master and it will be included in the next ROOT release.


Thanks a lot! Looking forward to it.