Branch addresses for TLorentzVector

I can’t get the data out of a ROOT tree made by DELPHES because it is in a TLorentzVector, and I can’t figure out how to do the Branch addressing. Help!

I can access it no problem via the browser

root[2] Delphes->Draw(“FatJet.TrimmedP4[0][0].M()”)

But the code below always returns zeros. What’s the magic incantation?


========================== My file is here:


============================= ROOT version
$ which root

=========================== short code snippet

#include “TTree.h”
#include “TFile.h”
#include “TLorentzVector.h”

void readtlv()
TFile *f = new TFile(“delphes_events.root”);
TTree t = (TTree)f->Get(“Delphes”);
Long64_t nentries = t->GetEntries();

TLorentzVector FatJet_TrimmedP4[5][15];
TBranch *b_FatJet_TrimmedP4; //!
t->SetBranchAddress(“FatJet.TrimmedP4[5]”, FatJet_TrimmedP4, &b_FatJet_TrimmedP4);

Int_t FatJet_size;
TBranch *b_FatJet_size; //!
t->SetBranchAddress(“FatJet_size”, &FatJet_size, &b_FatJet_size);

for (Long64_t i=0;i<2;i++)
for (int j=0;j<FatJet_size;j++)
std::cout << " event " << i << " jet " << j << " pt = " << FatJet_TrimmedP4[0][j].Pt() << std::endl;


1 Like

Just for the record: this is really awkward to extract without dictionary.

Daniel decided to change the Delphes output file; that will likely be our recommendation to the Delphes authors, too. I will contact one of them once he arrives at CERN.