Fork me on GitHub

Opened 10 years ago

Last modified 10 years ago

#273 new How to

Reading the constituents of a jet

Reported by: Milen Lazarov Owned by:
Priority: minor Milestone:
Component: Delphes miscellaneous Version: Delphes 3
Keywords: Cc:

Description

I am trying to do some analysis on a jet substructure. For that, I need to access the constituents of a jet. I am using MadGraph to generate a simple event, like p p -> j j, then run Delphes with fastjet to select the jets. I use ExRootTreeReaer to read the output root file. When I loop over the events, I get the jets in each event from the Jet branch. Each jet has a Constituents member which returns a reasonable number from Constituents->GetEntries() but calling Constituents->At(i) always returns a NULL pointer. What am I missing? What is the proper way to get the values for these entries? I tried dumping the four vectors for the constituents in the TreeWriter module before they are written out and they are definitely non-zeroed. I have pasted the sample code that I use to read the output file below.

Thanks,
Milen

int main() {

TChain* chain = new TChain("Delphes");
chain->Add("/Research/outputs/short.root");
ExRootTreeReader* reader = new ExRootTreeReader(chain);
TClonesArray* branchJet = reader->UseBranch("Jet10");
int eventCount = reader->GetEntries();

for (int i = 0; i < eventCount; ++i) {

reader->ReadEntry(i);
for (int jetNum = 0; jetNum < branchJet->GetEntries(); jetNum++) {

Jet* jet = (Jet*)branchJet->At(jetNum);
for (int ci = 0; ci < jet->Constituents.GetEntriesFast(); ci++) {

TObject* object = jet->Constituents.At(ci);
cout << object << endl;

}

}

}

return 0;

}

Change History (2)

comment:1 by Michele Selvaggi, 10 years ago

Hi Milen,

you need to declare the branches that actually contain the jet constituents.
You can have a look a this ticket where this a similar question was addressed:

https://cp3.irmp.ucl.ac.be/projects/delphes/ticket/238

Also I suggest you have a look at examples/Example3.C where the procedure to access constituents is detailed.

Michele

comment:2 by Milen Lazarov, 10 years ago

Hi Michele,

Thank you very much for the quick reply. That was exactly the problem that I had. The sample that I posted was something that I tried while troubleshooting a more complicated analysis code which was having a slightly different problem with the constituents - some of them were duplicates of each other or had outright different values from what was being written in TreeWriter. Filling the branches mentioned in the other post resolved the problems in there as well.

Thanks!
Milen

Note: See TracTickets for help on using tickets.