How to read track numbers

ROOT team hello,

I am a beginner (apologize) and trying to read a value of Jet.Pt. from a 3-event root file, which I attached.
My code is as follows:

{
gROOT->ProcessLine(".L $ROOTSYS/lib/libPhysics.so");
gROOT->ProcessLine(".L Event.cxx");
Int_t jetsize;
Event *event;
Track *track;
TClonesArray *a=new TClonesArray();   
TFile *fi=new TFile("Event.root","READ");
TTree *mt=(TTree *)fi->Get("LHCO;1");
mt->SetBranchAddress("Jet_size",&jetsize);
mt->GetEntry(2);
mt->Show();
Event *event= new Event();
TBranch *branch  = mt->GetBranch("Jet");
mt->SetBranchAddress("Jet",&a);
cout << endl;
cout << jetsize << endl;
cout << &event << endl;
Track *track= new Track();
*track=a[1];
cout << track->GetPt() << endl;
};

However, I only succeed in getting the value of the Jet_size. Here is the output (of the third event):

Only the Jet_size reading (i.e. 6) is correct. My question is, how do I read also the values of e.g. Jet.PT (or e.g. Jet.Phi). For example I want to read the value of 881.47 (the first Jet.PT). What am I doing wrong?

Thanks very much in advance.
Event.root (18.8 KB)

I think we also need Event.cxx:

you do:

gROOT->ProcessLine(".L Event.cxx");

Hi.
I used this line in the code (it’s the second line).
I attach Event.cxx.
Thanks.
Event.cxx (18 KB)

I get:

root [0] .x diaspar.C
Error: cannot open file "Event.h"  Event.cxx:87:
*** Interpreter error recovered ***
Error: Symbol Event is not defined in current scope  diaspar.C:5:
Error: Symbol event is not defined in current scope  diaspar.C:5:
*** Interpreter error recovered ***

I’m sorry about this, I don’t know why this happens.
I changed the code a bit and removed references to events:

{
gROOT->ProcessLine(".L $ROOTSYS/lib/libPhysics.so");
Int_t jetsize;
TFile *fi=new TFile("Event.root","READ");
TTree *mt=(TTree *)fi->Get("LHCO;1");
mt->SetBranchAddress("Jet_size",&jetsize);
mt->GetEntry(2);
mt->Show();
TBranch *branch  = mt->GetBranch("Jet");
cout << endl;
cout << jetsize << endl;
};
I'm sorry about this, I don't know why this happens.

because you forgot to send Event.h

I also send Event.h.
Event.h (7.82 KB)

You should get all the Tracks from event using:

TClonesArray *All_Tracks = Event->GetTracks();

and the you us GetPt() on the track you need.

Got it.
One needs to install Pavel Demin’s package, ExRootAnalysis (available on the MADGRAPH site), and write the code from his README file:

{
gSystem->Load("ExRootAnalysis/libExRootAnalysis.so");
gSystem->Load("libPhysics");
TChain chain("LHCO");
chain.Add("Event.root");
ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
Long64_t numberOfEntries = treeReader->GetEntries();
TClonesArray *branchJet = treeReader->UseBranch("Jet");
for(Int_t entry = 0; entry < numberOfEntries; ++entry) {
treeReader->ReadEntry(entry);
TRootJet *jet = (TRootJet*) branchJet->At(1);
cout << jet->PT << endl;
}
}

This will give access to all the track numbers.