Alt$(primary,alternate)

Hi,
I find when I use tree->Draw(“muon_pt”), and tree->Draw(“Alt$(muon_pt, -1 )”), the plot is different. But I expected two plots should be the same since they are always equal :
root [91] Events->Scan(“muon_pt:Alt$(muon_pt, -1)”,“muon_pt!=Alt$(muon_pt, -1 )”)

Row Instance muon_pt Alt$(muon
==> 0 selected entries
(long long) 0

This syntax will actually “exclude” all the cases where muon_pt would trigger the Alt$ since the value (by definition) does not exist and thus by definition this will always reply 0 selection.

Now, it is also true that Draw("Alt$(name, value)") should be the same as Draw("name") since there no other variable/branch/column used that would extend the size of the internal array. So there is a problem here.

To narrow down the issue. Can you plot:
Draw("Length$( muon_pt )");
Draw("Length$( Alt$(muon_pt, -1) )");
Draw("Length$( muon_pt ) - Length$( Alt$(muon_pt, -1) ) ");

Hi , here they are. So the length of muon_pt is 2, but length of Alt$(muon_pt, -1) is only 1.
I also plot Draw(“Length$( muon_pt[0] )”); and Draw(“Length$( Alt$(muon_pt[0], -1) )”); to compare.
And they are 1.

Indeed, Alt$ seems broken in the absence of another array (probably because it was never tested in that case since it is sematically “useless” without another array to give the intended size to extent to).
Likely you will see what I mean if you try:

Scan("Alt$(muon_pt, -1) )")
vs
Scan("Alt$(muon_pt, -1) )","muon_pt");  // i.e. even using the same works.

to see Alt$ in action you need an array with a different dimension. Using the file Event.root generated by the test $ROOTSYS/test/Event, I see:

root [11] T->Scan("Alt$(fMeasures,-1):fMatrix")
***********************************************
*    Row   * Instance * Alt$(fMea *   fMatrix *
***********************************************
*        0 *        0 *         1 * 1.5405316 *
*        0 *        1 *         0 * 0.0947428 *
*        0 *        2 *         1 * 1.5246920 *
*        0 *        3 *         1 *         0 *
*        0 *        4 *         3 * -0.136309 *
*        0 *        5 *        16 * 0.8007842 *
*        0 *        6 *         4 * 1.7062356 *
*        0 *        7 *        22 *         0 *
*        0 *        8 *         8 * -1.160293 *
*        0 *        9 *         4 *  2.012362 *
*        0 *       10 *        -1 * 4.0220642 *
*        0 *       11 *        -1 *         0 *
*        0 *       12 *        -1 *         0 *
*        0 *       13 *        -1 *         0 *
*        0 *       14 *        -1 *         0 *
*        0 *       15 *        -1 *         0 *

(but “crazy” stuff if I omit the fMatrix)
Cheers,
Philippe.

Bug reported at https://github.com/root-project/root/issues/6378

Now, the more important question :). What lead you to try using Alt$ and is it working for that context or is there something else you should be using to accomplish your task?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.