> tree->Branch("b", "vector<SomeOtherClass>", &somepointer); This has not been implemented yet but should be implemented soon. Cheers, Philippe. -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Troy D. Straszheim Sent: Thursday, June 10, 2004 6:53 AM To: roottalk@pcroot.cern.ch Subject: [ROOT] branching STL vectors directly Hi Talk, I have an example here: branching a class, a typedef of a class, a template class (containing a vector), and a typedef of a template class containing a vector all work, but branching a vector directly does not. That is, the call tree->Branch("b", "MyTemplateClass<SomeOtherClass>", &somepointer); works fine, but tree->Branch("b", "vector<SomeOtherClass>", &somepointer); does not. Am I overlooking something? The example below should show the error with a simple % root -l test.C++ and the errors: % root -l test.C++ root [0] Processing test.C++... Info in <TUnixSystem::ACLiC>: creating shared library /home/troy/icetray/work/./test_C.so Error in <TTree::Bronch>: vector<XYZ> with no dictionary defined in branch: vectorofxyz Error in <TTree::Bronch>: vector<XYZ> with no dictionary defined in branch: vectorofxyz This is with today's root from CVS on Linux 2.4.26 with gcc 3.3.2. Any ideas would be greatly appreciated... Best, Troy Straszheim ============================================================ #include <TObject.h> #include <TSystem.h> #include <TTree.h> #include <iostream> #include <vector> using namespace std; struct XYZ { float x, y, z; }; typedef XYZ XYZ_Typedef; template <class T> struct TemplateClass { T array_of_t[15]; vector<T> vector_of_t; }; // explicit instantiations seem to make no difference // template class TemplateClass<XYZ>; // template class vector<XYZ>; typedef TemplateClass<XYZ> TemplateClassXYZTypedef; TTree *tree; void test2() { tree = new TTree("T", "T"); // branch a class: works XYZ *xyz_p = new XYZ; tree->Branch("XYZ", "XYZ", &xyz_p); tree->Fill(); // branch a typedef of a class: works tree->Branch("XYZ_Typedef", "XYZ_Typedef", &xyz_p); tree->Fill(); //////////////////////////////////////// TemplateClass<XYZ> *xyztemplate_p = new TemplateClass<XYZ>; // branch a template class: works, even when class contains a vector tree->Branch("templateofxyz", "TemplateClass<XYZ>", &xyztemplate_p); tree->Fill(); // branch a typedef of a template class: works tree->Branch("templateofxyztypedef", "TemplateClassXYZTypedef", &xyztemplate_p); tree->Fill(); vector<XYZ> *xyzvec_p = new vector<XYZ>(100); // doesn't work tree->Branch("vectorofxyz", "vector<XYZ>", &xyzvec_p); tree->Fill(); // also doesn't work, seemingly not a namespace issue tree->Branch("vectorofxyz", "std::vector<XYZ>", &xyzvec_p); tree->Fill(); }
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET