TColor name as string

Hi,

I have been developing a plotting tool that help to make plots a little more automatic and I would like to be able to pass as arguments for each histogram creator some parameters as the color, size and so on. I would like to be able to pass something like “kBlue” and that it would understand that is referred to the kBlue member of TColor.

I have found this thread: [root.cern.ch/phpBB3/viewtopic.p … ing#p56175](How to pass a TString as a TColor?

but it is a little bit old. Has it been any development in this? It suggest to use gROOT but I am not using the interpreter and I am not sure if I can use that when compiling the code.

Thanks a lot in advance,
Juanpe.

What do you mean by “pass” ? … is it parameter passing to some method of you histogram creator ? can you explain a bit more ?

Yes, it is a parameter. Basically I configure the entire tool via xml and in this way you can set different formatting for all kind of histograms and group different samples (copies of the same histogram corresponding to different inputs) and associated properties of each sample. Each sample will later be able to produce the given histogram and I would like to associate some attributes as color, linewith, fillstyle etc. to each sample. One attribute can be the color as I said and I was asking is there is a way of translating the readable names like kBlack into strings (in the same style) so it can be easily supplied when dfining the style.

kBlack is an integer and the usual way to go to string is to use TString::Format()…
Still I am not completely sure I fully understand where is the problem…

I would like to be able to pass as an argument something like “kBlack” (which can be written in an xml) and since kBlack is an integer it cannot be written like that since when parsing the configuration xml I will read kBlack as a string. As a simple example, this is what I am trying to accomplish:

XML file:

code:

The question is, do I need to translate the strings myslef or is it a way in which “kBlack”, as a string, can be understand as “kBlack” (or similar) to designate the integer kBlack.

Thanks.

I see. Having the integer value you want to find the name