Applying a function to a TTree branch

Dear rooters,

I’m trying to apply a custom function to data in a TTree, and I was wondering if there’s any way to do something like this that will work:

  TTree * tree = (TTree*) file->Get("Events");
  TF1 func("func",MyCustumFunction,0,100,0);
  tree->Draw("func(x1,x2,x2,x3) >> htemp(100,0,100)");

Thanks!

Marcos

Simply (assuming that MyCustumFunction is either interpreted or has a dictionary:ree->Draw("MyCustumFunction(x1,x2,x2,x3) >> htemp(100,0,100)");(and of course MyCustumFunction must be taking 4 numerical value as arguments).

Cheers,
Philippe.

Hi Philippe,

Thanks for your quick reply. I see, I thought that I had to call a TF1 by its name, but now I can bypass it. I got it to work now.

Best,

Marcos

PS: Sorry for the “Custum” typo :slight_smile: