Dear all,
I have a problem concerning a segmentation fault in code created by
rootcint (ROOT Version 4.01-02):
I have the example class MyExampleContainer with the header file
#ifndef MYEXAMPLECONTAINER_HH
#define MYEXAMPLECONTAINER_HH
#include <stdlib.h>
#include “TObject.h”
class MyExampleContainer : public TObject {
public:
MyExampleContainer();
~MyExampleContainer();
Float_t dummyfloat;
Int_t dummyint;
ClassDef(MyExampleContainer,1);
};
#endif
and the implementation
#include “MyExampleContainer.hh”
#include "TObject.h"
ClassImp(MyExampleContainer)
MyExampleContainer::MyExampleContainer()
{
dummyint = 0;
dummyfloat = 0;
}
MyExampleContainer::~MyExampleContainer()
{
}
and the LinkDef file
#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class MyExampleContainer;
#endif
Then I create a dictionary with
$ROOTSYS/bin/rootcint -f MyExampleContainerDict.cpp -c
MyExampleContainer.hh MyExampleContainerLinkDef.h
I use the class in the following context:
BtoXsGammaFile = new TFile (rootfilename.c_str(), “RECREATE”, “B to Xs
Gamma Selection Root File”);
// then define the contents of the tree by hand:
BtoXsGammaTree = new TTree(“BtoXsGammaTree”,“B0 -> Xs Gamma Fully Inclusive”);
// and now the objects in the tree:
testHeader = new MyExampleContainer();
ErrMsg(routine) << “creating branch MyExampleContainer” << endmsg;
TestBranch = BtoXsGammaTree->Branch(“Test”, “MyExampleContainer”,
testHeader, 64000,1 );
ErrMsg(routine) << “returning from branch MyExampleContainer” <<
endmsg;
which compiles and links without any problems. When I run it I get a
segmentation fault in
G__MyExampleContainerDict_228_7_0
which is a method in the dictionary file created by rootcint. It is called from TTree::Branch.
(An example code (not a very sensible one, I just plugged it into a code which was originally creating an ntuple, since the original code where the problem first occuerd is much too large to distribute it) can be found at
www.slac.stanford.edu/~bechtle/test/
(There might be minor differences in there from the example above, but the problem stays the same))
Can anyone please tell me the probably incredibly silly error that I am
making?
Thank you very much,
Philip