TTree: vector member variable contents not stored

Hi all,

I am trying to store a Branch in a TTree. This Branch represents a vector< MyClass >. When I examine the Branch, I see that, for the MyClass objects stored for each event in the vector, only some member variables are correctly stored.

MyClass looks something like this:

namespace myNamespace
{

    class MyClass
    {

        int A; //stored correctly
        myNamepsace::SomeOtherClass B; // stored correctly
        vector<int> C; // contents of vector are not stored. Only empty vector is stored.

    };

}

So in this case I cannot get C, a vector of integers, to be stored correctly. It is always stored as an empty vector. I have confirmed that it has a size usually > 1000 entries at the time the branch is filled.

I created a dictionary that looks like this:

#ifdef __MAKECINT__

#pragma link off all typedefs;
#pragma link off all globals;
#pragma link off all functions;
#pragma link off all classes;


#pragma link C++ class std::vector< int >+;

#pragma link C++ class myNamespace::SomeOtherClass+;
#pragma link C++ class std::vector< myNamespace::MyClass >+;
#pragma link C++ class myNamespace::MyClass+;



#endif /* __MAKECINT__ */

Could someone help me figure out what I need to do to get the contents of C stored in the tree? I imagine this may be a problem due to the complexity of the structure, a vector of objects containing vectors of integers. It could also be a problem with my dictionary. Any ideas?

Thanks for the help
–John

Hi John,

A priori, this looks like it should be working. Can you upload a running example showing the failure?

Cheers,
Philippe.

You are correct, this does work. After a lot of digging I found the mistake. It was not related to ROOT at all. Please feel free to delete this question.

Thanks for the help.