Access and modify TTree(Delphes)

Hello root experts,

I want to access and modify TTree(Delphes) by adding new Branches and varaibles within headerfile (tree=Delphes) ,not all branches are exist .Another meaning if i want to add a new branch such that the invariant mass that not exist in header file .Is i create a new tree to clone the old tree and modify it to add a new brach ? .This is my suggested idea or is there another way?.Could you clarify this issue with an attached example?.
I tried to do this But the warning message as

]+ Stopped root -l
[ahmeedsayed@EndeavourOS TMVAModified]$ root -l
root [0] .L treeAnalysis.C
root [1] treeAnalysis t
Warning in TClass::Init: no dictionary for class HepMCEvent is available
Warning in TClass::Init: no dictionary for class Event is available
Warning in TClass::Init: no dictionary for class Weight is available
Warning in TClass::Init: no dictionary for class GenParticle is available
Warning in TClass::Init: no dictionary for class SortableObject is available
Warning in TClass::Init: no dictionary for class Track is available
Warning in TClass::Init: no dictionary for class Tower is available
Warning in TClass::Init: no dictionary for class Jet is available
Warning in TClass::Init: no dictionary for class MissingET is available
Warning in TClass::Init: no dictionary for class Electron is available
Warning in TClass::Init: no dictionary for class Photon is available
Warning in TClass::Init: no dictionary for class Muon is available
Warning in TClass::Init: no dictionary for class ScalarHT is available
(treeAnalysis &) @0x7667dd55a000
root [2] t.Loop();

*** Break *** segmentation violation
Generating stack trace…
0x00007667ec3df5c0 in from /usr/lib/root/libCling.so
0x00007667ec3e17a8 in from /usr/lib/root/libCling.so
0x00007667ec3e1a5b in from /usr/lib/root/libCling.so
0x00007667ec4e2ac5 in from /usr/lib/root/libCling.so
0x00007667ec2d2a35 in from /usr/lib/root/libCling.so
0x00007667ec2f931a in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x145a from /usr/lib/root/libCling.so
0x00007667f3872266 in TRint::ProcessLineNr(char const*, char const*, int*) + 0x156 from /usr/lib/root/libRint.so
0x00007667f3872690 in TRint::HandleTermInput() + 0x210 from /usr/lib/root/libRint.so
0x00007667f358e20a in TUnixSystem::CheckDescriptors() + 0x9a from /usr/lib/root/libCore.so
0x00007667f3591859 in TUnixSystem::DispatchOneEvent(bool) + 0x569 from /usr/lib/root/libCore.so
0x00007667f34879e4 in TSystem::Run() + 0xe4 from /usr/lib/root/libCore.so
0x00007667f34056cf in TApplication::Run(bool) + 0x2f from /usr/lib/root/libCore.so
0x00007667f3874157 in TRint::Run(bool) + 0x2f7 from /usr/lib/root/libRint.so
0x000061ffe61290c6 in main + 0x56 from /usr/bin/root.exe
0x00007667f2c34e08 in from /usr/lib/libc.so.6
0x00007667f2c34ecc in __libc_start_main + 0x8c from /usr/lib/libc.so.6
0x000061ffe6129115 in _start + 0x25 from /usr/bin/root.exe
Root >
treeAnalysis.h (83.0 KB)
treeAnalysis.C (3.0 KB)

Hi,

I think some libraries are missing, as the messages seem to point out: are you sure they are correctly set up?

Best,
D

Hi,
Yes,all libraries are included but the issue appear when i create a new tree to clone the old tree and permit to access it .

Thanks,
Ahmed

@Danilo @yus @couet

Hi Ahmed,

do you mind sharing your /home/ahmeedsayed/Downloads/MG5_aMC_v3_5_6/pp_bb/Events/run_01/bb.root file?

Hi @yus ,
Yes.Here you are

Thanks,
Ahmed
bb.root (1.8 MB)

Thanks Ahmed!

Your immediate issue (I mean, the first one I encountered, which leads to your segmentation violation; there might be other issues that will manifest themselves after you fix the first one) is the following line in your treeAnalysis.C:

b1.SetPtEtaPhiE(Particle_PT[b_quarkIndex[0]], Particle_Eta[b_quarkIndex[0]], Particle_Phi[b_quarkIndex[0]], Particle_E[b_quarkIndex[0]]);

Are you sure that an element with index 0 of the b_quarkIndex vector exists? I checked, and it does not exist, the vector is empty. Hence the segmentation violation.

Yes. This element is exist.I will send a screenshot to confirm
Thanks
Ahmed

This std::vector<int> b_quarkIndex is empty in the very first TTree entry. I don’t understand what your screenshot is supposed to tell me.

Hi @yus ,
Ok. I modify on treeAnalysis.C by adding a ftriendTree function. could you again check
my code?. I suspend may be some thing wrong . Remembering that my big aim to add a new branch that not exisit on Tree(" Delphes") such that the invarient mass ,that i call it " h_mass" and and angular distance between two quarks ,call it " DR_b"

treeAnalysis.C (7.4 KB)
Thanks
Ahmed

Hi Ahmed,

how should I run this? Is this still valid:

$ root -l
root [0] .L treeAnalysis.C
root [1] treeAnalysis t
root [2] t.Loop();

? If so, your script runs and creates a BB_tree.root with t3f TTree and h_mass and DR_b branches inside. Is that what you wanted?

Hi yus,
Yes .The question here is this t3fTree " newTree"
manage me
to aceccs and add new branches instead
of originalTree" Delphes" ? .I find same
analysis,same plots e.g h_mass ,DR_b as if i create only tree.

To be honest, I don’t understand the question. Hopefully someone else will.

Ok,Yus

Thanks
Ahmed

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