I compiled a program in C++ (not with ROOT’s ACLiC) that contains objects of a non-standard class I3Particle stored in ROOT Trees. Here is the relevant part of the program:
I3Particle* GetI3ParticleEvent(int evtID) {
int curEvtID;
I3Particle* curEvtData;
I3Particle* evtData = 0;
bool foundEvt = 0;
for ( std::vector<TTree*>::iterator treeItr = fTrees.begin();
treeItr != fTrees.end(); treeItr++ ) {
(*treeItr)->SetBranchAddress("EventID", &curEvtID);
(*treeItr)->SetBranchAddress("I3Particle", &curEvtData);
for (int count=0; count < (*treeItr)->GetEntries(); count++) {
cout << (*treeItr)->GetEntries() << endl;
(*treeItr)->GetEntry(count);
if ( curEvtID == evtID && !foundEvt ) {
evtData = curEvtData;
foundEvt = 1;
break;
}
}
}
return evtData;
};
Everything works fine until I get to (*treeItr)->GetEntry(count) where a segmentation fault is produced (stack trace below). The previous line cout’s the correct number of entries in the tree so the pointer to the tree in the vector
seems to be correct.
Without the line containing SetBranchAddress(“I3Particle”, &curEvtData) the programs runs fine (at least until it requires some data from evtData) so there seems to be a problem with the I3Particle class in this context. Anybody any idea what is going wrong?
Regards, Alexander
The stack trace is:
*** Break *** segmentation violation
Generating stack trace...
0x00914dbe in TBuffer::operator>>(int&) + 0x14 from
/home/kappes/icecube/soft/i3tools/root-v5.10.00/lib/libCore.so.5.10
0x00a256c9 in int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char** const&, int, int, int, int) + 0xab9 from
/home/kappes/icecube/soft/i3tools/root-v5.10.00/lib/libCore.so.5.10
0x04c8efd5 in TBranchElement::ReadLeaves(TBuffer&) at TBranchElement.cxx:0 from
/home/kappes/icecube/soft/i3tools/root-v5.10.00/lib/libTree.so.5.10
0x04c87bd3 in TBranch::GetEntry(long long, int) + 0x263 from
/home/kappes/icecube/soft/i3tools/root-v5.10.00/lib/libTree.so.5.10
0x04c8d001 in TBranchElement::GetEntry(long long, int) + 0x17f from
/home/kappes/icecube/soft/i3tools/root-v5.10.00/lib/libTree.so.5.10
0x04c8cf8a in TBranchElement::GetEntry(long long, int) + 0x108 from
/home/kappes/icecube/soft/i3tools/root-v5.10.00/lib/libTree.so.5.10
0x04ccb28f in TTree::GetEntry(long long, int) + 0xc9 from
/home/kappes/icecube/soft/i3tools/root-v5.10.00/lib/libTree.so.5.10
0x08052119 in SimTree::GetI3ParticleEvent(int) + 0x181 from ./bin/trigger.exe
0x080522b1 in Reco::GetTrueEnergy(int) + 0x53 from ./bin/trigger.exe
0x08053df2 in Simulation::Process() + 0x49e from ./bin/trigger.exe
0x0804d3d3 in main + 0x489 from ./bin/trigger.exe
0x02d2af2c in __libc_start_main + 0xdc from /lib/libc.so.6
0x0804cdd1 in __gxx_personality_v0 + 0x125 from ./bin/trigger.exe
Aborted