2D vectors in a tree

Hello everybody,

I am using vectors of double to stock some variables in my analysis (for example Pt of the muons), like this :

_TopLepTauTree->Branch("_MuonPt" ,“std::vector” ,&_pMuonPt);

and everything works properly.
But I encountered the necessity to use 2D vectors containing doubles (which means vectors of vectors of double), for instance I would like to stock the Pt of each tau track by event.
I tried to use the sentence :

_TopLepTauTree->Branch("_pTau_Track_Pt" ,“std::vector< <std::vector >” ,&_pTau_track_Pt);

The compilation was ok but it crashed at the execution (seg fault).
Do somebody has an idea to solve this problem ?
Cheers,

Jerome

Hi,

Possibly because of a copy/paste, there is a typo in your text (extraneous pair of <>), I think your code should read:_TopLepTauTree->Branch("_pTau_Track_Pt" ,"std::vector< <std::vector<double> >" ,&_pTau_track_Pt); or better yet, let the compiler help you with the class name:_TopLepTauTree->Branch("_pTau_Track_Pt" ,&_pTau_track_Pt);

I recommend that you try running root.exe in valgrind to see more information about the reason of the crash.

Thanks,
Philippe.

Thank you for your help, but it was in fact a problem of initialization of my vectors.
My config file is running correctly now. However, when I look at the ouptut tree, I see that the sentence of my config file :

_TopLepTauTree->Branch("_Tau_tracks_Pt" ,“std::vector< std::vector >” ,&_pTau_tracks_Pt);

leads to the creation of a branch in the output tree, containing five leaves :
@size, capacity(), empty(), max_size(), size().

But this is not what I expected to encounter.
What I would like to have is the Pt of all tau tracks plotted, but keeping the structure of 2D vectors, in order to use it in a local program file.
I really don’t know what to do now.
Respectfully,

Jerome

[quote]leads to the creation of a branch in the output tree, containing five leaves :
@size, capacity(), empty(), max_size(), size(). [/quote]I think you are mis-interpreting the information TBrowser is providing you. When using the TBrowser to look at the content of TTree, it shows not only the actual content but also other operation/information that can be done/extract. So for example, double clicking on ‘size()’ will plot the various size of the vector across the events.

And indeed you currently can not plot the graph you need via the TBrowser.
(Note that this limitation has been lifted in the svn trunk).
To work around this, you will need to use on the command line:_TopLepTauTree->Draw("_Tau_tracks_Pt");

Cheers,
Philippe.

I tried to use the “TTree::Draw” method in root but what I have is just an empty canvas.
Best Regards,

Jerome

Here is the rootfile that I am using.
Cheers,

Jerome
My_Tree_Zmumu_presel.root (641 KB)

[quote]I tried to use the “TTree::Draw” method in root but what I have is just an empty canvas. [/quote]This is the expected result. Each and every of you inner vector are empty. For example in the first entry the vector<vector > contains 2 vector both of which are empty.

Cheers,
Philippe.