Hello, I got following weird behavior with TTree::SetBranchAddress():
I have a class TSelected that contains some class members like this:
[code] class TSelected{
private:
TTree* pTree;
Int_t myInt;
Double_t myDouble;
TObjArray* myBigProblem;
//[…] etc.
};[/code]
The Tree Pointer is associated with a TTree I get from a file in the constructor of TSelected. The problem I have occurs in a method of TSelected:
[code]void TSelected::InitializeTree()
{
pTree->SetBranchAddress(“myInt”, &myInt); //works fine
pTree->SetBranchAddress(“myDouble”, &myDouble); //works fine
pTree->SetBranchAddress(“myBigProblem”, &myBigProblem); //ERROR!!!
}[/code]
When running InitializeTree(), i get a segmentation violation calling SetBranchAddress() with a pointer to TObjArray. BUT I get it only when myBigProblem is a class member ob TSelected. When I declare it outside the class as a global variable, the code works without problems. And yes, the TTree contains a leaf with the corresponding name an correct type.
One might think I could leave myBigProblem outside the class definition, but thats no good option, not only because of aesthetical reasons (global variables are evil), but because I want to have more than just one instance of TSelected and the instances must not share myBigProblem.
So what can I do?