Intermittent problem with vector<vector<double> &gt

Hi,

I have a root file containing some branches of type vector<vector >. It’s produced using experiment-specific software, so I can’t demonstrate how it’s made, but there are no obvious errors in the file production. When reading them in root 5.16/00, most calls to TTree::Draw work fine, as shown below.

reco_ee_et is a vector<vector >, where the “inner” vector always has 3 elements:

CollectionTree->Draw("reco_ee_et");
// Plot has 3591 entries, and the distribution looks OK.

CollectionTree->Draw("reco_ee_et","reco_ee_et==0");
// Sanity check: No entries are passed - this is important later

CollectionTree->Draw("reco_ee_et[][0]"); // looks OK
// 1197 entries = 3591/3 as it should be

CollectionTree->Draw("reco_ee_et[][1]"); // also OK, 1197 entries

But this doesn’t work:

CollectionTree->Draw("reco_ee_et[][2]");

This gives a histogram with the correct number of entries (1197), but every single entry is zero!

The odd thing is that the earlier TTree::Draw() method, TTree::Scan() and a compiled TSelector based algorithm all show this element to be nonzero. Does anyone have any ideas why the above line might fail when everything else seems to work?

Thanks in advance,
Mike

Hi,

This problem might actually have been fixed this morning in the SVN trunk.
Could you try it out?
If it still does not work, can you send me your data file?

Thanks,
Philippe.

Hi Philippe,

Thanks for the quick reply. I’m afraid I’ve never used SVN before - any clues as to how to do this? The last version on the ROOT homepage was posted a month ago…

Thanks,
Mike

See root.cern.ch/root/Install.html

Cheers,
Philippe.

Hi again,

This still doesn’t appear to work :frowning:. Just to check - the trunk/head version is 5.19/03, right? I’ve attached the file in question (hopefully!). Of course if the file is corrupt, this is still very useful information, but I don’t think this is the case for the reasons outlined in my first post.

Thanks for the help,
Mike
AthenaCrossSection.root (229 KB)

Hi,

Thanks for your example. There is indeed a problem, I am investigating a solution.

Cheers,
Philippe.

Hi,

This problem has been fixed in the svn repository.

Cheers,
Philippe

Thank you, that works :smiley:

I also have another question relating to this actually. Is there an easy way of returning the size of the “inner” vector of a vector<vector >? This returns the size of the “outer” vector as it should:

CollectionTree->Draw("reco_ee_et@.size()");
But I can’t seem to find a way of getting the size of the “inner” vector. My first guess was

CollectionTree->Draw("(reco_ee_et[])@.size()"); // or CollectionTree->Draw("(reco_ee_et[0])@.size()");
but these both return the same as above, ie the “outer” vector. I feel I’m getting close with this next line, but it returns an error:

CollectionTree->Draw("(reco_ee_et@).at(0).size()") Error in <TTreeFormula::DefinedVariable>: Can not call method at(0).).size() on class without dictionary (vector<vector<double> >)! Error in <TTreeFormula::Compile>: Part of the Variable "(reco_ee_et@).at(0).size()" exists but some of it is not accessible or useable
I had already made a LinkDef.h file and compiled it, but when I try to use it in CINT, it tells me I can’t:

.L ../ROOT/TestDict.C+ Info in <TUnixSystem::ACLiC>: creating shared library /user1/flowerdew/testarea/13.0.40/MJFcode/ROOT/./../ROOT/TestDict_C.so In file included from /user1/flowerdew/testarea/13.0.40/MJFcode/ROOT/./../ROOT/TestDict.C:16, from /tmp/rootcint_V1mG9k.h:3, from /tmp/oz3loU_cint.cxx:1: /user1/flowerdew/testarea/13.0.40/MJFcode/ROOT/./../ROOT/TestDict.h:8:2: #error TestDict.h/C is only for compilation. Abort cint. Error: external preprocessing failed. :0: !!!Removing /user1/flowerdew/testarea/13.0.40/MJFcode/ROOT/./../ROOT/fileUJAHhR.cxx /user1/flowerdew/testarea/13.0.40/MJFcode/ROOT/./../ROOT/fileUJAHhR.h !!! Error: rootcint: error loading headers... Error in <ACLiC>: Dictionary generation failed! Info in <ACLiC>: Invoking compiler to check macro's validity Info in <ACLiC>: The compiler has not found any problem with your macro. Probably your macro uses something rootcint can't parse. Check http://root.cern.ch/root/Cint.phtml?limitations for Cint's limitations.
What am I doing wrong?

Cheers,
Mike

Cheers,
Philippe.

Thanks Philippe, but this still doesn’t work for me. Here is my LinkDef.h file:

#ifdef __CINT__ #include <vector> #pragma link C++ class std::vector<std::vector<bool> >+; #pragma link C++ class std::vector<std::vector<int> >+; #pragma link C++ class std::vector<std::vector<double> >+; #endif
and this is the error I get:

root [0] gROOT->GetVersion() (const char* 0x9fc4668)"5.19/03" root [1] .L LinkDef.h+ Info in <TUnixSystem::ACLiC>: creating shared library /user1/flowerdew/testarea/13.0.40/MJFcode/ROOT/./LinkDef_h.so rootcint: symbol lookup error: rootcint: undefined symbol: _ZN14G__ShadowMaker15NeedShadowClassER12G__ClassInfo Error in <ACLiC>: Dictionary generation failed! Info in <ACLiC>: Invoking compiler to check macro's validity Info in <ACLiC>: The compiler has not found any problem with your macro. Probably your macro uses something rootcint can't parse. Check http://root.cern.ch/root/Cint.phtml?limitations for Cint's limitations. root [2]
I’ve already tried one or two variations on the LinkDef.h file:

  • removing “std::” throughout;
  • using MAKECINT instead of CINT;
  • Having "#include " above the #ifdef line.
    All come back with essentially the same error. This also fails in ROOT 5.12/00e, except without the undefined symbol error, the error is this:

Any ideas?

Thanks,
Mike

Hi Mike,

you almost fixed all the four problems: move the #include outside the #ifdef CINT, rename your Linkdef.h to Loader.C, remove the “std::”, and fix the LD_LIBRARY_PATH for ROOT 5.19/03 - it is causing the unresolved symbol error. With all that, “.L Loader.C+” does what you want.

Cheers, Axel.

Hi Axel,

Thanks, now the library appears to load at least (is there any way to check this?). I still cannot plot the number I want though: the size of the second dimension in a vector<vector >. Things I have tried include:

[code]root [6] CollectionTree->Draw("((reco_ee_et[0])@).size()") // Plots nothing
Warning in TTreeFormula::DefinedVariable: Can not call method on content of vector in ((reco_ee_et[0])@).size()

Error in TTreeFormula::Compile: Part of the Variable “((reco_ee_et[0])@).size()” exists but some of it is not accessible or useable
root [7] CollectionTree->Draw("(reco_ee_et[0]@).size()")
// Plots size of first dimension, ie the same as “reco_ee_et@.size()”
[/code]
I have tried one or two other combinations of brackets, indices etc, all with one of the two results above. What is the proper syntax for this?

Cheers,
Mike

Hi,

This is a current limitation of TTree::Draw, you can not get the dimension of the inner collection in a vector<vector<>> … I am still investigating this issue.

Cheers,
Philippe.

OK Philippe, it’s good to know that… thanks for the answer!

Cheers,
Mike