Beginner in ROOT - How to output all of a Branch's values for a single event

Hello all,

I’ve been using pyROOT for quite some time, however I am now looking into display some of my data using EVE event display so the time has come for me to dive into C. I’m definitely a beginner so sorry if this is an easy question!

I have a Tree with 50,000 events that has the branches p_px, p_py, p_pz, and p_E, with 6 particles per event. I am able to access the individual branches, however I am having a lot of trouble accessing the branch’s individual data points found in each event. I’ve been running myself in circles trying different methods, but so far I haven’'t been able to make anything work.

My code so far for reference:

void C_testing() {
    TFile file("file.root");
    TTree* tree = (TTree*)file.Get("tree.root");

    TBranch *px_branch = tree->GetBranch("p_px");
    TBranch *py_branch = tree->GetBranch("p_py");
    TBranch *pz_branch = tree->GetBranch("p_pz");
    TBranch *E_branch = tree->GetBranch("p_E");
}

My end goal is to specify an event number and output 6 separate TLorentzVector objects. Any advice, examples I can use, or good resources would be greatly appreciated!

Cheers,
Sam

ROOT Version: 6.12/07
Platform: Linux
Compiler: Unsure


Hi Sam,

Welcome to the ROOT forum!

I’d suggest the TTreeReader API to get the values. Have a look at the second example. The TTreeReaderArray can give you access to the values of the individual particles in every event.

Cheers,
Jakob

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