Function call within TChain drawing

Hello,

I would like to know whether it’s possible to call a local function that uses one variable from a tree as input when using Draw in a TChain. As a simple example, this is what I would like to do:

TChain *chan = new TChain(“AnalysisTree”);
chan->Add(“myFile.root”);

Within the ‘AnalysisTree’ I have a variable called ‘RunNumber’. And I would like to draw a different variable, but assigning each entry a weight according to its ‘RunNumber’. I.e.:
chan->Draw(“pt”, “myFunction(RunNumber)*(cut1&&cut2)”);
where myFunction can be defined as:
float myFunction(int run)
{
if (run >202020) return 1.0;
else return 2.0;
}

Is this possible at all? If so, could you provide an example? (or the correct sintax)?

Many thanks for your feedback.
Arely

Hi all,

I found this old thread:

so my question was answered :slight_smile:

-Arely