Problem in root macro

Hi,

I am using ROOT 5.34/32 for analyzing root output from Delphes Detector simulation. I have produced 2jet events in MG5, passed through Pythia, passed through Delphes (standalone mode, not in MG5). Then using examples macro, I am trying to get jet PTs etc. For the hardest jet, I can print the PTs. But whenever I am trying to get the PTs of the 2nd jet, it is getting stuck after printing some,

*** Break *** segmentation violation
2nd Jet pt:

There was a crash.
This is the entire stack trace of all threads:

#0 0x00007ff67ccc306e in waitpid () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ff67cc57989 in ?? () from /lib/x86_64-linux-gnu/libc.so.6

I have attached the macro file. Any help/suggestions will be appreciated.

Thanks in advance,
Saurabh
Example1.C (1.49 KB)

Try: [code] // If event contains at least 2 jets
if(branchJet->GetEntries() > 1) {
jet[0] = (Jet*) branchJet->At(0); // the first jet
jet[1] = (Jet*) branchJet->At(1); // the second jet

  // Plot jet transverse momentum
  //histJetPT->Fill(jet[0]->PT);

  // Print jet transverse momentum
  std::cout << "hardest Jet pt: " << jet[0]->PT << std::endl;
  std::cout << "2nd Jet pt: " << jet[1]->PT << std::endl;
}[/code]

Hi,

Thanks for the reply.

I tried with your commands, but still the same error !!

Surprizingly, the problem is with printing the PT of the 2nd (and onwards) jet. If I comment the print command, it runs fine. Though, it prints the hardest jet PT for all events !!!

I can share my event files if you want. Thanks,

Regards,
Saurabh

Try to add:
branchJet->Clear();
right before:
treeReader->ReadEntry(entry);
Also, instead of:
branchJet->GetEntries()
you can use:
branchJet->GetEntriesFast()

No sir, it is the still same. It is printing only for some initial events (23 events) of the 2nd leading jet PT and then breaking away for segmentation voilation. I tried with other new event file (Wjj production), outcome is the same.

Anyway, thank you very much for your time and effort.

Regards,

Right after:
treeReader->ReadEntry(entry);
try to add:
branchJet->Compress();

Hi,

No, it is still not working :frowning: :frowning:

Anyway, I am uploading again the macro and also the error file, if that helps.

Btw, thanks for your prompt help. It is really amazing =D>

Regards,
Saurabh
error.txt (3.15 KB)
Example1.C (1.57 KB)

In your new macro, you have:
if(branchJet->GetEntriesFast() >= 1)
but you should have:
if(branchJet->GetEntriesFast() > 1) // at least 2 jets
or:
if(branchJet->GetEntriesFast() >= 2) // at least 2 jets

Oho, ok ok I understand. My silly mistake. Yes, now it is fine.
But, doesn’t branchJet->GetEntriesFast() >= 1 mean 1,2,3… (anything above 1 which includes 2 jet as well ).

Of course, there will be events where it will get only 1 jet and does not have anything for 2nd jet. But is this the source of error ?

Thanks, now it works

Regards,
Saurabh

Yes, if there is no “second jet” and you try to access it, then jet[1] will be set to NULL (I think) and then jet[1]->PT will die with a segmentation violation.
Note: if the number of entries is “n” then the entries’ indices are 0, 1, …, (n -1).
BTW. As it works now, you probably do not need branchJet->Compress(); any more (it will just take CPU time).

Ok, I understand. I have to keep in mind the numeber of entries beforehand.

But, frankly, this seems little odd though. I mean, at least it could give 0.00 for a non entry (without 2nd jet, for e.g). I am more used to old fortran coding, where we do this way. Anyway, just m y opinion.

Thanks everybody