\ell symbol in TH1 axis

Dear experts!

I spent some time googling my question but merely found answers related to ROOT vX with X<6 or answers that were not really related to my question. Apologies in case I still missed if this discussion has been answered some place else (given that it is quite obvious). For completeness: I am using ROOT v6.08.

I would like to ask if it was possible to use the LaTeX symbol \ell in a TH1 axis title or label.

For ROOTv5 a colleague of mine has found a way to use the symbol in a TMathText environment (though italic I found it to be displayed in an unusually strong inclination), but of course not for the axis, but only for a text element in the plot.

As I understood from [1] and past posts in this forum, TLatex (and therefore the TH1 axes) implement a subset of the math symbols available in LaTeX but I frankly do not see the logic in the selection of this subset. E.g. \ell is a quite common symbol for leptons and it would be well appreciated if this could be used in the axis titles. Also, I do see that \slash (as in ETmiss, which is barely used as people have moved to pTmiss) is implemented but \mathcal isn’t, which would be good for, e.g., branching fraction symbols.

Bottomline my question is: is \ell still not implemented in ROOTv6 and if yes will it be implemented in one of the upcoming versions? Alternatively, I’d like to ask if there is a way fo emulate the symbol \ell? I’ve played around with TTF, but haven’t been successful (yet). Obviously, I’d like to avoid (for now) painting a TMathText with solid fill color over the axis title.

Thank you and regards!
heico

[1] - https://root.cern.ch/doc/master/classTLatex.html

h.SetXTitle(“m_{\ell\ell}”)

works fine for me with ROOT 6.10/06, what version are you using?

you need to escape the “\”

The right syntax is:

h.SetXTitle("m_{\\ell\\ell}")

See this example .

Hi all.

Thank you for your answers.

The solution by couet works if I open ROOT directly and build a histogram there.
But if I want to use \ell in pyROOT it does not seem to work. I.e. my syntax is

h.GetXaxis().SetTitle("M_{\\ell\\ell}")

This merely results in #ell#ell (as subscript to M) being written in the axis.

I am using ROOT v6.08 and python 2.7.10.

Thanks!
heico

I am not an expert of python … but the idea is simply to find the way to escape the backslash … or may be in python escaping is not needed ? …

It is needed, so in a python string you’d put \ to have one .
For a short period of time I thought \ was required by ROOT and therefore I put \\, which results in ##ell.

Hm, maybe its just the wrong data type after all and it needs some more C++ conform type…

The double backslash is required by C++ not by ROOT. See the example I pointed.

Yeah right, that’s why I put \\ for python too.

OK I now tried in python prompt and there it works.
Must be a problem of my script then.

Thanks!
heico

python is very relaxed regarding escaping, it seems, so it accepts \e as such and doesn’t raise an error. But yeah, I forgot the escaping in my post. Note that you can use “raw strings” in python, which don’t do backslash escaping, to make it a bit more readable (note the r in front of the string):

h.GetXaxis().SetTitle(r"M_{\ell\ell}")

Sorry for my earlier confusion.

The problem is a different one: \\ell works perfectly fine also in my script.
The problem occurs when exporting to pdf. In png and eps I can see the ell properly
but the pdf places an #ell rather than the ell symbol.

Is this expected and if yes, how can I overcome it?

Thank you!
heico

Yes it is expected. TMathText specific characters like ell are not implemented in pdf.

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