Small error in using TTreeReader

Hi,
I am facing two errors. One related to reading TClonesArray and other related to stacking of histograms:
For, the TClonesArray, I am tring to access the following branch of a TTree:

The Brach I want to study is:
*............................................................................*
*Br  163 :GenJet    : Int_t GenJet_                                          *
*Entries :    10000 : Total  Size=     116365 bytes  File Size  =      27349 *
*Baskets :       26 : Basket Size=      64000 bytes  Compression=   3.01     *
*............................................................................*

The part of macro where I guess the problem is:
TTreeReaderArray<int>tnjet(readerxx1,"GenJet"); 
And the displayed error is:
Error in <TTreeReaderArrayBase::CreateContentProxy()>: The branch GenJet contains data of type Jet. It cannot be accessed by a TTreeReaderArray<int>

If I try to change it to TTreeReaderValue:

Error in <TTreeReaderValueBase::CreateProxy()>: The branch GenJet contains data of type TClonesArray. It cannot be accessed by a TTreeReaderValue<int>

Where am I going wrong?

Kind regards,
Krunal

Hi,

the type of the TTreeReaderArray should not be “int” but rather “Jet”.

Cheers,
D

1 Like

Thank you for the reply. It still does solve the issue:
/home/krunal/Downloads/MG5_aMC_v2_5_4/ExRootAnalysis/data.c:146:18: error: use of undeclared identifier 'Jet' TTreeReaderArray<Jet> tnjet(readerxx1,"GenJet"); ^ /home/krunal/Downloads/MG5_aMC_v2_5_4/ExRootAnalysis/data.c:265:20: error: use of undeclared identifier 'tnjet' for (size_t j=0; j<tnjet.GetSize();j++) ^

Hi,

this is C++ :slight_smile: you still need to include the header where the Jet class is defined. In order to read fromt he TTree, as usual, you’ll also need to load the dictionary for it.

Cheers,
D

1 Like

Hi,

Sorry,
But do you mean to add header #include<Jet.h> ?

Thanking you,

Hi,

if Jet is defined in there, yes. For what concerns the dictionaries, it’s another story. What library was used to create this TTree?

Cheers,
D

1 Like

Hi,

I actually used MG5+Pythia8 and then converted that .hepmc file of output to .root file using Delphes(as a stand alone program) (i.e I used Deplhes converter).

Thanks!

Hi,

make sure all libraries from those tools are in the library path. If you wrote the tree, it means that dictionaries are available.

Cheers,
D

1 Like

Hi,
Sorry, I am bit new to such errors.
On doing a search in Delphes (the tool which I used to get the TTree), I get the file: libDelphes.so

I am having all my TTrees and the macro in the same folder where this .so file is located. How should I proceed from there on?

Kind regards
Krunal

Hi,

try and see if you have issues. Let’s be pragmatic :wink:

D

1 Like

Hi,

I got those required header files added. The error message has gone!

Thank you :slight_smile:
Krunal

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