Fill table of histograms with multiple variables in a loop


I am trying to fill multiple histograms from a tree at once. I have a file which I specified the desired histograms in terms the histogram’s name, x-variable, y-variable, and corresponding binnings. I read the file to a string and then to an TObjArray filled with TStrings for each histogram entry:

TObjArray *histsToUse = locationOfFile.Tokenize("\n");

Each TString in the array is a string containing: histogramName, dimension (1D VS 2D), x-var, y-var, and the corresponding binnings Declaration of the histograms works alright using a table of TH2F’s as in this post. But when I want to fill them It gets troublesome.

Looping over the amount of elements in my TObjArray I want to:

Fill(tableofHists[histogramIterator], xvar, yvar, weigth);

where these x-var and y-vars are the corresponding parts of the TString of the accompanying histogram tableofHists[histogramIterator]. In my code xvar, y-var are already declared and taken from my tree using GetEntry().
However my x-var and y-var in the TStrings, are clearly not variables names the compiler will understand them. So I cant simply pass them to my Fill function as strings.

I have the feeling that a TString object is not the right way to go. Does someone maybe have a way to convert these variable names in the file to the corresponding variables in the tree, so that I can pass the desired variables to fill the histograms in a loop? A more elegant method to do such a thing is also welcome.

I hope you can help me.

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