Error in <TTree::SetBranchAddress>:

hi,
surely this issue was answered in the past, but i did not manage to find about it in the forum.
I have a TTree from which I generate the Class with the following recipe:
root -l
root [0] Cintex::Enable()
root [1] TFile f(“ntuple.root”)
root [3] TTree* CollectionTree
root [4] f.GetObject(“CollectionTree”,CollectionTree)
root [6] CollectionTree->MakeClass(“TopTree”)
root [7] .q
I added in the TopTree.h, these two lines:
using std::vector;
using std::string;

using gcc to compile it as a standalone application, it compiles well, expect that i get, when running loading the TTree:

Error in TTree::SetBranchAddress: The class requested (vector<long,allocator >) for the branch “LVL1TriggerInfo” refer to an stl coll
ection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector<long,allocator >)

is there some step that i am not aware of?
many thanks, Nabil.

Hi,

before
root [0] Cintex::Enable()
do
root [-1] #include
Does that help?

Cheers, Axel.

thanks for the reply. Indeed this file is already included:

root [0] #include
Note: File “vector” already loaded

I tried with the MakeSelector() instead of the MakeClass, but this did not help.
I have the feeling that when running (compiled version of the software) it simply fails.
For instance, it fails to generate the Class for matrices as well.
I store in the Tree, the information for all the Z bosons, and thus, i have to deal with matrices (first index: the i-th Z boson, and the second index being the j-th decay product of my i-th Z-boson)
Using MakeSelector()/MakeClass(), I get the following piece of code, which of course fails to compile since variables are declared several times.
How shall i proceed to create my class for a Tree which uses std::vector and matrices?
many thanks.

//TMatrixT *event_Z_decay_px;
UInt_t fUniqueID;
UInt_t fBits;
Int_t fNrows;
Int_t fNcols;
Int_t fRowLwb;
Int_t fColLwb;
Int_t fNelems;
Int_t fNrowIndex;
Double_t fTol;
Double_t fElements[1]; //[fNelems]
//TMatrixT *event_Z_decay_py;
UInt_t fUniqueID;
UInt_t fBits;
Int_t fNrows;
Int_t fNcols;
Int_t fRowLwb;
Int_t fColLwb;
Int_t fNelems;
Int_t fNrowIndex;
Double_t fTol;
Double_t fElements[1]; //[fNelems

thanks, nabil

[quote]using gcc to compile it as a standalone application, it compiles well, expect that i get, when running loading the TTree:

Error in TTree::SetBranchAddress: The class requested (vector<long,allocator >) for the branch “LVL1TriggerInfo” refer to an stl coll
ection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector<long,allocator >)[/quote]
As the message attempts to say, you must provide a dictionary for vector, either by adding #pragma link C++ class vector<long>;or by loading the pre-build dictionary by executing in your compiled codegROOT->ProcessLine("#include <vector>");which will induce the loading of a the proper shared library.

Cheers,
Philippe

thanks for the answer. I will give it a try, but still, how can i handle the TMatrixT issue?
namely how do i generate in a consistent way, the Class for matrices.
When I generate my class (including your advices), I get the following:

  • my matrix-like variable is commented out and instead, i get doubles and integer scalar variables. I guess that first, these variable names need as a prefix the name of my variable?
    is there some simple example on how to generate a Class from a TTree with matrices?
    thanks.

As i wrote it previously:
//TMatrixT *event_Z_decay_px;
UInt_t fUniqueID;
UInt_t fBits;
Int_t fNrows;
Int_t fNcols;
Int_t fRowLwb;
Int_t fColLwb;
Int_t fNelems;
Int_t fNrowIndex;
Double_t fTol;
Double_t fElements[1]; //[fNelems]
//TMatrixT *event_Z_decay_py;
UInt_t fUniqueID;
UInt_t fBits;
Int_t fNrows;
Int_t fNcols;
Int_t fRowLwb;
Int_t fColLwb;
Int_t fNelems;
Int_t fNrowIndex;
Double_t fTol;
Double_t fElements[1]; //[fNelems]

[quote]- my matrix-like variable is commented out and instead, i get doubles and integer scalar variables. I guess that first, these variable names need as a prefix the name of my variable?
is there some simple example on how to generate a Class from a TTree with matrices? [/quote]By definition MakeClass degenerate your event model down to int and float and when it is unable to do so, it just mark the ‘missing’ field with the commented out entry. A TTree can not be used in both the degenerated and the object model at the same time. (So even if you did uncomment the proper lines, the reading would not work properly).

To use a complete object oriented version of your TTree data you can either write your own TSelector or you can use the result of TTree::MakeProxy instead of MakeClass.

Cheers,
Philippe.

hi again,
I am trying to use the TTree::MakeProxy and i am a lit bit lost…
Basically I have to specify two file names. the first one being the skeleton file to be generated for the TTree. The second argument, i don’t really understand.
Could someone one point me to some example/tutorial about it?

In the documentation, it says:
“macrofilename” and optionally “cutfilename” are expected to point
to source file which will be included in by the generated skeletong.
Method of the same name as the file(minus the extension and path)
will be called by the generated skeleton’s Process method as follow:
[if (cutfilename())] htemp->Fill(macrofilename());

Hi,

A little further down in the documentation is an example using the tutorials hsimple.root file.
Also you can look at tutorials/tree (look at the file with Proxy in their name)

[quote]the input to the TTreeProxy is a script file (for example h1analysisProxy.C) and an optional cut script file (for example h1analysisProxyCut.C).

MakeProxy generate a selector with a Process method containing:

htemp->Fill(h1analysisProxy());
or
if (h1analysisProxyCut()) htemp->Fill(h1analysisProxy());

The addition is that, optionally, the generated selector will also
call method named scriptname_methodname in each of 6 main selector
methods if the method scriptname_methodname

Concretely, with the script h1analysisProxy.C,
The method calls the method (if it exist)
Begin -> h1analysisProxy_Begin
SlaveBegin -> h1analysisProxy_Begin
Notify -> h1analysisProxy_Begin
Process -> h1analysisProxy_Begin
SlaveTerminate -> h1analysisProxy_Begin
Terminate -> h1analysisProxy_Begin

This means that now

chain->Process(“h1analysis.C+”);
and
chain->Draw(“h1analysisProxy.C+”,“h1analysisProxyCut.C”)
are equivalent (i.e. should produce the same result in the same
amount of time (approx).[/quote]

Cheers,
Philippe.