TLorentzVector in TTree::Draw()

Hi !
I would like to use a function using TLorentzVector parameters called, as following:
GetXbjorken(const TLorentzVector&, const TLorentzVector&)
in order to draw a more complex variable.

I see this is working while calling functions with simple variables. But this is not working with more complex objects. Is it a limitation from TTreeFormula and I should then loop manually ?

Thank you !


if you’d like to achieve something (also significantly) more complex than what TTree::Draw allows to do, you could try RDataFrame: here you can find some examples, including a relatively sophisticated analysis re-discovering the Higgs boson with CMS Open Data.



For a more simple example how to create new columns (==variables) in a dataframe using TLorentzVector, you can have as well a look at the tutorial creating a dimuon spectrum from muon candidates.


Edit: Let me paste a snipplet here:

// Create dataframe of dataset tree in ROOT file data.root
ROOT::RDataFrame df("tree", "data.root");

// Compute invariant mass of the dimuon system
auto compute_mass = [](const RVec<float> &pt, const RVec<float> &eta, const RVec<float> &phi, const RVec<float> &mass) {
   // Compose four-vectors of both muons
   TLorentzVector p1, p2;
   p1.SetPtEtaPhiM(pt[0], eta[0], phi[0], mass[0]);
   p2.SetPtEtaPhiM(pt[1], eta[1], phi[1], mass[1]);
   // Add four-vectors to build dimuon system and return the invariant mass
   return (p1 + p2).M();
auto df_mass = df.Define("Dimuon_mass", compute_mass, {"Muon_pt", "Muon_eta", "Muon_phi", "Muon_mass"});

// Plot the invariant mass
auto h = df_mass.Histo1D("Dimuon_mass");

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