RooDataSet::reduce produces no entries incorrectly

Dear rooters,

The attached root file contains a RooDataSet with 100 entries. If I try to use the reduce method to produce a smaller RooDataSet, it returns an empty one incorrectly. The printout below shows that there are thetaL values greater than 1.5, but my dataset still has zero entries. If I instead call the underlying tree and Draw the same cut, I get a correct histogram. I’m guessing there is some Root magic missing when I create these files, but I’ve no idea what that is. I’m using root 5.22.00, but I’ve also tried 5.18.00.

Thanks,

Will

root [2] durhamData->Print(“V”);
Dataset durham (durham)
Contains 100 entries
Observables: RooArgSet::Dataset Variables: (Owning contents)
1) thetaL = 1.4557 C L(0 - 3.14159) “#theta_{l}”

root [3] durhamData->Scan(“thetaL”);


  • Row * thetaL *

  •    0 * 1.7318720 *
    
  •    1 * 1.7737401 *
    
  •    2 * 0.7109605 *
    

root [5] durhamData->reduce(“thetaL > 1.5”)->Print(“V”);
Dataset durham (durham)
Contains 0 entries
Observables: RooArgSet::Dataset Variables: (Owning contents)
1) thetaL = 1.8213 C L(0 - 3.14159) “#theta_{l}”

root [6] durhamData->tree().Draw(“thetaL”,“thetaL > 1.5”);
mc_data_mb_signal.root (21.9 KB)

Hi Will,

I looked at your dataset. The problem is in your pT observables.
Here the allowed ranges of your observables is [0,20] but you
have values like 800 stored in them, when make them ‘invalid’ entries.
root [4] durhamData->reduce(“thetaL > 1.5”)->Print(“V”);
Dataset durham (durham)
Contains 0 entries
Observables: RooArgSet::Dataset Variables: (Owning contents)
1) thetaL = 1.8213 C L(0 - 3.14159) "#theta
{l}"
2) thetaK = 2.35528 C L(0 - 3.14159) “#theta_{K}”
3) phi = 2.56709 C L(-3.14159 - 3.14159) “#phi
4) qsquare = 11.5948 C L(0 - 20) “q^{2}”
5) index = 98 C L(0 - 4.29497e+09) “index”
6) pi_pT = 849.33 C L(0 - 20) “p_{T} (#pi)”
7) K_pT = 316.819 C L(0 - 20) “p_{T} (K)”
8) muplus_pT = 1088.32 C L(0 - 20) “p_{T} (#mu+)”
9) muminus_pT = 1803.89 C L(0 - 20) “p_{T} (#mu-)”
10) B_pT = 402.705 C L(0 - 20) “p_{T} (B)”
11) kStar_pT = 1161.36 C L(0 - 20) "p_{T} (K
)"
12) MM_pT = 761.578 C L(0 - 20) “p_{T} (K*)”
13) mB = 5279.53 C L(0 - 20) “mB”
14) mK = 888.197 C L(0 - 20) “mK”
15) cat = signal “cat”
16) BID = Bbar “BID”
17) mMM = 3405.12 C L(0 - 20) “mMM”

When a reduce() operation is applied only entries where all observables
have valid values are kept, which in your case are none…

If you were to make a reduced dataset with e.g. theta only you see
that it works fine

root [10] durhamData->reduce(SelectVars(*thetaL),Cut(“thetaL > 1.5”))->Print(“V”);
Dataset durham (durham)
Contains 62 entries
Observables: RooArgSet::Dataset Variables: (Owning contents)
1) thetaL = 1.8213 C L(0 - 3.14159) “#theta_{l}”

How did you make this dataset BTW? Normally all invalid entries are stripped
in any data import operation (from TTree or file), so my guess is that you changed
the range of observables after the dataset was created. Is that right?

Wouter

1 Like

Hi Wouter,

Thanks very much for taking a look at this. I’d been staring at it for a day and still had no idea what was going on. I’d completely ground to a halt on my analysis as a result!

So I was creating a RooArgSet with the limits set:

RooRealVar _qsquare(“qsquare”,“q^{2}”,0,20);
RooRealVar pi_pT(“pi_pT”,"p{T} (#pi)",0,20);
RooArgSet vars(_qsquare,_pi_pT,“vars”);

I then created a RooDataSet with this:

RooDataSet* ds = new RooDataSet(title,title,args);

which I then filled in a loop. When I filled it, the RooRealVars I used did not have the limits set.

for(Int_t i = 0; i < size; i++){
//calculate qsquare etc
RooRealVar _qsquare(“qsquare”,“q^{2}”,qsquare);
//here I forgot to convert from MeV to GeV
RooRealVar pi_pT(“pi_pT”,"p{T} (#pi)",pi.Pt());

RooArgSet vars(_qsquare,_pi_pT,"vars");
ds->add(vars);

}
ds->Write(“data”);

So I can see how it happened (and indeed it now works). I guess your question is whether this use should produce a warning or something. Problems like this are really hard to find, but I guess you’re worried about performance. Perhaps a check could be added in reduce?

Anyway, thanks again for the help. Its really appreciated.

Cheers!
Will

Hi Will,

The underlying filling code does issue a warning, but that seems to be suppressed by the message service by default. I will upgrade that message from INFO to WARNING level so that will be shown.

Wouter

Hi Wouter,

That sounds ideal. Thanks again for help.

Cheers!
Will