Hi,
I’m trying to fill the branch of a tree w/
std::vector
where MyClass was generated via Reflex.
The class is accessible in ROOT, but the code cashes when doing
tree->Fill()
However, filling a TBranch of MyClass (ie w/o the std::vector) works.
Most likely I don’t have what’s needed in either
selection.xml
MyPackageDict.h
Is there any documentation somewhere about how to use Reflex ?
I’e been shooting in the dark making those files.
Below are some code snippets.
I’m using Root 5.18 with ATLAS Athena software.
Any help welcome.
Cheers
-Anyes
selection.xml
<lcgdict>
<class name="MyClassContainer" id="954DE958-66C0-4BF5-8AE4-2BC13B60C671"/>
<class name="MyClass"/>
<class name="std::vector<MyClass*>" />
<class name="std::vector<MyClass*>::const_iterator" />
<class name="std::vector<MyClass*>::iterator" />
<class name="std::vector<MyClass>" />
<class name="std::vector<MyClass>::const_iterator" />
<class name="std::vector<MyClass>::iterator" />
<class name="MyOtherClass"/>
</lcgdict>
MyPackageDict
[code]
#ifndef MYPACKAGE_MYPACKAGEDICT_H
#define MYPACKAGE_MYPACKAGEDICT_H
#include “MyPackage/MyClass.h”
#include “MyPackage/MyOtherClass.h”
#include “MyPackage/MyClassContainers.h”
#include “MyPackage/MyPackageInterface.h”
namespace dummy_MyPackage{
MyOtherClass t m_dummy_OtherClass;
std::vector m_dummy_MyClass;
std::vector::const_iterator m_dummy_MyClass_cstIter;
std::vector::iterator m_dummy_MyClass_Iter;
std::vector<MyClass*> m_dummy_MyClassPtr;
std::vector<MyClass*>::const_iterator m_dummy_TMyClassPtr_cstIter;
std::vector<MyClass*>::iterator m_dummy_MyClassPtr_Iter;
}
#endif[/code]
In ROOT
I load the lib via
gSystem->Load("libCintex");
Cintex::Cintex::Enable();
gSystem->Load("libPhysics");
gSystem->Load("libMyPackage");
gSystem->Load("libMyPackageDict");
Then to make the tree
TFile* fP = new TFile("test.root","recreate");
TTree* tree = new TTree("MyTree","MyTree");
fP->cd();
std::vector<MyClass>* _myClassA = new std::vector<MyClass>();
TBranch* bMyClassA = tree->Branch("mA",&_myClassA, 32000, 99 );
for(int iEntries=1; iEntries<nMax; iEntries++){ //evt loop
/* Fill the array */
tree->Fill(); //Crashes here (see below)
}
...
#0 0x30343036 in ?? ()
#1 0x0056cc24 in TClass::Streamer () from /Atlas/Athena/LCGCMT/LCGCMT_54g/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#2 0x0774bcb1 in TBufferFile::WriteFastArray () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libRIO.so
#3 0x077c24cc in TStreamerInfo::WriteBufferAux<TVirtualCollectionProxy> () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libRIO.so
#4 0x077c20f0 in TStreamerInfo::WriteBufferSTL () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libRIO.so
#5 0x0166628c in TBranchElement::FillLeaves () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libTree.so
#6 0x0166117d in TBranch::Fill () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libTree.so
#7 0x01665dde in TBranchElement::Fill () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libTree.so
#8 0x01665dfc in TBranchElement::Fill () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libTree.so
#9 0x016a3108 in TTree::Fill () from /Atlas/Athena/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libTree.so