Problem in using Max$() with TTree::Draw()?

Hello all,

I wrote the following macro,

iterativeBayesTestThermal.C (8.7 KB)

but repeatedly got error output such as

Error in TTreeFormula::Compile: Bad numerical expression : “(0.00837315/*StokesHybridPlusCDF.WAISHPol),(0.31277/*StokesHybridPlusCDF.WAISVPol),(0.107212/*StokesHybridPlusCDF.HiCal2A),(0.105385/*StokesHybridPlusCDF.HiCal2B),(1/*StokesHybridPlusCDF.iceMC)”

As far as I can tell, this has to do with line 115 in the macro. I think it may have to do with how the Max$() function behaves within TTree::Draw(). It seems like Max$() gets confused when arguments within it aren’t simple statements of variables within a TTree? Here I’m attempting to multiply such variables by constants.

But perhaps line 115 just needs to be modified. Any suggestions?


Please read tips for efficient and successful posting and posting code

_ROOT Version:6.23/01
_Platform:_linux x86 64
_Compiler:_gcc


You might have misunderstood the semantic of Max$, it actually takes a single argument that is expected to be a name or expression including names that refer to a collection within the TTree and Max$ will return the maximum value of the expression when iterating over the element of the collection(s) for a given entry.

Hi @pcanal,

Thank you for your response. I now think you are right about the semantic of Max$(). When I used a cut such as on line 84 in the macro, I was under the false impression that the maximum among a list of variables enclosed in Max$() would be selected. However, your comment led me rearrange the variables inside of line 84 and found I got different results after using it in the function TTree::GetEntries().

So then is there a way to set a cut like line 84 in TTree:GetEntries()? I have also tried using something like

TTree::GetEntries("TMath::MaxElement(3, {var0, var1, var2}) > TMath::MaxElement(3, {var3, var4, var5})")

but that didn’t seem to work. Outside of nesting instances of TMath::Max(), is there a function that can be used to get the desired behavior that I want? Maybe I am missing something in the call to TMath::MaxElement() above?

Hi again @pcanal,

So combining what I learned here with what I then found searching around (https://root-forum.cern.ch/t/ttree-draw-and-functions/879/6), I was finally able to revise the macro to do what I wanted it to do.

iterativeBayesTestThermal.C (10.0 KB)

Has there been any changes to the behavior of TTree::Draw() since the message thread in the link above?

Great! :slight_smile:

There has been no upgrade to TTree::Draw itself since that post … However we also released RDataFrame as a successor to TTree::Draw which support more C++ construct and allow for run the queries using multiple cores.

1 Like