Error in <TTree::SetBranchAddress>: The pointer type given "vector<float>" does not correspond to the type needed "Float_t" (5) by the branch: m

I have run some simulations in Pythia from which I’m extracting a few values in a vector which I’m then saving in trees. After trying to reconstruct the vector from the root file this is the error im getting.

Processing tutorial13a.cc…
In file included from input_line_8:1:
/home/raseeb/code/pythia/tutorial13a.cc:149:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: m
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: eta
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: pT
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: phi
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: eng
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: M
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: Eta
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: PT
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: Phi
Error in TTree::SetBranchAddress: The pointer type given “vector” does not correspond to the type needed “Float_t” (5) by the branch: Eng
#0 0x00007f17dbeb645a in __GI___wait4 (pid=3958, stat_loc=stat_loc
entry=0x7ffc09901b28, options=options
entry=0, usage=usage
entry=0x0) at …/sysdeps/unix/sysv/linux/wait4.c:30
#1 0x00007f17dbeb641b in __GI___waitpid (pid=, stat_loc=stat_loc
entry=0x7ffc09901b28, options=options
entry=0) at ./posix/waitpid.c:38
#2 0x00007f17dbe1cbcb in do_system (line=) at …/sysdeps/posix/system.c:171
#3 0x00007f17dc56a2d4 in TUnixSystem::StackTrace() () from /home/raseeb/root/lib/libCore.so.6.26
#4 0x00007f17d7e35240 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /home/raseeb/root/lib/libCling.so
#5 0x00007f17d7e293e0 in cling_runtime_internal_throwIfInvalidPointer () from /home/raseeb/root/lib/libCling.so
#6 0x00007f17dc240a7d in ?? ()
#7 0x61656c65522f4550 in ?? ()
#8 0x00005575bb2f3140 in ?? ()
#9 0x00007f17d7e29380 in ?? () from /home/raseeb/root/lib/libCling.so
#10 0x3430323275746e75 in ?? ()
#11 0x0000000000000000 in ?? ()
Error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
/home/raseeb/code/pythia/tutorial13a.cc:76:3: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
pT->GetEntry(entries);

ROOT Version: 6.26/06
Platform: Ubuntu 22.04
Compiler: Not Provided


In principle, you should be able to get the types of branches using: your_tree->Print();

I actually want to put these values in a histogram. Currently I’m only trying to fill the pT histogram, but this is the error that I’m getting. My end goal is to reconstruct the Z boson using all of these properties. Im new to this ,and any help would be appreciated.

Looks like you’ve already had a similar problem, which has been solved (you now have “Float_t” variables, and previously there were “Double_t” ones):

That was a different case where I was using normal values and not vectors. Here I’m attaching both of my files that I’m using to create the tree and to exract the values from the tree.

tutorial13.cc (5.0 KB)
tutorial13a.cc (5.4 KB)

Looking at the “tutorial13.cc”, there is not much changed in the “tree” (and “tre”) structure. You just use “Float_t” where you previously used “Double_t”.

I’m a newbie, can you please elaborate a bit more, on how to fix this problem? as the last time had I started from scratch not used the tutorial9.C for my work.

As I said, you can start with my simple “fully working example” (just replace “Double_t” with “Float_t”).

1 Like

I used the above-mentioned thread, it does its job but doesn’t help me puting back the vector to be used with TLorentVector. I’m having trouble using it that way. Any further help would be appreciated.

You have a fully working loop over your “tree” entries, so inside this loop, you can put the retrieved values (event by event) into your vectors.

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