TH2 Drawing


So I have code like this that works great:

The thing is, now I want it to be a 2D plot, in which the y-component is the corresponding avgM (1:1 correlation with deltaM).

The only way I could think of to do it is this, is there a cleaner way to do it?


Usually you can define an alias for a formula which becomes very useful if you need to use it multiple times, a la

tree->SetAlias("m", "Min$(jet_pt > 10 ? deltaM : 1000000)"); // BROKEN

However this doesn’t seem to work with this special tree function, and I get the equivalent of

Error in <TTreeFormula::DefinedVariable>: The substitution of the alias "m" by "Min$(x)" failed.

and no entries. (I also couldn’t find out how to do SetBranchAddress with that alias expression)

Thanks for reply. I was able to get a little closer with this:

tree->Scan(“Min$((jets_p4.Pt() > 20 ? abs(deltaM[Iteration$]) : 1000000)):avgM[Iteration$]:Iteration$”)

Problem is, Iteration$ seems to reset every time; it doesn’t store the value (this is clear because the last column is always 0). Is there a way to do what I’m trying to do?


Scan and Draw handle a series of formula differently. Scan will treat each formula independently and this the last two column in your example will only have effectively one element per entry with Iteration$ == 0.
Draw on the other hand does correlate the formula and “Array[Iteration$]:Iteration$” for each even will plot ‘Array[0]:0’ and ‘Array[1]:1’ etc…