Using OR condition in TRestAnalysisPlot config.rml

REST version : v2.2.15
REST commit : 7dbff942

I am trying to make some plots with a cut that removes a middle range of the values of an observable, e.g., <globalCut variable="obs1" condition="<100||>300" value="ON"/>. I’ve tried several different options in the plot.rml config I’m using but I cannot find a way to do this, I always get the same error:

Plot string not properly constructed. Does the analysis observable exist inside the file?

The observable does exist. I’ve tried with a simple cut (e.g. <300) and it works.

Is this kind of cut possible to do? And if it is, what would be the right syntax in the .rml?

Hi Cristina,

it is actually not possible to do what you mention.

The reason behind is that <globalCut was only thought to work with && operator. And TRestAnalysisPlot will build the cut string given as argument to TTree->Draw method using the values from <globalCut observables + condition fields.

See for example section 14.20 from Chapter: Trees

In other words, internally, what TRestAnalysisPlots does is to build a cut string given to the Draw method. And the string is built as follows:

If the RML definitions are …

<globalCut variable="obs1" condition="<X1" value="ON"/>
<globalCut variable="obs2" condition="==X2" value="ON"/>
<globalCut variable="obs3" condition=">X3" value="ON"/>

… it will produce the following cut string passed to the ROOT TTree->Draw method.

obs1<X1 && obs2==X2 && obs3>X3

I have added a new piece of code to TRestAnalysisPlot so that we can build an additional arbitrary cutString being passed to the Draw method.

See changes in commit:

It will add a new <globalCutString line option to TRestAnalysisPlot where we can define a conditional string that will be added to the Draw method cut string.

The above RML code could become now.

<globalCut variable="obs1" condition="<X1" value="ON"/>
<globalCutString string="obs2==X2||obs3>X3" value="ON"/>

That would lead to the following cut string given to the Draw method.

obs1<X1 && (obs2==X2 || obs3>X3)

I do not have the time to test it, but I believe that will do the job. Let me know if that does.

I added a similar sentence construction for local cuts <cutString string="user_cut_string_condition"/>

Thanks Javier.
I moved to the latest commit 4b8a5176 but it doesn’t work. I can run restManager and I get no error now, but the ouput plot does not have the cut with the OR condition. I’ve saved the plot as a root.C macro and I’ve checked that the string is not there. It is as it was being ignored…

Please, set the section TRestAnalysisPlot to verboseLevel="debug" and attach the output as a txt. Attach also the RML file you are using to generate the output.

The debug output is debugOutput.txt (12.3 KB)

And the rml file muonPeakTime.rml (2.7 KB)

I found a small bug in code, perhaps that solves the problem?

Yes, it works. Thanks a lot :grinning: