Reading TMethodBrowsable containing ROOT::Math::LorentzVector

Hi,

I’ve been looking at this ROOT file which contains TMethodBrowsables (indicated by a leaf with an exclamation mark in TBrowser). The variable is denoted as ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D >.

Here is the “inspect” window explaining the type of variable I’m dealing with,

I recognise that I may be dealing with a method here, which I can use on a variable “PtEtaPhiM4D” but I’d like to know how to implement that and use that to perform operations on these variables. Does anyone have an idea on how to implement this?

EDIT: This is the output I get from printing the variable,

Hi Utsav,
I am not sure what you are asking: Px() is a method of LorentzVector, and of course it is already implemented.

Can you maybe elaborate a bit more on what you want to achieve and what the obstacle is?

Cheers,
Enrico

Hi Enrico,

What I want to do is merge Px() data from several similar ROOT Files. So I have the Tree structure as being

and the variable p4Polar_ contains the class “ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D >”.

I think what I want to do is use the TMethod “Px()” on the “p4Polar_” variable and save this to another variable for further calculations and analysis.

I don’t know the formal way of converting TMethods and TClass variables to my desired class even though it’s part of the definition.

Below is a screen grab of what I mean for “p4Polar_”

Thanks for your help,

Utsav

Hi,

if by similar you mean identical, what you are trying to achieve is a skim of the CMS data in another dataset containing a single column called px. Is this correct?

Cheers,
D

Hi,

Yes, this is what I would like to do.

Thanks,

Utsav

Hi,

did you have a look to the TDataFrame class and tutorials?

Note that you’ll perhaps have to turn some knobs since you are starting from a CMS dataset. You might also want to seek for help on CMS fora about this issue…

Cheers,
D

Hi there,

I’ve been working on this endlessly since your comment and I can’t seem to make it work. I think I’ll reiterate my concerns since after reading my previous posts, it seems very vague and maybe that helps you help me.

What I’d like to do is take the “TNonSplitBrowsable” named p4Polar_ and plot the result after performing the Px() method on it. I know that from reading the LorentzVector documentation that I should get integers out from individual “ROOT::Math::LorentzVector” vectors after passing the Px() method which can be used to fill a histogram/perform calculations. The problem I have is that I can’t actually get the vector in a tangible form whereby I can pass methods like “GetValue(i)” or “GetEntry(i)” in order to isolate individual vectors from the TNonSplitBrowsable.

Thanks,

Utsav

Hi,
as far as I understand, you have a tree with a p4Polar_ branch, and you want to extract a vector of the results of calling Px() on that branch for each entry. With TDataFrame (linked by dpiparo above) you do this like this:

#include "ROOT/TDataFrame.hxx"
using namespace ROOT::Experimental;

int main() {
  TDataFrame df("treename", "filename.root");
  auto allPx = df.Define("px", "p4Polar_.Px()")
                         .Take<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D>::Scalar>("px");
  return 0;
}

where ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D>::Scalar should be the type returned by the Px method, but I might have spelled it wrong.

A histogram of all Px is obtained like this:

#include "ROOT/TDataFrame.hxx"
using namespace ROOT::Experimental;

int main() {
  TDataFrame df("treename", "filename.root");
  auto h = df.Define("px", "p4Polar_.Px()").Histo1D("px");
  return 0;
}

You will need ROOT v6.10 or later to try this. Let me know if this helps.

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