I have a tree I wrote to disk like this
detectorTree = new TTree ( "Detectors","Detector Tree" );
recordedEvent = new BETAEvent();
detectorTree->Branch ( "aBetaEvent","BETAEvent",&recordedEvent );
// .. adding data and filling etc...
I can open up a TBrowser and everything looks fine (the data is there)
However when I try to read in the tree to do some analysis like this :
BETAEvent * event = new BETAEvent();
TFile * f = new TFile("data/beta.run.10825.root");
TTree *t = (TTree*)f->Get("Detectors");
Int_t nevent = t->GetEntries();
for (int i=0;i<nevent;i++)
t->GetEvent(i); // <- Crashes here
I get the infamous *** Break *** segmentation violation
Any ideas why?
Thanks in advance!
You must compile the user object/class. Use
Thanks for your response.
I made said changes and now it crashes at setting the branch address! However, I noticed after executing the script and getting :
*** Break *** segmentation violation
if I just run the script again ( .x EventDisplay.cxx)
without leaving the interpreter it appears to run fine!???
Any ideas what to do to fix this?
Can you provide a complete running example showing the issue?
In the tar file you will find the output of two sessions one without gDebug and one with gDebug=2.
After executing the script again (up arrow then return) it runs smoothly (as can be seen in the output)
I include the script and the event class code as well. There is also a root file which contains a tree with a few events.
buggy_event.tar (730 KB)
The problem, as shown by valgrind:
root  .x EventDisplay.cxx
==11080== Conditional jump or move depends on uninitialised value(s)
==11080== at 0x7BAE7A0: BETAEvent::~BETAEvent() (BETAEvent.C:18)
==11080== by 0x4E9F582: TClass::BuildRealData(void*, bool) (TClass.cxx:1333) is a missing initialization in the constructor of BETAEvent. Use:[code] BETAEvent::BETAEvent() : fChain(0)
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
SOLVED. After making the correction to BETAEvent it now works properly.
Thanks for your help!