Problem in entring function in argument

I wrote a macro CompareAdvanced.C (attached) which draws histogram. I am calling it through a macro written in Plot.C.

The function that I am calling is
compareQuantities(“genMuonPhi”,"",10,-4,4,"",6,“pp_WWJJ_phantom.root”);

I need to replace “genMuonPhi” with a function (of branches). Where genMuonPhi is the branch of tree and this is going into histo->Draw().

So, My problem is how can I call Draw a function (of branches) using the Draw()?
Plot.C (1.2 KB)

The first parameter of your “compareQuantities” is just a “std::string”, so you can put any function of leaves there, e.g. “SomeLeaf1 + SomeLeaf2”, or “SomeLeaf1 * SomeLeaf2”, … see the TTree::Draw for some “varexp” examples.

It means I could not put the first argument of Draw() with a function deltaPhi. where deltaPhi is

double deltaPhi(double phi1, double phi2)
{
double deltaphi = fabs(phi1-phi2);
if (deltaphi > TMath::PI ) deltaphi = 2 * TMath::PI - deltaphi;
if (deltaphi > 2 * TMath::PI ) cout<< "Delta Phi = "<<deltaphi<<endl;
return deltaphi;
};

where phi1 and phi2 are branches of tree.

for example like :
tree->Draw(“deltaPhi>>histo”);

If the TFormula is not sufficient for you then search for “MakeProxy” in the TTree::Draw method description.

Sorry Coyote. I tried but didn’t get how to use MakeProxy. Please let me know how can I use it. Thanks.