Hi everyone,
I encounter a strange problem with a TTree containing a 2D array of doubles and a std::vector.
First my general setup: All my code is fully compiled with gcc and runs standalone linked vs. ROOT. The code to loop over the TTree I am currently looking was generated using TTree::MakeClass().
The tree I use has dozens of branches, of which two give me problems:
Float_t ahc_hitPos[7289][3]; //[ahc_nHits]
vector<double> *trkLars_CosPhi;
I disable all branches except for these two (and the ahc_nHits branch to know how far I can loop in ahc_hitPos)
thisEvent->fChain->SetBranchStatus("*",0);
thisEvent->fChain->SetBranchStatus("ahc_nHits",1);
thisEvent->fChain->SetBranchStatus("ahc_hitPos",1);
thisEvent->fChain->SetBranchStatus("trkLars_CosPhi",1);
When I have both ahc_hitPos and trkLars_CosPhi branches enabled, access to ahc_hitPos works fine, while interacting with trkLars_CosPhi (e.g. trkLars_CosPhi->size()) causes an immediate segfault.
In this case the memory addresses of ahc_hitPos and trkLars_CosPhi are far away from each other:
ahc_hitPos: 0x17911a14
trkLars_CosPhi: 0xc2d2000044c2b87b
When I disable only ahc_hitPos, trkLars_CosPhi works fine though. Intriguingly in this case, the memory address of trkLars_CosPhi is “close” to the other variables in the same program:
ahc_hitPos: 0x8d83a14 (empty array in this case)
trkLars_CosPhi: 0x8bedb90
It seems to me that in the first case (both branches enabled) the vector pointer points into memory-nirvana.
Does anybody have any idea how to fix this problem? Like this i cannot have ahc_hitPos and trkLars_CosPhi active at the same time.
Thanks in advance and cheers,
Oskar