" *** Break *** segmentation violation " while trying to use TLorentzVector

Hi everybody, I have been trying to reconstruct the Z boson using Pythia output, I am getting a perfect .root file and histogram. Here I was trying to use the tree and LorentzVector to reconstruct the Z boson. Any help would be great.

`root [0]
Processing tutorial9b.C…

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007f49b3c3a45a in __GI___wait4 (pid=5723, stat_loc=stat_loc
entry=0x7ffe9efe9298, options=options
entry=0, usage=usage
entry=0x0) at …/sysdeps/unix/sysv/linux/wait4.c:30
#1 0x00007f49b3c3a41b in __GI___waitpid (pid=, stat_loc=stat_loc
entry=0x7ffe9efe9298, options=options
entry=0) at ./posix/waitpid.c:38
#2 0x00007f49b3ba0bcb in do_system (line=) at …/sysdeps/posix/system.c:171
#3 0x00007f49b42ee2d4 in TUnixSystem::StackTrace() () from /home/raseeb/root/lib/libCore.so.6.26
#4 0x00007f49b42eb5e5 in TUnixSystem::DispatchSignals(ESignals) () from /home/raseeb/root/lib/libCore.so.6.26
#5
#6 0x00007f49b3fc45b8 in ?? ()
#7 0x01003a00872cf96d in ?? ()
#8 0x6400000088010000 in ?? ()
#9 0x00007f49afbad380 in ?? () from /home/raseeb/root/lib/libCling.so
#10 0x0000000000000000 in ?? ()
===========================================================

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum ROOT Forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at Sign in to GitHub · GitHub Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6 0x00007f49b3fc45b8 in ?? ()
#7 0x01003a00872cf96d in ?? ()
#8 0x6400000088010000 in ?? ()
#9 0x00007f49afbad380 in ?? () from /home/raseeb/root/lib/libCling.so
#10 0x0000000000000000 in ?? ()
===========================================================

`

ROOT Version: 6.26/06
Platform: Ubuntu 22.04.1 LTS
Compiler: Not Provided


Maybe you need to ask the author(s) of the “tutorial9b.C” macro.

I am the author of the file.
tutorial9b.C (972 Bytes)

What do you get from: tree->Print();

This is what I’m getting.

root [0] 
Processing tutorial9b.C...
******************************************************************************
*Tree    :tree      : tree                                                   *
*Entries :     7811 : Total =          347702 bytes  File  Size =     242518 *
*        :          : Tree compression factor =   1.42                       *
******************************************************************************
*Br    0 :id        : id/I                                                   *
*Entries :     7811 : Total  Size=      31786 bytes  File Size  =        258 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression= 121.37     *
*............................................................................*
*Br    1 :m         : m/D                                                    *
*Entries :     7811 : Total  Size=      63101 bytes  File Size  =        565 *
*Baskets :        2 : Basket Size=      32000 bytes  Compression= 110.84     *
*............................................................................*
*Br    2 :pT        : pT/D                                                   *
*Entries :     7811 : Total  Size=      63107 bytes  File Size  =      59539 *
*Baskets :        2 : Basket Size=      32000 bytes  Compression=   1.05     *
*............................................................................*
*Br    3 :eta       : eta/D                                                  *
*Entries :     7811 : Total  Size=      63113 bytes  File Size  =      60731 *
*Baskets :        2 : Basket Size=      32000 bytes  Compression=   1.03     *
*............................................................................*
*Br    4 :phi       : phi/D                                                  *
*Entries :     7811 : Total  Size=      63113 bytes  File Size  =      60626 *
*Baskets :        2 : Basket Size=      32000 bytes  Compression=   1.03     *
*............................................................................*
*Br    5 :eng       : eng/D                                                  *
*Entries :     7811 : Total  Size=      63113 bytes  File Size  =      60061 *
*Baskets :        2 : Basket Size=      32000 bytes  Compression=   1.04     *
*............................................................................*

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f3d3e4f945a in __GI___wait4 (pid=4571, stat_loc=stat_loc
entry=0x7ffc4530b898, options=options
entry=0, usage=usage
entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
#1  0x00007f3d3e4f941b in __GI___waitpid (pid=<optimized out>, stat_loc=stat_loc
entry=0x7ffc4530b898, options=options
entry=0) at ./posix/waitpid.c:38
#2  0x00007f3d3e45fbcb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:171
#3  0x00007f3d3ebad2d4 in TUnixSystem::StackTrace() () from /home/raseeb/root/lib/libCore.so.6.26
#4  0x00007f3d3ebaa5e5 in TUnixSystem::DispatchSignals(ESignals) () from /home/raseeb/root/lib/libCore.so.6.26
#5  <signal handler called>
#6  0x00007f3d3e8834e4 in ?? ()
#7  0x5f6461704762696c in ?? ()
#8  0x63702e7463696472 in ?? ()
#9  0x00007f3d3a46c380 in ?? () from /home/raseeb/root/lib/libCling.so
#10 0x0000000000000000 in ?? ()
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum https://root.cern/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6  0x00007f3d3e8834e4 in ?? ()
#7  0x5f6461704762696c in ?? ()
#8  0x63702e7463696472 in ?? ()
#9  0x00007f3d3a46c380 in ?? () from /home/raseeb/root/lib/libCling.so
#10 0x0000000000000000 in ?? ()
===========================================================


Root > 


{
  TFile *f = TFile::Open("tutorial9.root");
  TTree *t; f->GetObject("tree", t);
  Int_t id;
  Double_t m, pT, eta, phi, eng;
  t->SetBranchAddress("id" , &id );
  t->SetBranchAddress("m"  , &m  );
  t->SetBranchAddress("pT" , &pT );
  t->SetBranchAddress("eta", &eta);
  t->SetBranchAddress("phi", &phi);
  t->SetBranchAddress("eng", &eng);
  gROOT->cd(); // newly created histograms should go here
  Long64_t n = t->GetEntries();
  for (Long64_t i = 0; i < n; i++) {
    t->GetEntry(i);
    std::cout << id << " " << m << " " << pT << " ... " << eng << "\n";
  }
  t->ResetBranchAddresses(); // disconnect from local variables
  delete f; // automatically deletes "t", too
}

I ran this code in a seperate macro. The forum wouldn’t let me post the entire output so I have saved it in a .txt file.
tutorial9c.txt (258.8 KB)

So, you now have a fully working example of how you can read your "tree" data (it only dumps events to “std::cout”).

BTW. For such a simple "tree" structure, (in the long run) you’d better switch to using: RDataFrame

Ok, I will look into using it.