DeltaPhi?

Hi,

I just disovered another awesome feature of my favorite function TTree::Draw(), namely that it can interpret calls to TMath functions!

I can’t find any TMath::DeltaPhi(phi1,phi2) TMath::DeltaR(…) functions though, which would be very useful to me in this context. Maybe these functions exist some place else though such that they can be interpreted as part of a TTree::Draw() selection?

Thanks,
Philipp

Hi Philipp,

Note that TTree::Draw can not only interpret calls to TMath function but it can also interprets calls to any free standing functions taking and returning numerical arguments. I.e. adding this functionality in your case is as simple as loading (via ACLiC for performance :slight_smile:) this script:

// Script MyMath.C namespace MyMath { double DeltaPhi(double phi1, double phi2) { .... return ...; } }and after root [] .L MyMath.C+you can call ‘MyMath::DeltaPhi(phi1,phi2)’ from TTree::Draw.

Cheers,
Philippe.

Awesome, I had no idea, thank you for the tip! :slight_smile:

Cheers, Philipp

Hi Philippe,

I am actually using compiled code (not macros), are there any restrictions / pitfalls there? My first attempt has failed …

Thanks,
Philipp

To be more precise: why does the attached DeltaPhi.C work, but deltaphi_x.cc (made with Makefile) does not?

Thanks, Philipp
DeltaPhi.tar.gz (958 Bytes)

Hi Philipp,

You are missing the dictionary for your namespace (and functions).

Cheers,
Philippe.

Got it, solution attached for reference (and in case you find something not optimal with it;)

Cheers,
Philipp
DeltaPhi.tar.gz (1.21 KB)

Hi,

just to let you know that the GenVector package provides the template functions DeltaPhi(v1,v2) and DeltaR(v1,v2) valid for any vector classes implementing Phi() and Eta()

See project-mathlibs.web.cern.ch/pro … rUtil.html

Best Regards

Lorenzo